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
|
---|---|---|---|---|
14 | // View function to see pending Tokens on frontend. | function pendingReward(address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo;
UserInfo storage user = userInfo[_user];
uint256 accRewardPerShare = pool.accRewardPerShare;
uint256 stakedSupply = syrup.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && stakedSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tokenReward = multiplier.mul(rewardPerBlock);
accRewardPerShare = accRewardPerShare.add(tokenReward.mul(1e12).div(stakedSupply));
}
return user.amount.mul(accRewardPerShare).div(1e12).sub(user.rewardDebt).add(user.rewardPending);
}
| function pendingReward(address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo;
UserInfo storage user = userInfo[_user];
uint256 accRewardPerShare = pool.accRewardPerShare;
uint256 stakedSupply = syrup.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && stakedSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 tokenReward = multiplier.mul(rewardPerBlock);
accRewardPerShare = accRewardPerShare.add(tokenReward.mul(1e12).div(stakedSupply));
}
return user.amount.mul(accRewardPerShare).div(1e12).sub(user.rewardDebt).add(user.rewardPending);
}
| 5,112 |
74 | // Returns the subtraction of two unsigned integers, reverting with custom message on overflow (when the result is negative). CAUTION: This function is deprecated because it requires allocating memory for the error | * message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
| * message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
| 24,501 |
35 | // Check timestamp of the new block | {
require(_newBlock.timestamp >= _previousBlock.timestamp, "g"); // Block should be after previous block
bool timestampNotTooSmall = block.timestamp.sub(COMMIT_TIMESTAMP_NOT_OLDER) <= _newBlock.timestamp;
bool timestampNotTooBig = _newBlock.timestamp <= block.timestamp.add(COMMIT_TIMESTAMP_APPROXIMATION_DELTA);
require(timestampNotTooSmall && timestampNotTooBig, "h"); // New block timestamp is not valid
}
| {
require(_newBlock.timestamp >= _previousBlock.timestamp, "g"); // Block should be after previous block
bool timestampNotTooSmall = block.timestamp.sub(COMMIT_TIMESTAMP_NOT_OLDER) <= _newBlock.timestamp;
bool timestampNotTooBig = _newBlock.timestamp <= block.timestamp.add(COMMIT_TIMESTAMP_APPROXIMATION_DELTA);
require(timestampNotTooSmall && timestampNotTooBig, "h"); // New block timestamp is not valid
}
| 59,798 |
24 | // purchased charges are deprecated, but still honored for anyone that purchased before deprecation | return charges + chargesData[bagId].chargesPurchased;
| return charges + chargesData[bagId].chargesPurchased;
| 25,237 |
11 | // Sets the buyer, ensuring that funds are transferred internally to the new buyer address. / | function setBuyer(Data storage self, address _buyer) internal {
// must use buyerFunds() and sellerFunds() instead of accountBalances directly so that dailyCommission is updated first
transfer(self, self.buyer, _buyer, buyerFunds(self));
self.buyer = _buyer;
}
| function setBuyer(Data storage self, address _buyer) internal {
// must use buyerFunds() and sellerFunds() instead of accountBalances directly so that dailyCommission is updated first
transfer(self, self.buyer, _buyer, buyerFunds(self));
self.buyer = _buyer;
}
| 31,658 |
2 | // solhint-disable quotes / | contract BleepsTokenURI is ITokenURI {
// svg from : https://codepen.io/rachelmcgrane/pen/VexWdX
function contractURI() external pure returns (string memory) {
return
'data:application/json,{"name":"Bleeps","description":"Composable%20Sounds%20Fully%20Generated%20On-Chain"}';
}
function tokenURI(uint256) external pure returns (string memory) {
return
'data:application/json,{"name":"Bleeps","description":"Composable%20Sounds%20Fully%20Generated%20On-Chain"}';
}
}
| contract BleepsTokenURI is ITokenURI {
// svg from : https://codepen.io/rachelmcgrane/pen/VexWdX
function contractURI() external pure returns (string memory) {
return
'data:application/json,{"name":"Bleeps","description":"Composable%20Sounds%20Fully%20Generated%20On-Chain"}';
}
function tokenURI(uint256) external pure returns (string memory) {
return
'data:application/json,{"name":"Bleeps","description":"Composable%20Sounds%20Fully%20Generated%20On-Chain"}';
}
}
| 44,833 |
72 | // 722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3 | contract ERC20 is Context, IERC20 {//722,333 people died that summer but history won't remember a single one.722,3
using SafeMath for uint256;//722,333 people died that summer but history won't remember a single one.722,3
using Address for address;//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
mapping (address => uint256) private _balances;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
mapping (address => mapping (address => uint256)) private _allowances;//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
uint256 private _totalSupply;//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
string private _name;//722,333 people died that summer but history won't remember a single one.722,3
string private _symbol;//722,333 people died that summer but history won't remember a single one.722,3
uint8 private _decimals;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
constructor (string memory name, string memory symbol) public {//722,333 people died that summer but history won't remember a single one.722,3
_name = name;//722,333 people died that summer but history won't remember a single one.722,3
_symbol = symbol;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
_decimals = 18;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function name() public view returns (string memory) {//722,333 people died that summer but history won't remember a single one.722,3
return _name;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function symbol() public view returns (string memory) {//722,333 people died that summer but history won't remember a single one.722,3
return _symbol;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function decimals() public view returns (uint8) {//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
return _decimals;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function totalSupply() public view override returns (uint256) {//722,333 people died that summer but history won't remember a single one.722,3
return _totalSupply;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function balanceOf(address account) public view override returns (uint256) {//722,333 people died that summer but history won't remember a single one.722,3
return _balances[account];//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_transfer(_msgSender(), recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function allowance(address owner, address spender) public view virtual override returns (uint256) {//722,333 people died that summer but history won't remember a single one.722,3
return _allowances[owner][spender];//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function approve(address spender, uint256 amount) public virtual override returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_approve(_msgSender(), spender, amount);//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_transfer(sender, recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function _transfer(address sender, address recipient, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(sender != address(0), "ERC20: transfer from the zero address");//722,333 people died that summer but history won't remember a single one.722,3
require(recipient != address(0), "ERC20: transfer to the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_beforeTokenTransfer(sender, recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");//722,333 people died that summer but history won't remember a single one.722,3
_balances[recipient] = _balances[recipient].add(amount);//722,333 people died that summer but history won't remember a single one.722,3
emit Transfer(sender, recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
function _mint(address account, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(account != address(0), "ERC20: mint to the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_beforeTokenTransfer(address(0), account, amount);//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_totalSupply = _totalSupply.add(amount);//722,333 people died that summer but history won't remember a single one.722,3
_balances[account] = _balances[account].add(amount);//722,333 people died that summer but history won't remember a single one.722,3
emit Transfer(address(0), account, amount);//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function _burn(address account, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(account != address(0), "ERC20: burn from the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_beforeTokenTransfer(account, address(0), amount);//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");//722,333 people died that summer but history won't remember a single one.722,3
_totalSupply = _totalSupply.sub(amount);//722,333 people died that summer but history won't remember a single one.722,3
emit Transfer(account, address(0), amount);//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function _approve(address owner, address spender, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(owner != address(0), "ERC20: approve from the zero address");//722,333 people died that summer but history won't remember a single one.722,3
require(spender != address(0), "ERC20: approve to the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_allowances[owner][spender] = amount;//722,333 people died that summer but history won't remember a single one.722,3
emit Approval(owner, spender, amount);//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
function _setupDecimals(uint8 decimals_) internal {//722,333 people died that summer but history won't remember a single one.722,3
_decimals = decimals_;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
| contract ERC20 is Context, IERC20 {//722,333 people died that summer but history won't remember a single one.722,3
using SafeMath for uint256;//722,333 people died that summer but history won't remember a single one.722,3
using Address for address;//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
mapping (address => uint256) private _balances;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
mapping (address => mapping (address => uint256)) private _allowances;//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
uint256 private _totalSupply;//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
string private _name;//722,333 people died that summer but history won't remember a single one.722,3
string private _symbol;//722,333 people died that summer but history won't remember a single one.722,3
uint8 private _decimals;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
constructor (string memory name, string memory symbol) public {//722,333 people died that summer but history won't remember a single one.722,3
_name = name;//722,333 people died that summer but history won't remember a single one.722,3
_symbol = symbol;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
_decimals = 18;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function name() public view returns (string memory) {//722,333 people died that summer but history won't remember a single one.722,3
return _name;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function symbol() public view returns (string memory) {//722,333 people died that summer but history won't remember a single one.722,3
return _symbol;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function decimals() public view returns (uint8) {//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
return _decimals;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function totalSupply() public view override returns (uint256) {//722,333 people died that summer but history won't remember a single one.722,3
return _totalSupply;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function balanceOf(address account) public view override returns (uint256) {//722,333 people died that summer but history won't remember a single one.722,3
return _balances[account];//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_transfer(_msgSender(), recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function allowance(address owner, address spender) public view virtual override returns (uint256) {//722,333 people died that summer but history won't remember a single one.722,3
return _allowances[owner][spender];//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function approve(address spender, uint256 amount) public virtual override returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_approve(_msgSender(), spender, amount);//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_transfer(sender, recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {//722,333 people died that summer but history won't remember a single one.722,3
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));//722,333 people died that summer but history won't remember a single one.722,3
return true;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function _transfer(address sender, address recipient, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(sender != address(0), "ERC20: transfer from the zero address");//722,333 people died that summer but history won't remember a single one.722,3
require(recipient != address(0), "ERC20: transfer to the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_beforeTokenTransfer(sender, recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");//722,333 people died that summer but history won't remember a single one.722,3
_balances[recipient] = _balances[recipient].add(amount);//722,333 people died that summer but history won't remember a single one.722,3
emit Transfer(sender, recipient, amount);//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
function _mint(address account, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(account != address(0), "ERC20: mint to the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_beforeTokenTransfer(address(0), account, amount);//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_totalSupply = _totalSupply.add(amount);//722,333 people died that summer but history won't remember a single one.722,3
_balances[account] = _balances[account].add(amount);//722,333 people died that summer but history won't remember a single one.722,3
emit Transfer(address(0), account, amount);//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function _burn(address account, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(account != address(0), "ERC20: burn from the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_beforeTokenTransfer(account, address(0), amount);//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");//722,333 people died that summer but history won't remember a single one.722,3
_totalSupply = _totalSupply.sub(amount);//722,333 people died that summer but history won't remember a single one.722,3
emit Transfer(account, address(0), amount);//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
function _approve(address owner, address spender, uint256 amount) internal virtual {//722,333 people died that summer but history won't remember a single one.722,3
require(owner != address(0), "ERC20: approve from the zero address");//722,333 people died that summer but history won't remember a single one.722,3
require(spender != address(0), "ERC20: approve to the zero address");//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
_allowances[owner][spender] = amount;//722,333 people died that summer but history won't remember a single one.722,3
emit Approval(owner, spender, amount);//722,333 people died that summer but history won't remember a single one.722,3//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
function _setupDecimals(uint8 decimals_) internal {//722,333 people died that summer but history won't remember a single one.722,3
_decimals = decimals_;//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
//722,333 people died that summer but history won't remember a single one.722,3
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }//722,333 people died that summer but history won't remember a single one.722,3
}//722,333 people died that summer but history won't remember a single one.722,3
| 34,220 |
103 | // Emitted by the pool for any swaps between token0 and token1/sender The address that initiated the swap call, and that received the callback/recipient The address that received the output of the swap/amount0 The delta of the token0 balance of the pool/amount1 The delta of the token1 balance of the pool/sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96/liquidity The liquidity of the pool after the swap/tick The log base 1.0001 of price of the pool after the swap | event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
| event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
| 53,457 |
44 | // checks if it's part of the allowed tokens / | modifier isTokenAllowed(uint256 _tokenId) {
bool found = false;
for (uint128 i = 0; i < allowedTokens.length; i++) {
if (allowedTokens[i] == _tokenId) found = true;
}
require(found, "BadCacheBridge: token id does not exists");
_;
}
| modifier isTokenAllowed(uint256 _tokenId) {
bool found = false;
for (uint128 i = 0; i < allowedTokens.length; i++) {
if (allowedTokens[i] == _tokenId) found = true;
}
require(found, "BadCacheBridge: token id does not exists");
_;
}
| 19,685 |
34 | // Get the access status for a address. | function getAddressAccess(address user) external view returns(bool) {
return extendedAccess[user];
}
| function getAddressAccess(address user) external view returns(bool) {
return extendedAccess[user];
}
| 22,522 |
75 | // Deletes a Controller _controller - Controller to be deletedreturn True if success / | function deleteController(address _controller)
public
onlyController
returns (bool)
| function deleteController(address _controller)
public
onlyController
returns (bool)
| 50,227 |
15 | // Sets the stored oracle address oracleAddress The address of the oracle contract / | function setChainlinkOracle(address oracleAddress) internal {
s_oracle = OperatorInterface(oracleAddress);
}
| function setChainlinkOracle(address oracleAddress) internal {
s_oracle = OperatorInterface(oracleAddress);
}
| 20,031 |
49 | // Appends a number to an instance of a TinyString: "1 + 2 = ".toTinyString().append(3) => "1 + 2 = 3".self an instance of TinyString to append the number to. number the number to append. return a new instance of TinyString. / | function appendNumber(TinyString self, uint number) internal pure returns (TinyString) {
// since we work on character level, we don't need range checks.
unchecked {
uint str = TinyString.unwrap(self);
if (number >= 100) {
// if number is > 100, append number of hundreds
str = (str << BITS_PER_CHARACTER) | (ZERO_ASCII_CODE + number / 100);
}
if (number >= 10) {
// if number is > 100, append number of tens
str = (str << BITS_PER_CHARACTER) | (ZERO_ASCII_CODE + number / 10 % 10);
}
// append any remainder (0..9) to the string
return TinyString.wrap((str << BITS_PER_CHARACTER) | (ZERO_ASCII_CODE + number % 10));
}
}
| function appendNumber(TinyString self, uint number) internal pure returns (TinyString) {
// since we work on character level, we don't need range checks.
unchecked {
uint str = TinyString.unwrap(self);
if (number >= 100) {
// if number is > 100, append number of hundreds
str = (str << BITS_PER_CHARACTER) | (ZERO_ASCII_CODE + number / 100);
}
if (number >= 10) {
// if number is > 100, append number of tens
str = (str << BITS_PER_CHARACTER) | (ZERO_ASCII_CODE + number / 10 % 10);
}
// append any remainder (0..9) to the string
return TinyString.wrap((str << BITS_PER_CHARACTER) | (ZERO_ASCII_CODE + number % 10));
}
}
| 2,485 |
11 | // Converts reward tokens to deposit tokens Always converts through router; there are no price checks enabledreturn deposit tokens received / | function _convertRewardTokensToDepositTokens(uint amount) private returns (uint) {
require(amount > 0, "DexStrategySAWithSwap::_convertRewardTokensToDepositTokens");
uint pathLength = 2;
address[] memory path = new address[](pathLength);
path[0] = address(rewardToken);
path[1] = address(depositToken);
uint amountOutToken = amount;
uint[] memory amountsOutToken = router.getAmountsOut(amount, path);
amountOutToken = amountsOutToken[amountsOutToken.length - 1];
router.swapExactTokensForTokens(amount, amountOutToken, path, address(this), block.timestamp);
return amountOutToken;
}
| function _convertRewardTokensToDepositTokens(uint amount) private returns (uint) {
require(amount > 0, "DexStrategySAWithSwap::_convertRewardTokensToDepositTokens");
uint pathLength = 2;
address[] memory path = new address[](pathLength);
path[0] = address(rewardToken);
path[1] = address(depositToken);
uint amountOutToken = amount;
uint[] memory amountsOutToken = router.getAmountsOut(amount, path);
amountOutToken = amountsOutToken[amountsOutToken.length - 1];
router.swapExactTokensForTokens(amount, amountOutToken, path, address(this), block.timestamp);
return amountOutToken;
}
| 25,195 |
5 | // Mint new COOP and return how much was minted / | function mint() public payable returns (uint256) {
// increase the total supply and the senders balance by an amount of
// COOP that maintains the COOP to ETH proportions.
uint256 price = coopPrice();
require(msg.value >= price);
uint256 amount = msg.value.div(price);
totalSupply = totalSupply.add(amount);
balances[msg.sender] = balances[msg.sender].add(amount);
return amount;
}
| function mint() public payable returns (uint256) {
// increase the total supply and the senders balance by an amount of
// COOP that maintains the COOP to ETH proportions.
uint256 price = coopPrice();
require(msg.value >= price);
uint256 amount = msg.value.div(price);
totalSupply = totalSupply.add(amount);
balances[msg.sender] = balances[msg.sender].add(amount);
return amount;
}
| 18,197 |
87 | // Update DebtLocker storage variables if Loan storage variables has been updated since last claim. | if (newFee > 0) lastFeePaid = newFee;
if (newExcess > 0) lastExcessReturned = newExcess;
if (newAmountRecovered > 0) lastAmountRecovered = newAmountRecovered;
| if (newFee > 0) lastFeePaid = newFee;
if (newExcess > 0) lastExcessReturned = newExcess;
if (newAmountRecovered > 0) lastAmountRecovered = newAmountRecovered;
| 5,353 |
2 | // Gets the "valid" reporter's NPM commission rate(upon each unstake claim invoked by individual "valid" stakers)for the given cover. Warning: this function does not validate the input arguments.s Specify store instance/ | function getGovernanceReporterCommissionInternal(IStore s) public view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION);
}
| function getGovernanceReporterCommissionInternal(IStore s) public view returns (uint256) {
return s.getUintByKey(ProtoUtilV1.NS_GOVERNANCE_REPORTER_COMMISSION);
}
| 1,334 |
9 | // shouldn't be trying to sell MyFriends | if (token == address(this))
return 0;
| if (token == address(this))
return 0;
| 17,518 |
2 | // check if an address has entered the matrix | mapping(address => bool) public isInMatrix;
address[] public users; //array of users in the matrix
uint public totalSupplyMultiplier; //total supply multiplier to adjust for vdush total supply calc on bnb chain
uint public ushPerSec;
mapping(address => uint) public initialEarned;
mapping(address => uint) public lastClaimTimestamp;
mapping(address => uint) public lastClaimVdUshBalance;
mapping(address => uint) public lastClaimTotalSupply;
| mapping(address => bool) public isInMatrix;
address[] public users; //array of users in the matrix
uint public totalSupplyMultiplier; //total supply multiplier to adjust for vdush total supply calc on bnb chain
uint public ushPerSec;
mapping(address => uint) public initialEarned;
mapping(address => uint) public lastClaimTimestamp;
mapping(address => uint) public lastClaimVdUshBalance;
mapping(address => uint) public lastClaimTotalSupply;
| 5,384 |
96 | // The decimals of the token. | uint256 public decimals;
| uint256 public decimals;
| 25,408 |
4 | // Event variables | uint public netDepositInd;
uint256 public netAmountEvent;
uint256 public maxDepositAmount;
uint256 public maxWithdrawAmount;
uint256 public withdrawAmountTotal;
uint256 public withdrawAmountTotalOld;
uint256 public depositAmountTotal;
uint256 public TIME_WITHDRAW_MANAGER = 0;
| uint public netDepositInd;
uint256 public netAmountEvent;
uint256 public maxDepositAmount;
uint256 public maxWithdrawAmount;
uint256 public withdrawAmountTotal;
uint256 public withdrawAmountTotalOld;
uint256 public depositAmountTotal;
uint256 public TIME_WITHDRAW_MANAGER = 0;
| 78,104 |
71 | // See ERC 165 | function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155PresetMinterPauserSupplyHolder, IERC165)
returns (bool)
| function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155PresetMinterPauserSupplyHolder, IERC165)
returns (bool)
| 2,141 |
118 | // Contract module that helps prevent reentrant calls to a function. Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifieravailable, which can be aplied to functions to make sure there are no nested(reentrant) calls to them. Note that because there is a single `nonReentrant` guard, functions marked as`nonReentrant` may not call one another. This can be worked around by makingthose functions `private`, and then adding `external` `nonReentrant` entrypoints to them. / | contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
constructor () internal {
// The counter starts at one to prevent changing it from zero to a non-zero
// value, which is a more expensive operation.
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}
| contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
constructor () internal {
// The counter starts at one to prevent changing it from zero to a non-zero
// value, which is a more expensive operation.
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}
| 750 |
888 | // Remove it from the tree so it no longer blocks parent claims if it is land | removeChildFromTree(token);
| removeChildFromTree(token);
| 21,790 |
22 | // Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To increment allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol_spender The address which will spend the funds._addedValue The amount of tokens to increase the allowance by./ | function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
| function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
| 2,700 |
10 | // mapping for staking status | mapping (uint256 => bool) public isStaked;
| mapping (uint256 => bool) public isStaked;
| 21,065 |
438 | // Mapping from currency id to maturity to its tightly packed cash group parameters | function getCashGroupStorage() internal pure
returns (mapping(uint256 => bytes32) storage store)
| function getCashGroupStorage() internal pure
returns (mapping(uint256 => bytes32) storage store)
| 64,963 |
10 | // move over our mask by one to open up a new bit | slots = slots << 1;
| slots = slots << 1;
| 10,148 |
48 | // Can only be triggered by owner or governance, not custodian Tokens are sent to the custodian, as a sort of safeguard |
ERC20(tokenAddress).transfer(custodian_address, tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
|
ERC20(tokenAddress).transfer(custodian_address, tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
| 25,273 |
331 | // Require that beneficiary fraction is strictly positive | if (0 >= beneficiaryFraction(beneficiaryAddress))
continue;
| if (0 >= beneficiaryFraction(beneficiaryAddress))
continue;
| 4,187 |
29 | // Events that are issued to make statistic recovery easier. | event FailedPayment(address indexed beneficiary, uint amount);
event VIPPayback(address indexed beneficiary, uint amount);
event WithdrawFunds(address indexed beneficiary, uint amount);
| event FailedPayment(address indexed beneficiary, uint amount);
event VIPPayback(address indexed beneficiary, uint amount);
event WithdrawFunds(address indexed beneficiary, uint amount);
| 2,138 |
1,096 | // https:etherscan.io/address/0xde3892383965FBa6eC434bE6350F85f140098708; | Synth existingSynth = Synth(0xde3892383965FBa6eC434bE6350F85f140098708);
| Synth existingSynth = Synth(0xde3892383965FBa6eC434bE6350F85f140098708);
| 34,534 |
16 | // claims and sells COMP on uniswap, returns total received comp and caller reward | function harvest(uint256 maxCompAmount_)
public
returns (uint256 compGot, uint256 underlyingHarvestReward)
| function harvest(uint256 maxCompAmount_)
public
returns (uint256 compGot, uint256 underlyingHarvestReward)
| 24,373 |
20 | // 私有的交易函数 / | function _transfer(address _from, address _to, uint _value) internal {
// 防止转移到0x0, 用burn代替这个功能
require(_to != 0x0);
// 检测发送者是否有足够的资金
//require(canOf[_from] >= _value);
require(balanceOf[_from] >= _value);
// 检查是否溢出(数据类型的溢出)
require(balanceOf[_to] + _value > balanceOf[_to]);
// 将此保存为将来的断言, 函数最后会有一个检验
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// 减少发送者资产
balanceOf[_from] -= _value;
// 增加接收者的资产
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// 断言检测, 不应该为错
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
| function _transfer(address _from, address _to, uint _value) internal {
// 防止转移到0x0, 用burn代替这个功能
require(_to != 0x0);
// 检测发送者是否有足够的资金
//require(canOf[_from] >= _value);
require(balanceOf[_from] >= _value);
// 检查是否溢出(数据类型的溢出)
require(balanceOf[_to] + _value > balanceOf[_to]);
// 将此保存为将来的断言, 函数最后会有一个检验
uint previousBalances = balanceOf[_from] + balanceOf[_to];
// 减少发送者资产
balanceOf[_from] -= _value;
// 增加接收者的资产
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
// 断言检测, 不应该为错
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
| 54,913 |
556 | // Updates the Vault on the value of the pool's investment returns / | function updateBalanceOfPool(bytes32 poolId) external;
| function updateBalanceOfPool(bytes32 poolId) external;
| 13,975 |
2 | // solium-disable-line | sstore(
_IMPLEMENTATION_SLOT,
codeAddress
)
| sstore(
_IMPLEMENTATION_SLOT,
codeAddress
)
| 4,833 |
209 | // function to disable gasless listings for security in case opensea ever shuts down or is compromised | function setIsOpenSeaProxyActive(bool _isOpenSeaProxyActive)
external
onlyOwner
| function setIsOpenSeaProxyActive(bool _isOpenSeaProxyActive)
external
onlyOwner
| 25,763 |
123 | // give out gu reward | if (_toReward > 0) {
plyr_[_affID].gu = _toReward.add(plyr_[_affID].gu); // give gu to player
plyrPhas_[_affID][_newPhID].guRewarded = _toReward.add(plyrPhas_[_affID][_newPhID].guRewarded);
phrase_[_newPhID].guGiven = 1e18.add(phrase_[_newPhID].guGiven);
allGuGiven_ = 1e18.add(allGuGiven_);
}
| if (_toReward > 0) {
plyr_[_affID].gu = _toReward.add(plyr_[_affID].gu); // give gu to player
plyrPhas_[_affID][_newPhID].guRewarded = _toReward.add(plyrPhas_[_affID][_newPhID].guRewarded);
phrase_[_newPhID].guGiven = 1e18.add(phrase_[_newPhID].guGiven);
allGuGiven_ = 1e18.add(allGuGiven_);
}
| 26,986 |
2 | // never overflows, and + overflow is desired | priceCumulative += uint256(priceLast) * timeElapsed;
| priceCumulative += uint256(priceLast) * timeElapsed;
| 17,908 |
6 | // Must be permitted to play the game | require(msg.sender==game.first_player || msg.sender==game.second_player, "Must be permitted to play the game");
| require(msg.sender==game.first_player || msg.sender==game.second_player, "Must be permitted to play the game");
| 28,613 |
118 | // Recover | return recoverSignature(abi.encode(payload), signature);
| return recoverSignature(abi.encode(payload), signature);
| 33,377 |
392 | // State transition per Vault. Just linear transitions. | enum State {Inactive, Deposit, Live, Withdraw}
// Only supports 2 tranches for now
enum Tranche {Senior, Junior}
struct VaultParams {
address seniorAsset;
address juniorAsset;
address strategist;
address strategy;
uint256 hurdleRate;
uint256 startTime;
uint256 enrollment;
uint256 duration;
string seniorName;
string seniorSym;
string juniorName;
string juniorSym;
uint256 seniorTrancheCap;
uint256 seniorUserCap;
uint256 juniorTrancheCap;
uint256 juniorUserCap;
}
| enum State {Inactive, Deposit, Live, Withdraw}
// Only supports 2 tranches for now
enum Tranche {Senior, Junior}
struct VaultParams {
address seniorAsset;
address juniorAsset;
address strategist;
address strategy;
uint256 hurdleRate;
uint256 startTime;
uint256 enrollment;
uint256 duration;
string seniorName;
string seniorSym;
string juniorName;
string juniorSym;
uint256 seniorTrancheCap;
uint256 seniorUserCap;
uint256 juniorTrancheCap;
uint256 juniorUserCap;
}
| 7,609 |
556 | // setManagementProxy(): configure the management proxy for _pointThe management proxy may perform "reversible" operations onbehalf of the owner. This includes public key configuration andoperations relating to sponsorship. | function setManagementProxy(uint32 _point, address _manager)
external
activePointManager(_point)
| function setManagementProxy(uint32 _point, address _manager)
external
activePointManager(_point)
| 43,638 |
25 | // Returns the remaining number of tokens that `spender` will beallowed to spend on behalf of `owner` through {transferFrom}. This iszero by default. This value changes when {approve} or {transferFrom} are called. / | function allowance(address owner, address spender) external view returns (uint256);
| function allowance(address owner, address spender) external view returns (uint256);
| 23,896 |
4 | // Restricted Functions |
function mintSecondary(address account, uint amount) external;
function mintSecondaryRewards(uint amount) external;
function burnSecondary(address account, uint amount) external;
|
function mintSecondary(address account, uint amount) external;
function mintSecondaryRewards(uint amount) external;
function burnSecondary(address account, uint amount) external;
| 42,496 |
0 | // Emits when the contract administrator is changed./oldAdmin The address of the previous administrator./newAdmin The address of the new administrator. | event AdminChanged(address oldAdmin, address newAdmin);
| event AdminChanged(address oldAdmin, address newAdmin);
| 33,446 |
61 | // event emitted upon a redemption | event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut);
| event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut);
| 66,727 |
18 | // This function returns who is authorized to lazy mint NFTs on your contract./ | function _canLazyMint() internal view virtual override returns (bool) {
return msg.sender == deployer || hasRole(MINTER_ROLE, msg.sender) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
| function _canLazyMint() internal view virtual override returns (bool) {
return msg.sender == deployer || hasRole(MINTER_ROLE, msg.sender) || hasRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
| 35,921 |
65 | // Update the reward token state before the user's state | _updateRewardState(reward);
UserRewardState storage userState = rewardStates[reward].userStates[user];
| _updateRewardState(reward);
UserRewardState storage userState = rewardStates[reward].userStates[user];
| 281 |
55 | // Deposit ether to get wrapped ether | function deposit() external payable;
| function deposit() external payable;
| 12,259 |
17 | // We still have some spare memory space on the left, as we have allocated 3 words (96 bytes) for up to 78 digits. | let length := mload(str) // Load the string length.
mstore(str, 0x2d) // Store the '-' character.
str := sub(str, 1) // Move back the string pointer by a byte.
mstore(str, add(length, 1)) // Update the string length.
| let length := mload(str) // Load the string length.
mstore(str, 0x2d) // Store the '-' character.
str := sub(str, 1) // Move back the string pointer by a byte.
mstore(str, add(length, 1)) // Update the string length.
| 23,420 |
116 | // Immutables are computed in the init code of the contract, and then inlined into the deployed bytecode. In other words, this variable won't change when it's checked at runtime. | original = address(this);
| original = address(this);
| 41,264 |
24 | // NOTE: Current solc won't allow using MAX_REWARD_ASSETS with abi.decode | (
uint8 transitionType,
bytes32 stateRoot,
uint32 poolId,
uint32 strategyId,
uint32[MAX_REWARD_ASSETS] memory rewardAssetIds,
uint256[MAX_REWARD_ASSETS] memory rewardPerEpoch,
uint256 stakeAdjustmentFactor,
uint64 startEpoch
) = abi.decode((_rawBytes), (uint8, bytes32, uint32, uint32, uint32[5], uint256[5], uint256, uint64));
| (
uint8 transitionType,
bytes32 stateRoot,
uint32 poolId,
uint32 strategyId,
uint32[MAX_REWARD_ASSETS] memory rewardAssetIds,
uint256[MAX_REWARD_ASSETS] memory rewardPerEpoch,
uint256 stakeAdjustmentFactor,
uint64 startEpoch
) = abi.decode((_rawBytes), (uint8, bytes32, uint32, uint32, uint32[5], uint256[5], uint256, uint64));
| 38,008 |
126 | // Overridden balanceOf function to automatically increase/decrease holder balances based on reflections | function balanceOf(address account) public view virtual override returns (uint256) {
uint256 reflectedRewards = (_totalReflected * _balances[account]) / (_totalReflected + totalSupply());
return _balances[account] + reflectedRewards;
}
| function balanceOf(address account) public view virtual override returns (uint256) {
uint256 reflectedRewards = (_totalReflected * _balances[account]) / (_totalReflected + totalSupply());
return _balances[account] + reflectedRewards;
}
| 17,808 |
2 | // Reverts if the contract is paused. / | modifier whenNotPaused() {
_ensureNotPaused();
_;
}
| modifier whenNotPaused() {
_ensureNotPaused();
_;
}
| 21,782 |
17 | // Withdraw Ether / | function withdraw() external onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No balance to withdraw");
(bool success, ) = payable(msg.sender).call{value: balance}("");
require(success, "Failed to withdraw payment");
}
| function withdraw() external onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No balance to withdraw");
(bool success, ) = payable(msg.sender).call{value: balance}("");
require(success, "Failed to withdraw payment");
}
| 30,075 |
31 | // function allow to now the necessary time for the Shujinko farming | function _ShujinkoDuration(uint256 _id) private view returns(uint256){
// function will return amount needed to farm Shujinko
uint256 _duration;
if(_id >= 1 && _id <= 10){
_duration = KillerShujinkoFarmingTime;
} else if(_id >= 11 && _id <= 60){
_duration = MonsterShujinkoFarmingTime;
} else if(_id >= 61 && _id <= 160){
_duration = PreyShujinkoFarmingTime;
}
return _duration;
}
| function _ShujinkoDuration(uint256 _id) private view returns(uint256){
// function will return amount needed to farm Shujinko
uint256 _duration;
if(_id >= 1 && _id <= 10){
_duration = KillerShujinkoFarmingTime;
} else if(_id >= 11 && _id <= 60){
_duration = MonsterShujinkoFarmingTime;
} else if(_id >= 61 && _id <= 160){
_duration = PreyShujinkoFarmingTime;
}
return _duration;
}
| 42,178 |
192 | // What is the balance of a particular account? | function balanceOf(address _owner) constant returns (uint256 balance) {
return tokenBalanceOf[_owner];
}
| function balanceOf(address _owner) constant returns (uint256 balance) {
return tokenBalanceOf[_owner];
}
| 72,604 |
14 | // return r the product of a point on G1 and a scalar, i.e./ p == p.scalar_mul(1) and p.addition(p) == p.scalar_mul(2) for all points p. | function scalar_mul(G1Point memory p, uint s) internal view returns (G1Point memory r) {
uint[3] memory input;
input[0] = p.X;
input[1] = p.Y;
input[2] = s;
bool success;
// solium-disable-next-line security/no-inline-assembly
assembly {
success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60)
// Use "invalid" to make gas estimation work
switch success case 0 { invalid() }
}
require (success,"pairing-mul-failed");
}
| function scalar_mul(G1Point memory p, uint s) internal view returns (G1Point memory r) {
uint[3] memory input;
input[0] = p.X;
input[1] = p.Y;
input[2] = s;
bool success;
// solium-disable-next-line security/no-inline-assembly
assembly {
success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60)
// Use "invalid" to make gas estimation work
switch success case 0 { invalid() }
}
require (success,"pairing-mul-failed");
}
| 12,151 |
20 | // Set a new Ipfs Base URI for the items metadata_ipfsbaseuri token URI in string format/ | function setIpfsBaseURI(string memory _ipfsbaseuri) external onlyOwner {
ipfsBaseURI = _ipfsbaseuri;
}
| function setIpfsBaseURI(string memory _ipfsbaseuri) external onlyOwner {
ipfsBaseURI = _ipfsbaseuri;
}
| 18,637 |
31 | // Burn shares amount | _burn(msg.sender, shares);
emit Withdraw(
address(asset),
msg.sender,
receiver,
assets,
shares,
fee
);
| _burn(msg.sender, shares);
emit Withdraw(
address(asset),
msg.sender,
receiver,
assets,
shares,
fee
);
| 46,167 |
277 | // User does not have permissions to join garden | uint256 internal constant USER_CANNOT_JOIN = 29;
| uint256 internal constant USER_CANNOT_JOIN = 29;
| 42,366 |
6 | // Eject current value from implentation/Doesn't call storage directly to allow implementation handle read in custom way | function getCounter() public view returns (uint) {
return counter.getCounter(store);
}
| function getCounter() public view returns (uint) {
return counter.getCounter(store);
}
| 51,019 |
12 | // if asset paused,reject the price | bool paused;
| bool paused;
| 28,079 |
0 | // Constructor function for Core_transferProxyThe address of the transfer proxy _vaultThe address of the vault / | constructor(
address _transferProxy,
address _vault
)
public
{
| constructor(
address _transferProxy,
address _vault
)
public
{
| 14,145 |
266 | // Create price sheet | function _createPriceSheet(
PriceSheet[] storage sheets,
uint accountIndex,
uint32 ethNum,
uint nestNum1k,
uint level_shares,
uint tokenAmountPerEth
| function _createPriceSheet(
PriceSheet[] storage sheets,
uint accountIndex,
uint32 ethNum,
uint nestNum1k,
uint level_shares,
uint tokenAmountPerEth
| 12,642 |
6 | // convert BPT-BEETS-FTM into fBeets | uint256 _bpt = IERC20(bptBeetsFtm).balanceOf(address(this));
IERC20(bptBeetsFtm).safeApprove(fBeets, 0);
IERC20(bptBeetsFtm).safeApprove(fBeets, _bpt);
IBeetsBar(fBeets).enter(_bpt);
| uint256 _bpt = IERC20(bptBeetsFtm).balanceOf(address(this));
IERC20(bptBeetsFtm).safeApprove(fBeets, 0);
IERC20(bptBeetsFtm).safeApprove(fBeets, _bpt);
IBeetsBar(fBeets).enter(_bpt);
| 25,214 |
50 | // Lock tokens for team | uint256 public releasedLockedAmount = 0;
| uint256 public releasedLockedAmount = 0;
| 33,318 |
10 | // ============================== ERC20 | event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
| event Transfer(
address indexed from,
address indexed to,
uint256 tokens
);
| 6,638 |
42 | // Specific code for a simple swap and a multihop (2 swaps in sequence) | if (swapSequences[i].length == 1) {
Swap memory swap = swapSequences[i][0];
TokenInterface SwapTokenIn = TokenInterface(swap.tokenIn);
PoolInterface pool = PoolInterface(swap.pool);
if (SwapTokenIn.allowance(address(this), swap.pool) > 0) {
safeApprove(SwapTokenIn, swap.pool, 0);
}
| if (swapSequences[i].length == 1) {
Swap memory swap = swapSequences[i][0];
TokenInterface SwapTokenIn = TokenInterface(swap.tokenIn);
PoolInterface pool = PoolInterface(swap.pool);
if (SwapTokenIn.allowance(address(this), swap.pool) > 0) {
safeApprove(SwapTokenIn, swap.pool, 0);
}
| 17,989 |
55 | // Set the agent that will authorize transfers _agent Address of agent / | function setTransferAgent(address _agent) external onlyGovernor {
transferAgent = _agent;
}
| function setTransferAgent(address _agent) external onlyGovernor {
transferAgent = _agent;
}
| 14,473 |
22 | // 当前时间是否大于 72 小时 | function isTime()view public returns(bool) {
if ((block.timestamp.sub(rechargeTime)) >= day && rechargeTime != 0){
return true;
}
return false;
}
| function isTime()view public returns(bool) {
if ((block.timestamp.sub(rechargeTime)) >= day && rechargeTime != 0){
return true;
}
return false;
}
| 24,134 |
9 | // ensures that the first tokens in the contract will be equally distributed meaning, no divine dump will be ever possible result: healthy longevity. | modifier antiEarlyWhale(uint256 _amountOfEthereum){
address _customerAddress = msg.sender;
// are we still in the vulnerable phase?
// if so, enact anti early whale protocol
if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){
require(
// is the customer in the ambassador list?
ambassadors_[_customerAddress] == true &&
// does the customer purchase exceed the max ambassador quota?
(ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_
);
// updated the accumulated quota
ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum);
// execute
_;
} else {
// in case the ether count drops low, the ambassador phase won't reinitiate
onlyAmbassadors = false;
_;
}
}
| modifier antiEarlyWhale(uint256 _amountOfEthereum){
address _customerAddress = msg.sender;
// are we still in the vulnerable phase?
// if so, enact anti early whale protocol
if( onlyAmbassadors && ((totalEthereumBalance() - _amountOfEthereum) <= ambassadorQuota_ )){
require(
// is the customer in the ambassador list?
ambassadors_[_customerAddress] == true &&
// does the customer purchase exceed the max ambassador quota?
(ambassadorAccumulatedQuota_[_customerAddress] + _amountOfEthereum) <= ambassadorMaxPurchase_
);
// updated the accumulated quota
ambassadorAccumulatedQuota_[_customerAddress] = SafeMath.add(ambassadorAccumulatedQuota_[_customerAddress], _amountOfEthereum);
// execute
_;
} else {
// in case the ether count drops low, the ambassador phase won't reinitiate
onlyAmbassadors = false;
_;
}
}
| 18,939 |
8 | // expmods[3] = point^(trace_length / 8). | mstore(0x4ee0, expmod(point, div(/*trace_length*/ mload(0x80), 8), PRIME))
| mstore(0x4ee0, expmod(point, div(/*trace_length*/ mload(0x80), 8), PRIME))
| 17,371 |
3 | // Query if a contract implements an interfaceinterfaceID The interface identifier, as specified in ERC-165Interface identification is specified in ERC-165 return `true` if the contract implements `interfaceID` and `interfaceID` is not 0xffffffff, `false` otherwise/ | function supportsInterface(bytes4 interfaceID) public view returns (bool) {
return interfaceID == 0xffffffff ? false : methodsImplementations[interfaceID] != address(0x00);
}
| function supportsInterface(bytes4 interfaceID) public view returns (bool) {
return interfaceID == 0xffffffff ? false : methodsImplementations[interfaceID] != address(0x00);
}
| 22,190 |
34 | // ERC721 tokens bulk transfer/https:github.com/gnkz/This smart contract allows to transfer multiple ERC721 tokens at once/The contract needs approvals for the tokens that are going to be transferred | contract ERC721BulkTransfer is IERC721BulkTransfer {
/// @inheritdoc IERC721BulkTransfer
function transfer(
address collection,
address recipient,
uint256[] calldata tokenIds
) external {
require(tokenIds.length > 0, "Invalid token ids amount");
for (uint256 i = 0; i < tokenIds.length; i++) {
uint256 tokenId = tokenIds[i];
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
/// @inheritdoc IERC721BulkTransfer
function transfer(address collection, ToRecipient[] calldata recipientsData)
external
{
require(recipientsData.length > 0, "Empty recipients data");
for (uint256 i = 0; i < recipientsData.length; i++) {
uint256 tokenId = recipientsData[i].tokenId;
address recipient = recipientsData[i].recipient;
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
/// @inheritdoc IERC721BulkTransfer
function transfer(
FromCollection[] calldata collectionsData,
address recipient
) external {
require(collectionsData.length > 0, "Empty collections data");
for (uint256 i = 0; i < collectionsData.length; i++) {
uint256 tokenId = collectionsData[i].tokenId;
address collection = collectionsData[i].collection;
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
/// @inheritdoc IERC721BulkTransfer
function transfer(FromCollectionToRecipient[] calldata transferData)
external
{
require(transferData.length > 0, "Empty transfer data");
for (uint256 i = 0; i < transferData.length; i++) {
uint256 tokenId = transferData[i].tokenId;
address collection = transferData[i].collection;
address recipient = transferData[i].recipient;
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
} | contract ERC721BulkTransfer is IERC721BulkTransfer {
/// @inheritdoc IERC721BulkTransfer
function transfer(
address collection,
address recipient,
uint256[] calldata tokenIds
) external {
require(tokenIds.length > 0, "Invalid token ids amount");
for (uint256 i = 0; i < tokenIds.length; i++) {
uint256 tokenId = tokenIds[i];
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
/// @inheritdoc IERC721BulkTransfer
function transfer(address collection, ToRecipient[] calldata recipientsData)
external
{
require(recipientsData.length > 0, "Empty recipients data");
for (uint256 i = 0; i < recipientsData.length; i++) {
uint256 tokenId = recipientsData[i].tokenId;
address recipient = recipientsData[i].recipient;
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
/// @inheritdoc IERC721BulkTransfer
function transfer(
FromCollection[] calldata collectionsData,
address recipient
) external {
require(collectionsData.length > 0, "Empty collections data");
for (uint256 i = 0; i < collectionsData.length; i++) {
uint256 tokenId = collectionsData[i].tokenId;
address collection = collectionsData[i].collection;
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
/// @inheritdoc IERC721BulkTransfer
function transfer(FromCollectionToRecipient[] calldata transferData)
external
{
require(transferData.length > 0, "Empty transfer data");
for (uint256 i = 0; i < transferData.length; i++) {
uint256 tokenId = transferData[i].tokenId;
address collection = transferData[i].collection;
address recipient = transferData[i].recipient;
IERC721(collection).transferFrom(msg.sender, recipient, tokenId);
}
}
} | 19,270 |
1 | // Set the staking token for the contract | constructor(
uint256 _duration,
address _stakingToken,
IERC20Metadata _rewardToken,
address _treasury
| constructor(
uint256 _duration,
address _stakingToken,
IERC20Metadata _rewardToken,
address _treasury
| 8,402 |
51 | // TwoDimensions TwoDimensions TwoDimensions is an ERC223 Token with ERC20 functions and events Fully backward compatible with ERC20 / | contract TwoDimensions is ERC223, Ownable {
using SafeMath for uint256;
string public name = "TwoDimensions";
string public symbol = "2D";
uint8 public decimals = 8;
uint256 public totalSupply = 240e9 * 1e8;
uint256 public distributeAmount = 0;
bool public mintingFinished = false;
mapping(address => uint256) public balanceOf;
mapping(address => mapping (address => uint256)) public allowance;
mapping (address => bool) public frozenAccount;
mapping (address => uint256) public unlockUnixTime;
event FrozenFunds(address indexed target, bool frozen);
event LockedFunds(address indexed target, uint256 locked);
event Burn(address indexed from, uint256 amount);
event Mint(address indexed to, uint256 amount);
event MintFinished();
/**
* @dev Constructor is called only once and can not be called again
*/
function TwoDimensions() public {
balanceOf[msg.sender] = totalSupply;
}
function name() public view returns (string _name) {
return name;
}
function symbol() public view returns (string _symbol) {
return symbol;
}
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balanceOf[_owner];
}
/**
* @dev Prevent targets from sending or receiving tokens
* @param targets Addresses to be frozen
* @param isFrozen either to freeze it or not
*/
function freezeAccounts(address[] targets, bool isFrozen) onlyOwner public {
require(targets.length > 0);
for (uint j = 0; j < targets.length; j++) {
require(targets[j] != 0x0);
frozenAccount[targets[j]] = isFrozen;
FrozenFunds(targets[j], isFrozen);
}
}
/**
* @dev Prevent targets from sending or receiving tokens by setting Unix times
* @param targets Addresses to be locked funds
* @param unixTimes Unix times when locking up will be finished
*/
function lockupAccounts(address[] targets, uint[] unixTimes) onlyOwner public {
require(targets.length > 0
&& targets.length == unixTimes.length);
for(uint j = 0; j < targets.length; j++){
require(unlockUnixTime[targets[j]] < unixTimes[j]);
unlockUnixTime[targets[j]] = unixTimes[j];
LockedFunds(targets[j], unixTimes[j]);
}
}
/**
* @dev Function that is called when a user or another contract wants to transfer funds
*/
function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
if (isContract(_to)) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
assert(_to.call.value(0)(bytes4(keccak256(_custom_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
} else {
return transferToAddress(_to, _value, _data);
}
}
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
if (isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Standard function transfer similar to ERC20 transfer with no _data
* Added due to backwards compatibility reasons
*/
function transfer(address _to, uint _value) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
bytes memory empty;
if (isContract(_to)) {
return transferToContract(_to, _value, empty);
} else {
return transferToAddress(_to, _value, empty);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* Added due to backwards compatibility with ERC20
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0)
&& _value > 0
&& balanceOf[_from] >= _value
&& allowance[_from][msg.sender] >= _value
&& frozenAccount[_from] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[_from]
&& now > unlockUnixTime[_to]);
balanceOf[_from] = balanceOf[_from].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Allows _spender to spend no more than _value tokens in your behalf
* Added due to backwards compatibility with ERC20
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender
* Added due to backwards compatibility with ERC20
* @param _owner address The address which owns the funds
* @param _spender address The address which will spend the funds
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowance[_owner][_spender];
}
/**
* @dev Burns a specific amount of tokens.
* @param _from The address that will burn the tokens.
* @param _unitAmount The amount of token to be burned.
*/
function burn(address _from, uint256 _unitAmount) onlyOwner public {
require(_unitAmount > 0
&& balanceOf[_from] >= _unitAmount);
balanceOf[_from] = balanceOf[_from].sub(_unitAmount);
totalSupply = totalSupply.sub(_unitAmount);
Burn(_from, _unitAmount);
}
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _unitAmount The amount of tokens to mint.
*/
function mint(address _to, uint256 _unitAmount) onlyOwner canMint public returns (bool) {
require(_unitAmount > 0);
totalSupply = totalSupply.add(_unitAmount);
balanceOf[_to] = balanceOf[_to].add(_unitAmount);
Mint(_to, _unitAmount);
Transfer(address(0), _to, _unitAmount);
return true;
}
/**
* @dev Function to stop minting new tokens.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
/**
* @dev Function to distribute tokens to the list of addresses by the provided amount
*/
function distributeAirdrop(address[] addresses, uint256 amount) public returns (bool) {
require(amount > 0
&& addresses.length > 0
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
amount = amount.mul(1e8);
uint256 totalAmount = amount.mul(addresses.length);
require(balanceOf[msg.sender] >= totalAmount);
for (uint j = 0; j < addresses.length; j++) {
require(addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
balanceOf[addresses[j]] = balanceOf[addresses[j]].add(amount);
Transfer(msg.sender, addresses[j], amount);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(totalAmount);
return true;
}
function distributeAirdrop(address[] addresses, uint[] amounts) public returns (bool) {
require(addresses.length > 0
&& addresses.length == amounts.length
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
uint256 totalAmount = 0;
for(uint j = 0; j < addresses.length; j++){
require(amounts[j] > 0
&& addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
amounts[j] = amounts[j].mul(1e8);
totalAmount = totalAmount.add(amounts[j]);
}
require(balanceOf[msg.sender] >= totalAmount);
for (j = 0; j < addresses.length; j++) {
balanceOf[addresses[j]] = balanceOf[addresses[j]].add(amounts[j]);
Transfer(msg.sender, addresses[j], amounts[j]);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(totalAmount);
return true;
}
/**
* @dev Function to collect tokens from the list of addresses
*/
function collectTokens(address[] addresses, uint[] amounts) onlyOwner public returns (bool) {
require(addresses.length > 0
&& addresses.length == amounts.length);
uint256 totalAmount = 0;
for (uint j = 0; j < addresses.length; j++) {
require(amounts[j] > 0
&& addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
amounts[j] = amounts[j].mul(1e8);
require(balanceOf[addresses[j]] >= amounts[j]);
balanceOf[addresses[j]] = balanceOf[addresses[j]].sub(amounts[j]);
totalAmount = totalAmount.add(amounts[j]);
Transfer(addresses[j], msg.sender, amounts[j]);
}
balanceOf[msg.sender] = balanceOf[msg.sender].add(totalAmount);
return true;
}
function setDistributeAmount(uint256 _unitAmount) onlyOwner public {
distributeAmount = _unitAmount;
}
/**
* @dev Function to distribute tokens to the msg.sender automatically
* If distributeAmount is 0, this function doesn't work
*/
function autoDistribute() payable public {
require(distributeAmount > 0
&& balanceOf[owner] >= distributeAmount
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
if(msg.value > 0) owner.transfer(msg.value);
balanceOf[owner] = balanceOf[owner].sub(distributeAmount);
balanceOf[msg.sender] = balanceOf[msg.sender].add(distributeAmount);
Transfer(owner, msg.sender, distributeAmount);
}
/**
* @dev fallback function
*/
function() payable public {
autoDistribute();
}
} | contract TwoDimensions is ERC223, Ownable {
using SafeMath for uint256;
string public name = "TwoDimensions";
string public symbol = "2D";
uint8 public decimals = 8;
uint256 public totalSupply = 240e9 * 1e8;
uint256 public distributeAmount = 0;
bool public mintingFinished = false;
mapping(address => uint256) public balanceOf;
mapping(address => mapping (address => uint256)) public allowance;
mapping (address => bool) public frozenAccount;
mapping (address => uint256) public unlockUnixTime;
event FrozenFunds(address indexed target, bool frozen);
event LockedFunds(address indexed target, uint256 locked);
event Burn(address indexed from, uint256 amount);
event Mint(address indexed to, uint256 amount);
event MintFinished();
/**
* @dev Constructor is called only once and can not be called again
*/
function TwoDimensions() public {
balanceOf[msg.sender] = totalSupply;
}
function name() public view returns (string _name) {
return name;
}
function symbol() public view returns (string _symbol) {
return symbol;
}
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balanceOf[_owner];
}
/**
* @dev Prevent targets from sending or receiving tokens
* @param targets Addresses to be frozen
* @param isFrozen either to freeze it or not
*/
function freezeAccounts(address[] targets, bool isFrozen) onlyOwner public {
require(targets.length > 0);
for (uint j = 0; j < targets.length; j++) {
require(targets[j] != 0x0);
frozenAccount[targets[j]] = isFrozen;
FrozenFunds(targets[j], isFrozen);
}
}
/**
* @dev Prevent targets from sending or receiving tokens by setting Unix times
* @param targets Addresses to be locked funds
* @param unixTimes Unix times when locking up will be finished
*/
function lockupAccounts(address[] targets, uint[] unixTimes) onlyOwner public {
require(targets.length > 0
&& targets.length == unixTimes.length);
for(uint j = 0; j < targets.length; j++){
require(unlockUnixTime[targets[j]] < unixTimes[j]);
unlockUnixTime[targets[j]] = unixTimes[j];
LockedFunds(targets[j], unixTimes[j]);
}
}
/**
* @dev Function that is called when a user or another contract wants to transfer funds
*/
function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
if (isContract(_to)) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
assert(_to.call.value(0)(bytes4(keccak256(_custom_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
} else {
return transferToAddress(_to, _value, _data);
}
}
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
if (isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Standard function transfer similar to ERC20 transfer with no _data
* Added due to backwards compatibility reasons
*/
function transfer(address _to, uint _value) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
bytes memory empty;
if (isContract(_to)) {
return transferToContract(_to, _value, empty);
} else {
return transferToAddress(_to, _value, empty);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* Added due to backwards compatibility with ERC20
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0)
&& _value > 0
&& balanceOf[_from] >= _value
&& allowance[_from][msg.sender] >= _value
&& frozenAccount[_from] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[_from]
&& now > unlockUnixTime[_to]);
balanceOf[_from] = balanceOf[_from].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Allows _spender to spend no more than _value tokens in your behalf
* Added due to backwards compatibility with ERC20
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender
* Added due to backwards compatibility with ERC20
* @param _owner address The address which owns the funds
* @param _spender address The address which will spend the funds
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowance[_owner][_spender];
}
/**
* @dev Burns a specific amount of tokens.
* @param _from The address that will burn the tokens.
* @param _unitAmount The amount of token to be burned.
*/
function burn(address _from, uint256 _unitAmount) onlyOwner public {
require(_unitAmount > 0
&& balanceOf[_from] >= _unitAmount);
balanceOf[_from] = balanceOf[_from].sub(_unitAmount);
totalSupply = totalSupply.sub(_unitAmount);
Burn(_from, _unitAmount);
}
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _unitAmount The amount of tokens to mint.
*/
function mint(address _to, uint256 _unitAmount) onlyOwner canMint public returns (bool) {
require(_unitAmount > 0);
totalSupply = totalSupply.add(_unitAmount);
balanceOf[_to] = balanceOf[_to].add(_unitAmount);
Mint(_to, _unitAmount);
Transfer(address(0), _to, _unitAmount);
return true;
}
/**
* @dev Function to stop minting new tokens.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
/**
* @dev Function to distribute tokens to the list of addresses by the provided amount
*/
function distributeAirdrop(address[] addresses, uint256 amount) public returns (bool) {
require(amount > 0
&& addresses.length > 0
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
amount = amount.mul(1e8);
uint256 totalAmount = amount.mul(addresses.length);
require(balanceOf[msg.sender] >= totalAmount);
for (uint j = 0; j < addresses.length; j++) {
require(addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
balanceOf[addresses[j]] = balanceOf[addresses[j]].add(amount);
Transfer(msg.sender, addresses[j], amount);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(totalAmount);
return true;
}
function distributeAirdrop(address[] addresses, uint[] amounts) public returns (bool) {
require(addresses.length > 0
&& addresses.length == amounts.length
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
uint256 totalAmount = 0;
for(uint j = 0; j < addresses.length; j++){
require(amounts[j] > 0
&& addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
amounts[j] = amounts[j].mul(1e8);
totalAmount = totalAmount.add(amounts[j]);
}
require(balanceOf[msg.sender] >= totalAmount);
for (j = 0; j < addresses.length; j++) {
balanceOf[addresses[j]] = balanceOf[addresses[j]].add(amounts[j]);
Transfer(msg.sender, addresses[j], amounts[j]);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(totalAmount);
return true;
}
/**
* @dev Function to collect tokens from the list of addresses
*/
function collectTokens(address[] addresses, uint[] amounts) onlyOwner public returns (bool) {
require(addresses.length > 0
&& addresses.length == amounts.length);
uint256 totalAmount = 0;
for (uint j = 0; j < addresses.length; j++) {
require(amounts[j] > 0
&& addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
amounts[j] = amounts[j].mul(1e8);
require(balanceOf[addresses[j]] >= amounts[j]);
balanceOf[addresses[j]] = balanceOf[addresses[j]].sub(amounts[j]);
totalAmount = totalAmount.add(amounts[j]);
Transfer(addresses[j], msg.sender, amounts[j]);
}
balanceOf[msg.sender] = balanceOf[msg.sender].add(totalAmount);
return true;
}
function setDistributeAmount(uint256 _unitAmount) onlyOwner public {
distributeAmount = _unitAmount;
}
/**
* @dev Function to distribute tokens to the msg.sender automatically
* If distributeAmount is 0, this function doesn't work
*/
function autoDistribute() payable public {
require(distributeAmount > 0
&& balanceOf[owner] >= distributeAmount
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
if(msg.value > 0) owner.transfer(msg.value);
balanceOf[owner] = balanceOf[owner].sub(distributeAmount);
balanceOf[msg.sender] = balanceOf[msg.sender].add(distributeAmount);
Transfer(owner, msg.sender, distributeAmount);
}
/**
* @dev fallback function
*/
function() payable public {
autoDistribute();
}
} | 47,377 |
2 | // To prevent Owner from overriding fees, Administrator must/ first initialize with fee. | error AdministratorMustInitializeWithFee();
| error AdministratorMustInitializeWithFee();
| 11,851 |
112 | // Decrease the _amount of tokens that an owner has allowed to a _spender. _spender The address which will spend the funds. _subtractedValue The _amount of tokens to decrease the allowance by. / | function decreaseAllowance(address _spender, uint256 _subtractedValue)
public
returns (bool)
| function decreaseAllowance(address _spender, uint256 _subtractedValue)
public
returns (bool)
| 18,747 |
214 | // Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. / | function isApprovedForAll(address owner, address operator)
public
view
override
returns (bool)
| function isApprovedForAll(address owner, address operator)
public
view
override
returns (bool)
| 86,963 |
21 | // ------------------------------------------------------------------------ Transfer tokens from the from account to the to accountThe calling account must already have sufficient tokens approve(...)-d for spending from the from account and - From account must have sufficient balance to transfer - Spender must have sufficient allowance to transfer - 0 value transfers are allowed ------------------------------------------------------------------------ | function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
| function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
| 23,459 |
29 | // TODO: maybe emit only once in the future | emit Shaman(_applicant, _applicantShares, _applicantLoot, mint);
| emit Shaman(_applicant, _applicantShares, _applicantLoot, mint);
| 8,678 |
138 | // Main entry point to initiate a rebase operation.The Orchestrator calls rebase on the policy and notifies downstream applications.Contracts are guarded from calling, to avoid flash loan attacks on liquidityproviders.If a transaction in the transaction list reverts, it is swallowed and the remainingtransactions are executed. / | function rebase()
external
onlyOwner
| function rebase()
external
onlyOwner
| 13,203 |
2 | // Indices are signed integers because the queue can grow in any direction. They are 128 bits so begin and endare packed in a single storage slot for efficient access. Since the items are added one at a time we can safelyassume that these 128-bit indices will not overflow, and use unchecked arithmetic. Struct members have an underscore prefix indicating that they are "private" and should not be read or written todirectly. Use the functions provided below instead. Modifying the struct manually may violate assumptions andlead to unexpected behavior. Indices are in the range [begin, end) which means the first item | struct Bytes32Deque {
int128 _begin;
int128 _end;
mapping(int128 => bytes32) _data;
}
| struct Bytes32Deque {
int128 _begin;
int128 _end;
mapping(int128 => bytes32) _data;
}
| 50,584 |
375 | // Handles transferring funds from msg.sender to thetransaction manager contract. Used in prepare, addLiquidity assetId The address to transfer specifiedAmount The specified amount to transfer. May not be theactual amount transferred (i.e. fee on transfertokens) / | function transferAssetToContract(address assetId, uint256 specifiedAmount) internal returns (uint256) {
uint256 trueAmount = specifiedAmount;
// Validate correct amounts are transferred
if (LibAsset.isEther(assetId)) {
require(msg.value >= specifiedAmount, "#TA:005");
} else {
uint256 starting = LibAsset.getOwnBalance(assetId);
// require(msg.value == 0, "#TA:006"); // consider relayer fee for prepare
LibAsset.transferFromERC20(assetId, msg.sender, address(this), specifiedAmount);
// Calculate the *actual* amount that was sent here
trueAmount = LibAsset.getOwnBalance(assetId) - starting;
}
return trueAmount;
}
| function transferAssetToContract(address assetId, uint256 specifiedAmount) internal returns (uint256) {
uint256 trueAmount = specifiedAmount;
// Validate correct amounts are transferred
if (LibAsset.isEther(assetId)) {
require(msg.value >= specifiedAmount, "#TA:005");
} else {
uint256 starting = LibAsset.getOwnBalance(assetId);
// require(msg.value == 0, "#TA:006"); // consider relayer fee for prepare
LibAsset.transferFromERC20(assetId, msg.sender, address(this), specifiedAmount);
// Calculate the *actual* amount that was sent here
trueAmount = LibAsset.getOwnBalance(assetId) - starting;
}
return trueAmount;
}
| 15,766 |
8 | // Toggles between 4 bool options within a specified chapter.option == 1: Permission for the NFT to be transfered, option == 2: Criteria if addresses must be unique to become a StarSibling, option == 3: Allows Avatars to be burned and become a StarSibling, option == 4: Unlocks chapter to overwrite entire chapter (Not recommended)_tokenId can also be thought of as indexoption of which bool to toggle / | function toggleOption(uint256 _tokenId, uint256 option) external onlyAdmins {
Chapter storage chapter = chapters[_tokenId];
if (option == 1)
{
chapter.transferable = !chapter.transferable;
}
else if (option == 2)
{
chapter.unique = !chapter.unique;
}
else if (option == 3)
{
chapter.active = !chapter.active;
}
else if (option == 4)
{
chapter.locked = !chapter.locked;
}
}
| function toggleOption(uint256 _tokenId, uint256 option) external onlyAdmins {
Chapter storage chapter = chapters[_tokenId];
if (option == 1)
{
chapter.transferable = !chapter.transferable;
}
else if (option == 2)
{
chapter.unique = !chapter.unique;
}
else if (option == 3)
{
chapter.active = !chapter.active;
}
else if (option == 4)
{
chapter.locked = !chapter.locked;
}
}
| 26,732 |
281 | // Increase the token debt | msdTokenData[_token].debt = msdTokenData[_token].debt.add(_amount);
| msdTokenData[_token].debt = msdTokenData[_token].debt.add(_amount);
| 52,215 |
9 | // Pull liquidity tokens from liquidity and receive the tokens/shares Number of liquidity tokens to pull from liquidity/tickLower lower tick/tickUpper upper tick/amountMin min outs / return amount0 amount of token0 received from base position/ return amount1 amount of token1 received from base position | function pullLiquidity(
int24 tickLower,
int24 tickUpper,
uint128 shares,
uint256[2] memory amountMin
| function pullLiquidity(
int24 tickLower,
int24 tickUpper,
uint128 shares,
uint256[2] memory amountMin
| 17,853 |
50 | // messageHash can be used only once | bytes32 messageHash = message(_user,amount,_time);
require(!msgHash[messageHash], "claim: signature duplicate");
| bytes32 messageHash = message(_user,amount,_time);
require(!msgHash[messageHash], "claim: signature duplicate");
| 40,372 |
2 | // Number of bytes in formatted message before `body` field | uint256 internal constant PREFIX_LENGTH = 76;
| uint256 internal constant PREFIX_LENGTH = 76;
| 21,400 |
22 | // This function updates the unipilot contract address _unipilot: unipilot contract address / | function updateUnipilotAddress(address _unipilot) external onlyGovernance {
require(_unipilot != address(0), "ZA");
unipilot = _unipilot;
}
| function updateUnipilotAddress(address _unipilot) external onlyGovernance {
require(_unipilot != address(0), "ZA");
unipilot = _unipilot;
}
| 43,026 |
782 | // if USDC value is greater than the amount required, return excess USDC to msg.sender | uint256 donationInUSDC = newManagerRepToken.mul(reptokenPrice).div(PRECISION);
if (receivedUSDC > donationInUSDC) {
usdc.safeTransfer(msg.sender, receivedUSDC.sub(donationInUSDC));
receivedUSDC = donationInUSDC;
}
| uint256 donationInUSDC = newManagerRepToken.mul(reptokenPrice).div(PRECISION);
if (receivedUSDC > donationInUSDC) {
usdc.safeTransfer(msg.sender, receivedUSDC.sub(donationInUSDC));
receivedUSDC = donationInUSDC;
}
| 41,051 |
11 | // Returns the integer division of two unsigned integers, reverting ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Requirements: - The divisor cannot be zero. / | function div(uint a, uint b) internal pure returns (uint) {
return a / b;
}
| function div(uint a, uint b) internal pure returns (uint) {
return a / b;
}
| 71,610 |
30 | // No need to set default ANONYMOUS_PENDING status |
_allVotesToIndex[voter][claimIndex] = _voteIndex;
_allVotesIndexes.add(_voteIndex);
_voteIndex++;
|
_allVotesToIndex[voter][claimIndex] = _voteIndex;
_allVotesIndexes.add(_voteIndex);
_voteIndex++;
| 36,897 |
15 | // Traslate a payment in USD to ETHs _paymentAmount --> Payment amount in USDreturn Returns the ETH amount in weis / | function calculateETHPayment(uint256 _paymentAmount) external view returns(uint256) {
uint256 usdETH = _getUSDETHPrice();
return (_paymentAmount * 10 ** 18) / usdETH;
}
| function calculateETHPayment(uint256 _paymentAmount) external view returns(uint256) {
uint256 usdETH = _getUSDETHPrice();
return (_paymentAmount * 10 ** 18) / usdETH;
}
| 57,899 |
4 | // TODO: RENAME ME !! | contract TheConcept is Ownable, ERC20 {
uint public lastModified;
string internal _name = "";
string internal _symbol = 'N/A';
bytes32 latest_name_hash;
bytes32 latest_symbol_hash;
bytes32 constant EMPTY_HASH = keccak256(abi.encode(""));
bytes32 constant ZERO_HASH = keccak256(abi.encode(0));
event NewName(string name);
event NewSymbol(string symbol);
constructor() {
lastModified = block.timestamp;
latest_symbol_hash = keccak256(abi.encode("N/A"));
_initializeOwner(msg.sender);
_mint(msg.sender, 7_777_777 ether);
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function rename(string memory _new_name, string memory _new_symbol) public onlyOwner returns (bool) {
require(block.timestamp >= lastModified + 8 hours, "cooldown");
bytes32 name_hash = keccak256(abi.encode(_new_name));
bytes32 symbol_hash = keccak256(abi.encode(_new_symbol));
bool modified = false;
if (name_hash != ZERO_HASH && name_hash != EMPTY_HASH
&& name_hash != latest_name_hash) {
latest_name_hash = name_hash;
_name = _new_name;
modified = true;
emit NewName(_new_name);
}
if (symbol_hash != ZERO_HASH && symbol_hash != EMPTY_HASH
&& symbol_hash != latest_symbol_hash) {
latest_symbol_hash = symbol_hash;
_symbol = _new_symbol;
modified = true;
emit NewSymbol(_new_symbol);
}
require(modified, "nothing changed");
lastModified = block.timestamp;
return modified;
}
}
| contract TheConcept is Ownable, ERC20 {
uint public lastModified;
string internal _name = "";
string internal _symbol = 'N/A';
bytes32 latest_name_hash;
bytes32 latest_symbol_hash;
bytes32 constant EMPTY_HASH = keccak256(abi.encode(""));
bytes32 constant ZERO_HASH = keccak256(abi.encode(0));
event NewName(string name);
event NewSymbol(string symbol);
constructor() {
lastModified = block.timestamp;
latest_symbol_hash = keccak256(abi.encode("N/A"));
_initializeOwner(msg.sender);
_mint(msg.sender, 7_777_777 ether);
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function rename(string memory _new_name, string memory _new_symbol) public onlyOwner returns (bool) {
require(block.timestamp >= lastModified + 8 hours, "cooldown");
bytes32 name_hash = keccak256(abi.encode(_new_name));
bytes32 symbol_hash = keccak256(abi.encode(_new_symbol));
bool modified = false;
if (name_hash != ZERO_HASH && name_hash != EMPTY_HASH
&& name_hash != latest_name_hash) {
latest_name_hash = name_hash;
_name = _new_name;
modified = true;
emit NewName(_new_name);
}
if (symbol_hash != ZERO_HASH && symbol_hash != EMPTY_HASH
&& symbol_hash != latest_symbol_hash) {
latest_symbol_hash = symbol_hash;
_symbol = _new_symbol;
modified = true;
emit NewSymbol(_new_symbol);
}
require(modified, "nothing changed");
lastModified = block.timestamp;
return modified;
}
}
| 30,841 |
15 | // 先检查该红包有没有余额 | require(playerInfo[id].balance > 0, "redpack is empty");
require(playerInfo[id].count > playerInfo[id].hunterList.length, "exceed number of redpacks");
require(!checkHunterExists(id, msg.sender), 'already grabbed');
if(playerInfo[id].isRandom) {
| require(playerInfo[id].balance > 0, "redpack is empty");
require(playerInfo[id].count > playerInfo[id].hunterList.length, "exceed number of redpacks");
require(!checkHunterExists(id, msg.sender), 'already grabbed');
if(playerInfo[id].isRandom) {
| 5,679 |
325 | // deprecated | uint256 public constant PERCENTAGE_FACTOR = ONE; //percentage plus two decimals
| uint256 public constant PERCENTAGE_FACTOR = ONE; //percentage plus two decimals
| 19,618 |
286 | // we didn't reach the target, so take the remainder of the maximum input as fee | feeAmount = uint256(amountRemaining) - amountIn;
| feeAmount = uint256(amountRemaining) - amountIn;
| 3,552 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.