contract_name
stringlengths
1
61
file_path
stringlengths
5
50.4k
contract_address
stringlengths
42
42
language
stringclasses
1 value
class_name
stringlengths
1
61
class_code
stringlengths
4
330k
class_documentation
stringlengths
0
29.1k
class_documentation_type
stringclasses
6 values
func_name
stringlengths
0
62
func_code
stringlengths
1
303k
func_documentation
stringlengths
2
14.9k
func_documentation_type
stringclasses
4 values
compiler_version
stringlengths
15
42
license_type
stringclasses
14 values
swarm_source
stringlengths
0
71
meta
dict
__index_level_0__
int64
0
60.4k
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
totalSupply
function totalSupply() public view returns (uint256) { return _totalSupply; }
/** * @dev See {IERC20-totalSupply}. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 287, 375 ] }
54,661
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
balanceOf
function balanceOf(address account) public view returns (uint256) { return _balances[account]; }
/** * @dev See {IERC20-balanceOf}. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 429, 536 ] }
54,662
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transfer
function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
/** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 735, 886 ] }
54,663
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; }
/** * @dev See {IERC20-allowance}. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 940, 1071 ] }
54,664
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; }
/** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1205, 1350 ] }
54,665
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
/** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1804, 2097 ] }
54,666
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
increaseAllowance
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); 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. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2488, 2691 ] }
54,667
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
decreaseAllowance
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 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`. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3174, 3428 ] }
54,668
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_transfer
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 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`. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3898, 4350 ] }
54,669
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_mint
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 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. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 4616, 4909 ] }
54,670
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_burn
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 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. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 5224, 5557 ] }
54,671
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_approve
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 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. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 5978, 6301 ] }
54,672
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20
contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for `sender`'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal { require(account != address(0), "ERC20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal { require(account != address(0), "ERC20: burn from the zero address"); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); } }
/** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20Mintable}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */
NatSpecMultiLine
_burnFrom
function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); }
/** * @dev Destroys `amount` tokens from `account`.`amount` is then deducted * from the caller's allowance. * * See {_burn} and {_approve}. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 6475, 6700 ] }
54,673
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Pausable
contract Pausable is Context { /** * @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 owner to pause, triggers stopped state. */ function _pause() internal { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a owner to unpause, returns to normal state. */ function _unpause() internal { _paused = false; emit Unpaused(_msgSender()); } }
/** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */
NatSpecMultiLine
paused
function paused() public view returns (bool) { return _paused; }
/** * @dev Returns true if the contract is paused, and false otherwise. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 571, 646 ] }
54,674
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Pausable
contract Pausable is Context { /** * @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 owner to pause, triggers stopped state. */ function _pause() internal { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a owner to unpause, returns to normal state. */ function _unpause() internal { _paused = false; emit Unpaused(_msgSender()); } }
/** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */
NatSpecMultiLine
_pause
function _pause() internal { _paused = true; emit Paused(_msgSender()); }
/** * @dev Called by a owner to pause, triggers stopped state. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1106, 1195 ] }
54,675
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Pausable
contract Pausable is Context { /** * @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 owner to pause, triggers stopped state. */ function _pause() internal { _paused = true; emit Paused(_msgSender()); } /** * @dev Called by a owner to unpause, returns to normal state. */ function _unpause() internal { _paused = false; emit Unpaused(_msgSender()); } }
/** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */
NatSpecMultiLine
_unpause
function _unpause() internal { _paused = false; emit Unpaused(_msgSender()); }
/** * @dev Called by a owner to unpause, returns to normal state. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1280, 1374 ] }
54,676
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Ownable
contract Ownable is Context { address private _hiddenOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event HiddenOwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _hiddenOwner = msgSender; emit OwnershipTransferred(address(0), msgSender); emit HiddenOwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Returns the address of the current hidden owner. */ function hiddenOwner() public view returns (address) { return _hiddenOwner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Throws if called by any account other than the hidden owner. */ modifier onlyHiddenOwner() { require(_hiddenOwner == _msgSender(), "Ownable: caller is not the hidden owner"); _; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } /** * @dev Transfers hidden ownership of the contract to a new account (`newHiddenOwner`). */ function _transferHiddenOwnership(address newHiddenOwner) internal { require(newHiddenOwner != address(0), "Ownable: new hidden owner is the zero address"); emit HiddenOwnershipTransferred(_owner, newHiddenOwner); _hiddenOwner = newHiddenOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions, and hidden onwer account that can change owner. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 688, 764 ] }
54,677
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Ownable
contract Ownable is Context { address private _hiddenOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event HiddenOwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _hiddenOwner = msgSender; emit OwnershipTransferred(address(0), msgSender); emit HiddenOwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Returns the address of the current hidden owner. */ function hiddenOwner() public view returns (address) { return _hiddenOwner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Throws if called by any account other than the hidden owner. */ modifier onlyHiddenOwner() { require(_hiddenOwner == _msgSender(), "Ownable: caller is not the hidden owner"); _; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } /** * @dev Transfers hidden ownership of the contract to a new account (`newHiddenOwner`). */ function _transferHiddenOwnership(address newHiddenOwner) internal { require(newHiddenOwner != address(0), "Ownable: new hidden owner is the zero address"); emit HiddenOwnershipTransferred(_owner, newHiddenOwner); _hiddenOwner = newHiddenOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions, and hidden onwer account that can change owner. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
hiddenOwner
function hiddenOwner() public view returns (address) { return _hiddenOwner; }
/** * @dev Returns the address of the current hidden owner. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 843, 931 ] }
54,678
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Ownable
contract Ownable is Context { address private _hiddenOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event HiddenOwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _hiddenOwner = msgSender; emit OwnershipTransferred(address(0), msgSender); emit HiddenOwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Returns the address of the current hidden owner. */ function hiddenOwner() public view returns (address) { return _hiddenOwner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Throws if called by any account other than the hidden owner. */ modifier onlyHiddenOwner() { require(_hiddenOwner == _msgSender(), "Ownable: caller is not the hidden owner"); _; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } /** * @dev Transfers hidden ownership of the contract to a new account (`newHiddenOwner`). */ function _transferHiddenOwnership(address newHiddenOwner) internal { require(newHiddenOwner != address(0), "Ownable: new hidden owner is the zero address"); emit HiddenOwnershipTransferred(_owner, newHiddenOwner); _hiddenOwner = newHiddenOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions, and hidden onwer account that can change owner. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
_transferOwnership
function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
/** * @dev Transfers ownership of the contract to a new account (`newOwner`). */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1446, 1664 ] }
54,679
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Ownable
contract Ownable is Context { address private _hiddenOwner; address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event HiddenOwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; _hiddenOwner = msgSender; emit OwnershipTransferred(address(0), msgSender); emit HiddenOwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Returns the address of the current hidden owner. */ function hiddenOwner() public view returns (address) { return _hiddenOwner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Throws if called by any account other than the hidden owner. */ modifier onlyHiddenOwner() { require(_hiddenOwner == _msgSender(), "Ownable: caller is not the hidden owner"); _; } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). */ function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } /** * @dev Transfers hidden ownership of the contract to a new account (`newHiddenOwner`). */ function _transferHiddenOwnership(address newHiddenOwner) internal { require(newHiddenOwner != address(0), "Ownable: new hidden owner is the zero address"); emit HiddenOwnershipTransferred(_owner, newHiddenOwner); _hiddenOwner = newHiddenOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions, and hidden onwer account that can change owner. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
_transferHiddenOwnership
function _transferHiddenOwnership(address newHiddenOwner) internal { require(newHiddenOwner != address(0), "Ownable: new hidden owner is the zero address"); emit HiddenOwnershipTransferred(_owner, newHiddenOwner); _hiddenOwner = newHiddenOwner; }
/** * @dev Transfers hidden ownership of the contract to a new account (`newHiddenOwner`). */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1774, 2041 ] }
54,680
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Burnable
contract Burnable is Context { mapping(address => bool) private _burners; event BurnerAdded(address indexed account); event BurnerRemoved(address indexed account); /** * @dev Returns whether the address is burner. */ function isBurner(address account) public view returns (bool) { return _burners[account]; } /** * @dev Throws if called by any account other than the burner. */ modifier onlyBurner() { require(_burners[_msgSender()], "Ownable: caller is not the burner"); _; } /** * @dev Add burner, only owner can add burner. */ function _addBurner(address account) internal { _burners[account] = true; emit BurnerAdded(account); } /** * @dev Remove operator, only owner can remove operator */ function _removeBurner(address account) internal { _burners[account] = false; emit BurnerRemoved(account); } }
/** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */
NatSpecMultiLine
isBurner
function isBurner(address account) public view returns (bool) { return _burners[account]; }
/** * @dev Returns whether the address is burner. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 246, 348 ] }
54,681
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Burnable
contract Burnable is Context { mapping(address => bool) private _burners; event BurnerAdded(address indexed account); event BurnerRemoved(address indexed account); /** * @dev Returns whether the address is burner. */ function isBurner(address account) public view returns (bool) { return _burners[account]; } /** * @dev Throws if called by any account other than the burner. */ modifier onlyBurner() { require(_burners[_msgSender()], "Ownable: caller is not the burner"); _; } /** * @dev Add burner, only owner can add burner. */ function _addBurner(address account) internal { _burners[account] = true; emit BurnerAdded(account); } /** * @dev Remove operator, only owner can remove operator */ function _removeBurner(address account) internal { _burners[account] = false; emit BurnerRemoved(account); } }
/** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */
NatSpecMultiLine
_addBurner
function _addBurner(address account) internal { _burners[account] = true; emit BurnerAdded(account); }
/** * @dev Add burner, only owner can add burner. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 616, 734 ] }
54,682
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Burnable
contract Burnable is Context { mapping(address => bool) private _burners; event BurnerAdded(address indexed account); event BurnerRemoved(address indexed account); /** * @dev Returns whether the address is burner. */ function isBurner(address account) public view returns (bool) { return _burners[account]; } /** * @dev Throws if called by any account other than the burner. */ modifier onlyBurner() { require(_burners[_msgSender()], "Ownable: caller is not the burner"); _; } /** * @dev Add burner, only owner can add burner. */ function _addBurner(address account) internal { _burners[account] = true; emit BurnerAdded(account); } /** * @dev Remove operator, only owner can remove operator */ function _removeBurner(address account) internal { _burners[account] = false; emit BurnerRemoved(account); } }
/** * @dev Extension of {ERC20} that allows token holders to destroy both their own * tokens and those that they have an allowance for, in a way that can be * recognized off-chain (via event analysis). */
NatSpecMultiLine
_removeBurner
function _removeBurner(address account) internal { _burners[account] = false; emit BurnerRemoved(account); }
/** * @dev Remove operator, only owner can remove operator */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 812, 936 ] }
54,683
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
isLocker
function isLocker(address account) public view returns (bool) { return _lockers[account]; }
/** * @dev Returns whether the address is locker. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 817, 919 ] }
54,684
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
_addLocker
function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); }
/** * @dev Add locker, only owner can add locker */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 987, 1105 ] }
54,685
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
_removeLocker
function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); }
/** * @dev Remove locker, only owner can remove locker */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1179, 1303 ] }
54,686
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
isLocked
function isLocked(address account) public view returns (bool) { return _locks[account]; }
/** * @dev Returns whether the address is locked. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1372, 1472 ] }
54,687
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
_lock
function _lock(address account) internal { _locks[account] = true; emit Locked(account); }
/** * @dev Lock account, only locker can lock */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1537, 1643 ] }
54,688
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
_unlock
function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); }
/** * @dev Unlock account, only locker can unlock */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1712, 1823 ] }
54,689
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
_addTimeLock
function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); }
/** * @dev Add time lock, only locker can add */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1888, 2201 ] }
54,690
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
_removeTimeLock
function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); }
/** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2376, 2762 ] }
54,691
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
getTimeLockLength
function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; }
/** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2920, 3039 ] }
54,692
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
getTimeLock
function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); }
/** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3222, 3499 ] }
54,693
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
Lockable
contract Lockable is Context { using SafeMath for uint; struct TimeLock { uint amount; uint expiresAt; } mapping(address => bool) private _lockers; mapping(address => bool) private _locks; mapping(address => TimeLock[]) private _timeLocks; event LockerAdded(address indexed account); event LockerRemoved(address indexed account); event Locked(address indexed account); event Unlocked(address indexed account); event TimeLocked(address indexed account); event TimeUnlocked(address indexed account); /** * @dev Throws if called by any account other than the locker. */ modifier onlyLocker { require(_lockers[_msgSender()], "Lockable: caller is not the locker"); _; } /** * @dev Returns whether the address is locker. */ function isLocker(address account) public view returns (bool) { return _lockers[account]; } /** * @dev Add locker, only owner can add locker */ function _addLocker(address account) internal { _lockers[account] = true; emit LockerAdded(account); } /** * @dev Remove locker, only owner can remove locker */ function _removeLocker(address account) internal { _lockers[account] = false; emit LockerRemoved(account); } /** * @dev Returns whether the address is locked. */ function isLocked(address account) public view returns (bool) { return _locks[account]; } /** * @dev Lock account, only locker can lock */ function _lock(address account) internal { _locks[account] = true; emit Locked(account); } /** * @dev Unlock account, only locker can unlock */ function _unlock(address account) internal { _locks[account] = false; emit Unlocked(account); } /** * @dev Add time lock, only locker can add */ function _addTimeLock(address account, uint amount, uint expiresAt) internal { require(amount > 0, "Time Lock: lock amount must be greater than 0"); require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now"); _timeLocks[account].push(TimeLock(amount, expiresAt)); } /** * @dev Remove time lock, only locker can remove * @param account The address want to know the time lock state. * @param index Time lock index */ function _removeTimeLock(address account, uint8 index) internal { require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); uint len = _timeLocks[account].length; if (len - 1 != index) { // if it is not last item, swap it _timeLocks[account][index] = _timeLocks[account][len - 1]; } _timeLocks[account].pop(); } /** * @dev Get time lock array length * @param account The address want to know the time lock length. * @return time lock length */ function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; } /** * @dev Get time lock info * @param account The address want to know the time lock state. * @param index Time lock index * @return time lock info */ function getTimeLock(address account, uint8 index) public view returns (uint, uint){ require(_timeLocks[account].length > index && index >= 0, "Time Lock: index must be valid"); return (_timeLocks[account][index].amount, _timeLocks[account][index].expiresAt); } /** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */ function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; } }
/** * @dev Contract for locking mechanism. * Locker can add and remove locked account. * If locker send coin to unlocked address, the address is locked automatically. */
NatSpecMultiLine
getTimeLockedAmount
function getTimeLockedAmount(address account) public view returns (uint) { uint timeLockedAmount = 0; uint len = _timeLocks[account].length; for (uint i = 0; i < len; i++) { if (block.timestamp < _timeLocks[account][i].expiresAt) { timeLockedAmount = timeLockedAmount.add(_timeLocks[account][i].amount); } } return timeLockedAmount; }
/** * @dev get total time locked amount of address * @param account The address want to know the time lock amount. * @return time locked amount */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3672, 4062 ] }
54,694
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } }
/** * @dev Optional functions from the ERC20 standard. */
NatSpecMultiLine
name
function name() public view returns (string memory) { return _name; }
/** * @dev Returns the name of the token. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 518, 598 ] }
54,695
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } }
/** * @dev Optional functions from the ERC20 standard. */
NatSpecMultiLine
symbol
function symbol() public view returns (string memory) { return _symbol; }
/** * @dev Returns the symbol of the token, usually a shorter version of the * name. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 707, 791 ] }
54,696
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
ERC20Detailed
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of * these values are immutable: they can only be set once during * construction. */ constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } }
/** * @dev Optional functions from the ERC20 standard. */
NatSpecMultiLine
decimals
function decimals() public view returns (uint8) { return _decimals; }
/** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1336, 1416 ] }
54,697
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
recoverERC20
function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); }
/** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 435, 584 ] }
54,698
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
_beforeTokenTransfer
function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); }
/** * @dev lock and pause and check time lock before transfer token */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 671, 1111 ] }
54,699
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); }
/** * @dev only hidden owner can transfer ownership */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1596, 1722 ] }
54,700
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
transferHiddenOwnership
function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); }
/** * @dev only hidden owner can transfer hidden ownership */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 1800, 1950 ] }
54,701
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
addBurner
function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); }
/** * @dev only owner can add burner */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2006, 2108 ] }
54,702
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
removeBurner
function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); }
/** * @dev only owner can remove burner */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2167, 2275 ] }
54,703
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
burn
function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); }
/** * @dev burn burner's coin */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2324, 2490 ] }
54,704
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
pause
function pause() public onlyOwner whenNotPaused { _pause(); }
/** * @dev pause all coin transfer */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2544, 2616 ] }
54,705
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
unpause
function unpause() public onlyOwner whenPaused { _unpause(); }
/** * @dev unpause all coin transfer */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2672, 2745 ] }
54,706
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
addLocker
function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); }
/** * @dev only owner can add locker */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2801, 2903 ] }
54,707
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
removeLocker
function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); }
/** * @dev only owner can remove locker */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 2962, 3070 ] }
54,708
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
lock
function lock(address account) public onlyLocker whenNotPaused { _lock(account); }
/** * @dev only locker can lock account */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3129, 3222 ] }
54,709
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
unlock
function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); }
/** * @dev only owner can unlock account, not locker */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3294, 3390 ] }
54,710
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
addTimeLock
function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); }
/** * @dev only locker can add time lock */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3450, 3605 ] }
54,711
LGT
LGT.sol
0xbe960343df2a6ad4eeefe5b655df8591efd30564
Solidity
LGT
contract LGT is Pausable, Ownable, Burnable, Lockable, ERC20, ERC20Detailed { uint private constant _initialSupply = 700000000e18; constructor() ERC20Detailed("Life Garden Token", "LGT", 18) public { _mint(_msgSender(), _initialSupply); } /** * @dev Recover ERC20 coin in contract address. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } /** * @dev lock and pause and check time lock before transfer token */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal view { require(!isLocked(from), "Lockable: token transfer from locked account"); require(!isLocked(to), "Lockable: token transfer to locked account"); require(!paused(), "Pausable: token transfer while paused"); require(balanceOf(from).sub(getTimeLockedAmount(from)) >= amount, "Lockable: token transfer from time locked account"); } function transfer(address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(_msgSender(), recipient, amount); return super.transfer(recipient, amount); } function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { _beforeTokenTransfer(sender, recipient, amount); return super.transferFrom(sender, recipient, amount); } /** * @dev only hidden owner can transfer ownership */ function transferOwnership(address newOwner) public onlyHiddenOwner whenNotPaused { _transferOwnership(newOwner); } /** * @dev only hidden owner can transfer hidden ownership */ function transferHiddenOwnership(address newHiddenOwner) public onlyHiddenOwner whenNotPaused { _transferHiddenOwnership(newHiddenOwner); } /** * @dev only owner can add burner */ function addBurner(address account) public onlyOwner whenNotPaused { _addBurner(account); } /** * @dev only owner can remove burner */ function removeBurner(address account) public onlyOwner whenNotPaused { _removeBurner(account); } /** * @dev burn burner's coin */ function burn(uint256 amount) public onlyBurner whenNotPaused { _beforeTokenTransfer(_msgSender(), address(0), amount); _burn(_msgSender(), amount); } /** * @dev pause all coin transfer */ function pause() public onlyOwner whenNotPaused { _pause(); } /** * @dev unpause all coin transfer */ function unpause() public onlyOwner whenPaused { _unpause(); } /** * @dev only owner can add locker */ function addLocker(address account) public onlyOwner whenNotPaused { _addLocker(account); } /** * @dev only owner can remove locker */ function removeLocker(address account) public onlyOwner whenNotPaused { _removeLocker(account); } /** * @dev only locker can lock account */ function lock(address account) public onlyLocker whenNotPaused { _lock(account); } /** * @dev only owner can unlock account, not locker */ function unlock(address account) public onlyOwner whenNotPaused { _unlock(account); } /** * @dev only locker can add time lock */ function addTimeLock(address account, uint amount, uint expiresAt) public onlyLocker whenNotPaused { _addTimeLock(account, amount, expiresAt); } /** * @dev only owner can remove time lock */ function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); } }
/** * @dev Contract for Life Garden Token */
NatSpecMultiLine
removeTimeLock
function removeTimeLock(address account, uint8 index) public onlyOwner whenNotPaused { _removeTimeLock(account, index); }
/** * @dev only owner can remove time lock */
NatSpecMultiLine
v0.5.17+commit.d19bba13
MIT
bzzr://f53df6fd887ac457db38f009c876b022d2a7d28cae9823d0796f70dd669dab5f
{ "func_code_index": [ 3667, 3799 ] }
54,712
ConfigurationRegistry
ConfigurationRegistry.sol
0xc5c0ead7df3cefc45c8f4592e3a0f1500949e75d
Solidity
TwoStepOwnable
contract TwoStepOwnable { address private _owner; address private _newPotentialOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initialize contract by setting transaction submitter as initial owner. */ constructor() internal { _owner = tx.origin; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "TwoStepOwnable: caller is not the owner."); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows a new account (`newOwner`) to accept ownership. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "TwoStepOwnable: new potential owner is the zero address." ); _newPotentialOwner = newOwner; } /** * @dev Cancel a transfer of ownership to a new account. * Can only be called by the current owner. */ function cancelOwnershipTransfer() public onlyOwner { delete _newPotentialOwner; } /** * @dev Transfers ownership of the contract to the caller. * Can only be called by a new potential owner set by the current owner. */ function acceptOwnership() public { require( msg.sender == _newPotentialOwner, "TwoStepOwnable: current owner must set caller as new potential owner." ); delete _newPotentialOwner; emit OwnershipTransferred(_owner, msg.sender); _owner = msg.sender; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. * * In order to transfer ownership, a recipient must be specified, at which point * the specified recipient can call `acceptOwnership` and take ownership. */
NatSpecMultiLine
owner
function owner() public view returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.6.10+commit.00c0fcaf
MIT
ipfs://ddf2c8efaed22ebfc0279222db7a276bb3c1cb7f9f3f12e8b42e93327571f379
{ "func_code_index": [ 477, 553 ] }
54,713
ConfigurationRegistry
ConfigurationRegistry.sol
0xc5c0ead7df3cefc45c8f4592e3a0f1500949e75d
Solidity
TwoStepOwnable
contract TwoStepOwnable { address private _owner; address private _newPotentialOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initialize contract by setting transaction submitter as initial owner. */ constructor() internal { _owner = tx.origin; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "TwoStepOwnable: caller is not the owner."); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows a new account (`newOwner`) to accept ownership. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "TwoStepOwnable: new potential owner is the zero address." ); _newPotentialOwner = newOwner; } /** * @dev Cancel a transfer of ownership to a new account. * Can only be called by the current owner. */ function cancelOwnershipTransfer() public onlyOwner { delete _newPotentialOwner; } /** * @dev Transfers ownership of the contract to the caller. * Can only be called by a new potential owner set by the current owner. */ function acceptOwnership() public { require( msg.sender == _newPotentialOwner, "TwoStepOwnable: current owner must set caller as new potential owner." ); delete _newPotentialOwner; emit OwnershipTransferred(_owner, msg.sender); _owner = msg.sender; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. * * In order to transfer ownership, a recipient must be specified, at which point * the specified recipient can call `acceptOwnership` and take ownership. */
NatSpecMultiLine
isOwner
function isOwner() public view returns (bool) { return msg.sender == _owner; }
/** * @dev Returns true if the caller is the current owner. */
NatSpecMultiLine
v0.6.10+commit.00c0fcaf
MIT
ipfs://ddf2c8efaed22ebfc0279222db7a276bb3c1cb7f9f3f12e8b42e93327571f379
{ "func_code_index": [ 819, 908 ] }
54,714
ConfigurationRegistry
ConfigurationRegistry.sol
0xc5c0ead7df3cefc45c8f4592e3a0f1500949e75d
Solidity
TwoStepOwnable
contract TwoStepOwnable { address private _owner; address private _newPotentialOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initialize contract by setting transaction submitter as initial owner. */ constructor() internal { _owner = tx.origin; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "TwoStepOwnable: caller is not the owner."); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows a new account (`newOwner`) to accept ownership. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "TwoStepOwnable: new potential owner is the zero address." ); _newPotentialOwner = newOwner; } /** * @dev Cancel a transfer of ownership to a new account. * Can only be called by the current owner. */ function cancelOwnershipTransfer() public onlyOwner { delete _newPotentialOwner; } /** * @dev Transfers ownership of the contract to the caller. * Can only be called by a new potential owner set by the current owner. */ function acceptOwnership() public { require( msg.sender == _newPotentialOwner, "TwoStepOwnable: current owner must set caller as new potential owner." ); delete _newPotentialOwner; emit OwnershipTransferred(_owner, msg.sender); _owner = msg.sender; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. * * In order to transfer ownership, a recipient must be specified, at which point * the specified recipient can call `acceptOwnership` and take ownership. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "TwoStepOwnable: new potential owner is the zero address." ); _newPotentialOwner = newOwner; }
/** * @dev Allows a new account (`newOwner`) to accept ownership. * Can only be called by the current owner. */
NatSpecMultiLine
v0.6.10+commit.00c0fcaf
MIT
ipfs://ddf2c8efaed22ebfc0279222db7a276bb3c1cb7f9f3f12e8b42e93327571f379
{ "func_code_index": [ 1038, 1266 ] }
54,715
ConfigurationRegistry
ConfigurationRegistry.sol
0xc5c0ead7df3cefc45c8f4592e3a0f1500949e75d
Solidity
TwoStepOwnable
contract TwoStepOwnable { address private _owner; address private _newPotentialOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initialize contract by setting transaction submitter as initial owner. */ constructor() internal { _owner = tx.origin; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "TwoStepOwnable: caller is not the owner."); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows a new account (`newOwner`) to accept ownership. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "TwoStepOwnable: new potential owner is the zero address." ); _newPotentialOwner = newOwner; } /** * @dev Cancel a transfer of ownership to a new account. * Can only be called by the current owner. */ function cancelOwnershipTransfer() public onlyOwner { delete _newPotentialOwner; } /** * @dev Transfers ownership of the contract to the caller. * Can only be called by a new potential owner set by the current owner. */ function acceptOwnership() public { require( msg.sender == _newPotentialOwner, "TwoStepOwnable: current owner must set caller as new potential owner." ); delete _newPotentialOwner; emit OwnershipTransferred(_owner, msg.sender); _owner = msg.sender; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. * * In order to transfer ownership, a recipient must be specified, at which point * the specified recipient can call `acceptOwnership` and take ownership. */
NatSpecMultiLine
cancelOwnershipTransfer
function cancelOwnershipTransfer() public onlyOwner { delete _newPotentialOwner; }
/** * @dev Cancel a transfer of ownership to a new account. * Can only be called by the current owner. */
NatSpecMultiLine
v0.6.10+commit.00c0fcaf
MIT
ipfs://ddf2c8efaed22ebfc0279222db7a276bb3c1cb7f9f3f12e8b42e93327571f379
{ "func_code_index": [ 1390, 1483 ] }
54,716
ConfigurationRegistry
ConfigurationRegistry.sol
0xc5c0ead7df3cefc45c8f4592e3a0f1500949e75d
Solidity
TwoStepOwnable
contract TwoStepOwnable { address private _owner; address private _newPotentialOwner; event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev Initialize contract by setting transaction submitter as initial owner. */ constructor() internal { _owner = tx.origin; emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(isOwner(), "TwoStepOwnable: caller is not the owner."); _; } /** * @dev Returns true if the caller is the current owner. */ function isOwner() public view returns (bool) { return msg.sender == _owner; } /** * @dev Allows a new account (`newOwner`) to accept ownership. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public onlyOwner { require( newOwner != address(0), "TwoStepOwnable: new potential owner is the zero address." ); _newPotentialOwner = newOwner; } /** * @dev Cancel a transfer of ownership to a new account. * Can only be called by the current owner. */ function cancelOwnershipTransfer() public onlyOwner { delete _newPotentialOwner; } /** * @dev Transfers ownership of the contract to the caller. * Can only be called by a new potential owner set by the current owner. */ function acceptOwnership() public { require( msg.sender == _newPotentialOwner, "TwoStepOwnable: current owner must set caller as new potential owner." ); delete _newPotentialOwner; emit OwnershipTransferred(_owner, msg.sender); _owner = msg.sender; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be aplied to your functions to restrict their use to * the owner. * * In order to transfer ownership, a recipient must be specified, at which point * the specified recipient can call `acceptOwnership` and take ownership. */
NatSpecMultiLine
acceptOwnership
function acceptOwnership() public { require( msg.sender == _newPotentialOwner, "TwoStepOwnable: current owner must set caller as new potential owner." ); delete _newPotentialOwner; emit OwnershipTransferred(_owner, msg.sender); _owner = msg.sender; }
/** * @dev Transfers ownership of the contract to the caller. * Can only be called by a new potential owner set by the current owner. */
NatSpecMultiLine
v0.6.10+commit.00c0fcaf
MIT
ipfs://ddf2c8efaed22ebfc0279222db7a276bb3c1cb7f9f3f12e8b42e93327571f379
{ "func_code_index": [ 1638, 1939 ] }
54,717
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
owned
contract owned { address public owner; //*** OwnershipTransferred ***// event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function owned() public { owner = msg.sender; } //*** Change Owner ***// function changeOwner(address newOwner) onlyOwner public { owner = newOwner; } //*** Transfer OwnerShip ***// function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } //*** Only Owner ***// modifier onlyOwner { require(msg.sender == owner); _; } }
//*** Owner ***//
LineComment
changeOwner
function changeOwner(address newOwner) onlyOwner public { owner = newOwner; }
//*** Change Owner ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 265, 349 ] }
54,718
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
owned
contract owned { address public owner; //*** OwnershipTransferred ***// event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function owned() public { owner = msg.sender; } //*** Change Owner ***// function changeOwner(address newOwner) onlyOwner public { owner = newOwner; } //*** Transfer OwnerShip ***// function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; } //*** Only Owner ***// modifier onlyOwner { require(msg.sender == owner); _; } }
//*** Owner ***//
LineComment
transferOwnership
function transferOwnership(address newOwner) onlyOwner public { require(newOwner != address(0)); OwnershipTransferred(owner, newOwner); owner = newOwner; }
//*** Transfer OwnerShip ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 392, 584 ] }
54,719
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
function() payable public { require(msg.value>0); buyTokens(msg.sender);
//*** Payable ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 2571, 2670 ] }
54,720
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
buyTokens
function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); }
//*** Buy Tokens ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 2699, 3890 ] }
54,721
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
forwardFunds
function forwardFunds() internal { wallet.transfer(msg.value); }
//*** ForwardFunds ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 3927, 4010 ] }
54,722
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
getTokensForGraphenePower
function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; }
//*** GetTokensForGraphenePower ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 4060, 4541 ] }
54,723
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
allowance
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; }
//*** Allowance ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 4569, 4710 ] }
54,724
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
transfer
function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; }
/* Send coins */
Comment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 4733, 5063 ] }
54,725
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
mintToken
function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } }
//*** MintToken ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 5091, 5433 ] }
54,726
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
approve
function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
//*** Approve ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 5459, 5649 ] }
54,727
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
transferFrom
function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; }
//*** Transfer From ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 5681, 6270 ] }
54,728
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
issue
function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); }
//*** Issue ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 6294, 6541 ] }
54,729
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
burn
function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; }
//*** Burn ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 6564, 6708 ] }
54,730
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
destroy
function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); }
//*** Destroy ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 6734, 7032 ] }
54,731
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
killBalance
function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } }
//Kill
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7045, 7199 ] }
54,732
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
enabledMintTokens
function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; }
//Mint tokens
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7219, 7360 ] }
54,733
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
contractBalance
function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; }
//*** Contract Balance ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7395, 7498 ] }
54,734
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
startPreSale
function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; }
//Satart PreSale
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7521, 7643 ] }
54,735
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
endPreSale
function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; }
//End PreSale
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7663, 7785 ] }
54,736
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
startIco
function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; }
//Start ICO
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7803, 7913 ] }
54,737
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
endIco
function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; }
//End ICO
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 7929, 8040 ] }
54,738
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
isIco
function isIco() constant public returns (bool closed) { ool result=((icoStart+(35*24*60*60)) >= now); f(enableIco){ return true; lse{ return result;
//*** Is ico closed ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 8072, 8273 ] }
54,739
GraphenePowerToken
GraphenePowerToken.sol
0xf8dfac6cae56736fd2a05e45108490c6cb40147d
Solidity
GraphenePowerToken
contract GraphenePowerToken is owned,Utils{ //************** Token ************// string public standard = 'Token 0.1'; string public name = 'Graphene Power'; string public symbol = 'GRP'; uint8 public decimals = 18; uint256 _totalSupply =0; //*** Pre-sale ***// uint preSaleStart=1513771200; uint preSaleEnd=1515585600; uint256 preSaleTotalTokens=30000000; uint256 preSaleTokenCost=6000; address preSaleAddress; bool enablePreSale=false; //*** ICO ***// uint icoStart; uint256 icoSaleTotalTokens=400000000; address icoAddress; bool enableIco=false; //*** Advisers,Consultants ***// uint256 advisersConsultantTokens=15000000; address advisersConsultantsAddress; //*** Bounty ***// uint256 bountyTokens=15000000; address bountyAddress; //*** Founders ***// uint256 founderTokens=40000000; address founderAddress; //*** Walet ***// address public wallet; //*** Mint ***// bool enableMintTokens=true; //*** TranferCoin ***// bool public transfersEnabled = false; //*** Balance ***// mapping (address => uint256) balanceOf; //*** Alowed ***// mapping (address => mapping (address => uint256)) allowed; //*** Tranfer ***// event Transfer(address from, address to, uint256 value); //*** Approval ***// event Approval(address indexed _owner, address indexed _spender, uint256 _value); //*** Destruction ***// event Destruction(uint256 _amount); //*** Burn ***// event Burn(address indexed from, uint256 value); //*** Issuance ***// event Issuance(uint256 _amount); function GraphenePowerToken() public{ preSaleAddress=0xC07850969A0EC345A84289f9C5bb5F979f27110f; icoAddress=0x1C21Cf57BF4e2dd28883eE68C03a9725056D29F1; advisersConsultantsAddress=0xe8B6dA1B801b7F57e3061C1c53a011b31C9315C7; bountyAddress=0xD53E82Aea770feED8e57433D3D61674caEC1D1Be; founderAddress=0xDA0D3Dad39165EA2d7386f18F96664Ee2e9FD8db; _totalSupply =500000000; balanceOf[this]=_totalSupply; } //*** Check Transfer ***// modifier transfersAllowed { assert(transfersEnabled); _; } //*** ValidAddress ***// modifier validAddress(address _address) { require(_address != 0x0); _; } //*** Not This ***// modifier notThis(address _address) { require(_address != address(this)); _; } //*** Payable ***// function() payable public { require(msg.value>0); buyTokens(msg.sender); } //*** Buy Tokens ***// function buyTokens(address beneficiary) payable public { require(beneficiary != 0x0); uint256 weiAmount; uint256 tokens; wallet=owner; if(isPreSale()){ wallet=preSaleAddress; weiAmount=6000; } else if(isIco()){ wallet=icoAddress; if((icoStart+(7*24*60*60)) >= now){ weiAmount=4000; } else if((icoStart+(14*24*60*60)) >= now){ weiAmount=3750; } else if((icoStart+(21*24*60*60)) >= now){ weiAmount=3500; } else if((icoStart+(28*24*60*60)) >= now){ weiAmount=3250; } else if((icoStart+(35*24*60*60)) >= now){ weiAmount=3000; } else{ weiAmount=2000; } } else{ weiAmount=6000; } forwardFunds(); tokens=msg.value*weiAmount/1000000000000000000; mintToken(beneficiary, tokens); Transfer(this, beneficiary, tokens); } //*** ForwardFunds ***// function forwardFunds() internal { wallet.transfer(msg.value); } //*** GetTokensForGraphenePower ***// function getTokensForGraphenePower() onlyOwner public returns(bool result){ require(enableMintTokens); mintToken(bountyAddress, bountyTokens); Transfer(this, bountyAddress, bountyTokens); mintToken(founderAddress, founderTokens); Transfer(this, founderAddress, founderTokens); mintToken(advisersConsultantsAddress, advisersConsultantTokens); Transfer(this, advisersConsultantsAddress, advisersConsultantTokens); return true; } //*** Allowance ***// function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } /* Send coins */ function transfer(address _to, uint256 _value) transfersAllowed public returns (bool success) { require(balanceOf[_to] >= _value); // Subtract from the sender balanceOf[msg.sender] = (balanceOf[msg.sender] -_value); balanceOf[_to] =(balanceOf[_to] + _value); Transfer(msg.sender, _to, _value); return true; } //*** MintToken ***// function mintToken(address target, uint256 mintedAmount) onlyOwner public returns(bool result) { if(enableMintTokens){ balanceOf[target] += mintedAmount; _totalSupply =(_totalSupply-mintedAmount); Transfer(this, target, mintedAmount); return true; } else{ return false; } } //*** Approve ***// function approve(address _spender, uint256 _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } //*** Transfer From ***// function transferFrom(address _from, address _to, uint256 _value) transfersAllowed public returns (bool success) { require(transfersEnabled); // Check if the sender has enough require(balanceOf[_from] >= _value); // Check allowed require(_value <= allowed[_from][msg.sender]); // Subtract from the sender balanceOf[_from] = (balanceOf[_from] - _value); // Add the same to the recipient balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true; } //*** Issue ***// function issue(address _to, uint256 _amount) public onlyOwner validAddress(_to) notThis(_to) { _totalSupply = (_totalSupply - _amount); balanceOf[_to] = (balanceOf[_to] + _amount); Issuance(_amount); Transfer(this, _to, _amount); } //*** Burn ***// function burn(uint256 _value) public returns (bool success) { destroy(msg.sender, _value); Burn(msg.sender, _value); return true; } //*** Destroy ***// function destroy(address _from, uint256 _amount) public { require(msg.sender == _from); require(balanceOf[_from] >= _amount); balanceOf[_from] =(balanceOf[_from] - _amount); _totalSupply = (_totalSupply - _amount); Transfer(_from, this, _amount); Destruction(_amount); } //Kill function killBalance() onlyOwner public { require(!enablePreSale && !enableIco); if(this.balance > 0) { owner.transfer(this.balance); } } //Mint tokens function enabledMintTokens(bool value) onlyOwner public returns(bool result) { enableMintTokens = value; return enableMintTokens; } //*** Contract Balance ***// function contractBalance() constant public returns (uint256 balance) { return balanceOf[this]; } //Satart PreSale function startPreSale() onlyOwner public returns(bool result){ enablePreSale=true; return enablePreSale; } //End PreSale function endPreSale() onlyOwner public returns(bool result){ enablePreSale=false; return enablePreSale; } //Start ICO function startIco() onlyOwner public returns(bool result){ enableIco=true; return enableIco; } //End ICO function endIco() onlyOwner public returns(bool result){ enableIco=false; return enableIco; } //*** Is ico closed ***// function isIco() constant public returns (bool closed) { bool result=((icoStart+(35*24*60*60)) >= now); if(enableIco){ return true; } else{ return result; } } //*** Is preSale closed ***// function isPreSale() constant public returns (bool closed) { bool result=(preSaleEnd >= now); if(enablePreSale){ return true; } else{ return result; } } }
//*** GraphenePowerToken ***//
LineComment
isPreSale
function isPreSale() constant public returns (bool closed) { ol result=(preSaleEnd >= now); (enablePreSale){ return true; se{ return result;
//*** Is preSale closed ***//
LineComment
v0.4.18+commit.9cf6e910
bzzr://45c5e2e6de9bb444ba00b3b6feeeeb374ff737ed9bd37ce121c5aa61df5497a5
{ "func_code_index": [ 8315, 8503 ] }
54,740
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
IMigrator
interface IMigrator { // Return the desired amount of liquidity token that the migrator wants. function desiredLiquidity() external view returns (uint256); }
desiredLiquidity
function desiredLiquidity() external view returns (uint256);
// Return the desired amount of liquidity token that the migrator wants.
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 99, 163 ] }
54,741
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
initialize
function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); }
// called once by the factory at time of deployment
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 2692, 2948 ] }
54,742
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
_update
function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); }
// update reserves and, on the first call per block, price accumulators
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 3266, 4128 ] }
54,743
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
_mintFee
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } }
// if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k)
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 4211, 5054 ] }
54,744
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
mint
function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); }
// this low-level function should be called from a contract which performs important safety checks
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 5159, 6795 ] }
54,745
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
burn
function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); }
// this low-level function should be called from a contract which performs important safety checks
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 6900, 8351 ] }
54,746
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
swap
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); }
// this low-level function should be called from a contract which performs important safety checks
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 9187, 11713 ] }
54,747
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
skim
function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); }
// force balances to match reserves
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 20549, 20882 ] }
54,748
KingSwapPair
contracts/kingswap/KingSwapPair.sol
0x0d9476bab929513abbf45915fe83904166c40082
Solidity
KingSwapPair
contract KingSwapPair is KingSwapERC20 { using SafeMath for uint256; using UQ112x112 for uint224; uint256 public constant MINIMUM_LIQUIDITY = 10**3; bytes4 private constant SELECTOR = bytes4(keccak256(bytes("transfer(address,uint256)"))); uint256 public constant DECAY_PERIOD = 5 minutes; uint256 public constant UQ112 = 2**112; address public factory; address public token0; // shares single storage slot with lockedIn0 bool public lockedIn0; // if set, token0 gets locked in the contract address public token1; bool public lockedIn1; KingSwapSlippageToken public stoken; uint224 private virtualPrice; // token0 virtual price, uses single storage slot uint32 private lastPriceTime; // the latest exchange time uint112 private reserve0; // uses single storage slot, accessible via getReserves uint112 private reserve1; // uses single storage slot, accessible via getReserves uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves uint256 public price0CumulativeLast; uint256 public price1CumulativeLast; uint256 public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event uint256 private unlocked = 1; modifier lock() { require(unlocked == 1, "KingSwap: LOCKED"); unlocked = 0; _; unlocked = 1; } function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) { _reserve0 = reserve0; _reserve1 = reserve1; _blockTimestampLast = blockTimestampLast; } function getVirtualPrice() public view returns (uint224 _virtualPrice, uint32 _lastPriceTime) { _virtualPrice = virtualPrice; _lastPriceTime = lastPriceTime; } function _safeTransfer(address token, address to, uint256 value) private { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), "KingSwap: TRANSFER_FAILED"); } event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); event Lock(bool lockedIn0, bool lockedIn1); constructor() public { factory = msg.sender; } // called once by the factory at time of deployment function initialize(address _token0, address _token1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); // sufficient check token0 = _token0; token1 = _token1; stoken = new KingSwapSlippageToken(0); } function lockIn(bool _lockedIn0, bool _lockedIn1) external { require(msg.sender == factory, "KingSwap: FORBIDDEN"); lockedIn0 = _lockedIn0; lockedIn1 = _lockedIn1; emit Lock(lockedIn0, lockedIn1); } // update reserves and, on the first call per block, price accumulators function _update(uint256 balance0, uint256 balance1, uint112 _reserve0, uint112 _reserve1) private { require(balance0 <= uint112(-1) && balance1 <= uint112(-1), "KingSwap: OVERFLOW"); uint32 blockTimestamp = uint32(block.timestamp % 2**32); uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) { // * never overflows, and + overflow is desired price0CumulativeLast += uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed; price1CumulativeLast += uint256(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed; } reserve0 = uint112(balance0); reserve1 = uint112(balance1); blockTimestampLast = blockTimestamp; emit Sync(reserve0, reserve1); } // if fee is on, mint liquidity equivalent to 1/5th of the growth in sqrt(k) function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { address feeTo = IKingSwapFactory(factory).feeTo(); feeOn = feeTo != address(0); uint256 _kLast = kLast; // gas savings if (feeOn) { if (_kLast != 0) { uint256 rootK = Math.sqrt(uint256(_reserve0).mul(_reserve1)); uint256 rootKLast = Math.sqrt(_kLast); if (rootK > rootKLast) { uint256 numerator = totalSupply.mul(rootK.sub(rootKLast)); uint256 denominator = rootK.mul(4).add(rootKLast); uint256 liquidity = numerator / denominator; if (liquidity > 0) _mint(feeTo, liquidity); } } } else if (_kLast != 0) { kLast = 0; } } // this low-level function should be called from a contract which performs important safety checks function mint(address to) external lock returns (uint256 liquidity) { (uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings uint balance0 = IERC20(token0).balanceOf(address(this)); uint balance1 = IERC20(token1).balanceOf(address(this)); uint amount0 = balance0.sub(_reserve0); uint amount1 = balance1.sub(_reserve1); bool feeOn = _mintFee(_reserve0, _reserve1); uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee if (_totalSupply == 0) { address migrator = IKingSwapFactory(factory).migrator(); if (msg.sender == migrator) { liquidity = IMigrator(migrator).desiredLiquidity(); require(liquidity > 0 && liquidity != uint256(-1), "KingSwap: Bad desired liquidity"); } else { require(migrator == address(0), "KingSwap: Must not have migrator"); liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY); _mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens } } else { liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1); } require(liquidity > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_MINTED"); _mint(to, liquidity); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Mint(msg.sender, amount0, amount1); } // this low-level function should be called from a contract which performs important safety checks function burn(address to) external lock returns (uint256 amount0, uint256 amount1) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings address _token0 = token0; // gas savings address _token1 = token1; // gas savings uint256 balance0 = IERC20(_token0).balanceOf(address(this)); uint256 balance1 = IERC20(_token1).balanceOf(address(this)); bool feeOn = _mintFee(_reserve0, _reserve1); { uint256 liquidity = balanceOf[address(this)]; uint256 _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution require(amount0 > 0 && amount1 > 0, "KingSwap: INSUFFICIENT_LIQUIDITY_BURNED"); _burn(address(this), liquidity); } _safeTransfer(_token0, to, amount0); _safeTransfer(_token1, to, amount1); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); _update(balance0, balance1, _reserve0, _reserve1); if (feeOn) kLast = uint256(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date emit Burn(msg.sender, amount0, amount1, to); } function _updateVirtualPrice(uint112 _reserve0, uint112 _reserve1) internal { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); uint32 blockTimestamp = uint32(block.timestamp % 2**32); if (_lastPriceTime < blockTimestamp) { uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); uint256 price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); virtualPrice = uint224(price); lastPriceTime = blockTimestamp; } } // this low-level function should be called from a contract which performs important safety checks function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external lock { require(amount0Out > 0 || amount1Out > 0, "KingSwap: INSUFFICIENT_OUTPUT_AMOUNT"); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings require(amount0Out < _reserve0 && amount1Out < _reserve1, "KingSwap: INSUFFICIENT_LIQUIDITY"); uint256 balance0; uint256 balance1; { // scope for _token{0,1} and _lockedIn{0,1}, avoids stack too deep errors (address _token0, bool _lockedIn0) = _getTokenAndLocks0(); // gas savings (address _token1, bool _lockedIn1) = _getTokenAndLocks1(); require(to != _token0 && to != _token1, "KingSwap: INVALID_TO"); // revert if a token is locked in the contract require( (!_lockedIn0 || amount0Out == 0) && (!_lockedIn1 || amount1Out == 0), "KingSwap: TOKEN_LOCKED_IN" ); if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens if (data.length > 0) IKingSwapCallee(to).KingSwapCall(msg.sender, amount0Out, amount1Out, data); balance0 = IERC20(_token0).balanceOf(address(this)); balance1 = IERC20(_token1).balanceOf(address(this)); } uint256 amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0; uint256 amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0; require(amount0In > 0 || amount1In > 0, "KingSwap: INSUFFICIENT_INPUT_AMOUNT"); { // scope for reserve{0,1}Adjusted, avoids stack too deep errors uint256 balance0Adjusted = balance0.mul(1000); if (amount0In != 0) balance0Adjusted = balance0Adjusted.sub(amount0In.mul(25)/10); uint256 balance1Adjusted = balance1.mul(1000); if (amount1In != 0) balance1Adjusted = balance1Adjusted.sub(amount1In.mul(25)/10); require( balance0Adjusted.mul(balance1Adjusted) >= uint256(_reserve0).mul(_reserve1).mul(1000**2), "KingSwap: K" ); } _updateVirtualPrice(_reserve0, _reserve1); _update(balance0, balance1, _reserve0, _reserve1); emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to); } function _getTokenAndLocks0() private view returns (address, bool) { return (token0, lockedIn0); } function _getTokenAndLocks1() private view returns (address, bool) { return (token1, lockedIn1); } function _getToken0MarketPrice() internal view returns (uint256 price) { (uint256 _virtualPrice, uint32 _lastPriceTime) = getVirtualPrice(); (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); uint256 currentPrice = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); uint256 timePassed = Math.min(DECAY_PERIOD, block.timestamp.sub(_lastPriceTime)); uint256 timeRemain = DECAY_PERIOD.sub(timePassed); price = _virtualPrice.mul(timeRemain).add(currentPrice.mul(timePassed)) / (DECAY_PERIOD); } function getTokenMarketPrice(address token) external view returns (uint256 price) { uint256 t0Price = _getToken0MarketPrice(); token == token0 ? price = t0Price : price = UQ112.mul(UQ112) / t0Price; } function _getAmountOut(address token, uint256 amountIn, uint256 t0Price) internal view returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); if (token == token0) { uint256 numerator = amountInWithFee.mul(t0Price); uint256 denominator = UQ112.mul(10000); _out = numerator / denominator; } else { uint256 numerator = amountInWithFee.mul(UQ112); uint256 denominator = t0Price.mul(10000); _out = numerator / denominator; } } function _getAmountIn(address token, uint256 amountOut, uint256 t0Price) internal view returns (uint256 _in) { if (token == token0) { uint256 numerator = amountOut.mul(10000).mul(t0Price); uint256 denominator = UQ112.mul(9975); _in = numerator / denominator; } else { uint256 numerator = amountOut.mul(10000).mul(UQ112); uint256 denominator = t0Price.mul(9975); _in = numerator / denominator; } } function getAmountOutMarket(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInMarket(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { t0Price = _getToken0MarketPrice(); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutPool(address token, uint256 amountIn) public view returns (uint256 _out, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _out = _getAmountOut(token, amountIn, t0Price); } function getAmountInPool(address token, uint256 amountOut) public view returns (uint256 _in, uint256 t0Price) { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); t0Price = uint256(UQ112x112.encode(_reserve1).uqdiv(_reserve0)); _in = _getAmountIn(token, amountOut, t0Price); } function getAmountOutReal(uint256 amountIn, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _out) { uint256 amountInWithFee = amountIn.mul(9975); uint256 numerator = amountInWithFee.mul(_reserveOut); uint256 denominator = _reserveIn.mul(10000).add(amountInWithFee); _out = numerator / denominator; } function getAmountInReal(uint256 amountOut, uint256 _reserveIn, uint256 _reserveOut) internal pure returns (uint256 _in) { uint256 numerator = _reserveIn.mul(amountOut).mul(10000); uint256 denominator = _reserveOut.sub(amountOut).mul(9975); _in = (numerator / denominator).add(1); } function getAmountOutFinal(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); uint256 amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); (uint256 amountOutMarket, ) = getAmountOutMarket(token, amountIn); amountOut = amountOutReal; // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippage = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippage / 2; amountOut = amountOutReal.sub(halfSlippage); } (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(token, amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function getAmountInFinal(address token, uint256 amountOut) external view returns (uint256 amountIn, uint256 stokenAmount) { address _token0 = token0; (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = token == _token0 ? (_reserve1, _reserve0) : (_reserve0, _reserve1); uint256 amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (uint256 amountInMarket, ) = getAmountInMarket(token, amountOut); amountIn = amountInReal; // arbitrager if (amountInReal < amountInMarket) { uint256 slippage = amountInMarket.sub(amountInReal); uint256 extra = slippage / 2; amountIn = amountInReal.add(extra); } (uint256 amountInPool, uint256 t0Price) = getAmountInPool(token, amountOut); uint256 slippage = amountInReal.sub(amountInPool); stokenAmount = token == _token0 ? slippage : slippage.mul(t0Price) / UQ112; } function dealSlippageWithIn(address[] calldata path, uint256 amountIn, address to, bool ifmint) external lock returns (uint256 amountOut) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountOutReal; uint256 amountOutMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountOutReal = getAmountOutReal(amountIn, _reserveIn, _reserveOut); amountOut = amountOutReal; (amountOutMarket, ) = getAmountOutMarket(path[0], amountIn); uint256 balance = IERC20(path[0]).balanceOf(address(this)); uint256 amount = balance.sub(_reserveIn); require(amount >= amountIn, "KingSwap: Invalid Amount"); } // arbitrager if (amountOutReal > amountOutMarket) { uint256 slippageExtra = amountOutReal.sub(amountOutMarket); uint256 halfSlippage = slippageExtra / 2; amountOut = amountOutReal.sub(halfSlippage); } if (ifmint == true) { (uint256 amountOutPool, uint256 t0Price) = getAmountOutPool(path[0], amountIn); uint256 slippage = amountOutPool.sub(amountOutReal); uint256 mintAmount = path[1] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } function dealSlippageWithOut(address[] calldata path, uint256 amountOut, address to, bool ifmint) external lock returns (uint256 extra) { require(path.length == 2, "KingSwap: INVALID_PATH"); address _token0 = token0; uint256 amountInReal; uint256 amountInMarket; // avoids stack too deep errors { (uint112 _reserve0, uint112 _reserve1, ) = getReserves(); // gas savings (uint256 _reserveIn, uint256 _reserveOut) = path[0] == _token0 ? (_reserve0, _reserve1) : (_reserve1, _reserve0); amountInReal = getAmountInReal(amountOut, _reserveIn, _reserveOut); (amountInMarket, ) = getAmountInMarket(path[1], amountOut); } // arbitrager if (amountInReal < amountInMarket) { uint256 slippageExtra = amountInMarket.sub(amountInReal); extra = slippageExtra / 2; } if (ifmint == true) { (uint256 amountInPool, uint256 t0Price) = getAmountInPool(path[1], amountOut); uint256 slippage = amountInReal.sub(amountInPool); uint256 mintAmount = path[0] == _token0 ? slippage.mul(t0Price) / UQ112 : slippage; stoken.mint(to, mintAmount); } } // force balances to match reserves function skim(address to) external lock { address _token0 = token0; // gas savings address _token1 = token1; // gas savings _safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0)); _safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1)); } // force reserves to match balances function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); } }
sync
function sync() external lock { _update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1); }
// force reserves to match balances
LineComment
v0.6.12+commit.27d51765
{ "func_code_index": [ 20924, 21084 ] }
54,749
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } }
// // Unnamed function that runs when eth is sent to the contract //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 1547, 2111 ] }
54,750
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
checkCrowdsaleState
function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; }
// // Check crowdsale state and calibrate it //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 2171, 3501 ] }
54,751
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
refundTransaction
function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } }
// // Decide if throw or only return ether //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 3559, 3727 ] }
54,752
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
processTransaction
function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } }
// // Issue tokens and return if there is overflow //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 4146, 5769 ] }
54,753
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
salvageTokensFromContract
function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); }
// // Method is needed for recovering tokens accedentaly sent to token address //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 6145, 6320 ] }
54,754
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
withdrawEth
function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); }
// // withdrawEth when minimum cap is reached //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 6381, 6545 ] }
54,755
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
claimEthIfFailed
function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } }
// // Users can claim their contribution if min cap is not raised //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 6626, 7483 ] }
54,756
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
batchReturnEthIfFailed
function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } }
// // Owner can batch return contributors contributions(eth) //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 7559, 8930 ] }
54,757
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
withdrawRemainingBalanceForManualRecovery
function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig }
// // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 9047, 9523 ] }
54,758
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
setMultisigAddress
function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; }
// // Owner can set multisig address for crowdsale //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 10618, 10729 ] }
54,759
SportifyCrowdsale
SportifyCrowdsale.sol
0x53151a85ea7b82a4b43903427953efba067cde92
Solidity
Crowdsale
contract Crowdsale is ReentrancyHandlingContract, Owned { struct ContributorData { uint contributionAmount; uint tokensIssued; } mapping(address => ContributorData) public contributorList; uint nextContributorIndex; mapping(uint => address) contributorIndexes; state public crowdsaleState = state.pendingStart; enum state { pendingStart, crowdsale, crowdsaleEnded } uint public crowdsaleStartBlock; uint public crowdsaleEndedBlock; event CrowdsaleStarted(uint blockNumber); event CrowdsaleEnded(uint blockNumber); event ErrorSendingETH(address to, uint amount); event MinCapReached(uint blockNumber); event MaxCapReached(uint blockNumber); address tokenAddress = 0x0; uint decimals = 18; uint ethToTokenConversion; uint public minCap; uint public maxCap; uint public ethRaised; uint public tokenTotalSupply = 200000000 * 10**decimals; address public multisigAddress; uint blocksInADay; uint nextContributorToClaim; mapping(address => bool) hasClaimedEthWhenFail; uint crowdsaleTokenCap = 134000000 * 10**decimals; uint foundersAndTeamTokens = 36000000 * 10**decimals; uint advisorAndAmbassadorTokens = 20000000 * 10**decimals; uint futurePromoEventTokens = 10000000 * 10**decimals; bool foundersAndTeamTokensClaimed = false; bool advisorAndAmbassadorTokensClaimed = false; bool futurePromoEventTokensClaimed = false; // // Unnamed function that runs when eth is sent to the contract // function() noReentrancy payable public { require(msg.value != 0); // Throw if value is 0 require(crowdsaleState != state.crowdsaleEnded);// Check if crowdsale has ended bool stateChanged = checkCrowdsaleState(); // Check blocks and calibrate crowdsale state if (crowdsaleState == state.crowdsale) { processTransaction(msg.sender, msg.value); // Process transaction and issue tokens } else { refundTransaction(stateChanged); // Set state and return funds or throw } } // // Check crowdsale state and calibrate it // function checkCrowdsaleState() internal returns (bool) { if (ethRaised == maxCap && crowdsaleState != state.crowdsaleEnded) { // Check if max cap is reached crowdsaleState = state.crowdsaleEnded; CrowdsaleEnded(block.number); // Raise event return true; } if (block.number > crowdsaleStartBlock && block.number <= crowdsaleEndedBlock) { // Check if we are in crowdsale state if (crowdsaleState != state.crowdsale) { // Check if state needs to be changed crowdsaleState = state.crowdsale; // Set new state CrowdsaleStarted(block.number); // Raise event return true; } } else { if (crowdsaleState != state.crowdsaleEnded && block.number > crowdsaleEndedBlock) { // Check if crowdsale is over crowdsaleState = state.crowdsaleEnded; // Set new state CrowdsaleEnded(block.number); // Raise event return true; } } return false; } // // Decide if throw or only return ether // function refundTransaction(bool _stateChanged) internal { if (_stateChanged) { msg.sender.transfer(msg.value); } else { revert(); } } function calculateEthToToken(uint _eth, uint _blockNumber) constant public returns(uint) { if (_blockNumber < crowdsaleStartBlock + blocksInADay * 3) { return _eth * 3298; } if (_eth >= 100*10**decimals) { return _eth * 3298; } if (_blockNumber > crowdsaleStartBlock) { return _eth * 2998; } } // // Issue tokens and return if there is overflow // function processTransaction(address _contributor, uint _amount) internal{ uint contributionAmount = _amount; uint returnAmount = 0; if (_amount > (maxCap - ethRaised)) { // Check if max contribution is lower than _amount sent contributionAmount = maxCap - ethRaised; // Set that user contibutes his maximum alowed contribution returnAmount = _amount - contributionAmount; // Calculate howmuch he must get back } if (ethRaised + contributionAmount > minCap && minCap > ethRaised) { MinCapReached(block.number); } if (ethRaised + contributionAmount == maxCap && ethRaised < maxCap) { MaxCapReached(block.number); } if (contributorList[_contributor].contributionAmount == 0) { contributorIndexes[nextContributorIndex] = _contributor; nextContributorIndex += 1; } contributorList[_contributor].contributionAmount += contributionAmount; ethRaised += contributionAmount; // Add to eth raised uint tokenAmount = calculateEthToToken(contributionAmount, block.number); // Calculate how much tokens must contributor get if (tokenAmount > 0) { SportifyTokenInterface(tokenAddress).mint(_contributor, tokenAmount); // Issue new tokens contributorList[_contributor].tokensIssued += tokenAmount; // log token issuance } if (returnAmount != 0) { _contributor.transfer(returnAmount); } } function pushAngelInvestmentData(address _address, uint _ethContributed) onlyOwner public { assert(ethRaised + _ethContributed <= maxCap); processTransaction(_address, _ethContributed); } function depositAngelInvestmentEth() payable onlyOwner public {} // // Method is needed for recovering tokens accedentaly sent to token address // function salvageTokensFromContract(address _tokenAddress, address _to, uint _amount) onlyOwner public { ERC20TokenInterface(_tokenAddress).transfer(_to, _amount); } // // withdrawEth when minimum cap is reached // function withdrawEth() onlyOwner public { require(this.balance != 0); require(ethRaised >= minCap); multisigAddress.transfer(this.balance); } // // Users can claim their contribution if min cap is not raised // function claimEthIfFailed() public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed require(contributorList[msg.sender].contributionAmount > 0); // Check if contributor has contributed to crowdsaleEndedBlock require(!hasClaimedEthWhenFail[msg.sender]); // Check if contributor has already claimed his eth uint ethContributed = contributorList[msg.sender].contributionAmount; // Get contributors contribution hasClaimedEthWhenFail[msg.sender] = true; // Set that he has claimed if (!msg.sender.send(ethContributed)) { // Refund eth ErrorSendingETH(msg.sender, ethContributed); // If there is an issue raise event for manual recovery } } // // Owner can batch return contributors contributions(eth) // function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public { require(block.number > crowdsaleEndedBlock && ethRaised < minCap); // Check if crowdsale has failed address currentParticipantAddress; uint contribution; for (uint cnt = 0; cnt < _numberOfReturns; cnt++) { currentParticipantAddress = contributorIndexes[nextContributorToClaim]; // Get next unclaimed participant if (currentParticipantAddress == 0x0) { return; // Check if all the participants were compensated } if (!hasClaimedEthWhenFail[currentParticipantAddress]) { // Check if participant has already claimed contribution = contributorList[currentParticipantAddress].contributionAmount; // Get contribution of participant hasClaimedEthWhenFail[currentParticipantAddress] = true; // Set that he has claimed if (!currentParticipantAddress.send(contribution)) { // Refund eth ErrorSendingETH(currentParticipantAddress, contribution); // If there is an issue raise event for manual recovery } } nextContributorToClaim += 1; // Repeat } } // // If there were any issue/attach with refund owner can withraw eth at the end for manual recovery // function withdrawRemainingBalanceForManualRecovery() onlyOwner public { require(this.balance != 0); // Check if there are any eth to claim require(block.number > crowdsaleEndedBlock); // Check if crowdsale is over require(contributorIndexes[nextContributorToClaim] == 0x0); // Check if all the users were refunded multisigAddress.transfer(this.balance); // Withdraw to multisig } function claimTeamTokens(address _to, uint _choice) onlyOwner public { require(crowdsaleState == state.crowdsaleEnded); require(ethRaised >= minCap); uint mintAmount; if (_choice == 1) { assert(!advisorAndAmbassadorTokensClaimed); mintAmount = advisorAndAmbassadorTokens; advisorAndAmbassadorTokensClaimed = true; } else if (_choice == 2) { assert(!futurePromoEventTokensClaimed); mintAmount = futurePromoEventTokens; futurePromoEventTokensClaimed = true; } else if (_choice == 3) { assert(!foundersAndTeamTokensClaimed); assert(advisorAndAmbassadorTokensClaimed); assert(futurePromoEventTokensClaimed); assert(tokenTotalSupply > ERC20TokenInterface(tokenAddress).totalSupply()); mintAmount = tokenTotalSupply - ERC20TokenInterface(tokenAddress).totalSupply(); foundersAndTeamTokensClaimed = true; } else { revert(); } SportifyTokenInterface(tokenAddress).mint(_to, mintAmount); } // // Owner can set multisig address for crowdsale // function setMultisigAddress(address _newAddress) onlyOwner public { multisigAddress = _newAddress; } // // Owner can set token address where mints will happen // function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; } function getTokenAddress() constant public returns(address) { return tokenAddress; } function investorCount() constant public returns(uint) { return nextContributorIndex; } }
setToken
function setToken(address _newAddress) onlyOwner public { tokenAddress = _newAddress; }
// // Owner can set token address where mints will happen //
LineComment
v0.4.18+commit.9cf6e910
bzzr://dc7ca859c1b9f0a2d39ede808d7c10942a907750af9916839a1bdebf8287ab27
{ "func_code_index": [ 10802, 10900 ] }
54,760