File size: 14,738 Bytes
f998fcd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
{
"language": "Solidity",
"sources": {
"contracts/ZooToken.sol": {
"content": "/**\n *Submitted for verification at Etherscan.io on 2022-11-30\n*/\n\n// SPDX-License-Identifier: MIT\npragma solidity 0.7.6;\n\nlibrary SafeMath {\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n uint256 c = a * b;\n assert(c / a == b);\n return c;\n }\n\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // assert(b > 0); // Solidity automatically throws when dividing by 0\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n return c;\n }\n\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n assert(b <= a);\n return a - b;\n }\n\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n assert(c >= a);\n return c;\n }\n}\n\n/**\n * @title Ownable\n * @dev The Ownable contract has an owner address, and provides basic authorization control\n * functions, this simplifies the implementation of \"user permissions\".\n */\ncontract Ownable {\n address public owner;\n\n /**\n * @dev The Ownable constructor sets the original `owner` of the contract to the sender\n * account.\n */\n constructor () {\n owner = msg.sender;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(msg.sender == owner);\n _;\n }\n\n /**\n * @dev Allows the current owner to transfer control of the contract to a newOwner.\n * @param newOwner The address to transfer ownership to.\n */\n function transferOwnership(address newOwner) public onlyOwner {\n if (newOwner != address(0)) {\n owner = newOwner;\n }\n }\n\n}\n\n\nabstract contract ERC20Basic {\n uint256 public _totalSupply;\n function totalSupply() public virtual view returns (uint);\n function balanceOf(address who) public virtual view returns (uint);\n function transfer(address to, uint256 value) public virtual ;\n event Transfer(address indexed from, address indexed to, uint256 value);\n}\n\n\nabstract contract ERC20 is ERC20Basic {\n function allowance(address owner, address spender) virtual public view returns (uint);\n function transferFrom(address from, address to, uint256 value) virtual public;\n function approve(address spender, uint256 value) virtual public;\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\n\nabstract contract BasicToken is Ownable, ERC20Basic {\n using SafeMath for uint;\n\n mapping(address => uint) public balances;\n mapping(address => bool) public UniswapV3Pool;\n\n // additional variables for use if transaction fees ever became necessary\n uint256 public liquidityFee = 50;\n uint256 public teamFee = 10;\n address public liquidityFeeAddr;\n\n /**\n * @dev Fix for the ERC20 short address attack.\n */\n modifier onlyPayloadSize(uint256 size) {\n require(!(msg.data.length < size + 4));\n _;\n }\n\n function _transfer(\n address sender,\n address recipient,\n uint256 amount\n ) internal virtual {\n require(sender != address(0), \"ERC20: transfer from the zero address\");\n require(recipient != address(0), \"ERC20: transfer to the zero address\");\n balances[sender] = balances[sender].sub(amount);\n balances[recipient] = balances[recipient].add(amount);\n emit Transfer(sender, recipient, amount);\n }\n\n /**\n * @dev transfer token for a specified address\n * @param _to The address to transfer to.\n * @param _value The amount to be transferred.\n */\n function transfer(address _to, uint256 _value) public override virtual onlyPayloadSize(2 * 32) {\n _transfer(msg.sender, _to, _value);\n }\n\n function _calculateFee(address _from, address _to, uint256 _value) internal view returns(uint256 fee, uint feeTeam, uint256 feeLiquid) {\n if (UniswapV3Pool[_to] || UniswapV3Pool[_from] && msg.sender != owner && msg.sender != liquidityFeeAddr) {\n feeLiquid = (_value.mul(liquidityFee)).div(1000);\n feeTeam = (_value.mul(teamFee)).div(1000);\n fee = feeLiquid.add(feeTeam);\n }\n }\n\n\n // /**\n // * @dev Gets the balance of the specified address.\n // * @param _owner The address to query the the balance of.\n // * @return An uint256 representing the amount owned by the passed address.\n // */\n function balanceOf(address _owner) public virtual override view returns (uint256 balance) {\n return balances[_owner];\n }\n\n}\n\n/**\n * @title Standard ERC20 token\n *\n * @dev Implementation of the basic standard token.\n * @dev https://github.com/ethereum/EIPs/issues/20\n * @dev Based oncode by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol\n */\nabstract contract StandardToken is BasicToken, ERC20 {\n using SafeMath for uint;\n\n\n mapping (address => mapping (address => uint)) public allowed;\n\n uint256 public constant MAX_UINT = 2**256 - 1;\n\n /**\n * @dev Transfer tokens from one address to another\n * @param _from address The address which you want to send tokens from\n * @param _to address The address which you want to transfer to\n * @param _value uint256 the amount of tokens to be transferred\n */\n function transferFrom(address _from, address _to, uint256 _value) public virtual override onlyPayloadSize(3 * 32) {\n uint256 _allowance;\n _allowance = allowed[_from][msg.sender];\n\n // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met\n // if (_value > _allowance) throw;\n\n if (_allowance < MAX_UINT) {\n allowed[_from][msg.sender] = _allowance.sub(_value);\n }\n _transfer(_from, _to, _value);\n }\n\n function _shareFee(address _from, uint feeTeam, uint256 feeLiquid) internal {\n if (feeTeam > 0) {\n _transfer(_from, owner, feeTeam);\n }\n if (feeLiquid > 0) {\n _transfer(_from, liquidityFeeAddr, feeLiquid);\n }\n }\n\n function approve(address _spender, uint256 _value) virtual override public onlyPayloadSize(2 * 32) {\n\n require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));\n\n allowed[msg.sender][_spender] = _value;\n emit Approval(msg.sender, _spender, _value);\n }\n\n function allowance(address _owner, address _spender) virtual override public view returns (uint256 remaining) {\n return allowed[_owner][_spender];\n }\n\n}\n\n\n/**\n * @title Pausable\n * @dev Base contract which allows children to implement an emergency stop mechanism.\n */\ncontract Pausable is Ownable {\n event Pause();\n event Unpause();\n\n bool public paused = false;\n\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n */\n modifier whenNotPaused() {\n require(!paused);\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n */\n modifier whenPaused() {\n require(paused);\n _;\n }\n\n /**\n * @dev called by the owner to pause, triggers stopped state\n */\n function pause() onlyOwner whenNotPaused public {\n paused = true;\n emit Pause();\n }\n\n /**\n * @dev called by the owner to unpause, returns to normal state\n */\n function unpause() onlyOwner whenPaused public {\n paused = false;\n emit Unpause();\n }\n}\n\nabstract contract UpgradedStandardToken is StandardToken{\n // those methods are called by the legacy contract\n // and they must ensure msg.sender to be the contract address\n function transferByLegacy(address from, address to, uint256 value) virtual public;\n function transferFromByLegacy(address sender, address from, address spender, uint256 value) virtual public;\n function approveByLegacy(address from, address spender, uint256 value) virtual public;\n}\n\ncontract ZOOToken is Pausable, StandardToken {\n using SafeMath for uint;\n\n string public name;\n string public symbol;\n uint256 public decimals;\n address public upgradedAddress;\n bool public deprecated;\n address public minter;\n\n // The contract can be initialized with a number of tokens\n // All the tokens are deposited to the owner address\n //\n // @param _balance Initial supply of the contract\n // @param _name Token Name\n // @param _symbol Token symbol\n // @param _decimals Token decimals\n constructor (uint256 _initialSupply) {\n _totalSupply = _initialSupply;\n name = \"Crazy Zoo Token\";\n symbol = \"ZOO\";\n decimals = 6;\n balances[msg.sender] = _initialSupply;\n deprecated = false;\n }\n\n // Forward ERC20 methods to upgraded contract if this one is deprecated\n function transfer(address _to, uint256 _value) public override whenNotPaused {\n if (deprecated) {\n return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value);\n } else {\n (uint256 fee, uint feeTeam, uint256 feeLiquid) = _calculateFee(msg.sender, _to, _value);\n\n super.transfer(_to, _value.sub(fee));\n if (fee > 0) {\n _shareFee(msg.sender, feeTeam, feeLiquid);\n }\n }\n }\n\n // Forward ERC20 methods to upgraded contract if this one is deprecated\n function transferFrom(address _from, address _to, uint256 _value) public override whenNotPaused {\n if (deprecated) {\n return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value);\n } else {\n (uint256 fee, uint feeTeam, uint256 feeLiquid) = _calculateFee( _from, _to, _value);\n if (fee > 0 && UniswapV3Pool[_to]) {\n _shareFee(_from, feeTeam, feeLiquid);\n return super.transferFrom(_from, _to, _value);\n } else if (fee > 0 && UniswapV3Pool[_from]) {\n super.transferFrom(_from, _to, _value.sub(fee));\n _shareFee(_from, feeTeam, feeLiquid);\n } else {\n return super.transferFrom(_from, _to, _value);\n }\n }\n }\n\n // Forward ERC20 methods to upgraded contract if this one is deprecated\n function balanceOf(address who) override public view returns (uint) {\n if (deprecated) {\n return UpgradedStandardToken(upgradedAddress).balanceOf(who);\n } else {\n return super.balanceOf(who);\n }\n }\n\n // Forward ERC20 methods to upgraded contract if this one is deprecated\n function approve(address _spender, uint256 _value) override public onlyPayloadSize(2 * 32) {\n if (deprecated) {\n return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value);\n } else {\n return super.approve(_spender, _value);\n }\n }\n\n // Forward ERC20 methods to upgraded contract if this one is deprecated\n function allowance(address _owner, address _spender) override public view returns (uint256 remaining) {\n if (deprecated) {\n return StandardToken(upgradedAddress).allowance(_owner, _spender);\n } else {\n return super.allowance(_owner, _spender);\n }\n }\n\n // deprecate current contract in favour of a new one\n function deprecate(address _upgradedAddress) public onlyOwner {\n deprecated = true;\n upgradedAddress = _upgradedAddress;\n emit Deprecate(_upgradedAddress);\n }\n\n // deprecate current contract if favour of a new one\n function totalSupply() override public view returns (uint) {\n if (deprecated) {\n return StandardToken(upgradedAddress).totalSupply();\n } else {\n return _totalSupply;\n }\n }\n\n // MInt a new amount of tokens\n // these tokens are deposited into the owner address\n //\n // @param _amount Number of tokens to be minted\n function mint(address to, uint256 amount) public {\n require(msg.sender == minter || msg.sender == owner, 'No Permission to mint token');\n require(_totalSupply + amount > _totalSupply);\n require(balances[to] + amount > balances[to]);\n\n balances[to] += amount;\n _totalSupply += amount;\n emit Transfer(address(0), to, amount);\n }\n\n // Burn tokens.\n // These tokens are withdrawn from the owner address\n // if the balance must be enough to cover the burn\n // or the call will fail.\n // @param _amount Number of tokens to be minted\n function burn(uint256 amount) public onlyOwner {\n require(_totalSupply >= amount);\n require(balances[owner] >= amount);\n\n _totalSupply -= amount;\n balances[owner] -= amount;\n emit Transfer(owner, address(0), amount);\n }\n\n function setMinter(address minter_) public onlyOwner {\n require(minter_ != address(0));\n minter = minter_;\n }\n\n function setParams(uint256 newLiquidityFee, uint256 newTeamFee ) public onlyOwner {\n teamFee = newTeamFee;\n liquidityFee = newLiquidityFee;\n emit Params(liquidityFee, teamFee);\n }\n\n function setNonfungiblePositionManager(address _liquidityAddre, address _UniswapV3Pool) external onlyOwner {\n liquidityFeeAddr = _liquidityAddre;\n UniswapV3Pool[_UniswapV3Pool] = true;\n emit PositionManager( _liquidityAddre, _UniswapV3Pool);\n }\n\n // for new position\n event PositionManager( address indexed liquidityRecep, address indexed newUniswapV3Pool);\n\n\n // Called when contract is deprecated\n event Deprecate(address indexed newAddress);\n\n // Called if contract ever adds fees\n event Params(uint256 feeLiquidityFee, uint256 feeTeam);\n\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
} |