Unnamed: 0
int64
0
7.36k
comments
stringlengths
3
35.2k
code_string
stringlengths
1
527k
code
stringlengths
1
527k
__index_level_0__
int64
0
88.6k
60
// calculates how much eth would be in contract given a number of keys _keys number of keys "in contract" return eth that would exists /
function eth(uint256 _keys) internal pure returns(uint256)
function eth(uint256 _keys) internal pure returns(uint256)
28,304
52
// UpgradedERC20Token Contract - Implement methods which are called as legacy /
contract UpgradedERC20Token is StandardToken { function transferByLegacy(address from, address to, uint256 value) public returns (bool success); function transferFromByLegacy( address sender, address from, address spender, uint256 value ) public returns (bool success); function approveByLegacy(address from, address spender, uint256 value) public returns (bool success); }
contract UpgradedERC20Token is StandardToken { function transferByLegacy(address from, address to, uint256 value) public returns (bool success); function transferFromByLegacy( address sender, address from, address spender, uint256 value ) public returns (bool success); function approveByLegacy(address from, address spender, uint256 value) public returns (bool success); }
48,561
568
// Set liquidation incentive to new incentive
liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;
liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;
6,388
66
// Initializes the owner, admin and operator roles. _owner Address of the contract owner _initialAdmins The list of addresses that are granted the admin role. /
function initialize(address _owner, address[] memory _initialAdmins) public initializer { owner = _owner; // Grant the admin role to the initial admins for (uint256 i = 0; i < _initialAdmins.length; i++) { admins[_initialAdmins[i]] = true; } }
function initialize(address _owner, address[] memory _initialAdmins) public initializer { owner = _owner; // Grant the admin role to the initial admins for (uint256 i = 0; i < _initialAdmins.length; i++) { admins[_initialAdmins[i]] = true; } }
20,343
103
// засчитываем поражение
if (_useCoin) { require(coin.burn(heroes.ownerOf(_tokenId), 1));
if (_useCoin) { require(coin.burn(heroes.ownerOf(_tokenId), 1));
31,735
166
// Users are unable to claim fees if their collateralisation ratio drifts out of target threshold
function targetThreshold() external view returns (uint) { return getTargetThreshold(); }
function targetThreshold() external view returns (uint) { return getTargetThreshold(); }
48,967
163
// set the new leader bool to true
_eventData_.compressedData = _eventData_.compressedData + 100;
_eventData_.compressedData = _eventData_.compressedData + 100;
3,494
122
// increase next purchase eligibility by an hour
nextBoostPurchaseTime[user] = block.timestamp.add(3600);
nextBoostPurchaseTime[user] = block.timestamp.add(3600);
41,811
18
// Get the current fee return uint256 /
function fee() public view returns (uint256) { return s_fee; }
function fee() public view returns (uint256) { return s_fee; }
51,970
1
// Three different options for minting MyCollectibles (basic, premium, and gold). /
enum Option { Basic, Premium, Gold }
enum Option { Basic, Premium, Gold }
2,665
327
// migrate user HOLY tokens to HH tokens (without multipliers) allowance should be already provided to this contract address by user
function emergencyMigrate() public { require(block.timestamp >= migrationStartTimestamp && block.timestamp < migrationEndTimestamp, "time not in migration window"); uint256 userBalance = oldToken.balanceOf(msg.sender); uint256 contractAllowance = oldToken.allowance(msg.sender, address(this)); require(userBalance > 0, "no tokens to migrate"); require(contractAllowance >= userBalance, "insufficient allowance"); oldToken.safeTransferFrom(msg.sender, BURN_ADDRESS, userBalance); // burn old token newToken.mint(msg.sender, userBalance); // mint new token to user address migratedTokens[msg.sender] += userBalance; emit Migrated(msg.sender, userBalance); }
function emergencyMigrate() public { require(block.timestamp >= migrationStartTimestamp && block.timestamp < migrationEndTimestamp, "time not in migration window"); uint256 userBalance = oldToken.balanceOf(msg.sender); uint256 contractAllowance = oldToken.allowance(msg.sender, address(this)); require(userBalance > 0, "no tokens to migrate"); require(contractAllowance >= userBalance, "insufficient allowance"); oldToken.safeTransferFrom(msg.sender, BURN_ADDRESS, userBalance); // burn old token newToken.mint(msg.sender, userBalance); // mint new token to user address migratedTokens[msg.sender] += userBalance; emit Migrated(msg.sender, userBalance); }
24,362
22
// Stores usernames used
mapping (string => address) usernames;
mapping (string => address) usernames;
34,597
47
// Submit the answer whose hash you sent in a previous submitAnswerCommitment() transaction/Checks the parameters supplied recreate an existing commitment, and stores the revealed answer/ Updates the current answer unless someone has since supplied a new answer with a higher bond/ msg.sender is intentionally not restricted to the user who originally sent the commitment; / For example, the user may want to provide the answer+nonce to a third-party service and let them send the tx/ NB If we are pending arbitration, it will be up to the arbitrator to wait and see any outstanding reveal is sent/question_id The ID of the
function submitAnswerReveal(bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) stateOpenOrPendingArbitration(question_id)
function submitAnswerReveal(bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) stateOpenOrPendingArbitration(question_id)
26,584
238
// return if minting is finished or not. /
function mintingFinished() public view returns (bool) { return _mintingFinished; }
function mintingFinished() public view returns (bool) { return _mintingFinished; }
6,246
20
// Validator is blamed during investigation phase
ValidatorIsPunished, // 7
ValidatorIsPunished, // 7
46,993
3
// Edition description
string description;
string description;
30,766
79
// bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58ebytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432abytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 /
bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;
bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;
12,486
3
// 2018-08-20 23:59:59 GMT - end time for pre sale
uint256 private constant presaleEndTime = 1534809599;
uint256 private constant presaleEndTime = 1534809599;
48,927
157
// Cancel bet and relase all the bets back to the betters if, for any reason, payouts cannot be completed. (For example Oracle fails.) Triggered by owners.
function cancel() private { canceled = true; completed = false; }
function cancel() private { canceled = true; completed = false; }
52,273
58
//
* @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
* @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
588
37
// Phase information for slow-release tokens.
uint public phaseStart = 0; uint public constant PHASE_DURATION = 180 days; uint public constant UNLOCK_PHASES = 4;
uint public phaseStart = 0; uint public constant PHASE_DURATION = 180 days; uint public constant UNLOCK_PHASES = 4;
13,315
90
// Query the quantity of the target quotation/channelId 报价通道编号/index The index of the sheet/ return minedBlocks Mined block period from previous block/ return totalShares Total shares of sheets in the block
function getMinedBlocks( uint channelId, uint index ) external view returns (uint minedBlocks, uint totalShares);
function getMinedBlocks( uint channelId, uint index ) external view returns (uint minedBlocks, uint totalShares);
30,454
344
// Getter functions for Rewards contract
function getCurrentRewardWeek() external view returns(uint256)
function getCurrentRewardWeek() external view returns(uint256)
10,714
101
// Emits a {Transfer} event with `from` set to the zero address. Requirements - `to` cannot be the zero address. /
function _mint(address account, uint256 amount) internal { require(account != address(0), "BEP20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
function _mint(address account, uint256 amount) internal { require(account != address(0), "BEP20: mint to the zero address"); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); }
10,447
30
// Call Approve of JPYC contract before claimDo all requestDamageInformation() before claimUse "require" to call this function after insuredDeadline when you make your product. /
function determineTotalPayoutAmount() public onlyOwner { require(block.timestamp > insuredDeadline, "The insuredDeadline has not come."); uint256 _compensatedAmount; uint256 _remainingAmount; if (totalMaxPayoutAmount <= riskPoolBalanceForPayout) { _remainingAmount = riskPoolBalanceForPayout - totalMaxPayoutAmount; JPYC.transfer(investedPoolAddress, _remainingAmount); riskPoolBalanceForPayout -= _remainingAmount; investedPoolRemainingBalanceForPayout = investedPoolMaxBalanceForPayout + _remainingAmount; } else if ( riskPoolBalanceForPayout < totalMaxPayoutAmount && totalMaxPayoutAmount <= riskPoolBalanceForPayout.add(investedPoolMaxBalanceForPayout) ) { _compensatedAmount = totalMaxPayoutAmount.sub(riskPoolBalanceForPayout); JPYC.transferFrom(investedPoolAddress, address(this), _compensatedAmount); riskPoolBalanceForPayout += _compensatedAmount; investedPoolRemainingBalanceForPayout = investedPoolMaxBalanceForPayout - _compensatedAmount; } else { _compensatedAmount = investedPoolMaxBalanceForPayout; JPYC.transferFrom(investedPoolAddress, address(this), _compensatedAmount); riskPoolBalanceForPayout += _compensatedAmount; investedPoolRemainingBalanceForPayout = 0; } totalPayoutAmount = riskPoolBalanceForPayout; }
function determineTotalPayoutAmount() public onlyOwner { require(block.timestamp > insuredDeadline, "The insuredDeadline has not come."); uint256 _compensatedAmount; uint256 _remainingAmount; if (totalMaxPayoutAmount <= riskPoolBalanceForPayout) { _remainingAmount = riskPoolBalanceForPayout - totalMaxPayoutAmount; JPYC.transfer(investedPoolAddress, _remainingAmount); riskPoolBalanceForPayout -= _remainingAmount; investedPoolRemainingBalanceForPayout = investedPoolMaxBalanceForPayout + _remainingAmount; } else if ( riskPoolBalanceForPayout < totalMaxPayoutAmount && totalMaxPayoutAmount <= riskPoolBalanceForPayout.add(investedPoolMaxBalanceForPayout) ) { _compensatedAmount = totalMaxPayoutAmount.sub(riskPoolBalanceForPayout); JPYC.transferFrom(investedPoolAddress, address(this), _compensatedAmount); riskPoolBalanceForPayout += _compensatedAmount; investedPoolRemainingBalanceForPayout = investedPoolMaxBalanceForPayout - _compensatedAmount; } else { _compensatedAmount = investedPoolMaxBalanceForPayout; JPYC.transferFrom(investedPoolAddress, address(this), _compensatedAmount); riskPoolBalanceForPayout += _compensatedAmount; investedPoolRemainingBalanceForPayout = 0; } totalPayoutAmount = riskPoolBalanceForPayout; }
29,066
68
// beneficiary address of the beneficiary to whom vested tokens are transferredcliff duration in seconds of the cliff in which tokens will begin to vestduration duration in seconds of the period in which the tokens will vest/
function AddVest(address beneficiary, uint256 start, uint256 cliff, uint256 duration, uint256 amount) internal { require(beneficiary != address(0), "ZONE::AddVest Invalid beneficiary"); require(cliff <= duration, "ZONE::AddVest cliff > duration"); Vest memory vest = Vest({ beneficiary: beneficiary, start: start, cliff: start.add(cliff), duration: duration, amount: amount, claimedAmount: 0, revoked: false }); vests[beneficiary] = vest; emit VestAdded(beneficiary, start, cliff, duration, amount); }
function AddVest(address beneficiary, uint256 start, uint256 cliff, uint256 duration, uint256 amount) internal { require(beneficiary != address(0), "ZONE::AddVest Invalid beneficiary"); require(cliff <= duration, "ZONE::AddVest cliff > duration"); Vest memory vest = Vest({ beneficiary: beneficiary, start: start, cliff: start.add(cliff), duration: duration, amount: amount, claimedAmount: 0, revoked: false }); vests[beneficiary] = vest; emit VestAdded(beneficiary, start, cliff, duration, amount); }
45,998
33
// Divides two exponentials, returning a new exponential. (a/scale) / (b/scale) = (a/scale)(scale/b) = a/b,which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)/
function divExp(Exp memory a, Exp memory b) pure internal returns (Error, Exp memory) { return getExp(a.mantissa, b.mantissa); }
function divExp(Exp memory a, Exp memory b) pure internal returns (Error, Exp memory) { return getExp(a.mantissa, b.mantissa); }
38,451
54
// Whether `a` is less than or equal to `b`. a a FixedPoint.Signed. b a FixedPoint.Signed.return True if `a <= b`, or False. /
function isLessThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; }
function isLessThanOrEqual(Signed memory a, Signed memory b) internal pure returns (bool) { return a.rawValue <= b.rawValue; }
34,147
33
// Note: We don't need to check their balance as the _convert() below will do a safe subtraction which requires the subtraction to not overflow, which would happen if their balance is not sufficient.
_convert( sourceCurrencyKey, from, sourceAmountAfterSettlement, destinationCurrencyKey, amountReceived, destinationAddress, false // no vsynths );
_convert( sourceCurrencyKey, from, sourceAmountAfterSettlement, destinationCurrencyKey, amountReceived, destinationAddress, false // no vsynths );
41,477
11
// diagonal
if(board[1][1] != SquareState.Empty && board[1][1] == board[0][0] && board[1][1] == board[2][2]) { return board[1][1]; }
if(board[1][1] != SquareState.Empty && board[1][1] == board[0][0] && board[1][1] == board[2][2]) { return board[1][1]; }
22,134
114
// NOTE: the offset 32 is added to skip the `size` field of both bytes variables
uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) }
uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) }
14,131
425
// to set address of kyc authentication_add is the new address /
function setKycAuthAddress(address _add) external onlyInternal { kycAuthAddress = _add; }
function setKycAuthAddress(address _add) external onlyInternal { kycAuthAddress = _add; }
22,375
177
// must override
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); }
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) { super._beforeTokenTransfer(from, to, tokenId); }
23,887
46
// There must be enough balance to stake.
require( _unstakedBalanceOf >= _amount, "TicketBooth::stake: INSUFFICIENT_FUNDS" );
require( _unstakedBalanceOf >= _amount, "TicketBooth::stake: INSUFFICIENT_FUNDS" );
81,816
5
// Disputes
mapping (uint256=>Disputes) private disputes_;
mapping (uint256=>Disputes) private disputes_;
53,016
434
// Get the non-fungible balance record for the given wallet, type, currency/ and block number/wallet The address of the concerned wallet/_type The balance type/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20)/_blockNumber The concerned block number/ return The balance record
function nonFungibleRecordByBlockNumber(address wallet, bytes32 _type, address currencyCt, uint256 currencyId, uint256 _blockNumber) public view returns (int256[] ids, uint256 blockNumber)
function nonFungibleRecordByBlockNumber(address wallet, bytes32 _type, address currencyCt, uint256 currencyId, uint256 _blockNumber) public view returns (int256[] ids, uint256 blockNumber)
59,036
4
// 將不同地址映射到不同的貨幣持有量
mapping(address => uint256) balances;
mapping(address => uint256) balances;
34,534
68
// transfer tokens to pair
token.safeTransferFrom(from, to, amount);
token.safeTransferFrom(from, to, amount);
4,453
112
// claim ARA allocation based on old + new invested amounts
function claimARA() public onlyEOA { require(canClaim, "cannot claim yet"); require(!claimed[msg.sender], "already claimed"); require(!blacklisted[msg.sender], "blacklisted"); if (invested[msg.sender] > 0) { ERC20(ARA).transfer(msg.sender, invested[msg.sender]); } claimed[msg.sender] = true; }
function claimARA() public onlyEOA { require(canClaim, "cannot claim yet"); require(!claimed[msg.sender], "already claimed"); require(!blacklisted[msg.sender], "blacklisted"); if (invested[msg.sender] > 0) { ERC20(ARA).transfer(msg.sender, invested[msg.sender]); } claimed[msg.sender] = true; }
9,261
30
// Means permHash is not currently set.
if (currentFlag == UNSET_FLAG) { permissionsHashed[permHash] = ALLOW_FLAG; emit Granted(_permissionId, msg.sender, _where, _who, ALLOW_FLAG); }
if (currentFlag == UNSET_FLAG) { permissionsHashed[permHash] = ALLOW_FLAG; emit Granted(_permissionId, msg.sender, _where, _who, ALLOW_FLAG); }
8,292
158
// Provides a standard implementation for transferring unspent spend assets/ from an adapter to a VaultProxy at the end of an adapter action
modifier postActionSpendAssetsTransferHandler(address _vaultProxy, bytes memory _assetData) { _; (address[] memory spendAssets, , ) = __decodeAssetData(_assetData); __pushFullAssetBalances(_vaultProxy, spendAssets); }
modifier postActionSpendAssetsTransferHandler(address _vaultProxy, bytes memory _assetData) { _; (address[] memory spendAssets, , ) = __decodeAssetData(_assetData); __pushFullAssetBalances(_vaultProxy, spendAssets); }
22,228
1,235
// (tokenB, tokenC, tokenA)
return (2, 0, 1);
return (2, 0, 1);
13,842
4
// Compatible with old version 1
return address(0);
return address(0);
16,467
77
// Returns the xxx of the token. /
_allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
_allowances[owner][spender] = amount; emit Approval(owner, spender, amount);
40,217
10
// Called by the payer to store the sent amount as credit to be pulled.dest The destination address of the funds.amount The amount to transfer./
function asyncSend(address dest, uint256 amount) internal { payments[dest] = payments[dest].add(amount); totalPayments = totalPayments.add(amount); }
function asyncSend(address dest, uint256 amount) internal { payments[dest] = payments[dest].add(amount); totalPayments = totalPayments.add(amount); }
4,591
172
// _fromToken will be either fromToken of toToken of the previous path
IERC20 _fromToken = i > 0 ? IERC20(path[i - 1].to) : IERC20(fromToken); IERC20 _toToken = IERC20(path[i].to); if (i > 0 && address(_fromToken) == Utils.ethAddress()) { _fromAmount = _fromAmount.sub(path[i].totalNetworkFee); }
IERC20 _fromToken = i > 0 ? IERC20(path[i - 1].to) : IERC20(fromToken); IERC20 _toToken = IERC20(path[i].to); if (i > 0 && address(_fromToken) == Utils.ethAddress()) { _fromAmount = _fromAmount.sub(path[i].totalNetworkFee); }
19,934
450
// returns `(x + y) % 2 ^ 256` /
function _unsafeAdd(uint256 x, uint256 y) private pure returns (uint256) { unchecked { return x + y; } }
function _unsafeAdd(uint256 x, uint256 y) private pure returns (uint256) { unchecked { return x + y; } }
65,095
129
// The seller have enought tokens to fulfill the request!
_verifyOwnershipOfTokens(_companyId, msg.sender, _amount); order.amountFilled += uint32(_amount);
_verifyOwnershipOfTokens(_companyId, msg.sender, _amount); order.amountFilled += uint32(_amount);
44,386
3
// list of all citizens of the DAO
EnumerableSet.AddressSet Citizens_List;
EnumerableSet.AddressSet Citizens_List;
6,556
58
// Allow lender to set repayment recipient of a given loan./ loanID_ of lender's loan./ recipient_ reciever of repayments
function setRepaymentAddress(uint256 loanID_, address recipient_) external { if (msg.sender != loans[loanID_].lender) revert OnlyApproved(); // Update the repayment method. loans[loanID_].recipient = recipient_; }
function setRepaymentAddress(uint256 loanID_, address recipient_) external { if (msg.sender != loans[loanID_].lender) revert OnlyApproved(); // Update the repayment method. loans[loanID_].recipient = recipient_; }
14,601
37
// Contract can change ICO finish date up to 7 days, but only one time
bool public isTryedFinishCrowdsale = false; bool public isBurnActive = false;
bool public isTryedFinishCrowdsale = false; bool public isBurnActive = false;
36,854
13
// Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],but performing a static call. _Available since v3.3._ /
function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); }
function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); }
21,554
128
// Pay transmitter back this much LINK per unit eth spent on gas (1e-6LINK/ETH units)
uint32 microLinkPerEth;
uint32 microLinkPerEth;
25,953
86
// 0xE1873e7f38F2e88Dd0283ce4a2d8Cc9AAbD55EcF
contract Controller { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public governance; address public onesplit; address public rewards; address public timelock; mapping(address => address) public vaults; mapping(address => address) public strategies; mapping(address => mapping(address => address)) public converters; mapping(address => mapping(address => bool)) public approvedStrategies; uint256 public split = 500; uint256 public constant max = 10000; constructor(address _rewards,address _timelock) public { governance = msg.sender; onesplit = address(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e); rewards = _rewards; timelock = _timelock; } function setRewards(address _rewards) public { require(msg.sender == governance, "!governance"); rewards = _rewards; } function setSplit(uint256 _split) public { require(msg.sender == governance, "!governance"); require(_split < max, "inappropriate split fee"); split = _split; } function setOneSplit(address _onesplit) public { require(msg.sender == governance, "!governance"); onesplit = _onesplit; } function setGovernance(address _governance) public { require(msg.sender == timelock, "!timelock"); governance = _governance; } function setTimelock(address _timelock) public { require(msg.sender == timelock, "!timelock"); timelock = _timelock; } function approveStrategy(address _token, address _strategy) public { require(msg.sender == timelock, "!timelock"); approvedStrategies[_token][_strategy] = true; } function revokeStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); approvedStrategies[_token][_strategy] = false; } function setConverter( address _input, address _output, address _converter ) public { require(msg.sender == governance, "!governance"); converters[_input][_output] = _converter; } function setVault(address _token, address _vault) public { require(msg.sender == governance, "!governance"); require(vaults[_token] == address(0), "vault is 0"); require(Vault(_vault).token() == _token, "illegal vault"); vaults[_token] = _vault; } function setStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); require(approvedStrategies[_token][_strategy] == true, "!approved"); require(Strategy(_strategy).want() == _token, "illegal strategy"); address _current = strategies[_token]; if (_current != address(0)) { Strategy(_current).withdrawAll(); } strategies[_token] = _strategy; } function earn(address _token, uint256 _amount) public { address _strategy = strategies[_token]; address _want = Strategy(_strategy).want(); if (_want != _token) { address converter = converters[_token][_want]; IERC20(_token).safeTransfer(converter, _amount); _amount = Converter(converter).convert(_strategy); IERC20(_want).safeTransfer(_strategy, _amount); } else { IERC20(_token).safeTransfer(_strategy, _amount); } Strategy(_strategy).deposit(); } function balanceOf(address _token) external view returns (uint256) { return Strategy(strategies[_token]).balanceOf(); } function withdrawAll(address _token) public { require(msg.sender == governance, "!governance"); Strategy(strategies[_token]).withdrawAll(); } function inCaseTokensGetStuck(address _token, uint256 _amount) public { require(msg.sender == governance, "!governance"); IERC20(_token).safeTransfer(msg.sender, _amount); } function inCaseStrategyTokenGetStuck(address _strategy, address _token) public { require(msg.sender == governance, "!governance"); Strategy(_strategy).withdraw(_token); } function getExpectedReturn( address _strategy, address _token, uint256 parts ) public view returns (uint256 expected) { uint256 _balance = IERC20(_token).balanceOf(_strategy); address _want = Strategy(_strategy).want(); (expected, ) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _balance, parts, 0); } // Only allows to withdraw non-core strategy tokens ~ this is over and above normal yield function yearn( address _strategy, address _token, uint256 parts ) public { require(msg.sender == governance, "!governance"); // This contract should never have value in it, but just incase since this is a public call uint256 _before = IERC20(_token).balanceOf(address(this)); Strategy(_strategy).withdraw(_token); uint256 _after = IERC20(_token).balanceOf(address(this)); if (_after > _before) { uint256 _amount = _after.sub(_before); address _want = Strategy(_strategy).want(); uint256[] memory _distribution; uint256 _expected; _before = IERC20(_want).balanceOf(address(this)); IERC20(_token).safeApprove(onesplit, 0); IERC20(_token).safeApprove(onesplit, _amount); (_expected, _distribution) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _amount, parts, 0); OneSplitAudit(onesplit).swap(_token, _want, _amount, _expected, _distribution, 0); _after = IERC20(_want).balanceOf(address(this)); if (_after > _before) { _amount = _after.sub(_before); uint256 _reward = _amount.mul(split).div(max); earn(_want, _amount.sub(_reward)); IERC20(_want).safeTransfer(rewards, _reward); } } } function withdraw(address _token, uint256 _amount) public { require(msg.sender == vaults[_token], "!vault"); Strategy(strategies[_token]).withdraw(_amount); } }
contract Controller { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public governance; address public onesplit; address public rewards; address public timelock; mapping(address => address) public vaults; mapping(address => address) public strategies; mapping(address => mapping(address => address)) public converters; mapping(address => mapping(address => bool)) public approvedStrategies; uint256 public split = 500; uint256 public constant max = 10000; constructor(address _rewards,address _timelock) public { governance = msg.sender; onesplit = address(0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e); rewards = _rewards; timelock = _timelock; } function setRewards(address _rewards) public { require(msg.sender == governance, "!governance"); rewards = _rewards; } function setSplit(uint256 _split) public { require(msg.sender == governance, "!governance"); require(_split < max, "inappropriate split fee"); split = _split; } function setOneSplit(address _onesplit) public { require(msg.sender == governance, "!governance"); onesplit = _onesplit; } function setGovernance(address _governance) public { require(msg.sender == timelock, "!timelock"); governance = _governance; } function setTimelock(address _timelock) public { require(msg.sender == timelock, "!timelock"); timelock = _timelock; } function approveStrategy(address _token, address _strategy) public { require(msg.sender == timelock, "!timelock"); approvedStrategies[_token][_strategy] = true; } function revokeStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); approvedStrategies[_token][_strategy] = false; } function setConverter( address _input, address _output, address _converter ) public { require(msg.sender == governance, "!governance"); converters[_input][_output] = _converter; } function setVault(address _token, address _vault) public { require(msg.sender == governance, "!governance"); require(vaults[_token] == address(0), "vault is 0"); require(Vault(_vault).token() == _token, "illegal vault"); vaults[_token] = _vault; } function setStrategy(address _token, address _strategy) public { require(msg.sender == governance, "!governance"); require(approvedStrategies[_token][_strategy] == true, "!approved"); require(Strategy(_strategy).want() == _token, "illegal strategy"); address _current = strategies[_token]; if (_current != address(0)) { Strategy(_current).withdrawAll(); } strategies[_token] = _strategy; } function earn(address _token, uint256 _amount) public { address _strategy = strategies[_token]; address _want = Strategy(_strategy).want(); if (_want != _token) { address converter = converters[_token][_want]; IERC20(_token).safeTransfer(converter, _amount); _amount = Converter(converter).convert(_strategy); IERC20(_want).safeTransfer(_strategy, _amount); } else { IERC20(_token).safeTransfer(_strategy, _amount); } Strategy(_strategy).deposit(); } function balanceOf(address _token) external view returns (uint256) { return Strategy(strategies[_token]).balanceOf(); } function withdrawAll(address _token) public { require(msg.sender == governance, "!governance"); Strategy(strategies[_token]).withdrawAll(); } function inCaseTokensGetStuck(address _token, uint256 _amount) public { require(msg.sender == governance, "!governance"); IERC20(_token).safeTransfer(msg.sender, _amount); } function inCaseStrategyTokenGetStuck(address _strategy, address _token) public { require(msg.sender == governance, "!governance"); Strategy(_strategy).withdraw(_token); } function getExpectedReturn( address _strategy, address _token, uint256 parts ) public view returns (uint256 expected) { uint256 _balance = IERC20(_token).balanceOf(_strategy); address _want = Strategy(_strategy).want(); (expected, ) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _balance, parts, 0); } // Only allows to withdraw non-core strategy tokens ~ this is over and above normal yield function yearn( address _strategy, address _token, uint256 parts ) public { require(msg.sender == governance, "!governance"); // This contract should never have value in it, but just incase since this is a public call uint256 _before = IERC20(_token).balanceOf(address(this)); Strategy(_strategy).withdraw(_token); uint256 _after = IERC20(_token).balanceOf(address(this)); if (_after > _before) { uint256 _amount = _after.sub(_before); address _want = Strategy(_strategy).want(); uint256[] memory _distribution; uint256 _expected; _before = IERC20(_want).balanceOf(address(this)); IERC20(_token).safeApprove(onesplit, 0); IERC20(_token).safeApprove(onesplit, _amount); (_expected, _distribution) = OneSplitAudit(onesplit).getExpectedReturn(_token, _want, _amount, parts, 0); OneSplitAudit(onesplit).swap(_token, _want, _amount, _expected, _distribution, 0); _after = IERC20(_want).balanceOf(address(this)); if (_after > _before) { _amount = _after.sub(_before); uint256 _reward = _amount.mul(split).div(max); earn(_want, _amount.sub(_reward)); IERC20(_want).safeTransfer(rewards, _reward); } } } function withdraw(address _token, uint256 _amount) public { require(msg.sender == vaults[_token], "!vault"); Strategy(strategies[_token]).withdraw(_amount); } }
30,582
107
// Open a state channel through auth withdraw message library function can't be payable but can read msg.value in caller's context _self storage data of CelerLedger contract _openRequest bytes of open channel request message /
function openChannel(
function openChannel(
25,269
62
// Destroys `amount` tokens from `account`.`amount` is then deductedfrom the caller's allowance.
* See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); }
* See {_burn} and {_approve}. */ function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); }
28,307
13
// Pause sale if active, make active if paused
function flipSaleState() external onlyOwner { saleIsActive = !saleIsActive; }
function flipSaleState() external onlyOwner { saleIsActive = !saleIsActive; }
31,745
683
// Mints debt token to the `onBehalfOf` address.-Only callable by the LendingPool- The resulting rate is the weighted average between the rate of the new debtand the rate of the previous debt user The address receiving the borrowed underlying, being the delegatee in caseof credit delegate, or same as `onBehalfOf` otherwise onBehalfOf The address receiving the debt tokens amount The amount of debt tokens to mint rate The rate of the debt being minted /
) external override onlyLendingPool returns (bool) { MintLocalVars memory vars; if (user != onBehalfOf) { _decreaseBorrowAllowance(onBehalfOf, user, amount); } (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(onBehalfOf); vars.previousSupply = totalSupply(); vars.currentAvgStableRate = _avgStableRate; vars.nextSupply = _totalSupply = vars.previousSupply.add(amount); vars.amountInRay = amount.wadToRay(); vars.newStableRate = _usersStableRate[onBehalfOf] .rayMul(currentBalance.wadToRay()) .add(vars.amountInRay.rayMul(rate)) .rayDiv(currentBalance.add(amount).wadToRay()); require(vars.newStableRate <= type(uint128).max, Errors.SDT_STABLE_DEBT_OVERFLOW); _usersStableRate[onBehalfOf] = vars.newStableRate; //solium-disable-next-line _totalSupplyTimestamp = _timestamps[onBehalfOf] = uint40(block.timestamp); // Calculates the updated average stable rate vars.currentAvgStableRate = _avgStableRate = vars .currentAvgStableRate .rayMul(vars.previousSupply.wadToRay()) .add(rate.rayMul(vars.amountInRay)) .rayDiv(vars.nextSupply.wadToRay()); _mint(onBehalfOf, amount.add(balanceIncrease), vars.previousSupply); emit Transfer(address(0), onBehalfOf, amount); emit Mint( user, onBehalfOf, amount, currentBalance, balanceIncrease, vars.newStableRate, vars.currentAvgStableRate, vars.nextSupply ); return currentBalance == 0; }
) external override onlyLendingPool returns (bool) { MintLocalVars memory vars; if (user != onBehalfOf) { _decreaseBorrowAllowance(onBehalfOf, user, amount); } (, uint256 currentBalance, uint256 balanceIncrease) = _calculateBalanceIncrease(onBehalfOf); vars.previousSupply = totalSupply(); vars.currentAvgStableRate = _avgStableRate; vars.nextSupply = _totalSupply = vars.previousSupply.add(amount); vars.amountInRay = amount.wadToRay(); vars.newStableRate = _usersStableRate[onBehalfOf] .rayMul(currentBalance.wadToRay()) .add(vars.amountInRay.rayMul(rate)) .rayDiv(currentBalance.add(amount).wadToRay()); require(vars.newStableRate <= type(uint128).max, Errors.SDT_STABLE_DEBT_OVERFLOW); _usersStableRate[onBehalfOf] = vars.newStableRate; //solium-disable-next-line _totalSupplyTimestamp = _timestamps[onBehalfOf] = uint40(block.timestamp); // Calculates the updated average stable rate vars.currentAvgStableRate = _avgStableRate = vars .currentAvgStableRate .rayMul(vars.previousSupply.wadToRay()) .add(rate.rayMul(vars.amountInRay)) .rayDiv(vars.nextSupply.wadToRay()); _mint(onBehalfOf, amount.add(balanceIncrease), vars.previousSupply); emit Transfer(address(0), onBehalfOf, amount); emit Mint( user, onBehalfOf, amount, currentBalance, balanceIncrease, vars.newStableRate, vars.currentAvgStableRate, vars.nextSupply ); return currentBalance == 0; }
25,139
17
// Function to add APS manager to Yieldster./_manager Address of the manager.
function addManager(address _manager) public onlyYieldsterDAO
function addManager(address _manager) public onlyYieldsterDAO
40,240
22
// Assumes worst case scenario if FRAX slips out of range.Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION); return (collat_portion).add(frax_portion);
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION); return (collat_portion).add(frax_portion);
6,389
76
// Sets the minimum bond that is required for an answer to be accepted./bond Minimum bond that is required for an answer to be accepted/This can only be called by the owner
function setMinimumBond(uint256 bond) public onlyOwner { minimumBond = bond; }
function setMinimumBond(uint256 bond) public onlyOwner { minimumBond = bond; }
49,569
77
// setup _limits
_limits = MaxLimits({ maxWallet: TOTAL_SUPPLY * _limitRatios.wallet / _limitRatios.divisor, maxSell: TOTAL_SUPPLY * _limitRatios.sell / _limitRatios.divisor, maxBuy: TOTAL_SUPPLY * _limitRatios.buy / _limitRatios.divisor });
_limits = MaxLimits({ maxWallet: TOTAL_SUPPLY * _limitRatios.wallet / _limitRatios.divisor, maxSell: TOTAL_SUPPLY * _limitRatios.sell / _limitRatios.divisor, maxBuy: TOTAL_SUPPLY * _limitRatios.buy / _limitRatios.divisor });
24,038
10
// no payout has been made. subtract genesis from milkTill
totalDuration = milkTill - tokenData.genesis;
totalDuration = milkTill - tokenData.genesis;
8,305
601
// Emits a {Transfer} event. Requirements: - `src` must have a balance of at least `amount`. // if_succeeds {:msg "Transfer - src decrease"} old(_balanceOf[src]) >= _balanceOf[src];/ if_succeeds {:msg "Transfer - dst increase"} _balanceOf[dst] >= old(_balanceOf[dst]);/ if_succeeds {:msg "Transfer - supply"} old(_balanceOf[src]) + old(_balanceOf[dst]) == _balanceOf[src] + _balanceOf[dst];
function _transfer(address src, address dst, uint wad) internal virtual returns (bool) { require(_balanceOf[src] >= wad, "ERC20: Insufficient balance"); unchecked { _balanceOf[src] = _balanceOf[src] - wad; }
function _transfer(address src, address dst, uint wad) internal virtual returns (bool) { require(_balanceOf[src] >= wad, "ERC20: Insufficient balance"); unchecked { _balanceOf[src] = _balanceOf[src] - wad; }
20,141
56
// Verify whether order nonce has expired
require( (_isUserOrderNonceExecutedOrCancelled[makerOrder.signer][makerOrder.nonce] < type(uint256).max) && (makerOrder.nonce >= userMinOrderNonce[makerOrder.signer]), "Order: Matching order expired" );
require( (_isUserOrderNonceExecutedOrCancelled[makerOrder.signer][makerOrder.nonce] < type(uint256).max) && (makerOrder.nonce >= userMinOrderNonce[makerOrder.signer]), "Order: Matching order expired" );
28,325
667
// AmmExitProcess
library AmmExitProcess
library AmmExitProcess
81,202
163
// Migrate funds to the new liquidity provider.//_newLP The address of the new LiquidityPool contract.
function migrate(ILiquidityPool _newLP) public onlyOperator { for (uint256 i = 0; i < registeredTokens.length; i++) { address token = registeredTokens[i]; kTokens[token].addMinter(address(_newLP)); kTokens[token].renounceMinter(); _newLP.register(kTokens[token]); _transferOut(address(_newLP), token, borrowableBalance(token)); } _newLP.renounceOperator(); }
function migrate(ILiquidityPool _newLP) public onlyOperator { for (uint256 i = 0; i < registeredTokens.length; i++) { address token = registeredTokens[i]; kTokens[token].addMinter(address(_newLP)); kTokens[token].renounceMinter(); _newLP.register(kTokens[token]); _transferOut(address(_newLP), token, borrowableBalance(token)); } _newLP.renounceOperator(); }
50,942
27
// add owner
function addOwner(address owner) external onlyThis{ require(owner != address(0), "Zero address"); require(owners.length() < 127, "Too many owners"); require(owners.add(owner), "Owner already added"); ownersSetCounter++; // change owners set emit SetOwner(owner, true); }
function addOwner(address owner) external onlyThis{ require(owner != address(0), "Zero address"); require(owners.length() < 127, "Too many owners"); require(owners.add(owner), "Owner already added"); ownersSetCounter++; // change owners set emit SetOwner(owner, true); }
52,008
5
// Game information
struct GameInfo { // game start time uint256 timestamp; // game odds uint32 odd_homeTeam; uint32 odd_drawTeam; uint32 odd_awayTeam; uint32 odd_over; uint32 odd_under; uint32 odd_homeTeamAndDraw; uint32 odd_homeAndAwayTeam; uint32 odd_awayTeamAndDraw; // Checking the game status uint8 open_status; // Checking whether winning were paid bool isDone; }
struct GameInfo { // game start time uint256 timestamp; // game odds uint32 odd_homeTeam; uint32 odd_drawTeam; uint32 odd_awayTeam; uint32 odd_over; uint32 odd_under; uint32 odd_homeTeamAndDraw; uint32 odd_homeAndAwayTeam; uint32 odd_awayTeamAndDraw; // Checking the game status uint8 open_status; // Checking whether winning were paid bool isDone; }
38,054
4
// Address of the MANA ERC20 contract
IERC20 MANA;
IERC20 MANA;
23,568
52
// convert little endian bytes to uint
function getBytesLE(bytes data, uint pos, uint bits) returns (uint) { if (bits == 8) { return uint8(data[pos]); } else if (bits == 16) { return uint16(data[pos]) + uint16(data[pos + 1]) * 2 ** 8; } else if (bits == 32) { return uint32(data[pos]) + uint32(data[pos + 1]) * 2 ** 8 + uint32(data[pos + 2]) * 2 ** 16 + uint32(data[pos + 3]) * 2 ** 24; } else if (bits == 64) { return uint64(data[pos]) + uint64(data[pos + 1]) * 2 ** 8 + uint64(data[pos + 2]) * 2 ** 16 + uint64(data[pos + 3]) * 2 ** 24 + uint64(data[pos + 4]) * 2 ** 32 + uint64(data[pos + 5]) * 2 ** 40 + uint64(data[pos + 6]) * 2 ** 48 + uint64(data[pos + 7]) * 2 ** 56; } }
function getBytesLE(bytes data, uint pos, uint bits) returns (uint) { if (bits == 8) { return uint8(data[pos]); } else if (bits == 16) { return uint16(data[pos]) + uint16(data[pos + 1]) * 2 ** 8; } else if (bits == 32) { return uint32(data[pos]) + uint32(data[pos + 1]) * 2 ** 8 + uint32(data[pos + 2]) * 2 ** 16 + uint32(data[pos + 3]) * 2 ** 24; } else if (bits == 64) { return uint64(data[pos]) + uint64(data[pos + 1]) * 2 ** 8 + uint64(data[pos + 2]) * 2 ** 16 + uint64(data[pos + 3]) * 2 ** 24 + uint64(data[pos + 4]) * 2 ** 32 + uint64(data[pos + 5]) * 2 ** 40 + uint64(data[pos + 6]) * 2 ** 48 + uint64(data[pos + 7]) * 2 ** 56; } }
17,422
38
// Buy SPUME with ETH
function buy() public payable { require(closed == false, "Sale is closed"); int price = getETHUSDPrice(); require(price > 0, "Error with Chainlink"); uint256 spumeAmount = uint256(price) * msg.value; spumeAmount = (((spumeAmount / (10 ** 8)) * 3333) / 1000); require(spumeAmount >= minBuy, "Cannot buy that few tokens"); require(spumeAmount <= maxBuy, "Cannot buy that many tokens"); spumeAmount = spumeAmount / 2; require(spumeAmount <= token.allowance(owner, address(this)), "Sale is sold out"); owner.transfer(msg.value); token.transferFrom(owner, msg.sender, spumeAmount); claimable[msg.sender] += spumeAmount; }
function buy() public payable { require(closed == false, "Sale is closed"); int price = getETHUSDPrice(); require(price > 0, "Error with Chainlink"); uint256 spumeAmount = uint256(price) * msg.value; spumeAmount = (((spumeAmount / (10 ** 8)) * 3333) / 1000); require(spumeAmount >= minBuy, "Cannot buy that few tokens"); require(spumeAmount <= maxBuy, "Cannot buy that many tokens"); spumeAmount = spumeAmount / 2; require(spumeAmount <= token.allowance(owner, address(this)), "Sale is sold out"); owner.transfer(msg.value); token.transferFrom(owner, msg.sender, spumeAmount); claimable[msg.sender] += spumeAmount; }
85,755
4
// get the slot from storage and unpack it
uint256 slot = EDITION_SLOTS[slotForTokenId]; uint256 unpackedSlot = _unPackSlot(slot, slotIndex);
uint256 slot = EDITION_SLOTS[slotForTokenId]; uint256 unpackedSlot = _unPackSlot(slot, slotIndex);
75,979
139
// 44the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping (uint256 => address) private _owners; // Mapping owner address to token count mapping (address => uint256) private _balances; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden * in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
* {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping (uint256 => address) private _owners; // Mapping owner address to token count mapping (address => uint256) private _balances; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ''; } /** * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden * in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { // solhint-disable-next-line no-inline-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
40,403
265
// purchase multiple kidz at once
function purchaseKidz(uint256 _howMany) public payable { require(isSaleActive, "Sale not active"); _beforeMint(_howMany); require(_howMany <= 20, "Max 20 kidz at once"); uint256 _itemPrice = _howMany == 1 ? tier1Price : _howMany == 2 ? tier2Price : tier3Price; require(msg.value >= _itemPrice.mul(_howMany), "Insufficient ETH to mint"); for (uint256 i = 0; i < _howMany; i++) { _mintKidz(_msgSender()); } }
function purchaseKidz(uint256 _howMany) public payable { require(isSaleActive, "Sale not active"); _beforeMint(_howMany); require(_howMany <= 20, "Max 20 kidz at once"); uint256 _itemPrice = _howMany == 1 ? tier1Price : _howMany == 2 ? tier2Price : tier3Price; require(msg.value >= _itemPrice.mul(_howMany), "Insufficient ETH to mint"); for (uint256 i = 0; i < _howMany; i++) { _mintKidz(_msgSender()); } }
76,343
3
// State Variables // Transactions /
string _dob) public returns(bool success) { profiles[userAddress].username = _username; profiles[userAddress].email = _email; profiles[userAddress].firstName = _firstname; profiles[userAddress].lastName = _lastname; profiles[userAddress].occupation = _occupation; profiles[userAddress].dob = _dob; userAddresses.push(userAddress); return true; }
string _dob) public returns(bool success) { profiles[userAddress].username = _username; profiles[userAddress].email = _email; profiles[userAddress].firstName = _firstname; profiles[userAddress].lastName = _lastname; profiles[userAddress].occupation = _occupation; profiles[userAddress].dob = _dob; userAddresses.push(userAddress); return true; }
19,262
16
// Additional transaction functions below
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "Transfer from the zero address"); require(recipient != address(0), "Transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
function _transfer(address sender, address recipient, uint256 amount) internal { require(sender != address(0), "Transfer from the zero address"); require(recipient != address(0), "Transfer to the zero address"); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "Transfer amount exceeds balance"); _balances[sender] = senderBalance - amount; _balances[recipient] += amount; emit Transfer(sender, recipient, amount); }
31,003
1
// General proposal structure.
struct Proposal { uint256 id; address proposalAddress; address investTokenAddress; DaoFunction daoFunction; uint256 amount; address creator; uint256 endLifetime; EnumerableSet.AddressSet voterAddresses; uint256 votesFor; uint256 votesAgainst; uint256 votes; bool executed; }
struct Proposal { uint256 id; address proposalAddress; address investTokenAddress; DaoFunction daoFunction; uint256 amount; address creator; uint256 endLifetime; EnumerableSet.AddressSet voterAddresses; uint256 votesFor; uint256 votesAgainst; uint256 votes; bool executed; }
1,812
414
// Library for managing an enumerable variant of Solidity'stype. Maps have the following properties: - Entries are added, removed, and checked for existence in constant time(O(1)).- Entries are enumerated in O(n). No guarantees are made on the ordering. ```
* contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * }
* contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * }
33,605
55
// Manually back TTC owner address. /
function backTTCOwner() onlyOwner public { coin.transferOwnership(owner); }
function backTTCOwner() onlyOwner public { coin.transferOwnership(owner); }
20,710
0
// Network: Fuji TestnetLINK address: 0x47523b7C935671d6e4AC0CB8f9F6a3Fa60Fe298bFee: 0.001 LINK /
constructor() public { setChainlinkToken(0x326C977E6efc84E512bB9C30f76E30c160eD06FB); fee = 10 ** 15; // 0.001 LINK }
constructor() public { setChainlinkToken(0x326C977E6efc84E512bB9C30f76E30c160eD06FB); fee = 10 ** 15; // 0.001 LINK }
30,747
91
// feeEnabled is a failsafe incase something goes wrong - no one must get rekt, let's be able to turn off if required
if(feeEnabled) {
if(feeEnabled) {
36,584
446
// expmods_and_points.points[70] = -(g^8175z).
mstore(add(expmodsAndPoints, 0xb20), point)
mstore(add(expmodsAndPoints, 0xb20), point)
3,369
77
// Getter for the data encryption key and version. account The address of the account to get the key forreturn dataEncryptionKey secp256k1 public key for data encryption. Preferably compressed. /
function getDataEncryptionKey(address account) external view returns (bytes memory) { return accounts[account].dataEncryptionKey; }
function getDataEncryptionKey(address account) external view returns (bytes memory) { return accounts[account].dataEncryptionKey; }
15,229
116
// allow DEFALUT_ADMIN to withdraw as much as he wants
_checkAndUpdateEthMaxCap(amount); payable(to).transfer(amount);
_checkAndUpdateEthMaxCap(amount); payable(to).transfer(amount);
25,389
104
// require(bytes(_name).length > 0 && bytes(_symbol).length > 0);validate input
token = GACToken(tokenAddress); tokensPerUSD = 10 * 10 ** 18; valueToBeSent = token.valueToBeSent(); pricingstrategy = PricingStrategy(strategy);
token = GACToken(tokenAddress); tokensPerUSD = 10 * 10 ** 18; valueToBeSent = token.valueToBeSent(); pricingstrategy = PricingStrategy(strategy);
17,447
37
// Initializes timelock contract with the address of the governor/admin admin_ Address of the timelock admin. /
function initialize(address admin_) external onlyOwner initializer { admin = admin_; }
function initialize(address admin_) external onlyOwner initializer { admin = admin_; }
43,019
33
// Set the address as claimed with the _claimable amount.
addressToBBClaimed[msg.sender] += _claimable; // add the claimed amount
addressToBBClaimed[msg.sender] += _claimable; // add the claimed amount
26,386
216
// Construct a new Configurable Rights Pool (wrapper around BPool) _initialTokens and _swapFee are only used for temporary storage between construction and create pool, and should not be used thereafter! _initialTokens is destroyed in createPool to prevent this, and _swapFee is kept in sync (defensively), but should never be used except in this constructor and createPool() factoryAddress - the BPoolFactory used to create the underlying pool poolParams - struct containing pool parameters rightsStruct - Set of permissions we are assigning to this smart pool /
constructor( address factoryAddress, PoolParams memory poolParams, RightsManager.Rights memory rightsStruct ) public PCToken(poolParams.poolTokenSymbol, poolParams.poolTokenName)
constructor( address factoryAddress, PoolParams memory poolParams, RightsManager.Rights memory rightsStruct ) public PCToken(poolParams.poolTokenSymbol, poolParams.poolTokenName)
33,586
85
// burn
_updateAccountSnapshot(from); _updateTotalSupplySnapshot();
_updateAccountSnapshot(from); _updateTotalSupplySnapshot();
20,441
201
// Allows owner to set Max mints per tx _newMaxMint maximum amount of tokens allowed to mint per tx. Must be >= 1 /
function setMaxMint(uint256 _newMaxMint) public onlyOwner { require(_newMaxMint >= 1, "Max mint must be at least 1"); maxBatchSize = _newMaxMint; }
function setMaxMint(uint256 _newMaxMint) public onlyOwner { require(_newMaxMint >= 1, "Max mint must be at least 1"); maxBatchSize = _newMaxMint; }
15,927
155
// whether a certain entity has a permission
mapping (bytes32 => bytes32) permissions; // 0 for no permission, or parameters id mapping (bytes32 => Param[]) public permissionParams;
mapping (bytes32 => bytes32) permissions; // 0 for no permission, or parameters id mapping (bytes32 => Param[]) public permissionParams;
27,597
118
// Owner can KYC (or revoke) addresses until close of funding
function addKycAddress(address _addr, bool _kyc) public noReentry onlyOwner returns (bool)
function addKycAddress(address _addr, bool _kyc) public noReentry onlyOwner returns (bool)
985
9
// Approve tokens from gnosis safe to attacker contract
token.approve(spender, type(uint256).max);
token.approve(spender, type(uint256).max);
38,599
7
// Add a token to the end of the list /
function add(uint16 _id) public onlyAllowed { data[actualSize] = _id; actualSize++; }
function add(uint16 _id) public onlyAllowed { data[actualSize] = _id; actualSize++; }
54,480
3
// Status of a risk provider
mapping(address => bool) private _provider;
mapping(address => bool) private _provider;
5,022
85
// manages the Collateralization Oracle as well as other protocol oracles.
bytes32 internal constant ORACLE_ADMIN = keccak256("ORACLE_ADMIN_ROLE");
bytes32 internal constant ORACLE_ADMIN = keccak256("ORACLE_ADMIN_ROLE");
49,491
79
// ----------- PCV Controller only state changing api -----------
function withdraw(address to, uint256 amount) external; function withdrawERC20(address token, address to, uint256 amount) external; function withdrawETH(address payable to, uint256 amount) external;
function withdraw(address to, uint256 amount) external; function withdrawERC20(address token, address to, uint256 amount) external; function withdrawETH(address payable to, uint256 amount) external;
27,928
47
// Do reverse order of fees charged in joinswap_ExternAmountIn, this way``` pAo == joinswap_ExternAmountIn(Ti, joinswap_PoolAmountOut(pAo, Ti)) ```uint tAi = tAiAfterFee / (1 - (1-weightTi)swapFee) ;
uint zar = bmul(bsub(BConst.BONE, normalizedWeight), swapFee); tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BConst.BONE, zar)); return tokenAmountIn;
uint zar = bmul(bsub(BConst.BONE, normalizedWeight), swapFee); tokenAmountIn = bdiv(tokenAmountInAfterFee, bsub(BConst.BONE, zar)); return tokenAmountIn;
20,741
0
// if ether is sent to this address, send it back.
throw;
throw;
23,133