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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Dogecoin | @openzeppelin/contracts/token/ERC20/ERC20.sol | 0xd2292ef492697b0361bd22026861c905f1bfd64f | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | decreaseAllowance | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
| /**
* @dev 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.8.7+commit.e28d00a7 | MIT | ipfs://6d5fa39edbc25359b7c15f8705d8f34d094f0e27847dca39790f696280f8acdb | {
"func_code_index": [
5146,
5528
]
} | 4,807 |
Dogecoin | @openzeppelin/contracts/token/ERC20/ERC20.sol | 0xd2292ef492697b0361bd22026861c905f1bfd64f | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _transfer | function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
| /**
* @dev 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.8.7+commit.e28d00a7 | MIT | ipfs://6d5fa39edbc25359b7c15f8705d8f34d094f0e27847dca39790f696280f8acdb | {
"func_code_index": [
6013,
6622
]
} | 4,808 |
Dogecoin | @openzeppelin/contracts/token/ERC20/ERC20.sol | 0xd2292ef492697b0361bd22026861c905f1bfd64f | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _mint | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), 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.8.7+commit.e28d00a7 | MIT | ipfs://6d5fa39edbc25359b7c15f8705d8f34d094f0e27847dca39790f696280f8acdb | {
"func_code_index": [
6899,
7283
]
} | 4,809 |
Dogecoin | @openzeppelin/contracts/token/ERC20/ERC20.sol | 0xd2292ef492697b0361bd22026861c905f1bfd64f | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _burn | function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
| /**
* @dev 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.8.7+commit.e28d00a7 | MIT | ipfs://6d5fa39edbc25359b7c15f8705d8f34d094f0e27847dca39790f696280f8acdb | {
"func_code_index": [
7611,
8110
]
} | 4,810 |
Dogecoin | @openzeppelin/contracts/token/ERC20/ERC20.sol | 0xd2292ef492697b0361bd22026861c905f1bfd64f | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _approve | function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| /**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This 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.8.7+commit.e28d00a7 | MIT | ipfs://6d5fa39edbc25359b7c15f8705d8f34d094f0e27847dca39790f696280f8acdb | {
"func_code_index": [
8543,
8894
]
} | 4,811 |
Dogecoin | @openzeppelin/contracts/token/ERC20/ERC20.sol | 0xd2292ef492697b0361bd22026861c905f1bfd64f | Solidity | ERC20 | contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0x8b9C35C79AF5319C70dd9A3E3850F368822ED64E), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
} | /**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/ | NatSpecMultiLine | _beforeTokenTransfer | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
| /**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://6d5fa39edbc25359b7c15f8705d8f34d094f0e27847dca39790f696280f8acdb | {
"func_code_index": [
9492,
9589
]
} | 4,812 |
LIZVIP | LIZVIP.sol | 0x9dad3e41ce1d34179e96f7195ec938f938f6b968 | Solidity | Ownable | contract Ownable {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://976454dabc64d22fa291fccd66b639edcecf2a66d7f2a6026a04812c80fbadec | {
"func_code_index": [
677,
874
]
} | 4,813 |
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | ContractOwner | contract ContractOwner {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
} | /**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
| /**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
641,
822
]
} | 4,814 |
|
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
89,
476
]
} | 4,815 |
|
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
560,
840
]
} | 4,816 |
|
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
954,
1070
]
} | 4,817 |
|
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
1134,
1264
]
} | 4,818 |
|
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | Etherauction | contract Etherauction is ContractOwner {
using SafeMath for uint256;
constructor() public payable {
owner = msg.sender;
gameId = 1;
gameStartTime = block.timestamp;
gameLastAuctionMoney = 10**15;
gameLastAuctionTime = block.timestamp;
gameSecondLeft = _getInitAuctionSeconds();
}
function adminAddMoney() public payable {
reward = reward + msg.value * 80 / 100;
nextReward = nextReward + msg.value * 20 / 100;
}
function addAuctionReward() public payable {
reward = reward + msg.value;
}
uint256 gameId; // gameId increase from 1
uint256 gameStartTime; // game start time
uint256 gameLastAuctionTime; // last auction time
uint256 gameLastAuctionMoney;
uint256 gameSecondLeft; // how many seconds left to auction
////////////////////////// money
uint256 reward; // reward for winner
uint256 dividends; // total dividends for players
uint256 nextReward; // reward for next round
uint256 dividendForDev;
////////////////////////// api
OracleBase oracleAPI;
function setOracleAPIAddress(address _addr) public onlyOwner {
oracleAPI = OracleBase(_addr);
}
uint rollCount = 100;
function getRandom() internal returns (uint256) {
rollCount = rollCount + 1;
return oracleAPI.getRandomForContract(100, rollCount);
}
////////////////////////// game money
function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
function _startNewRound(address _addr) internal {
reward = nextReward * 80 / 100;
nextReward = nextReward * 20 / 100;
gameId = gameId + 1;
dividends = 0;
gameStartTime = block.timestamp;
gameLastAuctionTime = block.timestamp;
uint256 price = _getMinAuctionStartPrice();
reward = reward.sub(price);
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][0].addr = _addr;
gameAuction[gameId][0].money = price;
gameAuction[gameId][0].bid = price;
gameAuction[gameId][0].refunded = false;
gameAuction[gameId][0].dividended = false;
gameLastAuctionMoney = price;
gameSecondLeft = _getInitAuctionSeconds();
emit GameAuction(gameId, _addr, price, price, gameSecondLeft, block.timestamp);
}
function adminPayout() public onlyOwner {
owner.transfer(dividendForDev);
dividendForDev = 0;
}
////////////////////////// game struct
struct GameData {
uint256 gameId;
uint256 reward;
uint256 dividends;
}
struct PlayerAuction {
address addr;
uint256 money;
uint256 bid;
bool refunded;
bool dividended;
}
mapping(uint256 => PlayerAuction[]) gameAuction;
GameData[] gameData;
////////////////////////// game event
event GameAuction(uint indexed gameId, address player, uint money, uint auctionValue, uint secondsLeft, uint datetime);
event GameRewardClaim(uint indexed gameId, address indexed player, uint money);
event GameRewardRefund(uint indexed gameId, address indexed player, uint money);
event GameEnd(uint indexed gameId, address indexed winner, uint money, uint datetime);
////////////////////////// game play
function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
function auction() public payable {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended) {
revert('this round end!!!');
}
uint256 len = gameAuction[gameId].length;
if (len > 1) {
address bidder = gameAuction[gameId][len - 1].addr;
if (msg.sender == bidder)
revert("wrong action");
}
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
uint256 maxAuctionValue = 3 * gap + gameLastAuctionMoney;
if (msg.value < auctionValue) {
revert("wrong eth value!");
}
if (msg.value >= maxAuctionValue) {
auctionValue = maxAuctionValue;
} else {
auctionValue = msg.value;
}
gameLastAuctionMoney = auctionValue;
_inMoney(auctionValue);
gameLastAuctionTime = block.timestamp;
uint256 random = getRandom();
gameSecondLeft = random * (_getMaxAuctionSeconds() - _getMinAuctionSeconds()) / 100 + _getMinAuctionSeconds();
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][gameAuction[gameId].length - 1].addr = msg.sender;
gameAuction[gameId][gameAuction[gameId].length - 1].money = msg.value;
gameAuction[gameId][gameAuction[gameId].length - 1].bid = auctionValue;
gameAuction[gameId][gameAuction[gameId].length - 1].refunded = false;
gameAuction[gameId][gameAuction[gameId].length - 1].dividended = false;
emit GameAuction(gameId, msg.sender, msg.value, auctionValue, gameSecondLeft, block.timestamp);
}
function claimReward(uint256 _id) public {
_claimReward(msg.sender, _id);
}
function _claimReward(address _addr, uint256 _id) internal {
if (_id == gameId) {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert('game is still on, cannot claim reward');
}
uint _reward = 0;
uint _dividends = 0;
uint _myMoney = 0;
uint _myDividends = 0;
uint _myRefund = 0;
uint _myReward = 0;
bool _claimed = false;
(_myMoney, _myDividends, _myRefund, _myReward, _claimed) = _getGameInfoPart1(_addr, _id);
(_reward, _dividends) = _getGameInfoPart2(_id);
if (_claimed)
revert('already claimed!');
for (uint k = 0; k < gameAuction[_id].length; k++) {
if (gameAuction[_id][k].addr == _addr) {
gameAuction[_id][k].dividended = true;
}
}
_addr.transfer(_myDividends + _myRefund + _myReward);
emit GameRewardClaim(_id, _addr, _myDividends + _myRefund + _myReward);
}
// can only refund game still on
function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
// anyone can end this round
function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
function getCurrCanRefund() public view returns (bool) {
if (gameAuction[gameId].length > 1) {
if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 2].addr) {
return false;
} else if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 1].addr) {
return false;
}
return true;
} else {
return false;
}
}
function getCurrGameInfo() public view returns (uint256 _gameId,
uint256 _reward,
uint256 _dividends,
uint256 _lastAuction,
uint256 _gap,
uint256 _lastAuctionTime,
uint256 _secondsLeft,
uint256 _myMoney,
uint256 _myDividends,
uint256 _myRefund,
bool _ended) {
_gameId = gameId;
_reward = reward;
_dividends = dividends;
_lastAuction = gameLastAuctionMoney;
_gap = _getGameAuctionGap();
_lastAuctionTime = gameLastAuctionTime;
_secondsLeft = gameSecondLeft;
_ended = (block.timestamp > _lastAuctionTime + _secondsLeft) ? true: false;
uint256 _moneyForCal = 0;
if (gameAuction[gameId].length > 1) {
uint256 totalMoney = 0;
for (uint256 i = 0; i < gameAuction[gameId].length; i++) {
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].dividended == true) {
}
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].refunded == false) {
if ((i == gameAuction[gameId].length - 2) || (i == gameAuction[gameId].length - 1)) {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid);
} else {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid.mul(15).div(100));
}
_myMoney = _myMoney + gameAuction[gameId][i].money;
_moneyForCal = _moneyForCal.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
if (gameAuction[gameId][i].refunded == false) {
totalMoney = totalMoney.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
}
if (totalMoney != 0)
_myDividends = _moneyForCal.mul(_dividends).div(totalMoney);
}
}
function getGameDataByIndex(uint256 _index) public view returns (uint256 _id, uint256 _reward, uint256 _dividends) {
uint256 len = gameData.length;
if (len >= (_index + 1)) {
GameData memory d = gameData[_index];
_id = d.gameId;
_reward = d.reward;
_dividends = d.dividends;
}
}
function getGameInfo(uint256 _id) public view returns (uint256 _reward, uint256 _dividends, uint256 _myMoney, uint256 _myDividends, uint256 _myRefund, uint256 _myReward, bool _claimed) {
(_reward, _dividends) = _getGameInfoPart2(_id);
(_myMoney, _myRefund, _myDividends, _myReward, _claimed) = _getGameInfoPart1(msg.sender, _id);
}
function _getGameInfoPart1(address _addr, uint256 _id) internal view returns (uint256 _myMoney, uint256 _myRefund, uint256 _myDividends, uint256 _myReward, bool _claimed) {
uint256 totalMoney = 0;
uint k = 0;
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
if (gameAuction[d.gameId].length > 1) {
// no.2 bidder can refund except for the last one
if (gameAuction[d.gameId][gameAuction[d.gameId].length - 1].addr == _addr) {
// if sender is winner
_myReward = d.reward;
_myReward = _myReward + gameAuction[d.gameId][gameAuction[d.gameId].length - 2].bid;
}
// add no.2 bidder's money to winner
// address loseBidder = gameAuction[d.gameId][gameAuction[d.gameId].length - 2].addr;
totalMoney = 0;
uint256 _moneyForCal = 0;
for (k = 0; k < gameAuction[d.gameId].length; k++) {
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].dividended == true) {
_claimed = true;
}
// k != (gameAuction[d.gameId].length - 2): for no.2 bidder, who cannot refund this bid
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
_myRefund = _myRefund.add( gameAuction[d.gameId][k].money.sub( gameAuction[d.gameId][k].bid.mul(15).div(100) ) );
_moneyForCal = _moneyForCal.add( (gameAuction[d.gameId][k].money.div(10**15)).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
_myMoney = _myMoney.add(gameAuction[d.gameId][k].money);
}
if (gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
totalMoney = totalMoney.add( ( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
}
}
if (totalMoney != 0)
_myDividends = d.dividends.mul(_moneyForCal).div(totalMoney);
}
break;
}
}
}
}
function _getGameInfoPart2(uint256 _id) internal view returns (uint256 _reward, uint256 _dividends) {
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
_reward = d.reward;
_dividends = d.dividends;
break;
}
}
}
}
////////////////////////// game rule
function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
function _getGameAuctionGap() internal view returns (uint256) {
if (gameLastAuctionMoney < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (gameLastAuctionMoney >= 10**n && gameLastAuctionMoney < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
function _getMinAuctionSeconds() internal pure returns (uint256) {
return 30 * 60;
// return 1 * 60; //test
}
function _getMaxAuctionSeconds() internal pure returns (uint256) {
return 12 * 60 * 60;
// return 3 * 60; //test
}
function _getInitAuctionSeconds() internal pure returns (uint256) {
return 3 * 24 * 60 * 60;
}
// only invoke at the beginning of auction
function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
} | _inMoney | function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
| ////////////////////////// game money | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
1427,
1652
]
} | 4,819 |
|||
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | Etherauction | contract Etherauction is ContractOwner {
using SafeMath for uint256;
constructor() public payable {
owner = msg.sender;
gameId = 1;
gameStartTime = block.timestamp;
gameLastAuctionMoney = 10**15;
gameLastAuctionTime = block.timestamp;
gameSecondLeft = _getInitAuctionSeconds();
}
function adminAddMoney() public payable {
reward = reward + msg.value * 80 / 100;
nextReward = nextReward + msg.value * 20 / 100;
}
function addAuctionReward() public payable {
reward = reward + msg.value;
}
uint256 gameId; // gameId increase from 1
uint256 gameStartTime; // game start time
uint256 gameLastAuctionTime; // last auction time
uint256 gameLastAuctionMoney;
uint256 gameSecondLeft; // how many seconds left to auction
////////////////////////// money
uint256 reward; // reward for winner
uint256 dividends; // total dividends for players
uint256 nextReward; // reward for next round
uint256 dividendForDev;
////////////////////////// api
OracleBase oracleAPI;
function setOracleAPIAddress(address _addr) public onlyOwner {
oracleAPI = OracleBase(_addr);
}
uint rollCount = 100;
function getRandom() internal returns (uint256) {
rollCount = rollCount + 1;
return oracleAPI.getRandomForContract(100, rollCount);
}
////////////////////////// game money
function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
function _startNewRound(address _addr) internal {
reward = nextReward * 80 / 100;
nextReward = nextReward * 20 / 100;
gameId = gameId + 1;
dividends = 0;
gameStartTime = block.timestamp;
gameLastAuctionTime = block.timestamp;
uint256 price = _getMinAuctionStartPrice();
reward = reward.sub(price);
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][0].addr = _addr;
gameAuction[gameId][0].money = price;
gameAuction[gameId][0].bid = price;
gameAuction[gameId][0].refunded = false;
gameAuction[gameId][0].dividended = false;
gameLastAuctionMoney = price;
gameSecondLeft = _getInitAuctionSeconds();
emit GameAuction(gameId, _addr, price, price, gameSecondLeft, block.timestamp);
}
function adminPayout() public onlyOwner {
owner.transfer(dividendForDev);
dividendForDev = 0;
}
////////////////////////// game struct
struct GameData {
uint256 gameId;
uint256 reward;
uint256 dividends;
}
struct PlayerAuction {
address addr;
uint256 money;
uint256 bid;
bool refunded;
bool dividended;
}
mapping(uint256 => PlayerAuction[]) gameAuction;
GameData[] gameData;
////////////////////////// game event
event GameAuction(uint indexed gameId, address player, uint money, uint auctionValue, uint secondsLeft, uint datetime);
event GameRewardClaim(uint indexed gameId, address indexed player, uint money);
event GameRewardRefund(uint indexed gameId, address indexed player, uint money);
event GameEnd(uint indexed gameId, address indexed winner, uint money, uint datetime);
////////////////////////// game play
function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
function auction() public payable {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended) {
revert('this round end!!!');
}
uint256 len = gameAuction[gameId].length;
if (len > 1) {
address bidder = gameAuction[gameId][len - 1].addr;
if (msg.sender == bidder)
revert("wrong action");
}
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
uint256 maxAuctionValue = 3 * gap + gameLastAuctionMoney;
if (msg.value < auctionValue) {
revert("wrong eth value!");
}
if (msg.value >= maxAuctionValue) {
auctionValue = maxAuctionValue;
} else {
auctionValue = msg.value;
}
gameLastAuctionMoney = auctionValue;
_inMoney(auctionValue);
gameLastAuctionTime = block.timestamp;
uint256 random = getRandom();
gameSecondLeft = random * (_getMaxAuctionSeconds() - _getMinAuctionSeconds()) / 100 + _getMinAuctionSeconds();
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][gameAuction[gameId].length - 1].addr = msg.sender;
gameAuction[gameId][gameAuction[gameId].length - 1].money = msg.value;
gameAuction[gameId][gameAuction[gameId].length - 1].bid = auctionValue;
gameAuction[gameId][gameAuction[gameId].length - 1].refunded = false;
gameAuction[gameId][gameAuction[gameId].length - 1].dividended = false;
emit GameAuction(gameId, msg.sender, msg.value, auctionValue, gameSecondLeft, block.timestamp);
}
function claimReward(uint256 _id) public {
_claimReward(msg.sender, _id);
}
function _claimReward(address _addr, uint256 _id) internal {
if (_id == gameId) {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert('game is still on, cannot claim reward');
}
uint _reward = 0;
uint _dividends = 0;
uint _myMoney = 0;
uint _myDividends = 0;
uint _myRefund = 0;
uint _myReward = 0;
bool _claimed = false;
(_myMoney, _myDividends, _myRefund, _myReward, _claimed) = _getGameInfoPart1(_addr, _id);
(_reward, _dividends) = _getGameInfoPart2(_id);
if (_claimed)
revert('already claimed!');
for (uint k = 0; k < gameAuction[_id].length; k++) {
if (gameAuction[_id][k].addr == _addr) {
gameAuction[_id][k].dividended = true;
}
}
_addr.transfer(_myDividends + _myRefund + _myReward);
emit GameRewardClaim(_id, _addr, _myDividends + _myRefund + _myReward);
}
// can only refund game still on
function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
// anyone can end this round
function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
function getCurrCanRefund() public view returns (bool) {
if (gameAuction[gameId].length > 1) {
if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 2].addr) {
return false;
} else if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 1].addr) {
return false;
}
return true;
} else {
return false;
}
}
function getCurrGameInfo() public view returns (uint256 _gameId,
uint256 _reward,
uint256 _dividends,
uint256 _lastAuction,
uint256 _gap,
uint256 _lastAuctionTime,
uint256 _secondsLeft,
uint256 _myMoney,
uint256 _myDividends,
uint256 _myRefund,
bool _ended) {
_gameId = gameId;
_reward = reward;
_dividends = dividends;
_lastAuction = gameLastAuctionMoney;
_gap = _getGameAuctionGap();
_lastAuctionTime = gameLastAuctionTime;
_secondsLeft = gameSecondLeft;
_ended = (block.timestamp > _lastAuctionTime + _secondsLeft) ? true: false;
uint256 _moneyForCal = 0;
if (gameAuction[gameId].length > 1) {
uint256 totalMoney = 0;
for (uint256 i = 0; i < gameAuction[gameId].length; i++) {
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].dividended == true) {
}
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].refunded == false) {
if ((i == gameAuction[gameId].length - 2) || (i == gameAuction[gameId].length - 1)) {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid);
} else {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid.mul(15).div(100));
}
_myMoney = _myMoney + gameAuction[gameId][i].money;
_moneyForCal = _moneyForCal.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
if (gameAuction[gameId][i].refunded == false) {
totalMoney = totalMoney.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
}
if (totalMoney != 0)
_myDividends = _moneyForCal.mul(_dividends).div(totalMoney);
}
}
function getGameDataByIndex(uint256 _index) public view returns (uint256 _id, uint256 _reward, uint256 _dividends) {
uint256 len = gameData.length;
if (len >= (_index + 1)) {
GameData memory d = gameData[_index];
_id = d.gameId;
_reward = d.reward;
_dividends = d.dividends;
}
}
function getGameInfo(uint256 _id) public view returns (uint256 _reward, uint256 _dividends, uint256 _myMoney, uint256 _myDividends, uint256 _myRefund, uint256 _myReward, bool _claimed) {
(_reward, _dividends) = _getGameInfoPart2(_id);
(_myMoney, _myRefund, _myDividends, _myReward, _claimed) = _getGameInfoPart1(msg.sender, _id);
}
function _getGameInfoPart1(address _addr, uint256 _id) internal view returns (uint256 _myMoney, uint256 _myRefund, uint256 _myDividends, uint256 _myReward, bool _claimed) {
uint256 totalMoney = 0;
uint k = 0;
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
if (gameAuction[d.gameId].length > 1) {
// no.2 bidder can refund except for the last one
if (gameAuction[d.gameId][gameAuction[d.gameId].length - 1].addr == _addr) {
// if sender is winner
_myReward = d.reward;
_myReward = _myReward + gameAuction[d.gameId][gameAuction[d.gameId].length - 2].bid;
}
// add no.2 bidder's money to winner
// address loseBidder = gameAuction[d.gameId][gameAuction[d.gameId].length - 2].addr;
totalMoney = 0;
uint256 _moneyForCal = 0;
for (k = 0; k < gameAuction[d.gameId].length; k++) {
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].dividended == true) {
_claimed = true;
}
// k != (gameAuction[d.gameId].length - 2): for no.2 bidder, who cannot refund this bid
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
_myRefund = _myRefund.add( gameAuction[d.gameId][k].money.sub( gameAuction[d.gameId][k].bid.mul(15).div(100) ) );
_moneyForCal = _moneyForCal.add( (gameAuction[d.gameId][k].money.div(10**15)).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
_myMoney = _myMoney.add(gameAuction[d.gameId][k].money);
}
if (gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
totalMoney = totalMoney.add( ( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
}
}
if (totalMoney != 0)
_myDividends = d.dividends.mul(_moneyForCal).div(totalMoney);
}
break;
}
}
}
}
function _getGameInfoPart2(uint256 _id) internal view returns (uint256 _reward, uint256 _dividends) {
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
_reward = d.reward;
_dividends = d.dividends;
break;
}
}
}
}
////////////////////////// game rule
function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
function _getGameAuctionGap() internal view returns (uint256) {
if (gameLastAuctionMoney < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (gameLastAuctionMoney >= 10**n && gameLastAuctionMoney < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
function _getMinAuctionSeconds() internal pure returns (uint256) {
return 30 * 60;
// return 1 * 60; //test
}
function _getMaxAuctionSeconds() internal pure returns (uint256) {
return 12 * 60 * 60;
// return 3 * 60; //test
}
function _getInitAuctionSeconds() internal pure returns (uint256) {
return 3 * 24 * 60 * 60;
}
// only invoke at the beginning of auction
function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
} | getMinAuctionValue | function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
| ////////////////////////// game play | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
3405,
3597
]
} | 4,820 |
|||
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | Etherauction | contract Etherauction is ContractOwner {
using SafeMath for uint256;
constructor() public payable {
owner = msg.sender;
gameId = 1;
gameStartTime = block.timestamp;
gameLastAuctionMoney = 10**15;
gameLastAuctionTime = block.timestamp;
gameSecondLeft = _getInitAuctionSeconds();
}
function adminAddMoney() public payable {
reward = reward + msg.value * 80 / 100;
nextReward = nextReward + msg.value * 20 / 100;
}
function addAuctionReward() public payable {
reward = reward + msg.value;
}
uint256 gameId; // gameId increase from 1
uint256 gameStartTime; // game start time
uint256 gameLastAuctionTime; // last auction time
uint256 gameLastAuctionMoney;
uint256 gameSecondLeft; // how many seconds left to auction
////////////////////////// money
uint256 reward; // reward for winner
uint256 dividends; // total dividends for players
uint256 nextReward; // reward for next round
uint256 dividendForDev;
////////////////////////// api
OracleBase oracleAPI;
function setOracleAPIAddress(address _addr) public onlyOwner {
oracleAPI = OracleBase(_addr);
}
uint rollCount = 100;
function getRandom() internal returns (uint256) {
rollCount = rollCount + 1;
return oracleAPI.getRandomForContract(100, rollCount);
}
////////////////////////// game money
function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
function _startNewRound(address _addr) internal {
reward = nextReward * 80 / 100;
nextReward = nextReward * 20 / 100;
gameId = gameId + 1;
dividends = 0;
gameStartTime = block.timestamp;
gameLastAuctionTime = block.timestamp;
uint256 price = _getMinAuctionStartPrice();
reward = reward.sub(price);
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][0].addr = _addr;
gameAuction[gameId][0].money = price;
gameAuction[gameId][0].bid = price;
gameAuction[gameId][0].refunded = false;
gameAuction[gameId][0].dividended = false;
gameLastAuctionMoney = price;
gameSecondLeft = _getInitAuctionSeconds();
emit GameAuction(gameId, _addr, price, price, gameSecondLeft, block.timestamp);
}
function adminPayout() public onlyOwner {
owner.transfer(dividendForDev);
dividendForDev = 0;
}
////////////////////////// game struct
struct GameData {
uint256 gameId;
uint256 reward;
uint256 dividends;
}
struct PlayerAuction {
address addr;
uint256 money;
uint256 bid;
bool refunded;
bool dividended;
}
mapping(uint256 => PlayerAuction[]) gameAuction;
GameData[] gameData;
////////////////////////// game event
event GameAuction(uint indexed gameId, address player, uint money, uint auctionValue, uint secondsLeft, uint datetime);
event GameRewardClaim(uint indexed gameId, address indexed player, uint money);
event GameRewardRefund(uint indexed gameId, address indexed player, uint money);
event GameEnd(uint indexed gameId, address indexed winner, uint money, uint datetime);
////////////////////////// game play
function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
function auction() public payable {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended) {
revert('this round end!!!');
}
uint256 len = gameAuction[gameId].length;
if (len > 1) {
address bidder = gameAuction[gameId][len - 1].addr;
if (msg.sender == bidder)
revert("wrong action");
}
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
uint256 maxAuctionValue = 3 * gap + gameLastAuctionMoney;
if (msg.value < auctionValue) {
revert("wrong eth value!");
}
if (msg.value >= maxAuctionValue) {
auctionValue = maxAuctionValue;
} else {
auctionValue = msg.value;
}
gameLastAuctionMoney = auctionValue;
_inMoney(auctionValue);
gameLastAuctionTime = block.timestamp;
uint256 random = getRandom();
gameSecondLeft = random * (_getMaxAuctionSeconds() - _getMinAuctionSeconds()) / 100 + _getMinAuctionSeconds();
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][gameAuction[gameId].length - 1].addr = msg.sender;
gameAuction[gameId][gameAuction[gameId].length - 1].money = msg.value;
gameAuction[gameId][gameAuction[gameId].length - 1].bid = auctionValue;
gameAuction[gameId][gameAuction[gameId].length - 1].refunded = false;
gameAuction[gameId][gameAuction[gameId].length - 1].dividended = false;
emit GameAuction(gameId, msg.sender, msg.value, auctionValue, gameSecondLeft, block.timestamp);
}
function claimReward(uint256 _id) public {
_claimReward(msg.sender, _id);
}
function _claimReward(address _addr, uint256 _id) internal {
if (_id == gameId) {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert('game is still on, cannot claim reward');
}
uint _reward = 0;
uint _dividends = 0;
uint _myMoney = 0;
uint _myDividends = 0;
uint _myRefund = 0;
uint _myReward = 0;
bool _claimed = false;
(_myMoney, _myDividends, _myRefund, _myReward, _claimed) = _getGameInfoPart1(_addr, _id);
(_reward, _dividends) = _getGameInfoPart2(_id);
if (_claimed)
revert('already claimed!');
for (uint k = 0; k < gameAuction[_id].length; k++) {
if (gameAuction[_id][k].addr == _addr) {
gameAuction[_id][k].dividended = true;
}
}
_addr.transfer(_myDividends + _myRefund + _myReward);
emit GameRewardClaim(_id, _addr, _myDividends + _myRefund + _myReward);
}
// can only refund game still on
function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
// anyone can end this round
function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
function getCurrCanRefund() public view returns (bool) {
if (gameAuction[gameId].length > 1) {
if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 2].addr) {
return false;
} else if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 1].addr) {
return false;
}
return true;
} else {
return false;
}
}
function getCurrGameInfo() public view returns (uint256 _gameId,
uint256 _reward,
uint256 _dividends,
uint256 _lastAuction,
uint256 _gap,
uint256 _lastAuctionTime,
uint256 _secondsLeft,
uint256 _myMoney,
uint256 _myDividends,
uint256 _myRefund,
bool _ended) {
_gameId = gameId;
_reward = reward;
_dividends = dividends;
_lastAuction = gameLastAuctionMoney;
_gap = _getGameAuctionGap();
_lastAuctionTime = gameLastAuctionTime;
_secondsLeft = gameSecondLeft;
_ended = (block.timestamp > _lastAuctionTime + _secondsLeft) ? true: false;
uint256 _moneyForCal = 0;
if (gameAuction[gameId].length > 1) {
uint256 totalMoney = 0;
for (uint256 i = 0; i < gameAuction[gameId].length; i++) {
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].dividended == true) {
}
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].refunded == false) {
if ((i == gameAuction[gameId].length - 2) || (i == gameAuction[gameId].length - 1)) {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid);
} else {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid.mul(15).div(100));
}
_myMoney = _myMoney + gameAuction[gameId][i].money;
_moneyForCal = _moneyForCal.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
if (gameAuction[gameId][i].refunded == false) {
totalMoney = totalMoney.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
}
if (totalMoney != 0)
_myDividends = _moneyForCal.mul(_dividends).div(totalMoney);
}
}
function getGameDataByIndex(uint256 _index) public view returns (uint256 _id, uint256 _reward, uint256 _dividends) {
uint256 len = gameData.length;
if (len >= (_index + 1)) {
GameData memory d = gameData[_index];
_id = d.gameId;
_reward = d.reward;
_dividends = d.dividends;
}
}
function getGameInfo(uint256 _id) public view returns (uint256 _reward, uint256 _dividends, uint256 _myMoney, uint256 _myDividends, uint256 _myRefund, uint256 _myReward, bool _claimed) {
(_reward, _dividends) = _getGameInfoPart2(_id);
(_myMoney, _myRefund, _myDividends, _myReward, _claimed) = _getGameInfoPart1(msg.sender, _id);
}
function _getGameInfoPart1(address _addr, uint256 _id) internal view returns (uint256 _myMoney, uint256 _myRefund, uint256 _myDividends, uint256 _myReward, bool _claimed) {
uint256 totalMoney = 0;
uint k = 0;
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
if (gameAuction[d.gameId].length > 1) {
// no.2 bidder can refund except for the last one
if (gameAuction[d.gameId][gameAuction[d.gameId].length - 1].addr == _addr) {
// if sender is winner
_myReward = d.reward;
_myReward = _myReward + gameAuction[d.gameId][gameAuction[d.gameId].length - 2].bid;
}
// add no.2 bidder's money to winner
// address loseBidder = gameAuction[d.gameId][gameAuction[d.gameId].length - 2].addr;
totalMoney = 0;
uint256 _moneyForCal = 0;
for (k = 0; k < gameAuction[d.gameId].length; k++) {
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].dividended == true) {
_claimed = true;
}
// k != (gameAuction[d.gameId].length - 2): for no.2 bidder, who cannot refund this bid
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
_myRefund = _myRefund.add( gameAuction[d.gameId][k].money.sub( gameAuction[d.gameId][k].bid.mul(15).div(100) ) );
_moneyForCal = _moneyForCal.add( (gameAuction[d.gameId][k].money.div(10**15)).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
_myMoney = _myMoney.add(gameAuction[d.gameId][k].money);
}
if (gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
totalMoney = totalMoney.add( ( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
}
}
if (totalMoney != 0)
_myDividends = d.dividends.mul(_moneyForCal).div(totalMoney);
}
break;
}
}
}
}
function _getGameInfoPart2(uint256 _id) internal view returns (uint256 _reward, uint256 _dividends) {
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
_reward = d.reward;
_dividends = d.dividends;
break;
}
}
}
}
////////////////////////// game rule
function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
function _getGameAuctionGap() internal view returns (uint256) {
if (gameLastAuctionMoney < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (gameLastAuctionMoney >= 10**n && gameLastAuctionMoney < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
function _getMinAuctionSeconds() internal pure returns (uint256) {
return 30 * 60;
// return 1 * 60; //test
}
function _getMaxAuctionSeconds() internal pure returns (uint256) {
return 12 * 60 * 60;
// return 3 * 60; //test
}
function _getInitAuctionSeconds() internal pure returns (uint256) {
return 3 * 24 * 60 * 60;
}
// only invoke at the beginning of auction
function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
} | refund | function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
| // can only refund game still on | LineComment | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
6298,
7094
]
} | 4,821 |
|||
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | Etherauction | contract Etherauction is ContractOwner {
using SafeMath for uint256;
constructor() public payable {
owner = msg.sender;
gameId = 1;
gameStartTime = block.timestamp;
gameLastAuctionMoney = 10**15;
gameLastAuctionTime = block.timestamp;
gameSecondLeft = _getInitAuctionSeconds();
}
function adminAddMoney() public payable {
reward = reward + msg.value * 80 / 100;
nextReward = nextReward + msg.value * 20 / 100;
}
function addAuctionReward() public payable {
reward = reward + msg.value;
}
uint256 gameId; // gameId increase from 1
uint256 gameStartTime; // game start time
uint256 gameLastAuctionTime; // last auction time
uint256 gameLastAuctionMoney;
uint256 gameSecondLeft; // how many seconds left to auction
////////////////////////// money
uint256 reward; // reward for winner
uint256 dividends; // total dividends for players
uint256 nextReward; // reward for next round
uint256 dividendForDev;
////////////////////////// api
OracleBase oracleAPI;
function setOracleAPIAddress(address _addr) public onlyOwner {
oracleAPI = OracleBase(_addr);
}
uint rollCount = 100;
function getRandom() internal returns (uint256) {
rollCount = rollCount + 1;
return oracleAPI.getRandomForContract(100, rollCount);
}
////////////////////////// game money
function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
function _startNewRound(address _addr) internal {
reward = nextReward * 80 / 100;
nextReward = nextReward * 20 / 100;
gameId = gameId + 1;
dividends = 0;
gameStartTime = block.timestamp;
gameLastAuctionTime = block.timestamp;
uint256 price = _getMinAuctionStartPrice();
reward = reward.sub(price);
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][0].addr = _addr;
gameAuction[gameId][0].money = price;
gameAuction[gameId][0].bid = price;
gameAuction[gameId][0].refunded = false;
gameAuction[gameId][0].dividended = false;
gameLastAuctionMoney = price;
gameSecondLeft = _getInitAuctionSeconds();
emit GameAuction(gameId, _addr, price, price, gameSecondLeft, block.timestamp);
}
function adminPayout() public onlyOwner {
owner.transfer(dividendForDev);
dividendForDev = 0;
}
////////////////////////// game struct
struct GameData {
uint256 gameId;
uint256 reward;
uint256 dividends;
}
struct PlayerAuction {
address addr;
uint256 money;
uint256 bid;
bool refunded;
bool dividended;
}
mapping(uint256 => PlayerAuction[]) gameAuction;
GameData[] gameData;
////////////////////////// game event
event GameAuction(uint indexed gameId, address player, uint money, uint auctionValue, uint secondsLeft, uint datetime);
event GameRewardClaim(uint indexed gameId, address indexed player, uint money);
event GameRewardRefund(uint indexed gameId, address indexed player, uint money);
event GameEnd(uint indexed gameId, address indexed winner, uint money, uint datetime);
////////////////////////// game play
function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
function auction() public payable {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended) {
revert('this round end!!!');
}
uint256 len = gameAuction[gameId].length;
if (len > 1) {
address bidder = gameAuction[gameId][len - 1].addr;
if (msg.sender == bidder)
revert("wrong action");
}
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
uint256 maxAuctionValue = 3 * gap + gameLastAuctionMoney;
if (msg.value < auctionValue) {
revert("wrong eth value!");
}
if (msg.value >= maxAuctionValue) {
auctionValue = maxAuctionValue;
} else {
auctionValue = msg.value;
}
gameLastAuctionMoney = auctionValue;
_inMoney(auctionValue);
gameLastAuctionTime = block.timestamp;
uint256 random = getRandom();
gameSecondLeft = random * (_getMaxAuctionSeconds() - _getMinAuctionSeconds()) / 100 + _getMinAuctionSeconds();
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][gameAuction[gameId].length - 1].addr = msg.sender;
gameAuction[gameId][gameAuction[gameId].length - 1].money = msg.value;
gameAuction[gameId][gameAuction[gameId].length - 1].bid = auctionValue;
gameAuction[gameId][gameAuction[gameId].length - 1].refunded = false;
gameAuction[gameId][gameAuction[gameId].length - 1].dividended = false;
emit GameAuction(gameId, msg.sender, msg.value, auctionValue, gameSecondLeft, block.timestamp);
}
function claimReward(uint256 _id) public {
_claimReward(msg.sender, _id);
}
function _claimReward(address _addr, uint256 _id) internal {
if (_id == gameId) {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert('game is still on, cannot claim reward');
}
uint _reward = 0;
uint _dividends = 0;
uint _myMoney = 0;
uint _myDividends = 0;
uint _myRefund = 0;
uint _myReward = 0;
bool _claimed = false;
(_myMoney, _myDividends, _myRefund, _myReward, _claimed) = _getGameInfoPart1(_addr, _id);
(_reward, _dividends) = _getGameInfoPart2(_id);
if (_claimed)
revert('already claimed!');
for (uint k = 0; k < gameAuction[_id].length; k++) {
if (gameAuction[_id][k].addr == _addr) {
gameAuction[_id][k].dividended = true;
}
}
_addr.transfer(_myDividends + _myRefund + _myReward);
emit GameRewardClaim(_id, _addr, _myDividends + _myRefund + _myReward);
}
// can only refund game still on
function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
// anyone can end this round
function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
function getCurrCanRefund() public view returns (bool) {
if (gameAuction[gameId].length > 1) {
if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 2].addr) {
return false;
} else if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 1].addr) {
return false;
}
return true;
} else {
return false;
}
}
function getCurrGameInfo() public view returns (uint256 _gameId,
uint256 _reward,
uint256 _dividends,
uint256 _lastAuction,
uint256 _gap,
uint256 _lastAuctionTime,
uint256 _secondsLeft,
uint256 _myMoney,
uint256 _myDividends,
uint256 _myRefund,
bool _ended) {
_gameId = gameId;
_reward = reward;
_dividends = dividends;
_lastAuction = gameLastAuctionMoney;
_gap = _getGameAuctionGap();
_lastAuctionTime = gameLastAuctionTime;
_secondsLeft = gameSecondLeft;
_ended = (block.timestamp > _lastAuctionTime + _secondsLeft) ? true: false;
uint256 _moneyForCal = 0;
if (gameAuction[gameId].length > 1) {
uint256 totalMoney = 0;
for (uint256 i = 0; i < gameAuction[gameId].length; i++) {
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].dividended == true) {
}
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].refunded == false) {
if ((i == gameAuction[gameId].length - 2) || (i == gameAuction[gameId].length - 1)) {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid);
} else {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid.mul(15).div(100));
}
_myMoney = _myMoney + gameAuction[gameId][i].money;
_moneyForCal = _moneyForCal.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
if (gameAuction[gameId][i].refunded == false) {
totalMoney = totalMoney.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
}
if (totalMoney != 0)
_myDividends = _moneyForCal.mul(_dividends).div(totalMoney);
}
}
function getGameDataByIndex(uint256 _index) public view returns (uint256 _id, uint256 _reward, uint256 _dividends) {
uint256 len = gameData.length;
if (len >= (_index + 1)) {
GameData memory d = gameData[_index];
_id = d.gameId;
_reward = d.reward;
_dividends = d.dividends;
}
}
function getGameInfo(uint256 _id) public view returns (uint256 _reward, uint256 _dividends, uint256 _myMoney, uint256 _myDividends, uint256 _myRefund, uint256 _myReward, bool _claimed) {
(_reward, _dividends) = _getGameInfoPart2(_id);
(_myMoney, _myRefund, _myDividends, _myReward, _claimed) = _getGameInfoPart1(msg.sender, _id);
}
function _getGameInfoPart1(address _addr, uint256 _id) internal view returns (uint256 _myMoney, uint256 _myRefund, uint256 _myDividends, uint256 _myReward, bool _claimed) {
uint256 totalMoney = 0;
uint k = 0;
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
if (gameAuction[d.gameId].length > 1) {
// no.2 bidder can refund except for the last one
if (gameAuction[d.gameId][gameAuction[d.gameId].length - 1].addr == _addr) {
// if sender is winner
_myReward = d.reward;
_myReward = _myReward + gameAuction[d.gameId][gameAuction[d.gameId].length - 2].bid;
}
// add no.2 bidder's money to winner
// address loseBidder = gameAuction[d.gameId][gameAuction[d.gameId].length - 2].addr;
totalMoney = 0;
uint256 _moneyForCal = 0;
for (k = 0; k < gameAuction[d.gameId].length; k++) {
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].dividended == true) {
_claimed = true;
}
// k != (gameAuction[d.gameId].length - 2): for no.2 bidder, who cannot refund this bid
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
_myRefund = _myRefund.add( gameAuction[d.gameId][k].money.sub( gameAuction[d.gameId][k].bid.mul(15).div(100) ) );
_moneyForCal = _moneyForCal.add( (gameAuction[d.gameId][k].money.div(10**15)).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
_myMoney = _myMoney.add(gameAuction[d.gameId][k].money);
}
if (gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
totalMoney = totalMoney.add( ( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
}
}
if (totalMoney != 0)
_myDividends = d.dividends.mul(_moneyForCal).div(totalMoney);
}
break;
}
}
}
}
function _getGameInfoPart2(uint256 _id) internal view returns (uint256 _reward, uint256 _dividends) {
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
_reward = d.reward;
_dividends = d.dividends;
break;
}
}
}
}
////////////////////////// game rule
function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
function _getGameAuctionGap() internal view returns (uint256) {
if (gameLastAuctionMoney < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (gameLastAuctionMoney >= 10**n && gameLastAuctionMoney < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
function _getMinAuctionSeconds() internal pure returns (uint256) {
return 30 * 60;
// return 1 * 60; //test
}
function _getMaxAuctionSeconds() internal pure returns (uint256) {
return 12 * 60 * 60;
// return 3 * 60; //test
}
function _getInitAuctionSeconds() internal pure returns (uint256) {
return 3 * 24 * 60 * 60;
}
// only invoke at the beginning of auction
function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
} | gameRoundEnd | function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
| // anyone can end this round | LineComment | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
7131,
7813
]
} | 4,822 |
|||
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | Etherauction | contract Etherauction is ContractOwner {
using SafeMath for uint256;
constructor() public payable {
owner = msg.sender;
gameId = 1;
gameStartTime = block.timestamp;
gameLastAuctionMoney = 10**15;
gameLastAuctionTime = block.timestamp;
gameSecondLeft = _getInitAuctionSeconds();
}
function adminAddMoney() public payable {
reward = reward + msg.value * 80 / 100;
nextReward = nextReward + msg.value * 20 / 100;
}
function addAuctionReward() public payable {
reward = reward + msg.value;
}
uint256 gameId; // gameId increase from 1
uint256 gameStartTime; // game start time
uint256 gameLastAuctionTime; // last auction time
uint256 gameLastAuctionMoney;
uint256 gameSecondLeft; // how many seconds left to auction
////////////////////////// money
uint256 reward; // reward for winner
uint256 dividends; // total dividends for players
uint256 nextReward; // reward for next round
uint256 dividendForDev;
////////////////////////// api
OracleBase oracleAPI;
function setOracleAPIAddress(address _addr) public onlyOwner {
oracleAPI = OracleBase(_addr);
}
uint rollCount = 100;
function getRandom() internal returns (uint256) {
rollCount = rollCount + 1;
return oracleAPI.getRandomForContract(100, rollCount);
}
////////////////////////// game money
function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
function _startNewRound(address _addr) internal {
reward = nextReward * 80 / 100;
nextReward = nextReward * 20 / 100;
gameId = gameId + 1;
dividends = 0;
gameStartTime = block.timestamp;
gameLastAuctionTime = block.timestamp;
uint256 price = _getMinAuctionStartPrice();
reward = reward.sub(price);
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][0].addr = _addr;
gameAuction[gameId][0].money = price;
gameAuction[gameId][0].bid = price;
gameAuction[gameId][0].refunded = false;
gameAuction[gameId][0].dividended = false;
gameLastAuctionMoney = price;
gameSecondLeft = _getInitAuctionSeconds();
emit GameAuction(gameId, _addr, price, price, gameSecondLeft, block.timestamp);
}
function adminPayout() public onlyOwner {
owner.transfer(dividendForDev);
dividendForDev = 0;
}
////////////////////////// game struct
struct GameData {
uint256 gameId;
uint256 reward;
uint256 dividends;
}
struct PlayerAuction {
address addr;
uint256 money;
uint256 bid;
bool refunded;
bool dividended;
}
mapping(uint256 => PlayerAuction[]) gameAuction;
GameData[] gameData;
////////////////////////// game event
event GameAuction(uint indexed gameId, address player, uint money, uint auctionValue, uint secondsLeft, uint datetime);
event GameRewardClaim(uint indexed gameId, address indexed player, uint money);
event GameRewardRefund(uint indexed gameId, address indexed player, uint money);
event GameEnd(uint indexed gameId, address indexed winner, uint money, uint datetime);
////////////////////////// game play
function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
function auction() public payable {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended) {
revert('this round end!!!');
}
uint256 len = gameAuction[gameId].length;
if (len > 1) {
address bidder = gameAuction[gameId][len - 1].addr;
if (msg.sender == bidder)
revert("wrong action");
}
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
uint256 maxAuctionValue = 3 * gap + gameLastAuctionMoney;
if (msg.value < auctionValue) {
revert("wrong eth value!");
}
if (msg.value >= maxAuctionValue) {
auctionValue = maxAuctionValue;
} else {
auctionValue = msg.value;
}
gameLastAuctionMoney = auctionValue;
_inMoney(auctionValue);
gameLastAuctionTime = block.timestamp;
uint256 random = getRandom();
gameSecondLeft = random * (_getMaxAuctionSeconds() - _getMinAuctionSeconds()) / 100 + _getMinAuctionSeconds();
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][gameAuction[gameId].length - 1].addr = msg.sender;
gameAuction[gameId][gameAuction[gameId].length - 1].money = msg.value;
gameAuction[gameId][gameAuction[gameId].length - 1].bid = auctionValue;
gameAuction[gameId][gameAuction[gameId].length - 1].refunded = false;
gameAuction[gameId][gameAuction[gameId].length - 1].dividended = false;
emit GameAuction(gameId, msg.sender, msg.value, auctionValue, gameSecondLeft, block.timestamp);
}
function claimReward(uint256 _id) public {
_claimReward(msg.sender, _id);
}
function _claimReward(address _addr, uint256 _id) internal {
if (_id == gameId) {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert('game is still on, cannot claim reward');
}
uint _reward = 0;
uint _dividends = 0;
uint _myMoney = 0;
uint _myDividends = 0;
uint _myRefund = 0;
uint _myReward = 0;
bool _claimed = false;
(_myMoney, _myDividends, _myRefund, _myReward, _claimed) = _getGameInfoPart1(_addr, _id);
(_reward, _dividends) = _getGameInfoPart2(_id);
if (_claimed)
revert('already claimed!');
for (uint k = 0; k < gameAuction[_id].length; k++) {
if (gameAuction[_id][k].addr == _addr) {
gameAuction[_id][k].dividended = true;
}
}
_addr.transfer(_myDividends + _myRefund + _myReward);
emit GameRewardClaim(_id, _addr, _myDividends + _myRefund + _myReward);
}
// can only refund game still on
function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
// anyone can end this round
function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
function getCurrCanRefund() public view returns (bool) {
if (gameAuction[gameId].length > 1) {
if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 2].addr) {
return false;
} else if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 1].addr) {
return false;
}
return true;
} else {
return false;
}
}
function getCurrGameInfo() public view returns (uint256 _gameId,
uint256 _reward,
uint256 _dividends,
uint256 _lastAuction,
uint256 _gap,
uint256 _lastAuctionTime,
uint256 _secondsLeft,
uint256 _myMoney,
uint256 _myDividends,
uint256 _myRefund,
bool _ended) {
_gameId = gameId;
_reward = reward;
_dividends = dividends;
_lastAuction = gameLastAuctionMoney;
_gap = _getGameAuctionGap();
_lastAuctionTime = gameLastAuctionTime;
_secondsLeft = gameSecondLeft;
_ended = (block.timestamp > _lastAuctionTime + _secondsLeft) ? true: false;
uint256 _moneyForCal = 0;
if (gameAuction[gameId].length > 1) {
uint256 totalMoney = 0;
for (uint256 i = 0; i < gameAuction[gameId].length; i++) {
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].dividended == true) {
}
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].refunded == false) {
if ((i == gameAuction[gameId].length - 2) || (i == gameAuction[gameId].length - 1)) {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid);
} else {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid.mul(15).div(100));
}
_myMoney = _myMoney + gameAuction[gameId][i].money;
_moneyForCal = _moneyForCal.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
if (gameAuction[gameId][i].refunded == false) {
totalMoney = totalMoney.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
}
if (totalMoney != 0)
_myDividends = _moneyForCal.mul(_dividends).div(totalMoney);
}
}
function getGameDataByIndex(uint256 _index) public view returns (uint256 _id, uint256 _reward, uint256 _dividends) {
uint256 len = gameData.length;
if (len >= (_index + 1)) {
GameData memory d = gameData[_index];
_id = d.gameId;
_reward = d.reward;
_dividends = d.dividends;
}
}
function getGameInfo(uint256 _id) public view returns (uint256 _reward, uint256 _dividends, uint256 _myMoney, uint256 _myDividends, uint256 _myRefund, uint256 _myReward, bool _claimed) {
(_reward, _dividends) = _getGameInfoPart2(_id);
(_myMoney, _myRefund, _myDividends, _myReward, _claimed) = _getGameInfoPart1(msg.sender, _id);
}
function _getGameInfoPart1(address _addr, uint256 _id) internal view returns (uint256 _myMoney, uint256 _myRefund, uint256 _myDividends, uint256 _myReward, bool _claimed) {
uint256 totalMoney = 0;
uint k = 0;
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
if (gameAuction[d.gameId].length > 1) {
// no.2 bidder can refund except for the last one
if (gameAuction[d.gameId][gameAuction[d.gameId].length - 1].addr == _addr) {
// if sender is winner
_myReward = d.reward;
_myReward = _myReward + gameAuction[d.gameId][gameAuction[d.gameId].length - 2].bid;
}
// add no.2 bidder's money to winner
// address loseBidder = gameAuction[d.gameId][gameAuction[d.gameId].length - 2].addr;
totalMoney = 0;
uint256 _moneyForCal = 0;
for (k = 0; k < gameAuction[d.gameId].length; k++) {
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].dividended == true) {
_claimed = true;
}
// k != (gameAuction[d.gameId].length - 2): for no.2 bidder, who cannot refund this bid
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
_myRefund = _myRefund.add( gameAuction[d.gameId][k].money.sub( gameAuction[d.gameId][k].bid.mul(15).div(100) ) );
_moneyForCal = _moneyForCal.add( (gameAuction[d.gameId][k].money.div(10**15)).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
_myMoney = _myMoney.add(gameAuction[d.gameId][k].money);
}
if (gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
totalMoney = totalMoney.add( ( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
}
}
if (totalMoney != 0)
_myDividends = d.dividends.mul(_moneyForCal).div(totalMoney);
}
break;
}
}
}
}
function _getGameInfoPart2(uint256 _id) internal view returns (uint256 _reward, uint256 _dividends) {
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
_reward = d.reward;
_dividends = d.dividends;
break;
}
}
}
}
////////////////////////// game rule
function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
function _getGameAuctionGap() internal view returns (uint256) {
if (gameLastAuctionMoney < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (gameLastAuctionMoney >= 10**n && gameLastAuctionMoney < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
function _getMinAuctionSeconds() internal pure returns (uint256) {
return 30 * 60;
// return 1 * 60; //test
}
function _getMaxAuctionSeconds() internal pure returns (uint256) {
return 12 * 60 * 60;
// return 3 * 60; //test
}
function _getInitAuctionSeconds() internal pure returns (uint256) {
return 3 * 24 * 60 * 60;
}
// only invoke at the beginning of auction
function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
} | _getGameStartAuctionMoney | function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
| ////////////////////////// game rule | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
14321,
14419
]
} | 4,823 |
|||
Etherauction | Etherauction.sol | 0x39f996a2cafca0e593d0c46b8365d3936b6cc1cf | Solidity | Etherauction | contract Etherauction is ContractOwner {
using SafeMath for uint256;
constructor() public payable {
owner = msg.sender;
gameId = 1;
gameStartTime = block.timestamp;
gameLastAuctionMoney = 10**15;
gameLastAuctionTime = block.timestamp;
gameSecondLeft = _getInitAuctionSeconds();
}
function adminAddMoney() public payable {
reward = reward + msg.value * 80 / 100;
nextReward = nextReward + msg.value * 20 / 100;
}
function addAuctionReward() public payable {
reward = reward + msg.value;
}
uint256 gameId; // gameId increase from 1
uint256 gameStartTime; // game start time
uint256 gameLastAuctionTime; // last auction time
uint256 gameLastAuctionMoney;
uint256 gameSecondLeft; // how many seconds left to auction
////////////////////////// money
uint256 reward; // reward for winner
uint256 dividends; // total dividends for players
uint256 nextReward; // reward for next round
uint256 dividendForDev;
////////////////////////// api
OracleBase oracleAPI;
function setOracleAPIAddress(address _addr) public onlyOwner {
oracleAPI = OracleBase(_addr);
}
uint rollCount = 100;
function getRandom() internal returns (uint256) {
rollCount = rollCount + 1;
return oracleAPI.getRandomForContract(100, rollCount);
}
////////////////////////// game money
function _inMoney(uint _m) internal {
dividends = dividends + _m * 7 / 100;
dividendForDev = dividendForDev + _m * 2 / 100;
reward = reward + _m * 2 / 100;
nextReward = nextReward + _m * 4 / 100;
}
function _startNewRound(address _addr) internal {
reward = nextReward * 80 / 100;
nextReward = nextReward * 20 / 100;
gameId = gameId + 1;
dividends = 0;
gameStartTime = block.timestamp;
gameLastAuctionTime = block.timestamp;
uint256 price = _getMinAuctionStartPrice();
reward = reward.sub(price);
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][0].addr = _addr;
gameAuction[gameId][0].money = price;
gameAuction[gameId][0].bid = price;
gameAuction[gameId][0].refunded = false;
gameAuction[gameId][0].dividended = false;
gameLastAuctionMoney = price;
gameSecondLeft = _getInitAuctionSeconds();
emit GameAuction(gameId, _addr, price, price, gameSecondLeft, block.timestamp);
}
function adminPayout() public onlyOwner {
owner.transfer(dividendForDev);
dividendForDev = 0;
}
////////////////////////// game struct
struct GameData {
uint256 gameId;
uint256 reward;
uint256 dividends;
}
struct PlayerAuction {
address addr;
uint256 money;
uint256 bid;
bool refunded;
bool dividended;
}
mapping(uint256 => PlayerAuction[]) gameAuction;
GameData[] gameData;
////////////////////////// game event
event GameAuction(uint indexed gameId, address player, uint money, uint auctionValue, uint secondsLeft, uint datetime);
event GameRewardClaim(uint indexed gameId, address indexed player, uint money);
event GameRewardRefund(uint indexed gameId, address indexed player, uint money);
event GameEnd(uint indexed gameId, address indexed winner, uint money, uint datetime);
////////////////////////// game play
function getMinAuctionValue() public view returns (uint256) {
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
return auctionValue;
}
function auction() public payable {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended) {
revert('this round end!!!');
}
uint256 len = gameAuction[gameId].length;
if (len > 1) {
address bidder = gameAuction[gameId][len - 1].addr;
if (msg.sender == bidder)
revert("wrong action");
}
uint256 gap = _getGameAuctionGap();
uint256 auctionValue = gap + gameLastAuctionMoney;
uint256 maxAuctionValue = 3 * gap + gameLastAuctionMoney;
if (msg.value < auctionValue) {
revert("wrong eth value!");
}
if (msg.value >= maxAuctionValue) {
auctionValue = maxAuctionValue;
} else {
auctionValue = msg.value;
}
gameLastAuctionMoney = auctionValue;
_inMoney(auctionValue);
gameLastAuctionTime = block.timestamp;
uint256 random = getRandom();
gameSecondLeft = random * (_getMaxAuctionSeconds() - _getMinAuctionSeconds()) / 100 + _getMinAuctionSeconds();
PlayerAuction memory p;
gameAuction[gameId].push(p);
gameAuction[gameId][gameAuction[gameId].length - 1].addr = msg.sender;
gameAuction[gameId][gameAuction[gameId].length - 1].money = msg.value;
gameAuction[gameId][gameAuction[gameId].length - 1].bid = auctionValue;
gameAuction[gameId][gameAuction[gameId].length - 1].refunded = false;
gameAuction[gameId][gameAuction[gameId].length - 1].dividended = false;
emit GameAuction(gameId, msg.sender, msg.value, auctionValue, gameSecondLeft, block.timestamp);
}
function claimReward(uint256 _id) public {
_claimReward(msg.sender, _id);
}
function _claimReward(address _addr, uint256 _id) internal {
if (_id == gameId) {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert('game is still on, cannot claim reward');
}
uint _reward = 0;
uint _dividends = 0;
uint _myMoney = 0;
uint _myDividends = 0;
uint _myRefund = 0;
uint _myReward = 0;
bool _claimed = false;
(_myMoney, _myDividends, _myRefund, _myReward, _claimed) = _getGameInfoPart1(_addr, _id);
(_reward, _dividends) = _getGameInfoPart2(_id);
if (_claimed)
revert('already claimed!');
for (uint k = 0; k < gameAuction[_id].length; k++) {
if (gameAuction[_id][k].addr == _addr) {
gameAuction[_id][k].dividended = true;
}
}
_addr.transfer(_myDividends + _myRefund + _myReward);
emit GameRewardClaim(_id, _addr, _myDividends + _myRefund + _myReward);
}
// can only refund game still on
function refund() public {
uint256 len = gameAuction[gameId].length;
if (len > 1) {
if (msg.sender != gameAuction[gameId][len - 2].addr
&& msg.sender != gameAuction[gameId][len - 1].addr) {
uint256 money = 0;
for (uint k = 0; k < gameAuction[gameId].length; k++) {
if (gameAuction[gameId][k].addr == msg.sender && gameAuction[gameId][k].refunded == false) {
money = money + gameAuction[gameId][k].bid * 85 / 100 + gameAuction[gameId][k].money;
gameAuction[gameId][k].refunded = true;
}
}
msg.sender.transfer(money);
emit GameRewardRefund(gameId, msg.sender, money);
} else {
revert('cannot refund because you are no.2 bidder');
}
}
}
// anyone can end this round
function gameRoundEnd() public {
bool ended = (block.timestamp > gameLastAuctionTime + gameSecondLeft) ? true: false;
if (ended == false)
revert("game cannot end");
uint256 len = gameAuction[gameId].length;
address winner = gameAuction[gameId][len - 1].addr;
GameData memory d;
gameData.push(d);
gameData[gameData.length - 1].gameId = gameId;
gameData[gameData.length - 1].reward = reward;
gameData[gameData.length - 1].dividends = dividends;
_startNewRound(msg.sender);
_claimReward(msg.sender, gameId - 1);
emit GameEnd(gameId - 1, winner, gameData[gameData.length - 1].reward, block.timestamp);
}
function getCurrCanRefund() public view returns (bool) {
if (gameAuction[gameId].length > 1) {
if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 2].addr) {
return false;
} else if (msg.sender == gameAuction[gameId][gameAuction[gameId].length - 1].addr) {
return false;
}
return true;
} else {
return false;
}
}
function getCurrGameInfo() public view returns (uint256 _gameId,
uint256 _reward,
uint256 _dividends,
uint256 _lastAuction,
uint256 _gap,
uint256 _lastAuctionTime,
uint256 _secondsLeft,
uint256 _myMoney,
uint256 _myDividends,
uint256 _myRefund,
bool _ended) {
_gameId = gameId;
_reward = reward;
_dividends = dividends;
_lastAuction = gameLastAuctionMoney;
_gap = _getGameAuctionGap();
_lastAuctionTime = gameLastAuctionTime;
_secondsLeft = gameSecondLeft;
_ended = (block.timestamp > _lastAuctionTime + _secondsLeft) ? true: false;
uint256 _moneyForCal = 0;
if (gameAuction[gameId].length > 1) {
uint256 totalMoney = 0;
for (uint256 i = 0; i < gameAuction[gameId].length; i++) {
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].dividended == true) {
}
if (gameAuction[gameId][i].addr == msg.sender && gameAuction[gameId][i].refunded == false) {
if ((i == gameAuction[gameId].length - 2) || (i == gameAuction[gameId].length - 1)) {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid);
} else {
_myRefund = _myRefund.add(gameAuction[gameId][i].money).sub(gameAuction[gameId][i].bid.mul(15).div(100));
}
_myMoney = _myMoney + gameAuction[gameId][i].money;
_moneyForCal = _moneyForCal.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
if (gameAuction[gameId][i].refunded == false) {
totalMoney = totalMoney.add((gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId][i].money.div(10**15)).mul(gameAuction[gameId].length + 1 - i));
}
}
if (totalMoney != 0)
_myDividends = _moneyForCal.mul(_dividends).div(totalMoney);
}
}
function getGameDataByIndex(uint256 _index) public view returns (uint256 _id, uint256 _reward, uint256 _dividends) {
uint256 len = gameData.length;
if (len >= (_index + 1)) {
GameData memory d = gameData[_index];
_id = d.gameId;
_reward = d.reward;
_dividends = d.dividends;
}
}
function getGameInfo(uint256 _id) public view returns (uint256 _reward, uint256 _dividends, uint256 _myMoney, uint256 _myDividends, uint256 _myRefund, uint256 _myReward, bool _claimed) {
(_reward, _dividends) = _getGameInfoPart2(_id);
(_myMoney, _myRefund, _myDividends, _myReward, _claimed) = _getGameInfoPart1(msg.sender, _id);
}
function _getGameInfoPart1(address _addr, uint256 _id) internal view returns (uint256 _myMoney, uint256 _myRefund, uint256 _myDividends, uint256 _myReward, bool _claimed) {
uint256 totalMoney = 0;
uint k = 0;
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
if (gameAuction[d.gameId].length > 1) {
// no.2 bidder can refund except for the last one
if (gameAuction[d.gameId][gameAuction[d.gameId].length - 1].addr == _addr) {
// if sender is winner
_myReward = d.reward;
_myReward = _myReward + gameAuction[d.gameId][gameAuction[d.gameId].length - 2].bid;
}
// add no.2 bidder's money to winner
// address loseBidder = gameAuction[d.gameId][gameAuction[d.gameId].length - 2].addr;
totalMoney = 0;
uint256 _moneyForCal = 0;
for (k = 0; k < gameAuction[d.gameId].length; k++) {
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].dividended == true) {
_claimed = true;
}
// k != (gameAuction[d.gameId].length - 2): for no.2 bidder, who cannot refund this bid
if (gameAuction[d.gameId][k].addr == _addr && gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
_myRefund = _myRefund.add( gameAuction[d.gameId][k].money.sub( gameAuction[d.gameId][k].bid.mul(15).div(100) ) );
_moneyForCal = _moneyForCal.add( (gameAuction[d.gameId][k].money.div(10**15)).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
_myMoney = _myMoney.add(gameAuction[d.gameId][k].money);
}
if (gameAuction[d.gameId][k].refunded == false && k != (gameAuction[d.gameId].length - 2)) {
totalMoney = totalMoney.add( ( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId][k].money.div(10**15) ).mul( gameAuction[d.gameId].length + 1 - k) );
}
}
if (totalMoney != 0)
_myDividends = d.dividends.mul(_moneyForCal).div(totalMoney);
}
break;
}
}
}
}
function _getGameInfoPart2(uint256 _id) internal view returns (uint256 _reward, uint256 _dividends) {
if (_id == gameId) {
} else {
for (uint256 i = 0; i < gameData.length; i++) {
GameData memory d = gameData[i];
if (d.gameId == _id) {
_reward = d.reward;
_dividends = d.dividends;
break;
}
}
}
}
////////////////////////// game rule
function _getGameStartAuctionMoney() internal pure returns (uint256) {
return 10**15;
}
function _getGameAuctionGap() internal view returns (uint256) {
if (gameLastAuctionMoney < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (gameLastAuctionMoney >= 10**n && gameLastAuctionMoney < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
function _getMinAuctionSeconds() internal pure returns (uint256) {
return 30 * 60;
// return 1 * 60; //test
}
function _getMaxAuctionSeconds() internal pure returns (uint256) {
return 12 * 60 * 60;
// return 3 * 60; //test
}
function _getInitAuctionSeconds() internal pure returns (uint256) {
return 3 * 24 * 60 * 60;
}
// only invoke at the beginning of auction
function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
} | _getMinAuctionStartPrice | function _getMinAuctionStartPrice() internal view returns (uint256) {
if (reward < 10**18) {
return 10**15;
}
uint256 n = 17;
for (n = 18; n < 200; n ++) {
if (reward >= 10**n && reward < 10**(n + 1)) {
break;
}
}
return 10**(n-2);
}
| // only invoke at the beginning of auction | LineComment | v0.4.24+commit.e67f0147 | bzzr://b41ad95a7a559f0ab44e80bbe03d81c0f6ce5b4a76e02a0cb7bb67023870aaf9 | {
"func_code_index": [
15180,
15483
]
} | 4,824 |
|||
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryAdd | function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
| /**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
161,
388
]
} | 4,825 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | trySub | function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
| /**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
536,
735
]
} | 4,826 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryMul | function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
| /**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
885,
1393
]
} | 4,827 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryDiv | function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
| /**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
1544,
1744
]
} | 4,828 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | tryMod | function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
| /**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
1905,
2105
]
} | 4,829 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
2347,
2450
]
} | 4,830 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
2728,
2831
]
} | 4,831 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
3085,
3188
]
} | 4,832 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
| /**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
3484,
3587
]
} | 4,833 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | mod | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
4049,
4152
]
} | 4,834 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | sub | function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
| /**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
4626,
4871
]
} | 4,835 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | div | function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
| /**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
5364,
5608
]
} | 4,836 |
Warsnails | @openzeppelin/contracts/utils/math/SafeMath.sol | 0x3c197a9bbedccd44d71f4dd8581bbf6a7196c57d | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
} | /**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/ | NatSpecMultiLine | mod | function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
| /**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | MIT | ipfs://965e4270ffb99672fc47ec19c80866d92c5b2b82ed007c03d36b5238214c5afa | {
"func_code_index": [
6266,
6510
]
} | 4,837 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getNumMarkets | function getNumMarkets()
public
view
returns (uint256);
| /**
* Get the total number of markets.
*
* @return The number of markets
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
331,
418
]
} | 4,838 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getMarketTokenAddress | function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
| /**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
587,
714
]
} | 4,839 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getMarketTotalPar | function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
| /**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
921,
1058
]
} | 4,840 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getMarketMarginPremium | function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
| /**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
1391,
1531
]
} | 4,841 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getMarketSpreadPremium | function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
| /**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
1834,
1974
]
} | 4,842 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getMarketIsClosing | function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
| /**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
2242,
2363
]
} | 4,843 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getMarketPrice | function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
| /**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
2556,
2690
]
} | 4,844 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getLiquidationSpreadForPair | function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
| /**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
3143,
3323
]
} | 4,845 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getNumExcessTokens | function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
| /**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
3753,
3886
]
} | 4,846 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getAccountPar | function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
| /**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
4180,
4346
]
} | 4,847 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getAccountWei | function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
| /**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
4578,
4744
]
} | 4,848 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getAccountStatus | function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
| /**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
4940,
5080
]
} | 4,849 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getAccountValues | function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
| /**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
5397,
5567
]
} | 4,850 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getAdjustedAccountValues | function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
| /**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
6333,
6511
]
} | 4,851 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getAccountBalances | function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
| /**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
6923,
7157
]
} | 4,852 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getIsLocalOperator | function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
| /**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
7616,
7761
]
} | 4,853 |
ExpiryV2 | contracts/protocol/Getters.sol | 0x739a1df6725657f6a16dc2d5519dc36fd7911a12 | Solidity | Getters | contract Getters {
// ============ Constants ============
bytes32 FILE = "Getters";
// ============ Getters for Risk ============
/* ... */
// ============ Getters for Markets ============
/**
* Get the total number of markets.
*
* @return The number of markets
*/
function getNumMarkets()
public
view
returns (uint256);
/**
* Get the ERC20 token address for a market.
*
* @param marketId The market to query
* @return The token address
*/
function getMarketTokenAddress(
uint256 marketId
)
public
view
returns (address);
/**
* Get the total principal amounts (borrowed and supplied) for a market.
*
* @param marketId The market to query
* @return The total principal amounts
*/
function getMarketTotalPar(
uint256 marketId
)
public
view
returns (Types.TotalPar memory);
/* ... */
/**
* Get the margin premium for a market. A margin premium makes it so that any positions that
* include the market require a higher collateralization to avoid being liquidated.
*
* @param marketId The market to query
* @return The market's margin premium
*/
function getMarketMarginPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Get the spread premium for a market. A spread premium makes it so that any liquidations
* that include the market have a higher spread than the global default.
*
* @param marketId The market to query
* @return The market's spread premium
*/
function getMarketSpreadPremium(
uint256 marketId
)
public
view
returns (Decimal.D256 memory);
/**
* Return true if a particular market is in closing mode. Additional borrows cannot be taken
* from a market that is closing.
*
* @param marketId The market to query
* @return True if the market is closing
*/
function getMarketIsClosing(
uint256 marketId
)
public
view
returns (bool);
/**
* Get the price of the token for a market.
*
* @param marketId The market to query
* @return The price of each atomic unit of the token
*/
function getMarketPrice(
uint256 marketId
)
public
view
returns (Monetary.Price memory);
/* ... */
/**
* Get the adjusted liquidation spread for some market pair. This is equal to the global
* liquidation spread multiplied by (1 + spreadPremium) for each of the two markets.
*
* @param heldMarketId The market for which the account has collateral
* @param owedMarketId The market for which the account has borrowed tokens
* @return The adjusted liquidation spread
*/
function getLiquidationSpreadForPair(
uint256 heldMarketId,
uint256 owedMarketId
)
public
view
returns (Decimal.D256 memory);
/* ... */
/**
* Get the number of excess tokens for a market. The number of excess tokens is calculated
* by taking the current number of tokens held in Solo, adding the number of tokens owed to Solo
* by borrowers, and subtracting the number of tokens owed to suppliers by Solo.
*
* @param marketId The market to query
* @return The number of excess tokens
*/
function getNumExcessTokens(
uint256 marketId
)
public
view
returns (Types.Wei memory);
// ============ Getters for Accounts ============
/**
* Get the principal value for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The principal value
*/
function getAccountPar(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Par memory);
/**
* Get the token balance for a particular account and market.
*
* @param account The account to query
* @param marketId The market to query
* @return The token amount
*/
function getAccountWei(
Account.Info memory account,
uint256 marketId
)
public
view
returns (Types.Wei memory);
/**
* Get the status of an account (Normal, Liquidating, or Vaporizing).
*
* @param account The account to query
* @return The account's status
*/
function getAccountStatus(
Account.Info memory account
)
public
view
returns (Account.Status);
/**
* Get the total supplied and total borrowed value of an account.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account
* - The borrowed value of the account
*/
function getAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get the total supplied and total borrowed values of an account adjusted by the marginPremium
* of each market. Supplied values are divided by (1 + marginPremium) for each market and
* borrowed values are multiplied by (1 + marginPremium) for each market. Comparing these
* adjusted values gives the margin-ratio of the account which will be compared to the global
* margin-ratio when determining if the account can be liquidated.
*
* @param account The account to query
* @return The following values:
* - The supplied value of the account (adjusted for marginPremium)
* - The borrowed value of the account (adjusted for marginPremium)
*/
function getAdjustedAccountValues(
Account.Info memory account
)
public
view
returns (Monetary.Value memory, Monetary.Value memory);
/**
* Get an account's summary for each market.
*
* @param account The account to query
* @return The following values:
* - The ERC20 token address for each market
* - The account's principal value for each market
* - The account's (supplied or borrowed) number of tokens for each market
*/
function getAccountBalances(
Account.Info memory account
)
public
view
returns (
address[] memory,
Types.Par[] memory,
Types.Wei[] memory
);
// ============ Getters for Permissions ============
/**
* Return true if a particular address is approved as an operator for an owner's accounts.
* Approved operators can act on the accounts of the owner as if it were the operator's own.
*
* @param owner The owner of the accounts
* @param operator The possible operator
* @return True if operator is approved for owner's accounts
*/
function getIsLocalOperator(
address owner,
address operator
)
public
view
returns (bool);
/**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/
function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
} | /**
* @title Getters
* @author dYdX
*
* Public read-only functions that allow transparency into the state of Solo
*/ | NatSpecMultiLine | getIsGlobalOperator | function getIsGlobalOperator(
address operator
)
public
view
returns (bool);
| /**
* Return true if a particular address is approved as a global operator. Such an address can
* act on any account as if it were the operator's own.
*
* @param operator The address to query
* @return True if operator is a global operator
*/ | NatSpecMultiLine | v0.5.7+commit.6da8b019 | Apache-2.0 | bzzr://1fb5cd76566f136dd46aeb846f717b0de53b65aa3702601b2fed00de2dcc85d5 | {
"func_code_index": [
8060,
8182
]
} | 4,854 |
POIS | POIS.sol | 0x45fdc57ea9d9f9966a7da46c5a90d6f5980a11f2 | Solidity | POIS | contract POIS is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) public _isExcludedFromFee;
mapping(address => bool) public _isExcludedFromMaxTx;
mapping(address => bool) public _isSniper;
string private _name = "Planet Of Inus";
string private _symbol = "POIS";
uint8 private _decimals = 9;
uint256 private _totalSupply = 500000 * 1e9 * 1e9;
uniswapRouter public UniSwapRouter;
address public UniSwapPair;
address payable public marketDevWallet;
uint256 public maxTxAmount = _totalSupply.mul(1).div(100); // should be 1% percent per transaction
uint256 public minTokenToSwap = 100000 * 1e9;
uint256 public _launchTime; // can be set only once
uint256 public antiSnipingTime = 90 seconds;
bool public feesStatus = true; // enable by default
bool public _tradingOpen; //once switched on, can never be switched off.
uint256 public marketDevFee = 8; // Used for both marketing and development. Future staking,vesting, P2E
uint256 public maxHoldingLimit = _totalSupply.mul(1).div(100);
constructor(address payable _marketDevWallet) {
_balances[owner()] = _totalSupply;
marketDevWallet = _marketDevWallet;
uniswapRouter _uniSwapRouter = uniswapRouter(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D //uniswap router address
);
UniSwapPair = IUniswapV2Factory(_uniSwapRouter.factory()).createPair(
address(this),
_uniSwapRouter.WETH()
);
// set the rest of the contract variables
UniSwapRouter = _uniSwapRouter;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
// exclude from max tx
_isExcludedFromMaxTx[owner()] = true;
_isExcludedFromMaxTx[address(this)] = true;
emit Transfer(address(0), owner(), _totalSupply);
}
receive() external payable {}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"POIS: transfer amount exceeds allowance"
)
);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool)
{
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool)
{
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "POIS: decreased allowance below zero"));
return true;
}
function includeOrExcludeFromFee(address account, bool value) external onlyOwner
{
_isExcludedFromFee[account] = value;
}
function includeOrExcludeFromMaxTx(address _address, bool value) external onlyOwner
{
_isExcludedFromMaxTx[_address] = value;
}
function setMaxTxAmount(uint256 _amount) external onlyOwner {
maxTxAmount = _amount;
}
// for 1% input 100
function setMaxHoldingPercent(uint256 value) public onlyOwner {
maxHoldingLimit = _totalSupply.mul(value).div(100);
}
function setMinTokenToSwap(uint256 _amount) external onlyOwner {
minTokenToSwap = _amount;
}
function setFeePercent(uint256 _marketDevFee) external onlyOwner {
marketDevFee = _marketDevFee;
}
function enableOrDisableFees(bool _value) external onlyOwner {
feesStatus = _value;
}
function UpdateMarketDevWalle(address payable _marketDevWallet) external onlyOwner {
marketDevWallet = _marketDevWallet;
}
function setRouterAddress(uniswapRouter _router, address _pair) external onlyOwner
{
UniSwapRouter = _router;
UniSwapPair = _pair;
}
function startTrading() external onlyOwner {
require(!_tradingOpen, "POIS: Already enabled");
_tradingOpen = true;
_launchTime = block.timestamp;
}
function setTimeForSniping(uint256 _time) external onlyOwner {
antiSnipingTime = _time;
}
function addSniperInList(address _account) external onlyOwner {
require(
_account != address(UniSwapRouter),
"POIS: We can not blacklist UniSwapRouter"
);
require(!_isSniper[_account], "POIS: sniper already exist");
_isSniper[_account] = true;
}
function removeSniperFromList(address _account) external onlyOwner {
require(_isSniper[_account], "POIS: Not a sniper");
_isSniper[_account] = false;
}
function totalFeePerTx(uint256 amount) public view returns (uint256) {
uint256 fee = amount.mul(marketDevFee).div(1e2);
return fee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "POIS: approve from the zero address");
require(spender != address(0), "POIS: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "POIS: transfer from the zero address");
require(to != address(0), "POIS: transfer to the zero address");
require(amount > 0, "POIS: Amount must be greater than zero");
require(!_isSniper[to], "POIS: Sniper detected");
require(!_isSniper[from], "POIS: Sniper detected");
if(from == UniSwapPair && to != owner()){
require(balanceOf(to).add(amount) <= maxHoldingLimit," POIS: Max Holding limit reached");
}
if (
_isExcludedFromMaxTx[from] == false &&
_isExcludedFromMaxTx[to] == false // by default false
) {
require(amount <= maxTxAmount, "POIS: amount exceeded max limit");
if (!_tradingOpen) {
require(
from != UniSwapPair && to != UniSwapPair,
"POIS: Trading is not enabled yet"
);
}
if (
block.timestamp < _launchTime + antiSnipingTime &&
from != address(UniSwapRouter)
) {
if (from == UniSwapPair) {
_isSniper[to] = true;
} else if (to == UniSwapPair) {
_isSniper[from] = true;
}
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if (
_isExcludedFromFee[from] ||
_isExcludedFromFee[to] ||
!feesStatus
) {
takeFee = false;
}
_tokenTransfer(from, to, amount, takeFee);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if ((sender == UniSwapPair || recipient == UniSwapPair) && takeFee) {
uint256 allFee = totalFeePerTx(amount);
uint256 tTransferAmount = amount.sub(allFee);
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(tTransferAmount);
emit Transfer(sender, recipient, tTransferAmount);
_takeMarketDevFee(sender,amount);
}
else {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
}
function _takeMarketDevFee(address sender,uint256 amount) internal {
uint256 fee = amount.mul(marketDevFee).div(1e2);
_balances[address(marketDevWallet)] = _balances[address(marketDevWallet)].add(fee);
emit Transfer(sender, address(marketDevWallet), fee);
}
} | setMaxHoldingPercent | function setMaxHoldingPercent(uint256 value) public onlyOwner {
maxHoldingLimit = _totalSupply.mul(value).div(100);
}
| // for 1% input 100 | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://fbf77c416cbc7265534464135ed4d10a8fd73f6a677c0c6f08326812d88364f9 | {
"func_code_index": [
4624,
4760
]
} | 4,855 |
||
POIS | POIS.sol | 0x45fdc57ea9d9f9966a7da46c5a90d6f5980a11f2 | Solidity | POIS | contract POIS is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) public _isExcludedFromFee;
mapping(address => bool) public _isExcludedFromMaxTx;
mapping(address => bool) public _isSniper;
string private _name = "Planet Of Inus";
string private _symbol = "POIS";
uint8 private _decimals = 9;
uint256 private _totalSupply = 500000 * 1e9 * 1e9;
uniswapRouter public UniSwapRouter;
address public UniSwapPair;
address payable public marketDevWallet;
uint256 public maxTxAmount = _totalSupply.mul(1).div(100); // should be 1% percent per transaction
uint256 public minTokenToSwap = 100000 * 1e9;
uint256 public _launchTime; // can be set only once
uint256 public antiSnipingTime = 90 seconds;
bool public feesStatus = true; // enable by default
bool public _tradingOpen; //once switched on, can never be switched off.
uint256 public marketDevFee = 8; // Used for both marketing and development. Future staking,vesting, P2E
uint256 public maxHoldingLimit = _totalSupply.mul(1).div(100);
constructor(address payable _marketDevWallet) {
_balances[owner()] = _totalSupply;
marketDevWallet = _marketDevWallet;
uniswapRouter _uniSwapRouter = uniswapRouter(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D //uniswap router address
);
UniSwapPair = IUniswapV2Factory(_uniSwapRouter.factory()).createPair(
address(this),
_uniSwapRouter.WETH()
);
// set the rest of the contract variables
UniSwapRouter = _uniSwapRouter;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
// exclude from max tx
_isExcludedFromMaxTx[owner()] = true;
_isExcludedFromMaxTx[address(this)] = true;
emit Transfer(address(0), owner(), _totalSupply);
}
receive() external payable {}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256)
{
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"POIS: transfer amount exceeds allowance"
)
);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool)
{
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool)
{
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "POIS: decreased allowance below zero"));
return true;
}
function includeOrExcludeFromFee(address account, bool value) external onlyOwner
{
_isExcludedFromFee[account] = value;
}
function includeOrExcludeFromMaxTx(address _address, bool value) external onlyOwner
{
_isExcludedFromMaxTx[_address] = value;
}
function setMaxTxAmount(uint256 _amount) external onlyOwner {
maxTxAmount = _amount;
}
// for 1% input 100
function setMaxHoldingPercent(uint256 value) public onlyOwner {
maxHoldingLimit = _totalSupply.mul(value).div(100);
}
function setMinTokenToSwap(uint256 _amount) external onlyOwner {
minTokenToSwap = _amount;
}
function setFeePercent(uint256 _marketDevFee) external onlyOwner {
marketDevFee = _marketDevFee;
}
function enableOrDisableFees(bool _value) external onlyOwner {
feesStatus = _value;
}
function UpdateMarketDevWalle(address payable _marketDevWallet) external onlyOwner {
marketDevWallet = _marketDevWallet;
}
function setRouterAddress(uniswapRouter _router, address _pair) external onlyOwner
{
UniSwapRouter = _router;
UniSwapPair = _pair;
}
function startTrading() external onlyOwner {
require(!_tradingOpen, "POIS: Already enabled");
_tradingOpen = true;
_launchTime = block.timestamp;
}
function setTimeForSniping(uint256 _time) external onlyOwner {
antiSnipingTime = _time;
}
function addSniperInList(address _account) external onlyOwner {
require(
_account != address(UniSwapRouter),
"POIS: We can not blacklist UniSwapRouter"
);
require(!_isSniper[_account], "POIS: sniper already exist");
_isSniper[_account] = true;
}
function removeSniperFromList(address _account) external onlyOwner {
require(_isSniper[_account], "POIS: Not a sniper");
_isSniper[_account] = false;
}
function totalFeePerTx(uint256 amount) public view returns (uint256) {
uint256 fee = amount.mul(marketDevFee).div(1e2);
return fee;
}
function _approve(
address owner,
address spender,
uint256 amount
) private {
require(owner != address(0), "POIS: approve from the zero address");
require(spender != address(0), "POIS: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(
address from,
address to,
uint256 amount
) private {
require(from != address(0), "POIS: transfer from the zero address");
require(to != address(0), "POIS: transfer to the zero address");
require(amount > 0, "POIS: Amount must be greater than zero");
require(!_isSniper[to], "POIS: Sniper detected");
require(!_isSniper[from], "POIS: Sniper detected");
if(from == UniSwapPair && to != owner()){
require(balanceOf(to).add(amount) <= maxHoldingLimit," POIS: Max Holding limit reached");
}
if (
_isExcludedFromMaxTx[from] == false &&
_isExcludedFromMaxTx[to] == false // by default false
) {
require(amount <= maxTxAmount, "POIS: amount exceeded max limit");
if (!_tradingOpen) {
require(
from != UniSwapPair && to != UniSwapPair,
"POIS: Trading is not enabled yet"
);
}
if (
block.timestamp < _launchTime + antiSnipingTime &&
from != address(UniSwapRouter)
) {
if (from == UniSwapPair) {
_isSniper[to] = true;
} else if (to == UniSwapPair) {
_isSniper[from] = true;
}
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if (
_isExcludedFromFee[from] ||
_isExcludedFromFee[to] ||
!feesStatus
) {
takeFee = false;
}
_tokenTransfer(from, to, amount, takeFee);
}
//this method is responsible for taking all fee, if takeFee is true
function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if ((sender == UniSwapPair || recipient == UniSwapPair) && takeFee) {
uint256 allFee = totalFeePerTx(amount);
uint256 tTransferAmount = amount.sub(allFee);
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(tTransferAmount);
emit Transfer(sender, recipient, tTransferAmount);
_takeMarketDevFee(sender,amount);
}
else {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
}
function _takeMarketDevFee(address sender,uint256 amount) internal {
uint256 fee = amount.mul(marketDevFee).div(1e2);
_balances[address(marketDevWallet)] = _balances[address(marketDevWallet)].add(fee);
emit Transfer(sender, address(marketDevWallet), fee);
}
} | _tokenTransfer | function _tokenTransfer(
address sender,
address recipient,
uint256 amount,
bool takeFee
) private {
if ((sender == UniSwapPair || recipient == UniSwapPair) && takeFee) {
uint256 allFee = totalFeePerTx(amount);
uint256 tTransferAmount = amount.sub(allFee);
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(tTransferAmount);
emit Transfer(sender, recipient, tTransferAmount);
_takeMarketDevFee(sender,amount);
}
else {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
}
| //this method is responsible for taking all fee, if takeFee is true | LineComment | v0.8.9+commit.e5eed63a | MIT | ipfs://fbf77c416cbc7265534464135ed4d10a8fd73f6a677c0c6f08326812d88364f9 | {
"func_code_index": [
8718,
9562
]
} | 4,856 |
||
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | Ownable | contract Ownable {
address public owner;
address public candidate;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to _request_ transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function requestOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
candidate = newOwner;
}
/**
* @dev Allows the _NEW_ candidate to complete transfer control of the contract to him.
*/
function confirmOwnership() public {
require(candidate == msg.sender);
owner = candidate;
OwnershipTransferred(owner, candidate);
}
} | /**
* @title Ownable smart contract
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | Ownable | function Ownable() public {
owner = msg.sender;
}
| /**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
297,
365
]
} | 4,857 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | Ownable | contract Ownable {
address public owner;
address public candidate;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to _request_ transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function requestOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
candidate = newOwner;
}
/**
* @dev Allows the _NEW_ candidate to complete transfer control of the contract to him.
*/
function confirmOwnership() public {
require(candidate == msg.sender);
owner = candidate;
OwnershipTransferred(owner, candidate);
}
} | /**
* @title Ownable smart contract
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | requestOwnership | function requestOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
candidate = newOwner;
}
| /**
* @dev Allows the current owner to _request_ transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
719,
866
]
} | 4,858 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | Ownable | contract Ownable {
address public owner;
address public candidate;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to _request_ transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function requestOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
candidate = newOwner;
}
/**
* @dev Allows the _NEW_ candidate to complete transfer control of the contract to him.
*/
function confirmOwnership() public {
require(candidate == msg.sender);
owner = candidate;
OwnershipTransferred(owner, candidate);
}
} | /**
* @title Ownable smart contract
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/ | NatSpecMultiLine | confirmOwnership | function confirmOwnership() public {
require(candidate == msg.sender);
owner = candidate;
OwnershipTransferred(owner, candidate);
}
| /**
* @dev Allows the _NEW_ candidate to complete transfer control of the contract to him.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
980,
1156
]
} | 4,859 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
| /**
* @dev Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
93,
306
]
} | 4,860 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
398,
691
]
} | 4,861 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
814,
942
]
} | 4,862 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
1014,
1166
]
} | 4,863 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() public view returns (uint256) {
return totalSupply_;
}
| /**
* @dev total number of tokens in existence
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
211,
307
]
} | 4,864 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | transfer | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
| /**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
477,
900
]
} | 4,865 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | BasicToken | contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) balances;
uint256 totalSupply_;
/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
} | /**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
| /**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
1118,
1238
]
} | 4,866 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
| /**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
411,
899
]
} | 4,867 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | approve | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| /**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
1544,
1750
]
} | 4,868 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | allowance | function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
| /**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
2083,
2222
]
} | 4,869 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | increaseApproval | function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
2701,
2981
]
} | 4,870 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | StandardToken | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
} | /**
* @title Standard ERC20 token
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/ | NatSpecMultiLine | decreaseApproval | function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| /**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
3465,
3915
]
} | 4,871 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | /**
* @title Mintable token smart contract
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/ | NatSpecMultiLine | mint | function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
| /**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
508,
805
]
} | 4,872 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | MintableToken | contract MintableToken is StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
Mint(_to, _amount);
Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
} | /**
* @title Mintable token smart contract
* @author Copyright (c) 2016 Smart Contract Solutions, Inc.
* @author "Manuel Araoz <[email protected]>"
* @dev license: "MIT", source: https://github.com/OpenZeppelin/zeppelin-solidity
* @author modification: Dmitriy Khizhinskiy @McFly.aero
* @dev Simple ERC20 Token example, with mintable token creation
* @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120
* Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol
*/ | NatSpecMultiLine | finishMinting | function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
| /**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
929,
1087
]
} | 4,873 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyToken | contract McFlyToken is MintableToken {
string public constant name = "McFlyToken";
string public constant symbol = "McFLY";
uint8 public constant decimals = 18;
/// @dev mapping for whitelist
mapping(address=>bool) whitelist;
/// @dev event throw when allowed to transfer address added to whitelist
/// @param from address
event AllowTransfer(address from);
/// @dev check for allowence of transfer
modifier canTransfer() {
require(mintingFinished || whitelist[msg.sender]);
_;
}
/// @dev add address to whitelist
/// @param from address to add
function allowTransfer(address from) onlyOwner public {
whitelist[from] = true;
AllowTransfer(from);
}
/// @dev Do the transfer from address to address value
/// @param from address from
/// @param to address to
/// @param value uint256
function transferFrom(address from, address to, uint256 value) canTransfer public returns (bool) {
return super.transferFrom(from, to, value);
}
/// @dev Do the transfer from token address to "to" address value
/// @param to address to
/// @param value uint256 value
function transfer(address to, uint256 value) canTransfer public returns (bool) {
return super.transfer(to, value);
}
} | /**
* @title McFly token smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
*/ | NatSpecMultiLine | allowTransfer | function allowTransfer(address from) onlyOwner public {
whitelist[from] = true;
AllowTransfer(from);
}
| /// @dev add address to whitelist
/// @param from address to add | NatSpecSingleLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
645,
775
]
} | 4,874 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyToken | contract McFlyToken is MintableToken {
string public constant name = "McFlyToken";
string public constant symbol = "McFLY";
uint8 public constant decimals = 18;
/// @dev mapping for whitelist
mapping(address=>bool) whitelist;
/// @dev event throw when allowed to transfer address added to whitelist
/// @param from address
event AllowTransfer(address from);
/// @dev check for allowence of transfer
modifier canTransfer() {
require(mintingFinished || whitelist[msg.sender]);
_;
}
/// @dev add address to whitelist
/// @param from address to add
function allowTransfer(address from) onlyOwner public {
whitelist[from] = true;
AllowTransfer(from);
}
/// @dev Do the transfer from address to address value
/// @param from address from
/// @param to address to
/// @param value uint256
function transferFrom(address from, address to, uint256 value) canTransfer public returns (bool) {
return super.transferFrom(from, to, value);
}
/// @dev Do the transfer from token address to "to" address value
/// @param to address to
/// @param value uint256 value
function transfer(address to, uint256 value) canTransfer public returns (bool) {
return super.transfer(to, value);
}
} | /**
* @title McFly token smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address from, address to, uint256 value) canTransfer public returns (bool) {
return super.transferFrom(from, to, value);
}
| /// @dev Do the transfer from address to address value
/// @param from address from
/// @param to address to
/// @param value uint256 | NatSpecSingleLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
932,
1095
]
} | 4,875 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyToken | contract McFlyToken is MintableToken {
string public constant name = "McFlyToken";
string public constant symbol = "McFLY";
uint8 public constant decimals = 18;
/// @dev mapping for whitelist
mapping(address=>bool) whitelist;
/// @dev event throw when allowed to transfer address added to whitelist
/// @param from address
event AllowTransfer(address from);
/// @dev check for allowence of transfer
modifier canTransfer() {
require(mintingFinished || whitelist[msg.sender]);
_;
}
/// @dev add address to whitelist
/// @param from address to add
function allowTransfer(address from) onlyOwner public {
whitelist[from] = true;
AllowTransfer(from);
}
/// @dev Do the transfer from address to address value
/// @param from address from
/// @param to address to
/// @param value uint256
function transferFrom(address from, address to, uint256 value) canTransfer public returns (bool) {
return super.transferFrom(from, to, value);
}
/// @dev Do the transfer from token address to "to" address value
/// @param to address to
/// @param value uint256 value
function transfer(address to, uint256 value) canTransfer public returns (bool) {
return super.transfer(to, value);
}
} | /**
* @title McFly token smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
*/ | NatSpecMultiLine | transfer | function transfer(address to, uint256 value) canTransfer public returns (bool) {
return super.transfer(to, value);
}
| /// @dev Do the transfer from token address to "to" address value
/// @param to address to
/// @param value uint256 value | NatSpecSingleLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
1235,
1370
]
} | 4,876 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | Haltable | contract Haltable is MultiOwners {
bool public halted;
modifier stopInEmergency {
require(!halted);
_;
}
modifier onlyInEmergency {
require(halted);
_;
}
/// @dev called by the owner on emergency, triggers stopped state
function halt() external onlyOwner {
halted = true;
}
/// @dev called by the owner on end of emergency, returns to normal state
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
} | /**
* @title Haltable smart contract - controls owner access
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
*/ | NatSpecMultiLine | halt | function halt() external onlyOwner {
halted = true;
}
| /// @dev called by the owner on emergency, triggers stopped state | NatSpecSingleLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
297,
369
]
} | 4,877 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | Haltable | contract Haltable is MultiOwners {
bool public halted;
modifier stopInEmergency {
require(!halted);
_;
}
modifier onlyInEmergency {
require(halted);
_;
}
/// @dev called by the owner on emergency, triggers stopped state
function halt() external onlyOwner {
halted = true;
}
/// @dev called by the owner on end of emergency, returns to normal state
function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
} | /**
* @title Haltable smart contract - controls owner access
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
*/ | NatSpecMultiLine | unhalt | function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
| /// @dev called by the owner on end of emergency, returns to normal state | NatSpecSingleLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
453,
544
]
} | 4,878 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | McFlyCrowd | function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
| /**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
5255,
8124
]
} | 4,879 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | withinPeriod | function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
| /**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
8237,
8357
]
} | 4,880 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | running | function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
| /**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
8489,
8612
]
} | 4,881 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | stageName | function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
| /**
* @dev check current stage name
* @return uint8 stage number
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
8708,
10090
]
} | 4,882 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | setFundMintingAgent | function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
| /**
* @dev change agent for minting
* @param agent - new agent address
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
10193,
10339
]
} | 4,883 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | setTeamWallet | function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
| /**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
10515,
10670
]
} | 4,884 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | setAdvisoryWallet | function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
| /**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
10854,
11033
]
} | 4,885 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | setReservedWallet | function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
| /**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
11217,
11396
]
} | 4,886 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | setMinETHin | function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
| /**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
11508,
11646
]
} | 4,887 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | setStartEndTimeTLP | function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
| /**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
11760,
12059
]
} | 4,888 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | fundMinting | function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
| /**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
12197,
12642
]
} | 4,889 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | calcAmountAt | function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
| /**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
12972,
14221
]
} | 4,890 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | function() external payable {
return getTokens(msg.sender);
}
| /**
* @dev fallback for processing ether
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
14287,
14367
]
} | 4,891 |
||
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | getTokens | function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
| /**
* @dev sell token and send to contributor address
* @param contributor address
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
14481,
16162
]
} | 4,892 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | closeWindow | function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
| /**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
16301,
16500
]
} | 4,893 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | sendTokensWindow | function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
| /**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
16632,
17652
]
} | 4,894 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | newWindow | function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
| /**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
17868,
18057
]
} | 4,895 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | finishCrowd | function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
| /**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
18153,
18730
]
} | 4,896 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | vestingWithdraw | function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
| /**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
19108,
20062
]
} | 4,897 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | teamWithdraw | function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
| /**
* @dev withdraw tokens amount within vesting rules for team
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
20151,
20281
]
} | 4,898 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | advisoryWithdraw | function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
| /**
* @dev withdraw tokens amount within vesting rules for advisory
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
20374,
20524
]
} | 4,899 |
|
McFlyCrowd | McFlyCrowd.sol | 0xc7c6d400b1bcf7841a1b5061a4d69525c9aa0966 | Solidity | McFlyCrowd | contract McFlyCrowd is MultiOwners, Haltable {
using SafeMath for uint256;
/// @dev Total ETH received during WAVES, TLP1.2 & window[1-5]
uint256 public counter_in; // tlp2
/// @dev minimum ETH to partisipate in window 1-5
uint256 public minETHin = 1e18; // 1 ETH
/// @dev Token
McFlyToken public token;
/// @dev Withdraw wallet
address public wallet;
/// @dev start and end timestamp for TLP 1.2, other values callculated
uint256 public sT2; // startTimeTLP2
uint256 constant dTLP2 = 118 days; // days of TLP2
uint256 constant dBt = 60 days; // days between Windows
uint256 constant dW = 12 days; // 12 days for 3,4,5,6,7 windows;
/// @dev Cap maximum possible tokens for minting
uint256 public constant hardCapInTokens = 1800e24; // 1,800,000,000 MFL
/// @dev maximum possible tokens for sell
uint256 public constant mintCapInTokens = 1260e24; // 1,260,000,000 MFL
/// @dev tokens crowd within TLP2
uint256 public crowdTokensTLP2;
uint256 public _preMcFly;
/// @dev maximum possible tokens for fund minting
uint256 constant fundTokens = 270e24; // 270,000,000 MFL
uint256 public fundTotalSupply;
address public fundMintingAgent;
/// @dev maximum possible tokens to convert from WAVES
uint256 constant wavesTokens = 100e24; // 100,000,000 MFL
address public wavesAgent;
address public wavesGW;
/// @dev Vesting param for team, advisory, reserve.
uint256 constant VestingPeriodInSeconds = 30 days; // 24 month
uint256 constant VestingPeriodsCount = 24;
/// @dev Team 10%
uint256 constant _teamTokens = 180e24;
uint256 public teamTotalSupply;
address public teamWallet;
/// @dev Bounty 5% (2% + 3%)
/// @dev Bounty online 2%
uint256 constant _bountyOnlineTokens = 36e24;
address public bountyOnlineWallet;
address public bountyOnlineGW;
/// @dev Bounty offline 3%
uint256 constant _bountyOfflineTokens = 54e24;
address public bountyOfflineWallet;
/// @dev Advisory 5%
uint256 constant _advisoryTokens = 90e24;
uint256 public advisoryTotalSupply;
address public advisoryWallet;
/// @dev Reserved for future 9%
uint256 constant _reservedTokens = 162e24;
uint256 public reservedTotalSupply;
address public reservedWallet;
/// @dev AirDrop 1%
uint256 constant _airdropTokens = 18e24;
address public airdropWallet;
address public airdropGW;
/// @dev PreMcFly wallet (MFL)
address public preMcFlyWallet;
/// @dev Ppl structure for Win1-5
struct Ppl {
address addr;
uint256 amount;
}
mapping (uint32 => Ppl) public ppls;
/// @dev Window structure for Win1-5
struct Window {
bool active;
uint256 totalEthInWindow;
uint32 totalTransCnt;
uint32 refundIndex;
uint256 tokenPerWindow;
}
mapping (uint8 => Window) public ww;
/// @dev Events
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event TokenPurchaseInWindow(address indexed beneficiary, uint256 value, uint8 winnum, uint32 totalcnt, uint256 totaleth1);
event TransferOddEther(address indexed beneficiary, uint256 value);
event FundMinting(address indexed beneficiary, uint256 value);
event WithdrawVesting(address indexed beneficiary, uint256 period, uint256 value, uint256 valueTotal);
event TokenWithdrawAtWindow(address indexed beneficiary, uint256 value);
event SetFundMintingAgent(address newAgent);
event SetTeamWallet(address newTeamWallet);
event SetAdvisoryWallet(address newAdvisoryWallet);
event SetReservedWallet(address newReservedWallet);
event SetStartTimeTLP2(uint256 newStartTimeTLP2);
event SetMinETHincome(uint256 newMinETHin);
event NewWindow(uint8 winNum, uint256 amountTokensPerWin);
event TokenETH(uint256 totalEth, uint32 totalCnt);
/// @dev check for Non zero value
modifier validPurchase() {
require(msg.value != 0);
_;
}
/**
* @dev conctructor of contract, set main params, create new token, do minting for some wallets
* @param _startTimeTLP2 - set date time of starting of TLP2 (main date!)
* @param _preMcFlyTotalSupply - set amount in wei total supply of previouse contract (MFL)
* @param _wallet - wallet for transfer ETH to it
* @param _wavesAgent - wallet for WAVES gw
* @param _wavesGW - wallet for WAVES gw
* @param _fundMintingAgent - wallet who allowed to mint before TLP2
* @param _teamWallet - wallet for team vesting
* @param _bountyOnlineWallet - wallet for online bounty
* @param _bountyOnlineGW - wallet for online bounty GW
* @param _bountyOfflineWallet - wallet for offline bounty
* @param _advisoryWallet - wallet for advisory vesting
* @param _reservedWallet - wallet for reserved vesting
* @param _airdropWallet - wallet for airdrop
* @param _airdropGW - wallet for airdrop GW
* @param _preMcFlyWallet - wallet for transfer old MFL->McFly (once)
*/
function McFlyCrowd(
uint256 _startTimeTLP2,
uint256 _preMcFlyTotalSupply,
address _wallet,
address _wavesAgent,
address _wavesGW,
address _fundMintingAgent,
address _teamWallet,
address _bountyOnlineWallet,
address _bountyOnlineGW,
address _bountyOfflineWallet,
address _advisoryWallet,
address _reservedWallet,
address _airdropWallet,
address _airdropGW,
address _preMcFlyWallet
) public
{
require(_startTimeTLP2 >= block.timestamp);
require(_preMcFlyTotalSupply > 0);
require(_wallet != 0x0);
require(_wavesAgent != 0x0);
require(_wavesGW != 0x0);
require(_fundMintingAgent != 0x0);
require(_teamWallet != 0x0);
require(_bountyOnlineWallet != 0x0);
require(_bountyOnlineGW != 0x0);
require(_bountyOfflineWallet != 0x0);
require(_advisoryWallet != 0x0);
require(_reservedWallet != 0x0);
require(_airdropWallet != 0x0);
require(_airdropGW != 0x0);
require(_preMcFlyWallet != 0x0);
token = new McFlyToken();
wallet = _wallet;
sT2 = _startTimeTLP2;
wavesAgent = _wavesAgent;
wavesGW = _wavesGW;
fundMintingAgent = _fundMintingAgent;
teamWallet = _teamWallet;
bountyOnlineWallet = _bountyOnlineWallet;
bountyOnlineGW = _bountyOnlineGW;
bountyOfflineWallet = _bountyOfflineWallet;
advisoryWallet = _advisoryWallet;
reservedWallet = _reservedWallet;
airdropWallet = _airdropWallet;
airdropGW = _airdropGW;
preMcFlyWallet = _preMcFlyWallet;
/// @dev Mint all tokens and than control it by vesting
_preMcFly = _preMcFlyTotalSupply;
token.mint(preMcFlyWallet, _preMcFly); // McFly for thansfer to old MFL owners
token.allowTransfer(preMcFlyWallet);
crowdTokensTLP2 = crowdTokensTLP2.add(_preMcFly);
token.mint(wavesAgent, wavesTokens); // 100,000,000 MFL
token.allowTransfer(wavesAgent);
token.allowTransfer(wavesGW);
crowdTokensTLP2 = crowdTokensTLP2.add(wavesTokens);
token.mint(this, _teamTokens); // mint to contract address
token.mint(bountyOnlineWallet, _bountyOnlineTokens);
token.allowTransfer(bountyOnlineWallet);
token.allowTransfer(bountyOnlineGW);
token.mint(bountyOfflineWallet, _bountyOfflineTokens);
token.allowTransfer(bountyOfflineWallet);
token.mint(this, _advisoryTokens);
token.mint(this, _reservedTokens);
token.mint(airdropWallet, _airdropTokens);
token.allowTransfer(airdropWallet);
token.allowTransfer(airdropGW);
}
/**
* @dev check is TLP2 is active?
* @return false if crowd TLP2 event was ended
*/
function withinPeriod() constant public returns (bool) {
return (now >= sT2 && now <= (sT2+dTLP2));
}
/**
* @dev check is TLP2 is active and minting Not finished
* @return false if crowd event was ended
*/
function running() constant public returns (bool) {
return withinPeriod() && !token.mintingFinished();
}
/**
* @dev check current stage name
* @return uint8 stage number
*/
function stageName() constant public returns (uint8) {
uint256 eT2 = sT2+dTLP2;
if (now < sT2) {return 101;} // not started
if (now >= sT2 && now <= eT2) {return (102);} // TLP1.2
if (now > eT2 && now < eT2+dBt) {return (103);} // preTLP1.3
if (now >= (eT2+dBt) && now <= (eT2+dBt+dW)) {return (0);} // TLP1.3
if (now > (eT2+dBt+dW) && now < (eT2+dBt+dW+dBt)) {return (104);} // preTLP1.4
if (now >= (eT2+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW)) {return (1);} // TLP1.4
if (now > (eT2+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt)) {return (105);} // preTLP1.5
if (now >= (eT2+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW)) {return (2);} // TLP1.5
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (106);} // preTLP1.6
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (3);} // TLP1.6
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW) && now < (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt)) {return (107);} // preTLP1.7
if (now >= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt) && now <= (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (4);} // TLP1.7"
if (now > (eT2+dBt+dW+dBt+dW+dBt+dW+dBt+dW+dBt+dW)) {return (200);} // Finished
return (201); // unknown
}
/**
* @dev change agent for minting
* @param agent - new agent address
*/
function setFundMintingAgent(address agent) onlyOwner public {
fundMintingAgent = agent;
SetFundMintingAgent(agent);
}
/**
* @dev change wallet for team vesting (this make possible to set smart-contract address later)
* @param _newTeamWallet - new wallet address
*/
function setTeamWallet(address _newTeamWallet) onlyOwner public {
teamWallet = _newTeamWallet;
SetTeamWallet(_newTeamWallet);
}
/**
* @dev change wallet for advisory vesting (this make possible to set smart-contract address later)
* @param _newAdvisoryWallet - new wallet address
*/
function setAdvisoryWallet(address _newAdvisoryWallet) onlyOwner public {
advisoryWallet = _newAdvisoryWallet;
SetAdvisoryWallet(_newAdvisoryWallet);
}
/**
* @dev change wallet for reserved vesting (this make possible to set smart-contract address later)
* @param _newReservedWallet - new wallet address
*/
function setReservedWallet(address _newReservedWallet) onlyOwner public {
reservedWallet = _newReservedWallet;
SetReservedWallet(_newReservedWallet);
}
/**
* @dev change min ETH income during Window1-5
* @param _minETHin - new limit
*/
function setMinETHin(uint256 _minETHin) onlyOwner public {
minETHin = _minETHin;
SetMinETHincome(_minETHin);
}
/**
* @dev set TLP1.X (2-7) start & end dates
* @param _at - new or old start date
*/
function setStartEndTimeTLP(uint256 _at) onlyOwner public {
require(block.timestamp < sT2); // forbid change time when TLP1.2 is active
require(block.timestamp < _at); // should be great than current block timestamp
sT2 = _at;
SetStartTimeTLP2(_at);
}
/**
* @dev Large Token Holder minting
* @param to - mint to address
* @param amount - how much mint
*/
function fundMinting(address to, uint256 amount) stopInEmergency public {
require(msg.sender == fundMintingAgent || isOwner());
require(block.timestamp < sT2);
require(fundTotalSupply.add(amount) <= fundTokens);
require(token.totalSupply().add(amount) <= hardCapInTokens);
fundTotalSupply = fundTotalSupply.add(amount);
token.mint(to, amount);
FundMinting(to, amount);
}
/**
* @dev calculate amount
* @param amount - ether to be converted to tokens
* @param at - current time
* @param _totalSupply - total supplied tokens
* @return tokens amount that we should send to our dear ppl
* @return odd ethers amount, which contract should send back
*/
function calcAmountAt(
uint256 amount,
uint256 at,
uint256 _totalSupply
) public constant returns (uint256, uint256)
{
uint256 estimate;
uint256 price;
if (at >= sT2 && at <= (sT2+dTLP2)) {
if (at <= sT2 + 15 days) {price = 12e13;} else if (at <= sT2 + 30 days) {
price = 14e13;} else if (at <= sT2 + 45 days) {
price = 16e13;} else if (at <= sT2 + 60 days) {
price = 18e13;} else if (at <= sT2 + 75 days) {
price = 20e13;} else if (at <= sT2 + 90 days) {
price = 22e13;} else if (at <= sT2 + 105 days) {
price = 24e13;} else if (at <= sT2 + 118 days) {
price = 26e13;} else {revert();}
} else {revert();}
estimate = _totalSupply.add(amount.mul(1e18).div(price));
if (estimate > hardCapInTokens) {
return (
hardCapInTokens.sub(_totalSupply),
estimate.sub(hardCapInTokens).mul(price).div(1e18)
);
}
return (estimate.sub(_totalSupply), 0);
}
/**
* @dev fallback for processing ether
*/
function() external payable {
return getTokens(msg.sender);
}
/**
* @dev sell token and send to contributor address
* @param contributor address
*/
function getTokens(address contributor) payable stopInEmergency validPurchase public {
uint256 amount;
uint256 oddEthers;
uint256 ethers;
uint256 _at;
uint8 _winNum;
_at = block.timestamp;
require(contributor != 0x0);
if (withinPeriod()) {
(amount, oddEthers) = calcAmountAt(msg.value, _at, token.totalSupply());
require(amount.add(token.totalSupply()) <= hardCapInTokens);
ethers = msg.value.sub(oddEthers);
token.mint(contributor, amount); // fail if minting is finished
TokenPurchase(contributor, ethers, amount);
counter_in = counter_in.add(ethers);
crowdTokensTLP2 = crowdTokensTLP2.add(amount);
if (oddEthers > 0) {
require(oddEthers < msg.value);
contributor.transfer(oddEthers);
TransferOddEther(contributor, oddEthers);
}
wallet.transfer(ethers);
} else {
require(msg.value >= minETHin); // checks min ETH income
_winNum = stageName();
require(_winNum >= 0 && _winNum < 5);
Window storage w = ww[_winNum];
require(w.tokenPerWindow > 0); // check that we have tokens!
w.totalEthInWindow = w.totalEthInWindow.add(msg.value);
ppls[w.totalTransCnt].addr = contributor;
ppls[w.totalTransCnt].amount = msg.value;
w.totalTransCnt++;
TokenPurchaseInWindow(contributor, msg.value, _winNum, w.totalTransCnt, w.totalEthInWindow);
}
}
/**
* @dev close Window and transfer Eth to wallet address
* @param _winNum - number of window 0-4 to close
*/
function closeWindow(uint8 _winNum) onlyOwner stopInEmergency public {
require(ww[_winNum].active);
ww[_winNum].active = false;
wallet.transfer(this.balance);
}
/**
* @dev transfer tokens to ppl accts (window1-5)
* @param _winNum - number of window 0-4 to close
*/
function sendTokensWindow(uint8 _winNum) onlyOwner stopInEmergency public {
uint256 _tokenPerETH;
uint256 _tokenToSend = 0;
address _tempAddr;
uint32 index = ww[_winNum].refundIndex;
TokenETH(ww[_winNum].totalEthInWindow, ww[_winNum].totalTransCnt);
require(ww[_winNum].active);
require(ww[_winNum].totalEthInWindow > 0);
require(ww[_winNum].totalTransCnt > 0);
_tokenPerETH = ww[_winNum].tokenPerWindow.div(ww[_winNum].totalEthInWindow); // max McFly in window / ethInWindow
while (index < ww[_winNum].totalTransCnt && msg.gas > 100000) {
_tokenToSend = _tokenPerETH.mul(ppls[index].amount);
ppls[index].amount = 0;
_tempAddr = ppls[index].addr;
ppls[index].addr = 0;
index++;
token.transfer(_tempAddr, _tokenToSend);
TokenWithdrawAtWindow(_tempAddr, _tokenToSend);
}
ww[_winNum].refundIndex = index;
}
/**
* @dev open new window 0-5 and write totl token per window in structure
* @param _winNum - number of window 0-4 to close
* @param _tokenPerWindow - total token for window 0-4
*/
function newWindow(uint8 _winNum, uint256 _tokenPerWindow) private {
ww[_winNum] = Window(true, 0, 0, 0, _tokenPerWindow);
NewWindow(_winNum, _tokenPerWindow);
}
/**
* @dev Finish crowdsale TLP1.2 period and open window1-5 crowdsale
*/
function finishCrowd() onlyOwner public {
uint256 _tokenPerWindow;
require(now > (sT2.add(dTLP2)) || hardCapInTokens == token.totalSupply());
require(!token.mintingFinished());
_tokenPerWindow = (mintCapInTokens.sub(crowdTokensTLP2).sub(fundTotalSupply)).div(5);
token.mint(this, _tokenPerWindow.mul(5)); // mint to contract address
// shoud be MAX tokens minted!!! 1,800,000,000
for (uint8 y = 0; y < 5; y++) {
newWindow(y, _tokenPerWindow);
}
token.finishMinting();
}
/**
* @dev withdraw tokens amount within vesting rules for team, advisory and reserved
* @param withdrawWallet - wallet to transfer tokens
* @param withdrawTokens - amount of tokens to transfer to
* @param withdrawTotalSupply - total amount of tokens transfered to account
* @return unit256 total amount of tokens after transfer
*/
function vestingWithdraw(address withdrawWallet, uint256 withdrawTokens, uint256 withdrawTotalSupply) private returns (uint256) {
require(token.mintingFinished());
require(msg.sender == withdrawWallet || isOwner());
uint256 currentPeriod = (block.timestamp.sub(sT2.add(dTLP2))).div(VestingPeriodInSeconds);
if (currentPeriod > VestingPeriodsCount) {
currentPeriod = VestingPeriodsCount;
}
uint256 tokenAvailable = withdrawTokens.mul(currentPeriod).div(VestingPeriodsCount).sub(withdrawTotalSupply); // RECHECK!!!!!
require((withdrawTotalSupply.add(tokenAvailable)) <= withdrawTokens);
uint256 _withdrawTotalSupply = withdrawTotalSupply.add(tokenAvailable);
token.transfer(withdrawWallet, tokenAvailable);
WithdrawVesting(withdrawWallet, currentPeriod, tokenAvailable, _withdrawTotalSupply);
return _withdrawTotalSupply;
}
/**
* @dev withdraw tokens amount within vesting rules for team
*/
function teamWithdraw() public {
teamTotalSupply = vestingWithdraw(teamWallet, _teamTokens, teamTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for advisory
*/
function advisoryWithdraw() public {
advisoryTotalSupply = vestingWithdraw(advisoryWallet, _advisoryTokens, advisoryTotalSupply);
}
/**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/
function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
} | /**
* @title McFly crowdsale smart contract
* @author Copyright (c) 2018 McFly.aero
* @author Dmitriy Khizhinskiy
* @author "MIT"
* @dev inherited from MultiOwners & Haltable
*/ | NatSpecMultiLine | reservedWithdraw | function reservedWithdraw() public {
reservedTotalSupply = vestingWithdraw(reservedWallet, _reservedTokens, reservedTotalSupply);
}
| /**
* @dev withdraw tokens amount within vesting rules for reserved wallet
*/ | NatSpecMultiLine | v0.4.19+commit.c4cbbb05 | bzzr://4c830ad51b026fcc939bebe3d3fca769676dd770800ad28ffb1d1e8806a0fb59 | {
"func_code_index": [
20624,
20774
]
} | 4,900 |
|
HODLCapital | HODLCapital.sol | 0xeda47e13fd1192e32226753dc2261c4a14908fb7 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://9c2c7f9cafd0a7530d7a2a99d205ad7b42212cfac9a168d801b0469c70ebe7dd | {
"func_code_index": [
88,
146
]
} | 4,901 |
||
HODLCapital | HODLCapital.sol | 0xeda47e13fd1192e32226753dc2261c4a14908fb7 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://9c2c7f9cafd0a7530d7a2a99d205ad7b42212cfac9a168d801b0469c70ebe7dd | {
"func_code_index": [
223,
294
]
} | 4,902 |
||
HODLCapital | HODLCapital.sol | 0xeda47e13fd1192e32226753dc2261c4a14908fb7 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://9c2c7f9cafd0a7530d7a2a99d205ad7b42212cfac9a168d801b0469c70ebe7dd | {
"func_code_index": [
504,
584
]
} | 4,903 |
||
HODLCapital | HODLCapital.sol | 0xeda47e13fd1192e32226753dc2261c4a14908fb7 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | allowance | function allowance(address owner, address spender)
external
view
returns (uint256);
| /**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://9c2c7f9cafd0a7530d7a2a99d205ad7b42212cfac9a168d801b0469c70ebe7dd | {
"func_code_index": [
849,
950
]
} | 4,904 |
||
HODLCapital | HODLCapital.sol | 0xeda47e13fd1192e32226753dc2261c4a14908fb7 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://9c2c7f9cafd0a7530d7a2a99d205ad7b42212cfac9a168d801b0469c70ebe7dd | {
"func_code_index": [
1586,
1663
]
} | 4,905 |
||
HODLCapital | HODLCapital.sol | 0xeda47e13fd1192e32226753dc2261c4a14908fb7 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | transferFrom | function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
| /**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | None | ipfs://9c2c7f9cafd0a7530d7a2a99d205ad7b42212cfac9a168d801b0469c70ebe7dd | {
"func_code_index": [
1958,
2078
]
} | 4,906 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.