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 |
|---|---|---|---|---|
2 | // ================= Permit ====================== |
bytes32 public DOMAIN_SEPARATOR;
|
bytes32 public DOMAIN_SEPARATOR;
| 11,899 |
2 | // ============ Events ============ // ============ Constants ============ / 0 index stores protocol fee % on the controller, charged in the trade function | uint256 constant internal PROTOCOL_TRADE_FEE_INDEX = 0;
| uint256 constant internal PROTOCOL_TRADE_FEE_INDEX = 0;
| 30,879 |
234 | // Due to reason error bloat, internal functions are used to reduce bytecode size Module must be initialized on the SetToken and enabled by the controller / | function _validateOnlyModule() internal view {
require(
moduleStates[msg.sender] == ISetToken.ModuleState.INITIALIZED,
"Only the module can call"
);
require(
controller.isModule(msg.sender),
"Module must be enabled on controller"
);
}
| function _validateOnlyModule() internal view {
require(
moduleStates[msg.sender] == ISetToken.ModuleState.INITIALIZED,
"Only the module can call"
);
require(
controller.isModule(msg.sender),
"Module must be enabled on controller"
);
}
| 44,786 |
1 | // Contracts placing orders on the OrderBook must implement this method.In this method, the contract has to send the required token, or the transaction will revert.If there is a claim bounty to be refunded, it will be transferred via msg.value. inputToken The address of the token the user has to send. outputToken The address of the token the user has received. inputAmount The amount of tokens the user has to send. outputAmount The amount of tokens the user has received. data The user's custom callback data. / | function cloberMarketSwapCallback(
address inputToken,
address outputToken,
uint256 inputAmount,
uint256 outputAmount,
bytes calldata data
) external payable;
| function cloberMarketSwapCallback(
address inputToken,
address outputToken,
uint256 inputAmount,
uint256 outputAmount,
bytes calldata data
) external payable;
| 39,766 |
22 | // Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),Reverts when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remaining gas). Requirements: - The divisor cannot be zero. / | function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
| 1,894 |
77 | // ERC721TokenGeneric implementation for the required functionality of the ERC721 standard / | contract Economeme is ERC721, Ownable {
using SafeMath for uint256;
// Total amount of tokens
uint256 private totalTokens;
uint256 public developerCut;
uint256 public submissionPool; // The fund amount gained from submissions.
uint256 public submissionPrice; // How much it costs to submit a meme.
uint256 public endingBalance; // Balance at the end of the last purchase.
// Meme Data
mapping (uint256 => Meme) public memeData;
// Mapping from token ID to owner
mapping (uint256 => address) private tokenOwner;
// Mapping from token ID to approved address
mapping (uint256 => address) private tokenApprovals;
// Mapping from owner to list of owned token IDs
mapping (address => uint256[]) private ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private ownedTokensIndex;
// Balances from % payouts.
mapping (address => uint256) public creatorBalances;
// Events
event Purchase(uint256 indexed _tokenId, address indexed _buyer, address indexed _seller, uint256 _purchasePrice);
event Creation(address indexed _creator, uint256 _tokenId, uint256 _timestamp);
// Purchasing caps for determining next price
uint256 private firstCap = 0.02 ether;
uint256 private secondCap = 0.5 ether;
uint256 private thirdCap = 2.0 ether;
uint256 private finalCap = 5.0 ether;
// Struct to store Meme data
struct Meme {
uint256 price; // Current price of the item.
address owner; // Current owner of the item.
address creator; // Address that created dat boi.
}
function Economeme() public {
submissionPrice = 1 ether / 100;
}
/** ******************************* Buying ********************************* **/
/**
* @dev Purchase meme from previous owner
* @param _tokenId uint256 of token
*/
function buyToken(uint256 _tokenId) public
payable
{
// get data from storage
Meme storage meme = memeData[_tokenId];
uint256 price = meme.price;
address oldOwner = meme.owner;
address newOwner = msg.sender;
uint256 excess = msg.value.sub(price);
// revert checks
require(price > 0);
require(msg.value >= price);
require(oldOwner != msg.sender);
uint256 devCut = price.mul(2).div(100);
developerCut = developerCut.add(devCut);
uint256 creatorCut = price.mul(2).div(100);
creatorBalances[meme.creator] = creatorBalances[meme.creator].add(creatorCut);
uint256 transferAmount = price.sub(creatorCut + devCut);
transferToken(oldOwner, newOwner, _tokenId);
// raise event
emit Purchase(_tokenId, newOwner, oldOwner, price);
// set new price
meme.price = getNextPrice(price);
// Safe transfer to owner that will bypass throws on bad contracts.
safeTransfer(oldOwner, transferAmount);
// Send refund to buyer if needed
if (excess > 0) {
newOwner.transfer(excess);
}
// If safeTransfer did not succeed, we take lost funds into our cut and will return manually if it wasn't malicious.
// Otherwise we're going out for some beers.
if (address(this).balance > endingBalance + creatorCut + devCut) submissionPool += transferAmount;
endingBalance = address(this).balance;
}
/**
* @dev safeTransfer allows a push to an address that will not revert if the address throws.
* @param _oldOwner The owner that funds will be transferred to.
* @param _amount The amount of funds that will be transferred.
*/
function safeTransfer(address _oldOwner, uint256 _amount) internal {
assembly {
let x := mload(0x40)
let success := call(
5000,
_oldOwner,
_amount,
x,
0x0,
x,
0x20)
mstore(0x40,add(x,0x20))
}
}
/**
* @dev Transfer Token from Previous Owner to New Owner
* @param _from previous owner address
* @param _to new owner address
* @param _tokenId uint256 ID of token
*/
function transferToken(address _from, address _to, uint256 _tokenId) internal {
// check token exists
require(tokenExists(_tokenId));
// make sure previous owner is correct
require(memeData[_tokenId].owner == _from);
require(_to != address(0));
require(_to != address(this));
// clear approvals linked to this token
clearApproval(_from, _tokenId);
// remove token from previous owner
removeToken(_from, _tokenId);
// update owner and add token to new owner
addToken(_to, _tokenId);
// raise event
emit Transfer(_from, _to, _tokenId);
}
/**
* @dev Determines next price of token
* @param _price uint256 ID of current price
*/
function getNextPrice (uint256 _price) internal view returns (uint256 _nextPrice) {
if (_price < firstCap) {
return _price.mul(200).div(95);
} else if (_price < secondCap) {
return _price.mul(135).div(96);
} else if (_price < thirdCap) {
return _price.mul(125).div(97);
} else if (_price < finalCap) {
return _price.mul(117).div(97);
} else {
return _price.mul(115).div(98);
}
}
/** *********************** Player Administrative ************************** **/
/**
* @dev Used by posters to submit and create a new meme.
*/
function createToken() external payable {
// make sure token hasn't been used yet
uint256 tokenId = totalTokens + 1;
require(memeData[tokenId].price == 0);
require(msg.value == submissionPrice);
submissionPool += submissionPrice;
endingBalance = address(this).balance;
// create new token
memeData[tokenId] = Meme(1 ether / 100, msg.sender, msg.sender);
// mint new token
_mint(msg.sender, tokenId);
emit Creation(msg.sender, tokenId, block.timestamp);
}
/**
* @dev Withdraw anyone's creator balance.
* @param _beneficiary The person whose balance shall be sent to them.
*/
function withdrawBalance(address _beneficiary) external {
uint256 payout = creatorBalances[_beneficiary];
creatorBalances[_beneficiary] = 0;
_beneficiary.transfer(payout);
endingBalance = address(this).balance;
}
/** **************************** Frontend ********************************** **/
/**
* @dev Return all relevant data for a meme.
* @param _tokenId Unique meme ID.
*/
function getMemeData (uint256 _tokenId) external view
returns (address _owner, uint256 _price, uint256 _nextPrice, address _creator)
{
Meme memory meme = memeData[_tokenId];
return (meme.owner, meme.price, getNextPrice(meme.price), meme.creator);
}
/**
* @dev Check the creator balance of a certain address.
* @param _owner The address to check the balance of.
*/
function checkBalance(address _owner) external view returns (uint256) {
return creatorBalances[_owner];
}
/**
* @dev Determines if token exists by checking it's price
* @param _tokenId uint256 ID of token
*/
function tokenExists (uint256 _tokenId) public view returns (bool _exists) {
return memeData[_tokenId].price > 0;
}
/** ***************************** Only Admin ******************************* **/
/**
* @dev Withdraw dev's cut
* @param _devAmount The amount to withdraw from developer cut.
* @param _submissionAmount The amount to withdraw from submission pool.
*/
function withdraw(uint256 _devAmount, uint256 _submissionAmount) public onlyAdmin() {
if (_devAmount == 0) {
_devAmount = developerCut;
}
if (_submissionAmount == 0) {
_submissionAmount = submissionPool;
}
developerCut = developerCut.sub(_devAmount);
submissionPool = submissionPool.sub(_submissionAmount);
owner.transfer(_devAmount + _submissionAmount);
endingBalance = address(this).balance;
}
/**
* @dev Admin may refund a submission to a user.
* @param _refundee The address to refund.
* @param _amount The amount of wei to refund.
*/
function refundSubmission(address _refundee, uint256 _amount) external onlyAdmin() {
submissionPool = submissionPool.sub(_amount);
_refundee.transfer(_amount);
endingBalance = address(this).balance;
}
/**
* @dev Refund a submission by a specific tokenId.
* @param _tokenId The unique Id of the token to be refunded at current submission price.
*/
function refundByToken(uint256 _tokenId) external onlyAdmin() {
submissionPool = submissionPool.sub(submissionPrice);
memeData[_tokenId].creator.transfer(submissionPrice);
endingBalance = address(this).balance;
}
/**
* @dev Change how much it costs to submit a meme.
* @param _newPrice The new price of submission.
*/
function changeSubmissionPrice(uint256 _newPrice) external onlyAdmin() {
submissionPrice = _newPrice;
}
/** ***************************** Modifiers ******************************** **/
/**
* @dev Guarantees msg.sender is owner of the given token
* @param _tokenId uint256 ID of the token to validate its ownership belongs to msg.sender
*/
modifier onlyOwnerOf(uint256 _tokenId) {
require(ownerOf(_tokenId) == msg.sender);
_;
}
/** ******************************* ERC721 ********************************* **/
/**
* @dev Gets the total amount of tokens stored by the contract
* @return uint256 representing the total amount of tokens
*/
function totalSupply() public view returns (uint256) {
return totalTokens;
}
/**
* @dev Gets the balance of the specified address
* @param _owner address to query the balance of
* @return uint256 representing the amount owned by the passed address
*/
function balanceOf(address _owner) public view returns (uint256) {
return ownedTokens[_owner].length;
}
/**
* @dev Gets the list of tokens owned by a given address
* @param _owner address to query the tokens of
* @return uint256[] representing the list of tokens owned by the passed address
*/
function tokensOf(address _owner) public view returns (uint256[]) {
return ownedTokens[_owner];
}
/**
* @dev Gets the owner of the specified token ID
* @param _tokenId uint256 ID of the token to query the owner of
* @return owner address currently marked as the owner of the given token ID
*/
function ownerOf(uint256 _tokenId) public view returns (address) {
address owner = tokenOwner[_tokenId];
return owner;
}
/**
* @dev Gets the approved address to take ownership of a given token ID
* @param _tokenId uint256 ID of the token to query the approval of
* @return address currently approved to take ownership of the given token ID
*/
function approvedFor(uint256 _tokenId) public view returns (address) {
return tokenApprovals[_tokenId];
}
/**
* @dev Transfers the ownership of a given token ID to another address
* @param _to address to receive the ownership of the given token ID
* @param _tokenId uint256 ID of the token to be transferred
*/
function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
clearApprovalAndTransfer(msg.sender, _to, _tokenId);
}
/**
* @dev Approves another address to claim for the ownership of the given token ID
* @param _to address to be approved for the given token ID
* @param _tokenId uint256 ID of the token to be approved
*/
function approve(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
address owner = ownerOf(_tokenId);
require(_to != owner);
if (approvedFor(_tokenId) != 0 || _to != 0) {
tokenApprovals[_tokenId] = _to;
emit Approval(owner, _to, _tokenId);
}
}
/**
* @dev Claims the ownership of a given token ID
* @param _tokenId uint256 ID of the token being claimed by the msg.sender
*/
function takeOwnership(uint256 _tokenId) public {
require(isApprovedFor(msg.sender, _tokenId));
clearApprovalAndTransfer(ownerOf(_tokenId), msg.sender, _tokenId);
}
/**
* @dev Tells whether the msg.sender is approved for the given token ID or not
* This function is not private so it can be extended in further implementations like the operatable ERC721
* @param _owner address of the owner to query the approval of
* @param _tokenId uint256 ID of the token to query the approval of
* @return bool whether the msg.sender is approved for the given token ID or not
*/
function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
return approvedFor(_tokenId) == _owner;
}
/**
* @dev Internal function to clear current approval and transfer the ownership of a given token ID
* @param _from address which you want to send tokens from
* @param _to address which you want to transfer the token to
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApprovalAndTransfer(address _from, address _to, uint256 _tokenId) internal {
require(_to != address(0));
require(_to != ownerOf(_tokenId));
require(ownerOf(_tokenId) == _from);
clearApproval(_from, _tokenId);
removeToken(_from, _tokenId);
addToken(_to, _tokenId);
emit Transfer(_from, _to, _tokenId);
}
/**
* @dev Internal function to clear current approval of a given token ID
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApproval(address _owner, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _owner);
tokenApprovals[_tokenId] = 0;
emit Approval(_owner, 0, _tokenId);
}
/**
* @dev Mint token function
* @param _to The address that will own the minted token
* @param _tokenId uint256 ID of the token to be minted by the msg.sender
*/
function _mint(address _to, uint256 _tokenId) internal {
addToken(_to, _tokenId);
emit Transfer(0x0, _to, _tokenId);
}
/**
* @dev Internal function to add a token ID to the list of a given address
* @param _to address representing the new owner of the given token ID
* @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function addToken(address _to, uint256 _tokenId) private {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
memeData[_tokenId].owner = _to;
uint256 length = balanceOf(_to);
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
totalTokens = totalTokens.add(1);
}
/**
* @dev Internal function to remove a token ID from the list of a given address
* @param _from address representing the previous owner of the given token ID
* @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function removeToken(address _from, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _from);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = balanceOf(_from).sub(1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
tokenOwner[_tokenId] = 0;
ownedTokens[_from][tokenIndex] = lastToken;
ownedTokens[_from][lastTokenIndex] = 0;
// Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
// be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping
// the lastToken to the first position, and then dropping the element placed in the last position of the list
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
totalTokens = totalTokens.sub(1);
}
function name() public pure returns (string _name) {
return "Economeme Meme";
}
function symbol() public pure returns (string _symbol) {
return "ECME";
}
} | contract Economeme is ERC721, Ownable {
using SafeMath for uint256;
// Total amount of tokens
uint256 private totalTokens;
uint256 public developerCut;
uint256 public submissionPool; // The fund amount gained from submissions.
uint256 public submissionPrice; // How much it costs to submit a meme.
uint256 public endingBalance; // Balance at the end of the last purchase.
// Meme Data
mapping (uint256 => Meme) public memeData;
// Mapping from token ID to owner
mapping (uint256 => address) private tokenOwner;
// Mapping from token ID to approved address
mapping (uint256 => address) private tokenApprovals;
// Mapping from owner to list of owned token IDs
mapping (address => uint256[]) private ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private ownedTokensIndex;
// Balances from % payouts.
mapping (address => uint256) public creatorBalances;
// Events
event Purchase(uint256 indexed _tokenId, address indexed _buyer, address indexed _seller, uint256 _purchasePrice);
event Creation(address indexed _creator, uint256 _tokenId, uint256 _timestamp);
// Purchasing caps for determining next price
uint256 private firstCap = 0.02 ether;
uint256 private secondCap = 0.5 ether;
uint256 private thirdCap = 2.0 ether;
uint256 private finalCap = 5.0 ether;
// Struct to store Meme data
struct Meme {
uint256 price; // Current price of the item.
address owner; // Current owner of the item.
address creator; // Address that created dat boi.
}
function Economeme() public {
submissionPrice = 1 ether / 100;
}
/** ******************************* Buying ********************************* **/
/**
* @dev Purchase meme from previous owner
* @param _tokenId uint256 of token
*/
function buyToken(uint256 _tokenId) public
payable
{
// get data from storage
Meme storage meme = memeData[_tokenId];
uint256 price = meme.price;
address oldOwner = meme.owner;
address newOwner = msg.sender;
uint256 excess = msg.value.sub(price);
// revert checks
require(price > 0);
require(msg.value >= price);
require(oldOwner != msg.sender);
uint256 devCut = price.mul(2).div(100);
developerCut = developerCut.add(devCut);
uint256 creatorCut = price.mul(2).div(100);
creatorBalances[meme.creator] = creatorBalances[meme.creator].add(creatorCut);
uint256 transferAmount = price.sub(creatorCut + devCut);
transferToken(oldOwner, newOwner, _tokenId);
// raise event
emit Purchase(_tokenId, newOwner, oldOwner, price);
// set new price
meme.price = getNextPrice(price);
// Safe transfer to owner that will bypass throws on bad contracts.
safeTransfer(oldOwner, transferAmount);
// Send refund to buyer if needed
if (excess > 0) {
newOwner.transfer(excess);
}
// If safeTransfer did not succeed, we take lost funds into our cut and will return manually if it wasn't malicious.
// Otherwise we're going out for some beers.
if (address(this).balance > endingBalance + creatorCut + devCut) submissionPool += transferAmount;
endingBalance = address(this).balance;
}
/**
* @dev safeTransfer allows a push to an address that will not revert if the address throws.
* @param _oldOwner The owner that funds will be transferred to.
* @param _amount The amount of funds that will be transferred.
*/
function safeTransfer(address _oldOwner, uint256 _amount) internal {
assembly {
let x := mload(0x40)
let success := call(
5000,
_oldOwner,
_amount,
x,
0x0,
x,
0x20)
mstore(0x40,add(x,0x20))
}
}
/**
* @dev Transfer Token from Previous Owner to New Owner
* @param _from previous owner address
* @param _to new owner address
* @param _tokenId uint256 ID of token
*/
function transferToken(address _from, address _to, uint256 _tokenId) internal {
// check token exists
require(tokenExists(_tokenId));
// make sure previous owner is correct
require(memeData[_tokenId].owner == _from);
require(_to != address(0));
require(_to != address(this));
// clear approvals linked to this token
clearApproval(_from, _tokenId);
// remove token from previous owner
removeToken(_from, _tokenId);
// update owner and add token to new owner
addToken(_to, _tokenId);
// raise event
emit Transfer(_from, _to, _tokenId);
}
/**
* @dev Determines next price of token
* @param _price uint256 ID of current price
*/
function getNextPrice (uint256 _price) internal view returns (uint256 _nextPrice) {
if (_price < firstCap) {
return _price.mul(200).div(95);
} else if (_price < secondCap) {
return _price.mul(135).div(96);
} else if (_price < thirdCap) {
return _price.mul(125).div(97);
} else if (_price < finalCap) {
return _price.mul(117).div(97);
} else {
return _price.mul(115).div(98);
}
}
/** *********************** Player Administrative ************************** **/
/**
* @dev Used by posters to submit and create a new meme.
*/
function createToken() external payable {
// make sure token hasn't been used yet
uint256 tokenId = totalTokens + 1;
require(memeData[tokenId].price == 0);
require(msg.value == submissionPrice);
submissionPool += submissionPrice;
endingBalance = address(this).balance;
// create new token
memeData[tokenId] = Meme(1 ether / 100, msg.sender, msg.sender);
// mint new token
_mint(msg.sender, tokenId);
emit Creation(msg.sender, tokenId, block.timestamp);
}
/**
* @dev Withdraw anyone's creator balance.
* @param _beneficiary The person whose balance shall be sent to them.
*/
function withdrawBalance(address _beneficiary) external {
uint256 payout = creatorBalances[_beneficiary];
creatorBalances[_beneficiary] = 0;
_beneficiary.transfer(payout);
endingBalance = address(this).balance;
}
/** **************************** Frontend ********************************** **/
/**
* @dev Return all relevant data for a meme.
* @param _tokenId Unique meme ID.
*/
function getMemeData (uint256 _tokenId) external view
returns (address _owner, uint256 _price, uint256 _nextPrice, address _creator)
{
Meme memory meme = memeData[_tokenId];
return (meme.owner, meme.price, getNextPrice(meme.price), meme.creator);
}
/**
* @dev Check the creator balance of a certain address.
* @param _owner The address to check the balance of.
*/
function checkBalance(address _owner) external view returns (uint256) {
return creatorBalances[_owner];
}
/**
* @dev Determines if token exists by checking it's price
* @param _tokenId uint256 ID of token
*/
function tokenExists (uint256 _tokenId) public view returns (bool _exists) {
return memeData[_tokenId].price > 0;
}
/** ***************************** Only Admin ******************************* **/
/**
* @dev Withdraw dev's cut
* @param _devAmount The amount to withdraw from developer cut.
* @param _submissionAmount The amount to withdraw from submission pool.
*/
function withdraw(uint256 _devAmount, uint256 _submissionAmount) public onlyAdmin() {
if (_devAmount == 0) {
_devAmount = developerCut;
}
if (_submissionAmount == 0) {
_submissionAmount = submissionPool;
}
developerCut = developerCut.sub(_devAmount);
submissionPool = submissionPool.sub(_submissionAmount);
owner.transfer(_devAmount + _submissionAmount);
endingBalance = address(this).balance;
}
/**
* @dev Admin may refund a submission to a user.
* @param _refundee The address to refund.
* @param _amount The amount of wei to refund.
*/
function refundSubmission(address _refundee, uint256 _amount) external onlyAdmin() {
submissionPool = submissionPool.sub(_amount);
_refundee.transfer(_amount);
endingBalance = address(this).balance;
}
/**
* @dev Refund a submission by a specific tokenId.
* @param _tokenId The unique Id of the token to be refunded at current submission price.
*/
function refundByToken(uint256 _tokenId) external onlyAdmin() {
submissionPool = submissionPool.sub(submissionPrice);
memeData[_tokenId].creator.transfer(submissionPrice);
endingBalance = address(this).balance;
}
/**
* @dev Change how much it costs to submit a meme.
* @param _newPrice The new price of submission.
*/
function changeSubmissionPrice(uint256 _newPrice) external onlyAdmin() {
submissionPrice = _newPrice;
}
/** ***************************** Modifiers ******************************** **/
/**
* @dev Guarantees msg.sender is owner of the given token
* @param _tokenId uint256 ID of the token to validate its ownership belongs to msg.sender
*/
modifier onlyOwnerOf(uint256 _tokenId) {
require(ownerOf(_tokenId) == msg.sender);
_;
}
/** ******************************* ERC721 ********************************* **/
/**
* @dev Gets the total amount of tokens stored by the contract
* @return uint256 representing the total amount of tokens
*/
function totalSupply() public view returns (uint256) {
return totalTokens;
}
/**
* @dev Gets the balance of the specified address
* @param _owner address to query the balance of
* @return uint256 representing the amount owned by the passed address
*/
function balanceOf(address _owner) public view returns (uint256) {
return ownedTokens[_owner].length;
}
/**
* @dev Gets the list of tokens owned by a given address
* @param _owner address to query the tokens of
* @return uint256[] representing the list of tokens owned by the passed address
*/
function tokensOf(address _owner) public view returns (uint256[]) {
return ownedTokens[_owner];
}
/**
* @dev Gets the owner of the specified token ID
* @param _tokenId uint256 ID of the token to query the owner of
* @return owner address currently marked as the owner of the given token ID
*/
function ownerOf(uint256 _tokenId) public view returns (address) {
address owner = tokenOwner[_tokenId];
return owner;
}
/**
* @dev Gets the approved address to take ownership of a given token ID
* @param _tokenId uint256 ID of the token to query the approval of
* @return address currently approved to take ownership of the given token ID
*/
function approvedFor(uint256 _tokenId) public view returns (address) {
return tokenApprovals[_tokenId];
}
/**
* @dev Transfers the ownership of a given token ID to another address
* @param _to address to receive the ownership of the given token ID
* @param _tokenId uint256 ID of the token to be transferred
*/
function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
clearApprovalAndTransfer(msg.sender, _to, _tokenId);
}
/**
* @dev Approves another address to claim for the ownership of the given token ID
* @param _to address to be approved for the given token ID
* @param _tokenId uint256 ID of the token to be approved
*/
function approve(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
address owner = ownerOf(_tokenId);
require(_to != owner);
if (approvedFor(_tokenId) != 0 || _to != 0) {
tokenApprovals[_tokenId] = _to;
emit Approval(owner, _to, _tokenId);
}
}
/**
* @dev Claims the ownership of a given token ID
* @param _tokenId uint256 ID of the token being claimed by the msg.sender
*/
function takeOwnership(uint256 _tokenId) public {
require(isApprovedFor(msg.sender, _tokenId));
clearApprovalAndTransfer(ownerOf(_tokenId), msg.sender, _tokenId);
}
/**
* @dev Tells whether the msg.sender is approved for the given token ID or not
* This function is not private so it can be extended in further implementations like the operatable ERC721
* @param _owner address of the owner to query the approval of
* @param _tokenId uint256 ID of the token to query the approval of
* @return bool whether the msg.sender is approved for the given token ID or not
*/
function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
return approvedFor(_tokenId) == _owner;
}
/**
* @dev Internal function to clear current approval and transfer the ownership of a given token ID
* @param _from address which you want to send tokens from
* @param _to address which you want to transfer the token to
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApprovalAndTransfer(address _from, address _to, uint256 _tokenId) internal {
require(_to != address(0));
require(_to != ownerOf(_tokenId));
require(ownerOf(_tokenId) == _from);
clearApproval(_from, _tokenId);
removeToken(_from, _tokenId);
addToken(_to, _tokenId);
emit Transfer(_from, _to, _tokenId);
}
/**
* @dev Internal function to clear current approval of a given token ID
* @param _tokenId uint256 ID of the token to be transferred
*/
function clearApproval(address _owner, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _owner);
tokenApprovals[_tokenId] = 0;
emit Approval(_owner, 0, _tokenId);
}
/**
* @dev Mint token function
* @param _to The address that will own the minted token
* @param _tokenId uint256 ID of the token to be minted by the msg.sender
*/
function _mint(address _to, uint256 _tokenId) internal {
addToken(_to, _tokenId);
emit Transfer(0x0, _to, _tokenId);
}
/**
* @dev Internal function to add a token ID to the list of a given address
* @param _to address representing the new owner of the given token ID
* @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function addToken(address _to, uint256 _tokenId) private {
require(tokenOwner[_tokenId] == address(0));
tokenOwner[_tokenId] = _to;
memeData[_tokenId].owner = _to;
uint256 length = balanceOf(_to);
ownedTokens[_to].push(_tokenId);
ownedTokensIndex[_tokenId] = length;
totalTokens = totalTokens.add(1);
}
/**
* @dev Internal function to remove a token ID from the list of a given address
* @param _from address representing the previous owner of the given token ID
* @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function removeToken(address _from, uint256 _tokenId) private {
require(ownerOf(_tokenId) == _from);
uint256 tokenIndex = ownedTokensIndex[_tokenId];
uint256 lastTokenIndex = balanceOf(_from).sub(1);
uint256 lastToken = ownedTokens[_from][lastTokenIndex];
tokenOwner[_tokenId] = 0;
ownedTokens[_from][tokenIndex] = lastToken;
ownedTokens[_from][lastTokenIndex] = 0;
// Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
// be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping
// the lastToken to the first position, and then dropping the element placed in the last position of the list
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
totalTokens = totalTokens.sub(1);
}
function name() public pure returns (string _name) {
return "Economeme Meme";
}
function symbol() public pure returns (string _symbol) {
return "ECME";
}
} | 20,627 |
18 | // return of interest on the deposit | function collectPercent() isUserExists timePayment internal {
uint payout = payoutAmount(msg.sender);
_payout(msg.sender, payout, false);
}
| function collectPercent() isUserExists timePayment internal {
uint payout = payoutAmount(msg.sender);
_payout(msg.sender, payout, false);
}
| 48,668 |
16 | // Modifier to make a function callable only when the contract is not paused. Requirements: - The contract must not be paused. / | modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
| modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
| 1,895 |
51 | // are we before or after the sale period? | if(blockNow < blockStart || block02w <= blockNow) {
throw;
}
| if(blockNow < blockStart || block02w <= blockNow) {
throw;
}
| 43,764 |
89 | // Transfer between all splits. | for (uint256 _i = 0; _i < _splits.length; _i++) {
| for (uint256 _i = 0; _i < _splits.length; _i++) {
| 1,325 |
19 | // Sends a fee to this contract for splitting, as an ERC20 token. No royalties are expected./_token Currency for the fee as an ERC20 token/_amount Amount of token as fee to be claimed by this contract | function sendFees(IERC20 _token, uint256 _amount) external nonReentrant {
uint256 weights;
unchecked {
weights = totalWeights - royaltiesWeight;
}
uint256 balanceBeforeTransfer = _token.balanceOf(address(this));
SafeERC20.safeTransferFrom(_token, _msgSender(), address(this), _amount);
_sendFees(_token, _token.balanceOf(address(this)) - balanceBeforeTransfer, weights);
}
| function sendFees(IERC20 _token, uint256 _amount) external nonReentrant {
uint256 weights;
unchecked {
weights = totalWeights - royaltiesWeight;
}
uint256 balanceBeforeTransfer = _token.balanceOf(address(this));
SafeERC20.safeTransferFrom(_token, _msgSender(), address(this), _amount);
_sendFees(_token, _token.balanceOf(address(this)) - balanceBeforeTransfer, weights);
}
| 56,279 |
21 | // call return false when something wrong | require(_erc20Addr.call(bytes4(keccak256("transfer(address,uint256)")), _to, _value), "asmTransfer error");
| require(_erc20Addr.call(bytes4(keccak256("transfer(address,uint256)")), _to, _value), "asmTransfer error");
| 19,398 |
213 | // we're at the right boundary | return (atOrAfter.tickCumulative, atOrAfter.secondsPerLiquidityCumulativeX128);
| return (atOrAfter.tickCumulative, atOrAfter.secondsPerLiquidityCumulativeX128);
| 76,294 |
134 | // Fee management contract | address payable private treasury;
event PublicMintToggled();
event AllowlistMintToggled();
event MerkleRootSet(bytes32 indexed newMerkleRoot);
event HashingModuleSet(address indexed newHashingModule);
event LegacyMintingModuleSet(address indexed legacyMintingModule);
event PublicFeeSet(uint256 indexed newFee);
event AllowlistFeeSet(uint256 indexed newAllowlistFee);
event TreasuryAddressSet(address indexed newTreasuryAddress);
| address payable private treasury;
event PublicMintToggled();
event AllowlistMintToggled();
event MerkleRootSet(bytes32 indexed newMerkleRoot);
event HashingModuleSet(address indexed newHashingModule);
event LegacyMintingModuleSet(address indexed legacyMintingModule);
event PublicFeeSet(uint256 indexed newFee);
event AllowlistFeeSet(uint256 indexed newAllowlistFee);
event TreasuryAddressSet(address indexed newTreasuryAddress);
| 34,189 |
124 | // hasResidual is set to true if fCash assets need to be put back into the redeemer's portfolio | bool hasResidual = true;
if (sellTokenAssets) {
int256 assetCash;
| bool hasResidual = true;
if (sellTokenAssets) {
int256 assetCash;
| 88,432 |
77 | // Returns multiplied the number by 10^18.This is used when there is a very large difference between the two numbers passed to the `outOf` function. / | function mulBasis(uint256 _a) internal pure returns (uint256) {
return _a.mul(basisValue);
}
| function mulBasis(uint256 _a) internal pure returns (uint256) {
return _a.mul(basisValue);
}
| 20,531 |
12 | // while (current_id_owner != 0){pushstr("false"); | return;
| return;
| 66,868 |
109 | // ercAmount = amounttoken.balanceOf(exchane) / total_liquidity | ercAmount = _amount.mul(token.balanceOf(_exchange)).div(totalLiquidity);
| ercAmount = _amount.mul(token.balanceOf(_exchange)).div(totalLiquidity);
| 60,003 |
300 | // Since we pre-mint to "owner", allow this contract to transfer on behalf of "owner" for sales. | _setApprovalForAll(_msgSender(), address(this), true);
| _setApprovalForAll(_msgSender(), address(this), true);
| 29,577 |
22 | // Crowdsale{constructor}fired when contract is crated. Initializes all constant and initial values._dollarToEtherRatio {uint} how many dollars are in one eth.$333.44/ETH would be passed as 33344 | function Crowdsale(WhiteList _whiteList) public {
multisig = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA;
team = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA;
maxCap = 1510000000e8;
minInvestETH = 1 ether/2;
currentStep = Step.FundingPreSale;
dollarToEtherRatio = 56413;
numOfBlocksInMinute = 408; // E.g. 4.38 block/per minute wold be entered as 438
priorTokensSent = 4365098999e7; //tokens distributed in private sale and airdrops
whiteList = _whiteList; // white list address
| function Crowdsale(WhiteList _whiteList) public {
multisig = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA;
team = 0x10f78f2a70B52e6c3b490113c72Ba9A90ff1b5CA;
maxCap = 1510000000e8;
minInvestETH = 1 ether/2;
currentStep = Step.FundingPreSale;
dollarToEtherRatio = 56413;
numOfBlocksInMinute = 408; // E.g. 4.38 block/per minute wold be entered as 438
priorTokensSent = 4365098999e7; //tokens distributed in private sale and airdrops
whiteList = _whiteList; // white list address
| 44,747 |
112 | // stablecoins | address public constant usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
| address public constant usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
| 48,670 |
84 | // solhint-disable-next-line | pragma solidity ^0.4.19;
| pragma solidity ^0.4.19;
| 12,415 |
32 | // Performs a Solidity function call using a low level `call`. A plain`call` is an unsafe replacement for a function call: use this function instead. If `target` reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls). Returns the raw returned data. To convert to the expected return value, Requirements: - `target` must be a contract. - calling `target` with `data` must not revert. _Available since v3.1._/ | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| 10,130 |
218 | // remove token ownership record (also clears approval), remove token from both local and global collections | __removeToken(_tokenId);
| __removeToken(_tokenId);
| 3,683 |
6 | // Returns the Router contract address./ return The address of the Router contract. | function hashflowRouter() external view returns (address);
| function hashflowRouter() external view returns (address);
| 10,439 |
37 | // used to get the avarge price for Room, which will be used by rewrd center to determine how much room will be sent based on Reward | function getPrice() external view returns(uint256 roomAmount, uint256 usdAmount, uint8 decimals){
roomAmount = 1e18;
usdAmount = roomAvgPrice;
decimals = USDdecimals;
}
| function getPrice() external view returns(uint256 roomAmount, uint256 usdAmount, uint8 decimals){
roomAmount = 1e18;
usdAmount = roomAvgPrice;
decimals = USDdecimals;
}
| 29,956 |
124 | // Swap fee token for Lon | IUniswapRouterV2 router = IUniswapRouterV2(_exchangeAddr);
uint256[] memory amounts = router.swapExactTokensForTokens(
_amountFeeTokenToSwap,
_minLonAmount, // Minimum amount of Lon expected to receive
_path,
address(this),
block.timestamp + 60
);
swappedLonAmount = amounts[_path.length - 1];
| IUniswapRouterV2 router = IUniswapRouterV2(_exchangeAddr);
uint256[] memory amounts = router.swapExactTokensForTokens(
_amountFeeTokenToSwap,
_minLonAmount, // Minimum amount of Lon expected to receive
_path,
address(this),
block.timestamp + 60
);
swappedLonAmount = amounts[_path.length - 1];
| 33,483 |
13 | // Solidity does not require us to clean the trailing bytes. We do it anyway | result := and(result, 0xFFFF000000000000000000000000000000000000000000000000000000000000)
| result := and(result, 0xFFFF000000000000000000000000000000000000000000000000000000000000)
| 39,243 |
265 | // Splits the slice, setting `self` to everything after the first occurrence of `needle`, and returning everything before it. If `needle` does not occur in `self`, `self` is set to the empty slice, and the entirety of `self` is returned. self The slice to split. needle The text to search for in `self`.return The part of `self` up to the first occurrence of `delim`. / | function split(slice memory self, slice memory needle) internal pure returns (slice memory token) {
split(self, needle, token);
}
| function split(slice memory self, slice memory needle) internal pure returns (slice memory token) {
split(self, needle, token);
}
| 44,573 |
78 | // Interface of the ERC20 standard as defined in the EIP. Does not includethe optional functions; to access them see `ERC20Detailed`. / | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* > Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an `Approval` event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* > Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an `Approval` event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 4,904 |
75 | // Throws if called by any account other than a guardian account (temporary account allowed access to settings before DAO is fully enabled)/ | modifier onlyGuardian() {
require(msg.sender == rocketStorage.getGuardian(), "Account is not a temporary guardian");
_;
}
| modifier onlyGuardian() {
require(msg.sender == rocketStorage.getGuardian(), "Account is not a temporary guardian");
_;
}
| 7,982 |
51 | // update the rate / | function updateRate(uint256 rate_) public onlyOwner {
require(now <= initialTime);
rate = rate_;
emit UpdateRate(rate);
}
| function updateRate(uint256 rate_) public onlyOwner {
require(now <= initialTime);
rate = rate_;
emit UpdateRate(rate);
}
| 1,860 |
2 | // include ethereum signed approve ERC20 and call hash(`ERC20Token(baseToken).approve(_to, _value)` + `_to.call(_data)`).in return of gas proportional amount multiplied by `_gasPrice` of `_baseToken`fixes race condition in double transaction for ERC20. _baseToken token approved for `_to` and token being used for paying `msg.sender` _to destination of call _value call value (in `_baseToken`) _data call data _gasPrice price in `_gasToken` paid back to `msg.sender` per gas unit used _gasLimit maximum gas of this transacton _signature rsv concatenated ethereum signed message signatures required / | function approveAndCallGasRelay(
| function approveAndCallGasRelay(
| 39,139 |
97 | // Transfer a CobeFriend owned by another address, for which the calling address/has previously been granted transfer approval by the owner./_from The address that owns the CobeFriend to be transfered./_to The address that should take ownership of the CobeFriend. Can be any address,/including the caller./_tokenId The ID of the CobeFriend to be transferred./Required for ERC-721 compliance. | function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
| function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
whenNotPaused
| 26,466 |
3 | // We do our own memory management here. Solidity uses memory offset 0x40 to store the current end of memory. We write past it (as writes are memory extensions), but don&39;t update the offset so Solidity will reuse it. The memory used here is only needed for this context. |
bool ret;
address addr;
assembly {
let size := mload(0x40)
mstore(size, hash)
mstore(add(size, 32), v)
mstore(add(size, 64), r)
mstore(add(size, 96), s)
|
bool ret;
address addr;
assembly {
let size := mload(0x40)
mstore(size, hash)
mstore(add(size, 32), v)
mstore(add(size, 64), r)
mstore(add(size, 96), s)
| 37,655 |
127 | // Returns the cost of an amount of votes._votes Number of votes being used./ | function determineCatnipCost(uint256 _votes) view public returns(uint256) {
return _votes.div(voteDiv);
}
| function determineCatnipCost(uint256 _votes) view public returns(uint256) {
return _votes.div(voteDiv);
}
| 26,415 |
15 | // Apply the transaction and verify the state root after that. | bool ok;
bytes memory returnData;
| bool ok;
bytes memory returnData;
| 5,804 |
190 | // MODIFIER | modifier onlyMember1 {
require(msg.sender == member1);
_;
}
| modifier onlyMember1 {
require(msg.sender == member1);
_;
}
| 25,888 |
57 | // Removes a value from a set. O(1).Returns false if the value was not present in the set. / | function removeBytes32(Bytes32Set storage set, bytes32 value)
internal
returns (bool)
| function removeBytes32(Bytes32Set storage set, bytes32 value)
internal
returns (bool)
| 37,530 |
38 | // Stake Creator finalizes the stake, the stake receives the accumulated ETH as reward and calculates everyone's percentages. / | function closeStake() external {
require(msg.sender == stakeCreator, 'You cannot call this function');
Stake memory stake = stakes[stakeNum];
require(now >= stake.start.add(stakePeriod), 'You cannot call this function until stakePeriod is over');
stake.end = now;
stake.ethReward = stake.ethReward.add(totalEthRewards);
uint amtLayerx = stake.end.sub(stake.start).mul(amtByDay).div(1 days);
if(amtLayerx > balances[owner]) {
amtLayerx = balances[owner];
}
stake.layerxReward = amtLayerx;
stakes[stakeNum] = stake;
emit logCloseStake(msg.sender, stakeNum, block.timestamp);
uint256 sumAmountAge = _getSumAmountAge(stake.end);
for (uint i = 0; i < customers.length; i++) {
uint256 _amountAge = _getAmountAge(customers[i], stake.end);
if(_amountAge > 0) {
Rewards memory rwds = rewards[customers[i]];
rwds.layerx = rwds.layerx.add(_amountAge.mul(amtLayerx).div(sumAmountAge));
rwds.eth = rwds.eth.add(_amountAge.mul(stake.ethReward).div(sumAmountAge));
rewards[customers[i]] = rwds;
}
}
stakeNum++;
stakes[stakeNum] = Stake(now, 0, stake.layerLockedTotal, 0, 0);
totalEthRewards = 0;
}
| function closeStake() external {
require(msg.sender == stakeCreator, 'You cannot call this function');
Stake memory stake = stakes[stakeNum];
require(now >= stake.start.add(stakePeriod), 'You cannot call this function until stakePeriod is over');
stake.end = now;
stake.ethReward = stake.ethReward.add(totalEthRewards);
uint amtLayerx = stake.end.sub(stake.start).mul(amtByDay).div(1 days);
if(amtLayerx > balances[owner]) {
amtLayerx = balances[owner];
}
stake.layerxReward = amtLayerx;
stakes[stakeNum] = stake;
emit logCloseStake(msg.sender, stakeNum, block.timestamp);
uint256 sumAmountAge = _getSumAmountAge(stake.end);
for (uint i = 0; i < customers.length; i++) {
uint256 _amountAge = _getAmountAge(customers[i], stake.end);
if(_amountAge > 0) {
Rewards memory rwds = rewards[customers[i]];
rwds.layerx = rwds.layerx.add(_amountAge.mul(amtLayerx).div(sumAmountAge));
rwds.eth = rwds.eth.add(_amountAge.mul(stake.ethReward).div(sumAmountAge));
rewards[customers[i]] = rwds;
}
}
stakeNum++;
stakes[stakeNum] = Stake(now, 0, stake.layerLockedTotal, 0, 0);
totalEthRewards = 0;
}
| 29,791 |
229 | // ADD a horse index to exchange | if( currentProposal.methodId == 3 ) HorseyToken(tokenAddress).addHorseIndex(bytes32(currentProposal.parameter));
| if( currentProposal.methodId == 3 ) HorseyToken(tokenAddress).addHorseIndex(bytes32(currentProposal.parameter));
| 16,965 |
87 | // 返回已结束的一期彩票的中奖地址 | function getWinners() public view returns(ticket[] memory){
return winners;
}
| function getWinners() public view returns(ticket[] memory){
return winners;
}
| 2,716 |
1 | // struct to store a stake's token, owner, and earning values | struct Stake {
uint16 tokenId;
uint80 value;
address owner;
}
| struct Stake {
uint16 tokenId;
uint80 value;
address owner;
}
| 75,484 |
23 | // Standard ERC20 tokenImplementation of the basic standard token. / | contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
| contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
| 15,546 |
57 | // Keep track of addresses seen before, push new ones into accounts list/_tokenholder address to check for "newness" | function trackAddresses(address _tokenholder) internal {
if (!seenBefore[_tokenholder].seen) {
seenBefore[_tokenholder].seen = true;
accounts.push(_tokenholder);
seenBefore[_tokenholder].accountArrayIndex = accounts.length - 1;
}
| function trackAddresses(address _tokenholder) internal {
if (!seenBefore[_tokenholder].seen) {
seenBefore[_tokenholder].seen = true;
accounts.push(_tokenholder);
seenBefore[_tokenholder].accountArrayIndex = accounts.length - 1;
}
| 62,548 |
29 | // Decrease the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To decrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _subtractedValue The amount of tokens to decrease the allowance by. / | function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
returns (bool)
| function decreaseApproval(
address _spender,
uint _subtractedValue
)
public
returns (bool)
| 33,515 |
603 | // [Batched] version of {mint}.Requirements:- `_ids` and `_amounts` must have the same length.- If `_to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. / | function mintBatch(
address _to,
uint256[] memory _ids,
uint256[] memory _amounts,
bytes memory _data
) external onlyPermit {
require(_to != address(0), Errors.VL_ZERO_ADDR_1155);
require(_ids.length == _amounts.length, Errors.VL_INPUT_ERROR);
address operator = _msgSender();
| function mintBatch(
address _to,
uint256[] memory _ids,
uint256[] memory _amounts,
bytes memory _data
) external onlyPermit {
require(_to != address(0), Errors.VL_ZERO_ADDR_1155);
require(_ids.length == _amounts.length, Errors.VL_INPUT_ERROR);
address operator = _msgSender();
| 38,957 |
5 | // maximum limit | uint256 public maxLimit;
| uint256 public maxLimit;
| 24,837 |
5 | // A function to delete the image passed.Image will only be deleted if the current user is the owner of the image/ | function deleteImage(address sender, uint index) onlyOwner onlyImageOwner(sender, index) returns bool {
deleted++;
delete imagelist[index];
return true;
}
| function deleteImage(address sender, uint index) onlyOwner onlyImageOwner(sender, index) returns bool {
deleted++;
delete imagelist[index];
return true;
}
| 51,298 |
199 | // ZKSwap account id bytes lengths | uint8 constant ACCOUNT_ID_BYTES = 4;
uint8 constant AMOUNT_BYTES = 16;
| uint8 constant ACCOUNT_ID_BYTES = 4;
uint8 constant AMOUNT_BYTES = 16;
| 35,879 |
43 | // add to the deposit of the given account / | function depositTo(address account) external payable;
| function depositTo(address account) external payable;
| 10,325 |
6 | // Definition of contract accepting Halo3D tokensGames, casinos, anything can reuse this contract to support Halo3D tokens / | contract AcceptsHalo3D {
Halo3D public tokenContract;
function AcceptsHalo3D(address _tokenContract) public {
tokenContract = Halo3D(_tokenContract);
}
modifier onlyTokenContract {
require(msg.sender == address(tokenContract));
_;
}
/**
* @dev Standard ERC677 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool);
}
| contract AcceptsHalo3D {
Halo3D public tokenContract;
function AcceptsHalo3D(address _tokenContract) public {
tokenContract = Halo3D(_tokenContract);
}
modifier onlyTokenContract {
require(msg.sender == address(tokenContract));
_;
}
/**
* @dev Standard ERC677 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint256 _value, bytes _data) external returns (bool);
}
| 32,917 |
2 | // Exit the Dancefloor Valid next states: Restroom, Bar, VIP Lounge, and Foyer | function NightClub_Dancefloor_Exit(address _user, string memory _nextStateName)
external
pure
returns(string memory message)
| function NightClub_Dancefloor_Exit(address _user, string memory _nextStateName)
external
pure
returns(string memory message)
| 34,751 |
16 | // No gas refunds since London Fork, thus just returns | return(0, 0)
| return(0, 0)
| 29,957 |
82 | // Get the timestamp at which a forced trade request was queued. argsHashThe hash of the forced trade request args. return Timestamp at which the forced trade was queued, or zero, if it was not queued or was vetoed by the VETO_GUARDIAN_ROLE. / | function getQueuedForcedTradeTimestamp(
bytes32 argsHash
)
external
view
returns (uint256)
| function getQueuedForcedTradeTimestamp(
bytes32 argsHash
)
external
view
returns (uint256)
| 38,497 |
10 | // approve busd before call | function buyByBusd(uint256 amount) public {
validate(amount);
uint256 buyAmount = amount.mul(amountPerStable);
require(buyAmount <= token.balanceOf(address(this)), "Not Enough Token To Buy");
busdToken.transferFrom(msg.sender, address(this), amount);
token.transferTokenLock(msg.sender, buyAmount);
emit BuyBusd(msg.sender);
}
| function buyByBusd(uint256 amount) public {
validate(amount);
uint256 buyAmount = amount.mul(amountPerStable);
require(buyAmount <= token.balanceOf(address(this)), "Not Enough Token To Buy");
busdToken.transferFrom(msg.sender, address(this), amount);
token.transferTokenLock(msg.sender, buyAmount);
emit BuyBusd(msg.sender);
}
| 26,222 |
6 | // Transfer tokens to the beneficiary | token.transfer(beneficiary, amountToRelease);
emit TokensReleased(amountToRelease);
| token.transfer(beneficiary, amountToRelease);
emit TokensReleased(amountToRelease);
| 18,861 |
50 | // Only owner or Fair.xyz - withdraw contract balance to owner wallet. 6% primary sale fee to Fair.xyz / | function withdraw() external payable nonReentrant {
address fairWithdraw = IFairXYZWallets(FAIR_WALLETS_ADDRESS)
.viewWithdraw();
require(
hasRole(DEFAULT_ADMIN_ROLE, msg.sender) ||
msg.sender == fairWithdraw,
"Not owner or Fair.xyz!"
);
uint256 contractBalance = address(this).balance;
(bool sent, ) = fairWithdraw.call{value: (contractBalance * 3) / 50}(
""
);
if (!sent) revert ETHSendFail();
uint256 remainingContractBalance = address(this).balance;
(bool sent_, ) = _primarySaleReceiver.call{
value: remainingContractBalance
}("");
if (!sent_) revert ETHSendFail();
}
| function withdraw() external payable nonReentrant {
address fairWithdraw = IFairXYZWallets(FAIR_WALLETS_ADDRESS)
.viewWithdraw();
require(
hasRole(DEFAULT_ADMIN_ROLE, msg.sender) ||
msg.sender == fairWithdraw,
"Not owner or Fair.xyz!"
);
uint256 contractBalance = address(this).balance;
(bool sent, ) = fairWithdraw.call{value: (contractBalance * 3) / 50}(
""
);
if (!sent) revert ETHSendFail();
uint256 remainingContractBalance = address(this).balance;
(bool sent_, ) = _primarySaleReceiver.call{
value: remainingContractBalance
}("");
if (!sent_) revert ETHSendFail();
}
| 47,070 |
78 | // ERC721 token receiver interface Interface for any contract that wants to support safeTransfersfrom ERC721 asset contracts. / | contract ERC721Receiver {
/**
* @dev Magic value to be returned upon successful reception of an NFT
* Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`,
* which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
*/
bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;
/**
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a `safetransfer`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the contract address is always the message sender.
* @param _operator The address which called `safeTransferFrom` function
* @param _from The address which previously owned the token
* @param _tokenId The NFT identifier which is being transferred
* @param _data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data
)
public
returns(bytes4);
}
| contract ERC721Receiver {
/**
* @dev Magic value to be returned upon successful reception of an NFT
* Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`,
* which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
*/
bytes4 internal constant ERC721_RECEIVED = 0x150b7a02;
/**
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a `safetransfer`. This function MAY throw to revert and reject the
* transfer. Return of other than the magic value MUST result in the
* transaction being reverted.
* Note: the contract address is always the message sender.
* @param _operator The address which called `safeTransferFrom` function
* @param _from The address which previously owned the token
* @param _tokenId The NFT identifier which is being transferred
* @param _data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes _data
)
public
returns(bytes4);
}
| 5,474 |
0 | // The receiver address that will receive the targetToken after burn function is run / | address public receiver;
| address public receiver;
| 24,212 |
31 | // Provides a registered token's metadata, looked up by symbol./_symbol Symbol of registered token./ return Token metadata. | function getTokenBySymbol(string _symbol)
public
view
returns (
address, //tokenAddress
string, //name
string, //symbol
uint8, //decimals
string //url
)
| function getTokenBySymbol(string _symbol)
public
view
returns (
address, //tokenAddress
string, //name
string, //symbol
uint8, //decimals
string //url
)
| 8,140 |
58 | // Update prodInv to be 1/(d_0...d_{i-1}) by multiplying by d_i. | prodInv := mulmod(prodInv,
mload(add(currentPartialProductPtr, productsToValuesOffset)),
PRIME)
| prodInv := mulmod(prodInv,
mload(add(currentPartialProductPtr, productsToValuesOffset)),
PRIME)
| 31,314 |
131 | // Hotfricoin for Loot holders!/Hotfricoin <https:twitter.com/Hotfriescoin>/This contract mints Hotfriescoin for Loot holders and provides/ administrative functions to the Loot DAO. It allows:/Loot holders to claim Hotfriescoin/A DAO to set seasons for new opportunities to claim Hotfriescoin/A DAO to mint Hotfriescoin for use within the Loot ecosystem | contract Hotfriescoin is Context, Ownable, ERC20 {
// Loot contract is available at https://etherscan.io/address/0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7
address public lootContractAddress =
0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7;
IERC721Enumerable public lootContract;
// Give out 1243 Hotfriescoin for every Loot Bag that a user holds
uint256 public HotfriescoinPerTokenId = 1243 * (10**decimals());
// tokenIdStart of 1 is based on the following lines in the Loot contract:
/**
function claim(uint256 tokenId) public nonReentrant {
require(tokenId > 0 && tokenId < 7778, "Token ID invalid");
_safeMint(_msgSender(), tokenId);
}
*/
uint256 public tokenIdStart = 1;
// tokenIdEnd of 8000 is based on the following lines in the Loot contract:
/**
function ownerClaim(uint256 tokenId) public nonReentrant onlyOwner {
require(tokenId > 7777 && tokenId < 8001, "Token ID invalid");
_safeMint(owner(), tokenId);
}
*/
// 220000
uint256 public tokenIdEnd = 8000;
uint256 public PUBLIC_MINT_PRICE = 200000000000000; // 0.0002000000 eth
uint public MAX_SUPPLY = 4 * 10 ** (7+18);
uint public MAX_FREE_SUPPLY = 9.9944 * 10 ** (6+18);
uint256 public _totalSupply =4 * 10 **(7 + 18);
uint public MAX_PAID_SUPPLY = 2.9836 * 10 ** (7+18);
uint public totalFreeClaims = 0;
uint public totalPaidClaims = 0;
// uint public decimals = 0;
address private devWallet = 0x482e57C86D0eA19d7756Ea863fB8E58E6c69f0E9;
// Seasons are used to allow users to claim tokens regularly. Seasons are
// decided by the DAO.
uint256 public season = 0;
uint256 public contractorToken = 2.2 * 10 ** (5+18);
uint256 public tokenPrice = 0.0002 ether;
// 220,000 will be reserved for contratc creater
// Track claimed tokens within a season
// IMPORTANT: The format of the mapping is:
// claimedForSeason[season][tokenId][claimed]
mapping(uint256 => mapping(uint256 => bool)) public seasonClaimedByTokenId;
constructor() Ownable() ERC20("Hotfries", "HF") {
// Transfer ownership to the Loot DAO
// Ownable by OpenZeppelin automatically sets owner to msg.sender, but
// we're going to be using a separate wallet for deployment
// transferOwnership(0x482e57C86D0eA19d7756Ea863fB8E58E6c69f0E9);
lootContract = IERC721Enumerable(lootContractAddress);
_mint(msg.sender, (_totalSupply - MAX_FREE_SUPPLY));
_mint(lootContractAddress, MAX_FREE_SUPPLY);
// _mint(msg.sender, contractorToken);
// approve(address(this), _totalSupply - MAX_FREE_SUPPLY);
// payable(devWallet).transfer(contractorToken);
// toCreater();
// transfer(msg.sender, contractorToken);
}
// function toCreater() private{
// payable(lootContractAddress).transfer(MAX_FREE_SUPPLY);
// payable(msg.sender).transfer(contractorToken);
// }
/// @notice Claim Hotfriescoin for a given Loot ID
/// @param tokenId The tokenId of the Loot NFT
function claimById(uint256 tokenId) external {
// Follow the Checks-Effects-Interactions pattern to prevent reentrancy
// attacks
// Checks
// Check that the msgSender owns the token that is being claimed
require(
_msgSender() == lootContract.ownerOf(tokenId),
"MUST_OWN_TOKEN_ID"
);
// Further Checks, Effects, and Interactions are contained within the
// _claim() function
_claim(tokenId, _msgSender());
}
/// @notice Claim Hotfriescoin for all tokens owned by the sender
/// @notice This function will run out of gas if you have too much loot! If
/// this is a concern, you should use claimRangeForOwner and claim Hotfries
/// coin in batches.
function claimAllForOwner() payable public {
uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());
// Checks
require( tokenBalanceOwner <= HotfriescoinPerTokenId); // Each loot bag owner claim 1243 HFC Maximum.
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
// i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
//1243
function claimAllToken() external{
uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());
// Checks
require(tokenBalanceOwner == HotfriescoinPerTokenId , "1243 HFC Claimed by each user");
// if all token is claimed then 1HFC = 0.0016 eth minimum value of reselling tokens.
PUBLIC_MINT_PRICE = 1600000000000000;
}
/// @notice Claim Hotfriescoin for all tokens owned by the sender within a
/// given range
/// @notice This function is useful if you own too much Loot to claim all at
/// once or if you want to leave some Loot unclaimed. If you leave Loot
/// unclaimed, however, you cannot claim it once the next season starts.
function claimRangeForOwner(uint256 ownerIndexStart, uint256 ownerIndexEnd)
external
{
uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());
// Checks
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
// We use < for ownerIndexEnd and tokenBalanceOwner because
// tokenOfOwnerByIndex is 0-indexed while the token balance is 1-indexed
require(
ownerIndexStart >= 0 && ownerIndexEnd < tokenBalanceOwner,
"INDEX_OUT_OF_RANGE"
);
// i <= ownerIndexEnd because ownerIndexEnd is 0-indexed
for (uint256 i = ownerIndexStart; i <= ownerIndexEnd; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
/// @dev Internal function to mint Loot upon claiming
function _claim(uint256 tokenId, address tokenOwner) internal {
// Checks
// Check that the token ID is in range
// We use >= and <= to here because all of the token IDs are 0-indexed
require(
tokenId >= tokenIdStart && tokenId <= tokenIdEnd,
"TOKEN_ID_OUT_OF_RANGE"
);
// Check thatHotfriescoin have not already been claimed this season
// for a given tokenId
require(
!seasonClaimedByTokenId[season][tokenId],
"GOLD_CLAIMED_FOR_TOKEN_ID"
);
// Effects
// Mark that Hotfriescoin has been claimed for this season for the
// given tokenId
seasonClaimedByTokenId[season][tokenId] = true;
// Interactions
// Send Hotfriescoin to the owner of the token ID
_mint(tokenOwner, HotfriescoinPerTokenId);
}
/// @notice Allows the DAO to mint new tokens for use within the Loot
/// Ecosystem
/// @param amountDisplayValue The amount of Loot to mint. This should be
/// input as the display value, not in raw decimals. If you want to mint
/// 100 Loot, you should enter "100" rather than the value of 100 * 10^18.
function daoMint(uint256 amountDisplayValue) external onlyOwner {
_mint(owner(), amountDisplayValue * (10**decimals()));
}
/// @notice Allows the DAO to set a new contract address for Loot. This is
/// relevant in the event that Loot migrates to a new contract.
/// @param lootContractAddress_ The new contract address for Loot
function daoSetLootContractAddress(address lootContractAddress_)
external
onlyOwner
{
lootContractAddress = lootContractAddress_;
lootContract = IERC721Enumerable(lootContractAddress);
}
/// @notice Allows the DAO to set the token IDs that are eligible to claim
/// Loot
/// @param tokenIdStart_ The start of the eligible token range
/// @param tokenIdEnd_ The end of the eligible token range
/// @dev This is relevant in case a future Loot contract has a different
/// total supply of Loot
function daoSetTokenIdRange(uint256 tokenIdStart_, uint256 tokenIdEnd_)
external
onlyOwner
{
tokenIdStart = tokenIdStart_;
tokenIdEnd = tokenIdEnd_;
}
/// @notice Allows the DAO to set a season for new Hotfriescoin claims
/// @param season_ The season to use for claiming Loot
function daoSetSeason(uint256 season_) public onlyOwner {
season = season_;
}
/// @notice Allows the DAO to set the amount of Hotfriescoin that is
/// claimed per token ID
/// @param HotfriescoinDisplayValue The amount of Loot a user can claim.
/// This should be input as the display value, not in raw decimals. If you
/// want to mint 100 Loot, you should enter "100" rather than the value of
/// 100 * 10^18.
function daoSetHotfriescoinPerTokenId(uint256 HotfriescoinDisplayValue)
public
onlyOwner
{
HotfriescoinDisplayValue = 1243;
HotfriescoinPerTokenId = HotfriescoinDisplayValue * (10**decimals());
}
/// @notice Allows the DAO to set the season and Hotfriescoin per token ID
/// in one transaction. This ensures that there is not a gap where a user
/// can claim more Hotfriescoin than others
/// @param season_ The season to use for claiming loot
/// @param HotfriescoinDisplayValue The amount of Loot a user can claim.
/// This should be input as the display value, not in raw decimals. If you
/// want to mint 100 Loot, you should enter "100" rather than the value of
/// 100 * 10^18.
/// @dev We would save a tiny amount of gas by modifying the season and
/// Hotfriescoin variables directly. It is better practice for security,
/// however, to avoid repeating code. This function is so rarely used that
/// it's not worth moving these values into their own internal function to
/// skip the gas used on the modifier check.
function daoSetSeasonAndHotfriescoinPerTokenID(
uint256 season_,
uint256 HotfriescoinDisplayValue
) external onlyOwner {
daoSetSeason(season_);
daoSetHotfriescoinPerTokenId(HotfriescoinDisplayValue);
}
}
| contract Hotfriescoin is Context, Ownable, ERC20 {
// Loot contract is available at https://etherscan.io/address/0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7
address public lootContractAddress =
0xFF9C1b15B16263C61d017ee9F65C50e4AE0113D7;
IERC721Enumerable public lootContract;
// Give out 1243 Hotfriescoin for every Loot Bag that a user holds
uint256 public HotfriescoinPerTokenId = 1243 * (10**decimals());
// tokenIdStart of 1 is based on the following lines in the Loot contract:
/**
function claim(uint256 tokenId) public nonReentrant {
require(tokenId > 0 && tokenId < 7778, "Token ID invalid");
_safeMint(_msgSender(), tokenId);
}
*/
uint256 public tokenIdStart = 1;
// tokenIdEnd of 8000 is based on the following lines in the Loot contract:
/**
function ownerClaim(uint256 tokenId) public nonReentrant onlyOwner {
require(tokenId > 7777 && tokenId < 8001, "Token ID invalid");
_safeMint(owner(), tokenId);
}
*/
// 220000
uint256 public tokenIdEnd = 8000;
uint256 public PUBLIC_MINT_PRICE = 200000000000000; // 0.0002000000 eth
uint public MAX_SUPPLY = 4 * 10 ** (7+18);
uint public MAX_FREE_SUPPLY = 9.9944 * 10 ** (6+18);
uint256 public _totalSupply =4 * 10 **(7 + 18);
uint public MAX_PAID_SUPPLY = 2.9836 * 10 ** (7+18);
uint public totalFreeClaims = 0;
uint public totalPaidClaims = 0;
// uint public decimals = 0;
address private devWallet = 0x482e57C86D0eA19d7756Ea863fB8E58E6c69f0E9;
// Seasons are used to allow users to claim tokens regularly. Seasons are
// decided by the DAO.
uint256 public season = 0;
uint256 public contractorToken = 2.2 * 10 ** (5+18);
uint256 public tokenPrice = 0.0002 ether;
// 220,000 will be reserved for contratc creater
// Track claimed tokens within a season
// IMPORTANT: The format of the mapping is:
// claimedForSeason[season][tokenId][claimed]
mapping(uint256 => mapping(uint256 => bool)) public seasonClaimedByTokenId;
constructor() Ownable() ERC20("Hotfries", "HF") {
// Transfer ownership to the Loot DAO
// Ownable by OpenZeppelin automatically sets owner to msg.sender, but
// we're going to be using a separate wallet for deployment
// transferOwnership(0x482e57C86D0eA19d7756Ea863fB8E58E6c69f0E9);
lootContract = IERC721Enumerable(lootContractAddress);
_mint(msg.sender, (_totalSupply - MAX_FREE_SUPPLY));
_mint(lootContractAddress, MAX_FREE_SUPPLY);
// _mint(msg.sender, contractorToken);
// approve(address(this), _totalSupply - MAX_FREE_SUPPLY);
// payable(devWallet).transfer(contractorToken);
// toCreater();
// transfer(msg.sender, contractorToken);
}
// function toCreater() private{
// payable(lootContractAddress).transfer(MAX_FREE_SUPPLY);
// payable(msg.sender).transfer(contractorToken);
// }
/// @notice Claim Hotfriescoin for a given Loot ID
/// @param tokenId The tokenId of the Loot NFT
function claimById(uint256 tokenId) external {
// Follow the Checks-Effects-Interactions pattern to prevent reentrancy
// attacks
// Checks
// Check that the msgSender owns the token that is being claimed
require(
_msgSender() == lootContract.ownerOf(tokenId),
"MUST_OWN_TOKEN_ID"
);
// Further Checks, Effects, and Interactions are contained within the
// _claim() function
_claim(tokenId, _msgSender());
}
/// @notice Claim Hotfriescoin for all tokens owned by the sender
/// @notice This function will run out of gas if you have too much loot! If
/// this is a concern, you should use claimRangeForOwner and claim Hotfries
/// coin in batches.
function claimAllForOwner() payable public {
uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());
// Checks
require( tokenBalanceOwner <= HotfriescoinPerTokenId); // Each loot bag owner claim 1243 HFC Maximum.
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
// i < tokenBalanceOwner because tokenBalanceOwner is 1-indexed
for (uint256 i = 0; i < tokenBalanceOwner; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
//1243
function claimAllToken() external{
uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());
// Checks
require(tokenBalanceOwner == HotfriescoinPerTokenId , "1243 HFC Claimed by each user");
// if all token is claimed then 1HFC = 0.0016 eth minimum value of reselling tokens.
PUBLIC_MINT_PRICE = 1600000000000000;
}
/// @notice Claim Hotfriescoin for all tokens owned by the sender within a
/// given range
/// @notice This function is useful if you own too much Loot to claim all at
/// once or if you want to leave some Loot unclaimed. If you leave Loot
/// unclaimed, however, you cannot claim it once the next season starts.
function claimRangeForOwner(uint256 ownerIndexStart, uint256 ownerIndexEnd)
external
{
uint256 tokenBalanceOwner = lootContract.balanceOf(_msgSender());
// Checks
require(tokenBalanceOwner > 0, "NO_TOKENS_OWNED");
// We use < for ownerIndexEnd and tokenBalanceOwner because
// tokenOfOwnerByIndex is 0-indexed while the token balance is 1-indexed
require(
ownerIndexStart >= 0 && ownerIndexEnd < tokenBalanceOwner,
"INDEX_OUT_OF_RANGE"
);
// i <= ownerIndexEnd because ownerIndexEnd is 0-indexed
for (uint256 i = ownerIndexStart; i <= ownerIndexEnd; i++) {
// Further Checks, Effects, and Interactions are contained within
// the _claim() function
_claim(
lootContract.tokenOfOwnerByIndex(_msgSender(), i),
_msgSender()
);
}
}
/// @dev Internal function to mint Loot upon claiming
function _claim(uint256 tokenId, address tokenOwner) internal {
// Checks
// Check that the token ID is in range
// We use >= and <= to here because all of the token IDs are 0-indexed
require(
tokenId >= tokenIdStart && tokenId <= tokenIdEnd,
"TOKEN_ID_OUT_OF_RANGE"
);
// Check thatHotfriescoin have not already been claimed this season
// for a given tokenId
require(
!seasonClaimedByTokenId[season][tokenId],
"GOLD_CLAIMED_FOR_TOKEN_ID"
);
// Effects
// Mark that Hotfriescoin has been claimed for this season for the
// given tokenId
seasonClaimedByTokenId[season][tokenId] = true;
// Interactions
// Send Hotfriescoin to the owner of the token ID
_mint(tokenOwner, HotfriescoinPerTokenId);
}
/// @notice Allows the DAO to mint new tokens for use within the Loot
/// Ecosystem
/// @param amountDisplayValue The amount of Loot to mint. This should be
/// input as the display value, not in raw decimals. If you want to mint
/// 100 Loot, you should enter "100" rather than the value of 100 * 10^18.
function daoMint(uint256 amountDisplayValue) external onlyOwner {
_mint(owner(), amountDisplayValue * (10**decimals()));
}
/// @notice Allows the DAO to set a new contract address for Loot. This is
/// relevant in the event that Loot migrates to a new contract.
/// @param lootContractAddress_ The new contract address for Loot
function daoSetLootContractAddress(address lootContractAddress_)
external
onlyOwner
{
lootContractAddress = lootContractAddress_;
lootContract = IERC721Enumerable(lootContractAddress);
}
/// @notice Allows the DAO to set the token IDs that are eligible to claim
/// Loot
/// @param tokenIdStart_ The start of the eligible token range
/// @param tokenIdEnd_ The end of the eligible token range
/// @dev This is relevant in case a future Loot contract has a different
/// total supply of Loot
function daoSetTokenIdRange(uint256 tokenIdStart_, uint256 tokenIdEnd_)
external
onlyOwner
{
tokenIdStart = tokenIdStart_;
tokenIdEnd = tokenIdEnd_;
}
/// @notice Allows the DAO to set a season for new Hotfriescoin claims
/// @param season_ The season to use for claiming Loot
function daoSetSeason(uint256 season_) public onlyOwner {
season = season_;
}
/// @notice Allows the DAO to set the amount of Hotfriescoin that is
/// claimed per token ID
/// @param HotfriescoinDisplayValue The amount of Loot a user can claim.
/// This should be input as the display value, not in raw decimals. If you
/// want to mint 100 Loot, you should enter "100" rather than the value of
/// 100 * 10^18.
function daoSetHotfriescoinPerTokenId(uint256 HotfriescoinDisplayValue)
public
onlyOwner
{
HotfriescoinDisplayValue = 1243;
HotfriescoinPerTokenId = HotfriescoinDisplayValue * (10**decimals());
}
/// @notice Allows the DAO to set the season and Hotfriescoin per token ID
/// in one transaction. This ensures that there is not a gap where a user
/// can claim more Hotfriescoin than others
/// @param season_ The season to use for claiming loot
/// @param HotfriescoinDisplayValue The amount of Loot a user can claim.
/// This should be input as the display value, not in raw decimals. If you
/// want to mint 100 Loot, you should enter "100" rather than the value of
/// 100 * 10^18.
/// @dev We would save a tiny amount of gas by modifying the season and
/// Hotfriescoin variables directly. It is better practice for security,
/// however, to avoid repeating code. This function is so rarely used that
/// it's not worth moving these values into their own internal function to
/// skip the gas used on the modifier check.
function daoSetSeasonAndHotfriescoinPerTokenID(
uint256 season_,
uint256 HotfriescoinDisplayValue
) external onlyOwner {
daoSetSeason(season_);
daoSetHotfriescoinPerTokenId(HotfriescoinDisplayValue);
}
}
| 2,091 |
49 | // 2byte opcode to push well-known context data to the stack byte 1 is the push codepoint, byte 2 well-known context id | function execPushContext(Context memory context, bytes32[] memory, bytes32[] memory) internal view {
uint contextId = uint256(context.stack[context.stackLength-1]);
if (contextId == CONTEXT_TOKEN_ID) {
context.stack[context.stackLength-1] = bytes32(context.tokenId);
} else if (contextId == CONTEXT_TOKEN_OWNER ) {
context.stack[context.stackLength-1] = bytes32(uint256(uint160(context.owner)));
} else if (contextId == CONTEXT_BLOCK_TIMESTAMP ) {
// solhint-disable-next-line not-rely-on-time
context.stack[context.stackLength-1] = bytes32(uint256(block.timestamp));
} else if (contextId == CONTEXT_GENERATION) {
context.stack[context.stackLength-1] = bytes32(uint(context.generation));
} else if (contextId == CONTEXT_INDEX) {
context.stack[context.stackLength-1] = bytes32(context.index);
} else {
revert('Unknown/unsupported context ID');
}
}
| function execPushContext(Context memory context, bytes32[] memory, bytes32[] memory) internal view {
uint contextId = uint256(context.stack[context.stackLength-1]);
if (contextId == CONTEXT_TOKEN_ID) {
context.stack[context.stackLength-1] = bytes32(context.tokenId);
} else if (contextId == CONTEXT_TOKEN_OWNER ) {
context.stack[context.stackLength-1] = bytes32(uint256(uint160(context.owner)));
} else if (contextId == CONTEXT_BLOCK_TIMESTAMP ) {
// solhint-disable-next-line not-rely-on-time
context.stack[context.stackLength-1] = bytes32(uint256(block.timestamp));
} else if (contextId == CONTEXT_GENERATION) {
context.stack[context.stackLength-1] = bytes32(uint(context.generation));
} else if (contextId == CONTEXT_INDEX) {
context.stack[context.stackLength-1] = bytes32(context.index);
} else {
revert('Unknown/unsupported context ID');
}
}
| 39,171 |
16 | // SafeMath.sol // Ownable.sol // Ownable The Ownable contract has an owner address, and provides basic authorization controlfunctions, this simplifies the implementation of "user permissions". / | contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
| contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
| 16,444 |
8 | // Vesting records. / | struct Beneficiary {
uint256 start;
uint256 duration;
uint256 cliff;
uint256 totalAmount;
uint256 releasedAmount;
}
| struct Beneficiary {
uint256 start;
uint256 duration;
uint256 cliff;
uint256 totalAmount;
uint256 releasedAmount;
}
| 75,163 |
26 | // Only deploy if a smart wallet doesn't already exist at expected address. | bytes32 hash;
| bytes32 hash;
| 8,382 |
40 | // A Solidity high level call has three parts:1. The target address is checked to verify it contains contract code2. The call itself is made, and success asserted3. The return value is decoded, which in turn checks the size of the returned data. solhint-disable-next-line max-line-length | require(address(token).isContract(), "SafeERC20: call to non-contract");
| require(address(token).isContract(), "SafeERC20: call to non-contract");
| 18,181 |
7 | // Internal call to take collateral tokens from the bank./token The token to take back./amount The amount to take back. | function doTakeCollateral(address token, uint amount) internal {
if (amount > 0) {
if (amount == uint(-1)) {
(, , , amount) = bank.getCurrentPositionInfo();
}
bank.takeCollateral(address(werc20), uint(token), amount);
werc20.burn(token, amount);
}
}
| function doTakeCollateral(address token, uint amount) internal {
if (amount > 0) {
if (amount == uint(-1)) {
(, , , amount) = bank.getCurrentPositionInfo();
}
bank.takeCollateral(address(werc20), uint(token), amount);
werc20.burn(token, amount);
}
}
| 52,319 |
759 | // Import a position from src urn to the urn owned by cdp | function enter(
address src,
uint cdp
) public urnAllowed(src) cdpAllowed(cdp) {
(uint ink, uint art) = VatLike(vat).urns(ilks[cdp], src);
VatLike(vat).fork(
ilks[cdp],
src,
urns[cdp],
toInt(ink),
| function enter(
address src,
uint cdp
) public urnAllowed(src) cdpAllowed(cdp) {
(uint ink, uint art) = VatLike(vat).urns(ilks[cdp], src);
VatLike(vat).fork(
ilks[cdp],
src,
urns[cdp],
toInt(ink),
| 12,103 |
16 | // Withdraw all from Gauge | (, uint256 gaugePTokens, uint256 totalPTokens) = _getTotalPTokens();
_lpWithdraw(gaugePTokens);
| (, uint256 gaugePTokens, uint256 totalPTokens) = _getTotalPTokens();
_lpWithdraw(gaugePTokens);
| 20,953 |
111 | // unwrap WETH | if (_token == WETH) {
IWETH(WETH).withdraw(_balance);
}
| if (_token == WETH) {
IWETH(WETH).withdraw(_balance);
}
| 6,445 |
111 | // tokens created | uint256 created;
| uint256 created;
| 41,350 |
19 | // 30.11.2017 09:00:00 | dividends.push(Dividend(1512032400, 20, 0));
| dividends.push(Dividend(1512032400, 20, 0));
| 37,524 |
5 | // We do not use decimals here becuase the msg.sender will send wei | uint value = msg.value.div(2);
require(value <= balanceOf(owner()), "Not enough supply.");
_transfer(owner(), msg.sender, value);
| uint value = msg.value.div(2);
require(value <= balanceOf(owner()), "Not enough supply.");
_transfer(owner(), msg.sender, value);
| 11,193 |
6 | // This method relies on extcodesize/address.code.length, which returns 0 for contracts in construction, since the code is only stored at the end of the constructor execution. |
return account.code.length > 0;
|
return account.code.length > 0;
| 40,633 |
208 | // Get member stakerAddressesaccount Member address return Address array / | function getStakerAddresses(address account) external view returns (address[] memory);
| function getStakerAddresses(address account) external view returns (address[] memory);
| 74,361 |
144 | // Prevents other msg.sender than controller address | modifier onlyController() {
require(_msgSender() == controller, "!controller");
_;
}
| modifier onlyController() {
require(_msgSender() == controller, "!controller");
_;
}
| 65,547 |
39 | // the following function were added for transparency regarding ETH raised and prize pool calculations | uint256 totalWithdrawn = 0;
| uint256 totalWithdrawn = 0;
| 22,460 |
31 | // Returns detailed information for a Pool's registered token. `cash` is the number of tokens the Vault currently holds for the Pool. `managed` is the number of tokenswithdrawn and held outside the Vault by the Pool's token Asset Manager. The Pool's total balance for `token`equals the sum of `cash` and `managed`. Internally, `cash` and `managed` are stored using 112 bits. No action can ever cause a Pool's token `cash`,`managed` or `total` balance to be greater than 2^112 - 1. `lastChangeBlock` is the number of the block in which `token`'s total balance was last modified (via either ajoin, exit, swap, or Asset | function getPoolTokenInfo(bytes32 poolId, IERC20 token)
| function getPoolTokenInfo(bytes32 poolId, IERC20 token)
| 4,844 |
19 | // This function uses pseudorandomness to choose a faction that has remaining availability and remove 1 from the availability and return it to the CREATE DNA function, which assigns the faction to the tokenFaction map. the big 🧠 play is this function will MOST LIKELY give a somewhat equal distribution of factions to a minter. This means FACTION MAXI's will have to go to secondary to get factions they want. |
function subtractFromRandomFaction(uint256 totalminted)
public
returns (uint256 faction)
|
function subtractFromRandomFaction(uint256 totalminted)
public
returns (uint256 faction)
| 22,469 |
175 | // Liquidity generation logic/ Steps - All tokens tat will ever exist go to this contract/ This contract accepts ETH as payable/ ETH is mapped to people/ When liquidity generationevent is over veryone can call/ the mint LP function which will put all the ETH and tokens inside the uniswap contract/ without any involvement/ This LP will go into this contract/ And will be able to proportionally be withdrawn based on ETH put in/ A emergency drain function allows the contract owner to drain all ETH and tokens from this contract/ After the liquidity generation event happened. In case something goes |
string public liquidityGenerationParticipationAgreement = "I agree that the developers and affiliated parties of the Levels team are not responsible for your funds";
|
string public liquidityGenerationParticipationAgreement = "I agree that the developers and affiliated parties of the Levels team are not responsible for your funds";
| 23,105 |
21 | // pragma solidity 0.6.7; // import "./LinkedList.sol"; / | abstract contract SAFEEngineLike_12 {
function collateralTypes(bytes32) virtual public view returns (
uint256 debtAmount, // [wad]
uint256 accumulatedRate // [ray]
);
function updateAccumulatedRate(bytes32,address,int256) virtual external;
function coinBalance(address) virtual public view returns (uint256);
}
| abstract contract SAFEEngineLike_12 {
function collateralTypes(bytes32) virtual public view returns (
uint256 debtAmount, // [wad]
uint256 accumulatedRate // [ray]
);
function updateAccumulatedRate(bytes32,address,int256) virtual external;
function coinBalance(address) virtual public view returns (uint256);
}
| 54,547 |
195 | // Reimburse transmitter of the report for gas usage | require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
| require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
| 26,000 |
15 | // OBJECT BIT SHIFTS FOR READING FROM CALLDATA -- don't bother with using 'shr' if any of these is 0 uint256 internal constant BIT_SHIFT_headerHash = 256 - BIT_LENGTH_headerHash; uint256 internal constant BIT_SHIFT_durationDataStoreId = 256 - BIT_LENGTH_durationDataStoreId; uint256 internal constant BIT_SHIFT_globalDataStoreId = 256 - BIT_LENGTH_globalDataStoreId; uint256 internal constant BIT_SHIFT_referenceBlockNumber = 256 - BIT_LENGTH_referenceBlockNumber; uint256 internal constant BIT_SHIFT_blockNumber = 256 - BIT_LENGTH_blockNumber; uint256 internal constant BIT_SHIFT_fee = 256 - BIT_LENGTH_fee; uint256 internal constant BIT_SHIFT_confirmer = 256 - BIT_LENGTH_confirmer; uint256 internal constant BIT_SHIFT_signatoryRecordHash = 256 - BIT_LENGTH_signatoryRecordHash; uint256 internal constant BIT_SHIFT_duration = 256 - BIT_LENGTH_duration; uint256 internal constant BIT_SHIFT_timestamp = 256 - BIT_LENGTH_timestamp; uint256 | uint256 internal constant BIT_SHIFT_headerHash = 0;
uint256 internal constant BIT_SHIFT_durationDataStoreId = 224;
uint256 internal constant BIT_SHIFT_globalDataStoreId = 224;
uint256 internal constant BIT_SHIFT_referenceBlockNumber = 224;
uint256 internal constant BIT_SHIFT_blockNumber = 224;
uint256 internal constant BIT_SHIFT_fee = 160;
uint256 internal constant BIT_SHIFT_confirmer = 96;
uint256 internal constant BIT_SHIFT_signatoryRecordHash = 0;
uint256 internal constant BIT_SHIFT_duration = 248;
uint256 internal constant BIT_SHIFT_timestamp = 0;
| uint256 internal constant BIT_SHIFT_headerHash = 0;
uint256 internal constant BIT_SHIFT_durationDataStoreId = 224;
uint256 internal constant BIT_SHIFT_globalDataStoreId = 224;
uint256 internal constant BIT_SHIFT_referenceBlockNumber = 224;
uint256 internal constant BIT_SHIFT_blockNumber = 224;
uint256 internal constant BIT_SHIFT_fee = 160;
uint256 internal constant BIT_SHIFT_confirmer = 96;
uint256 internal constant BIT_SHIFT_signatoryRecordHash = 0;
uint256 internal constant BIT_SHIFT_duration = 248;
uint256 internal constant BIT_SHIFT_timestamp = 0;
| 29,606 |
11 | // the address of the GenesisGroup contract/ return genesis group contract | function genesisGroup() external view returns(address);
| function genesisGroup() external view returns(address);
| 56,246 |
59 | // Internal function to remove a unicorn ID from the list of a given address_from address representing the previous owner of the given unicorn ID_unicornId uint256 ID of the unicorn to be removed from the unicorns list of the given address/ | function removeUnicorn(address _from, uint256 _unicornId) private {
require(owns(_from, _unicornId));
uint256 unicornIndex = ownedUnicornsIndex[_unicornId];
// uint256 lastUnicornIndex = balanceOf(_from).sub(1);
uint256 lastUnicornIndex = ownedUnicorns[_from].length.sub(1);
uint256 lastUnicorn = ownedUnicorns[_from][lastUnicornIndex];
unicornOwner[_unicornId] = 0;
ownedUnicorns[_from][unicornIndex] = lastUnicorn;
ownedUnicorns[_from][lastUnicornIndex] = 0;
// Note that this will handle single-element arrays. In that case, both unicornIndex and lastUnicornIndex are going to
// be zero. Then we can make sure that we will remove _unicornId from the ownedUnicorns list since we are first swapping
// the lastUnicorn to the first position, and then dropping the element placed in the last position of the list
ownedUnicorns[_from].length--;
ownedUnicornsIndex[_unicornId] = 0;
ownedUnicornsIndex[lastUnicorn] = unicornIndex;
totalUnicorns = totalUnicorns.sub(1);
//deleting sale offer, if exists
//TODO check if contract exists?
// if (address(unicornBreeding) != address(0)) {
unicornBreeding.deleteOffer(_unicornId);
unicornBreeding.deleteHybridization(_unicornId);
// }
}
| function removeUnicorn(address _from, uint256 _unicornId) private {
require(owns(_from, _unicornId));
uint256 unicornIndex = ownedUnicornsIndex[_unicornId];
// uint256 lastUnicornIndex = balanceOf(_from).sub(1);
uint256 lastUnicornIndex = ownedUnicorns[_from].length.sub(1);
uint256 lastUnicorn = ownedUnicorns[_from][lastUnicornIndex];
unicornOwner[_unicornId] = 0;
ownedUnicorns[_from][unicornIndex] = lastUnicorn;
ownedUnicorns[_from][lastUnicornIndex] = 0;
// Note that this will handle single-element arrays. In that case, both unicornIndex and lastUnicornIndex are going to
// be zero. Then we can make sure that we will remove _unicornId from the ownedUnicorns list since we are first swapping
// the lastUnicorn to the first position, and then dropping the element placed in the last position of the list
ownedUnicorns[_from].length--;
ownedUnicornsIndex[_unicornId] = 0;
ownedUnicornsIndex[lastUnicorn] = unicornIndex;
totalUnicorns = totalUnicorns.sub(1);
//deleting sale offer, if exists
//TODO check if contract exists?
// if (address(unicornBreeding) != address(0)) {
unicornBreeding.deleteOffer(_unicornId);
unicornBreeding.deleteHybridization(_unicornId);
// }
}
| 28,127 |
14 | // event for investor disapproval logginginvestor disapproved investor/ | event Disapproved(address indexed investor);
constructor(address _owner)
public
Ownable(_owner)
| event Disapproved(address indexed investor);
constructor(address _owner)
public
Ownable(_owner)
| 39,667 |
26 | // Sparkly | setWingType(
6,
| setWingType(
6,
| 17,135 |
24 | // loop through _recipients | for {
let i := 0
} lt(i, sz) {
| for {
let i := 0
} lt(i, sz) {
| 31,522 |
38 | // Renders a custom animation as an embedded data URI/ | function getAnimationDataUri(uint tokenId, uint animationId) external override view returns(string memory) {
GIFEncoder.GIF memory gif = getAnimation(tokenId, animationId);
string memory dataUri = GIFEncoder.getDataUri(gif);
return dataUri;
}
| function getAnimationDataUri(uint tokenId, uint animationId) external override view returns(string memory) {
GIFEncoder.GIF memory gif = getAnimation(tokenId, animationId);
string memory dataUri = GIFEncoder.getDataUri(gif);
return dataUri;
}
| 29,254 |
160 | // Returns the percentage of the keyPrice to be sent to the referrer (in basis points) _referrer the address of the referrerreturn referrerFee the percentage of the keyPrice to be sent to the referrer (in basis points) / | function referrerFees(
| function referrerFees(
| 13,430 |
67 | // Multiplies x and y, rounding up to the closest representable number./ Assumes x and y are both fixed point with `decimals` digits. | function muldrup(uint256 x, uint256 y) internal pure returns (uint256)
| function muldrup(uint256 x, uint256 y) internal pure returns (uint256)
| 78,313 |
194 | // Start at token id 1 | _tokenIdCounter.increment();
| _tokenIdCounter.increment();
| 72,981 |
35 | // MasterChef was the master of LCN. He now governs over LCNS. He can make LCNs and he is a fair guy. Note that it's ownable and the owner wields tremendous power. The ownership will be transferred to a governance smart contract once LCNS is sufficiently distributed and the community can show to govern itself. Have fun reading it. Hopefully it's bug-free. God bless. | contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of LCNs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accLCNPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accLCNPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. LCNs to distribute per block.
uint256 lastRewardBlock; // Last block number that LCNs distribution occurs.
uint256 accLCNPerShare; // Accumulated LCNs per share, times 1e12. See below.
}
// The LCN TOKEN!
LocalleNetworkToken public LCN;
// Dev fund (2%, initially)
uint256 public devFundDivRate = 50;
// Dev address.
address public devaddr;
// Block number when bonus LCN period ends.
uint256 public bonusEndBlock;
// LCN tokens created per block.
uint256 public LCNPerBlock;
// Bonus muliplier for early LCN makers.
uint256 public constant BONUS_MULTIPLIER = 10;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when LCN mining starts.
uint256 public startBlock;
// Events
event Recovered(address token, uint256 amount);
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
constructor(
LocalleNetworkToken _LCN,
address _devaddr,
uint256 _LCNPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
LCN = _LCN;
devaddr = _devaddr;
LCNPerBlock = _LCNPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(
uint256 _allocPoint,
IERC20 _lpToken,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock
? block.number
: startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accLCNPerShare: 0
})
);
}
// Update the given pool's LCN allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(
_allocPoint
);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to)
public
view
returns (uint256)
{
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return
bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending LCNs on frontend.
function pendingLCN(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accLCNPerShare = pool.accLCNPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(
pool.lastRewardBlock,
block.number
);
uint256 LCNReward = multiplier
.mul(LCNPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
accLCNPerShare = accLCNPerShare.add(
LCNReward.mul(1e12).div(lpSupply)
);
}
return
user.amount.mul(accLCNPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 LCNReward = multiplier
.mul(LCNPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
LCN.mint(devaddr, LCNReward.div(devFundDivRate));
LCN.mint(address(this), LCNReward);
pool.accLCNPerShare = pool.accLCNPerShare.add(
LCNReward.mul(1e12).div(lpSupply)
);
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for LCN allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user
.amount
.mul(pool.accLCNPerShare)
.div(1e12)
.sub(user.rewardDebt);
safeLCNTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accLCNPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accLCNPerShare).div(1e12).sub(
user.rewardDebt
);
safeLCNTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accLCNPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe LCN transfer function, just in case if rounding error causes pool to not have enough LCNs.
function safeLCNTransfer(address _to, uint256 _amount) internal {
uint256 LCNBal = LCN.balanceOf(address(this));
if (_amount > LCNBal) {
LCN.transfer(_to, LCNBal);
} else {
LCN.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
// **** Additional functions separate from the original masterchef contract ****
function setLCNPerBlock(uint256 _LCNPerBlock) public onlyOwner {
require(_LCNPerBlock > 0, "!LCNPerBlock-0");
LCNPerBlock = _LCNPerBlock;
}
function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner {
bonusEndBlock = _bonusEndBlock;
}
function setDevFundDivRate(uint256 _devFundDivRate) public onlyOwner {
require(_devFundDivRate > 0, "!devFundDivRate-0");
devFundDivRate = _devFundDivRate;
}
}
| contract MasterChef is Ownable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// Info of each user.
struct UserInfo {
uint256 amount; // How many LP tokens the user has provided.
uint256 rewardDebt; // Reward debt. See explanation below.
//
// We do some fancy math here. Basically, any point in time, the amount of LCNs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accLCNPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accLCNPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
}
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // How many allocation points assigned to this pool. LCNs to distribute per block.
uint256 lastRewardBlock; // Last block number that LCNs distribution occurs.
uint256 accLCNPerShare; // Accumulated LCNs per share, times 1e12. See below.
}
// The LCN TOKEN!
LocalleNetworkToken public LCN;
// Dev fund (2%, initially)
uint256 public devFundDivRate = 50;
// Dev address.
address public devaddr;
// Block number when bonus LCN period ends.
uint256 public bonusEndBlock;
// LCN tokens created per block.
uint256 public LCNPerBlock;
// Bonus muliplier for early LCN makers.
uint256 public constant BONUS_MULTIPLIER = 10;
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes LP tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when LCN mining starts.
uint256 public startBlock;
// Events
event Recovered(address token, uint256 amount);
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(
address indexed user,
uint256 indexed pid,
uint256 amount
);
constructor(
LocalleNetworkToken _LCN,
address _devaddr,
uint256 _LCNPerBlock,
uint256 _startBlock,
uint256 _bonusEndBlock
) public {
LCN = _LCN;
devaddr = _devaddr;
LCNPerBlock = _LCNPerBlock;
bonusEndBlock = _bonusEndBlock;
startBlock = _startBlock;
}
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
// Add a new lp to the pool. Can only be called by the owner.
// XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do.
function add(
uint256 _allocPoint,
IERC20 _lpToken,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
uint256 lastRewardBlock = block.number > startBlock
? block.number
: startBlock;
totalAllocPoint = totalAllocPoint.add(_allocPoint);
poolInfo.push(
PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accLCNPerShare: 0
})
);
}
// Update the given pool's LCN allocation point. Can only be called by the owner.
function set(
uint256 _pid,
uint256 _allocPoint,
bool _withUpdate
) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(
_allocPoint
);
poolInfo[_pid].allocPoint = _allocPoint;
}
// Return reward multiplier over the given _from to _to block.
function getMultiplier(uint256 _from, uint256 _to)
public
view
returns (uint256)
{
if (_to <= bonusEndBlock) {
return _to.sub(_from).mul(BONUS_MULTIPLIER);
} else if (_from >= bonusEndBlock) {
return _to.sub(_from);
} else {
return
bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add(
_to.sub(bonusEndBlock)
);
}
}
// View function to see pending LCNs on frontend.
function pendingLCN(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accLCNPerShare = pool.accLCNPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(
pool.lastRewardBlock,
block.number
);
uint256 LCNReward = multiplier
.mul(LCNPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
accLCNPerShare = accLCNPerShare.add(
LCNReward.mul(1e12).div(lpSupply)
);
}
return
user.amount.mul(accLCNPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 LCNReward = multiplier
.mul(LCNPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
LCN.mint(devaddr, LCNReward.div(devFundDivRate));
LCN.mint(address(this), LCNReward);
pool.accLCNPerShare = pool.accLCNPerShare.add(
LCNReward.mul(1e12).div(lpSupply)
);
pool.lastRewardBlock = block.number;
}
// Deposit LP tokens to MasterChef for LCN allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user
.amount
.mul(pool.accLCNPerShare)
.div(1e12)
.sub(user.rewardDebt);
safeLCNTransfer(msg.sender, pending);
}
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accLCNPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw LP tokens from MasterChef.
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accLCNPerShare).div(1e12).sub(
user.rewardDebt
);
safeLCNTransfer(msg.sender, pending);
user.amount = user.amount.sub(_amount);
user.rewardDebt = user.amount.mul(pool.accLCNPerShare).div(1e12);
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
pool.lpToken.safeTransfer(address(msg.sender), user.amount);
emit EmergencyWithdraw(msg.sender, _pid, user.amount);
user.amount = 0;
user.rewardDebt = 0;
}
// Safe LCN transfer function, just in case if rounding error causes pool to not have enough LCNs.
function safeLCNTransfer(address _to, uint256 _amount) internal {
uint256 LCNBal = LCN.balanceOf(address(this));
if (_amount > LCNBal) {
LCN.transfer(_to, LCNBal);
} else {
LCN.transfer(_to, _amount);
}
}
// Update dev address by the previous dev.
function dev(address _devaddr) public {
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
// **** Additional functions separate from the original masterchef contract ****
function setLCNPerBlock(uint256 _LCNPerBlock) public onlyOwner {
require(_LCNPerBlock > 0, "!LCNPerBlock-0");
LCNPerBlock = _LCNPerBlock;
}
function setBonusEndBlock(uint256 _bonusEndBlock) public onlyOwner {
bonusEndBlock = _bonusEndBlock;
}
function setDevFundDivRate(uint256 _devFundDivRate) public onlyOwner {
require(_devFundDivRate > 0, "!devFundDivRate-0");
devFundDivRate = _devFundDivRate;
}
}
| 12,324 |
26 | // Transfer tokens from one address to another.Note that while this function emits an Approval event, this is not required as per the specification,and other compliant implementations may not emit the event. from address The address which you want to send tokens from to address The address which you want to transfer to value uint256 the amount of tokens to be transferred / | function transferFrom(address from, address to, uint256 value) public returns (bool) {
_transfer(from, to, value);
_approve(from, msg.sender, _allowed[from][msg.sender].sub(value));
return true;
}
| function transferFrom(address from, address to, uint256 value) public returns (bool) {
_transfer(from, to, value);
_approve(from, msg.sender, _allowed[from][msg.sender].sub(value));
return true;
}
| 8,537 |
34 | // Checks if `_operator` is an approved operator for `_owner`. _owner The address that owns the NFTs. _operator The address that acts on behalf of the owner.return True if approved for all, false otherwise. / | function isApprovedForAll(address _owner, address _operator)
external
view
override
returns (bool)
| function isApprovedForAll(address _owner, address _operator)
external
view
override
returns (bool)
| 20,389 |
164 | // Transition the minimum number of terms between the amount requested and the amount actually needed | uint64 neededTransitions = _neededTermTransitions();
uint256 transitions = uint256(_maxRequestedTransitions < neededTransitions ? _maxRequestedTransitions : neededTransitions);
require(transitions > 0, ERROR_INVALID_TRANSITION_TERMS);
uint64 blockNumber = getBlockNumber64();
uint64 previousTermId = termId;
uint64 currentTermId = previousTermId;
for (uint256 transition = 1; transition <= transitions; transition++) {
| uint64 neededTransitions = _neededTermTransitions();
uint256 transitions = uint256(_maxRequestedTransitions < neededTransitions ? _maxRequestedTransitions : neededTransitions);
require(transitions > 0, ERROR_INVALID_TRANSITION_TERMS);
uint64 blockNumber = getBlockNumber64();
uint64 previousTermId = termId;
uint64 currentTermId = previousTermId;
for (uint256 transition = 1; transition <= transitions; transition++) {
| 12,807 |
36 | // collect eth |
mapping (address => uint256) public buyers;
address[] private keys;
|
mapping (address => uint256) public buyers;
address[] private keys;
| 16,805 |
219 | // Internally calculates a swap between two tokens.The caller is expected to transfer the actual amounts (dx and dy)using the token contracts.self Swap struct to read from tokenIndexFrom the token to sell tokenIndexTo the token to buy dx the number of tokens to sell. If the token charges a fee on transfers,use the amount that gets transferred after the fee.return dy the number of tokens the user will getreturn dyFee the associated fee / | function _calculateSwap(
Swap storage self,
uint8 tokenIndexFrom,
uint8 tokenIndexTo,
uint256 dx
| function _calculateSwap(
Swap storage self,
uint8 tokenIndexFrom,
uint8 tokenIndexTo,
uint256 dx
| 19,630 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.