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
114
// Returns the URI for a given token ID Reverts if the token ID does not exist. /
function tokenURI(uint256 tokenId) external view returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string( abi.encodePacked( baseURI(), Strings.fromUint256(tokenId) ) ); }
function tokenURI(uint256 tokenId) external view returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return string( abi.encodePacked( baseURI(), Strings.fromUint256(tokenId) ) ); }
17,082
118
// increase no. of boosters bought
numBoostersBought[user] = numBoostersBought[user].add(1); updateBoostBalanceAndSupply(user, newBoostBalance);
numBoostersBought[user] = numBoostersBought[user].add(1); updateBoostBalanceAndSupply(user, newBoostBalance);
3,772
15
// for getTokenByIndex below, 0 based index so we do it before incrementing numIdentities
allTokens[numIdentities] = thisToken;
allTokens[numIdentities] = thisToken;
17,532
248
// ========== STRUCTS ========== / Struct for the stake
struct LockedStake { bytes32 kek_id; uint256 start_timestamp; uint256 liquidity; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 }
struct LockedStake { bytes32 kek_id; uint256 start_timestamp; uint256 liquidity; uint256 ending_timestamp; uint256 lock_multiplier; // 6 decimals of precision. 1x = 1000000 }
17,867
0
// use the mint function to create an NFT
function mint() public returns (uint256) { _tokenIds += 1; _mint(msg.sender, _tokenIds); return _tokenIds; }
function mint() public returns (uint256) { _tokenIds += 1; _mint(msg.sender, _tokenIds); return _tokenIds; }
24,942
190
// If an allocator is specified, funds will be sent to the allocator contract along with all properties of this split.
IJBSplitAllocator allocator;
IJBSplitAllocator allocator;
78,589
106
// permit
IPermit(address(stakingToken)).permit(msg.sender, address(this), amount, deadline, v, r, s); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount);
IPermit(address(stakingToken)).permit(msg.sender, address(this), amount, deadline, v, r, s); stakingToken.safeTransferFrom(msg.sender, address(this), amount); emit Staked(msg.sender, amount);
21,836
35
// Arguments for calling prepare()invariantData The data for a crosschain transaction that willnot change between sending and receiving chains.The hash of this data is used as the key to store the inforamtion that does change between chains (amount,expiry,preparedBlock) for verificationamount The amount of the transaction on this chainexpiry The block.timestamp when the transaction will no longer be fulfillable and is freely cancellable on this chainencryptedCallData The calldata to be executed when the tx isfulfilled. Used in the function to allow the userto reconstruct the tx from events. Hash is storedonchain to prevent shenanigans.encodedBid The encoded bid that was accepted by the
struct PrepareArgs { InvariantTransactionData invariantData; uint256 amount; uint256 expiry; bytes encryptedCallData; bytes encodedBid; bytes bidSignature; bytes encodedMeta; }
struct PrepareArgs { InvariantTransactionData invariantData; uint256 amount; uint256 expiry; bytes encryptedCallData; bytes encodedBid; bytes bidSignature; bytes encodedMeta; }
52,907
246
// Deposits all USDC held in this contract into the strategy
function deposit() external;
function deposit() external;
62,355
118
// Draws Dai from the CDP/If _daiAmount is bigger than max available we'll draw max/_cdpId Id of the CDP/_ilk Ilk of the CDP/_daiAmount Amount of Dai to draw
function drawDai(uint _cdpId, bytes32 _ilk, uint _daiAmount) internal returns (uint) { uint rate = Jug(JUG_ADDRESS).drip(_ilk); uint daiVatBalance = vat.dai(manager.urns(_cdpId)); uint maxAmount = getMaxDebt(_cdpId, _ilk); if (_daiAmount >= maxAmount) { _daiAmount = sub(maxAmount, 1); } manager.frob(_cdpId, int(0), normalizeDrawAmount(_daiAmount, rate, daiVatBalance)); manager.move(_cdpId, address(this), toRad(_daiAmount)); if (vat.can(address(this), address(DAI_JOIN_ADDRESS)) == 0) { vat.hope(DAI_JOIN_ADDRESS); } DaiJoin(DAI_JOIN_ADDRESS).exit(address(this), _daiAmount); return _daiAmount; }
function drawDai(uint _cdpId, bytes32 _ilk, uint _daiAmount) internal returns (uint) { uint rate = Jug(JUG_ADDRESS).drip(_ilk); uint daiVatBalance = vat.dai(manager.urns(_cdpId)); uint maxAmount = getMaxDebt(_cdpId, _ilk); if (_daiAmount >= maxAmount) { _daiAmount = sub(maxAmount, 1); } manager.frob(_cdpId, int(0), normalizeDrawAmount(_daiAmount, rate, daiVatBalance)); manager.move(_cdpId, address(this), toRad(_daiAmount)); if (vat.can(address(this), address(DAI_JOIN_ADDRESS)) == 0) { vat.hope(DAI_JOIN_ADDRESS); } DaiJoin(DAI_JOIN_ADDRESS).exit(address(this), _daiAmount); return _daiAmount; }
12,112
234
// Modifier to check whether the value can be stored in a 64 bit uint.
modifier fitsIn64Bits(uint256 _value) { require (_value == uint256(uint64(_value))); _; }
modifier fitsIn64Bits(uint256 _value) { require (_value == uint256(uint64(_value))); _; }
13,373
54
// This function will stop any ongoing passive airdrop /
function stopPassiveAirDropCompletely() public onlyOwner{ passiveAirdropTokensAllocation = 0; airdropAmount = 0; airdropClaimedIndex++; passiveAirdropStatus = false; }
function stopPassiveAirDropCompletely() public onlyOwner{ passiveAirdropTokensAllocation = 0; airdropAmount = 0; airdropClaimedIndex++; passiveAirdropStatus = false; }
6,193
3
// Throws if called by any account other than the owner.
modifier onlyOwner() { if (owner != msg.sender) { revert Ownable__NotOwner(owner, msg.sender); } _; }
modifier onlyOwner() { if (owner != msg.sender) { revert Ownable__NotOwner(owner, msg.sender); } _; }
4,893
6
// Combines 'self' and 'other' into a single array. Returns the concatenated arrays:[self[0], self[1], ... , self[self.length - 1], other[0], other[1], ... , other[other.length - 1]] The length of the new array is 'self.length + other.length'
function concat(bytes memory self, bytes memory other) internal pure returns (bytes memory)
function concat(bytes memory self, bytes memory other) internal pure returns (bytes memory)
33,430
139
// Track total allocations per subgraph Used for rewards calculations
subgraphAllocations[alloc.subgraphDeploymentID] = subgraphAllocations[alloc .subgraphDeploymentID] .add(alloc.tokens); emit AllocationCreated( _indexer, _subgraphDeploymentID, alloc.createdAtEpoch, alloc.tokens, _allocationID,
subgraphAllocations[alloc.subgraphDeploymentID] = subgraphAllocations[alloc .subgraphDeploymentID] .add(alloc.tokens); emit AllocationCreated( _indexer, _subgraphDeploymentID, alloc.createdAtEpoch, alloc.tokens, _allocationID,
20,657
537
// Unlock
int256 amount = _unlockFungible(lockedWallet, lockerWallet, currencyCt, currencyId, lockIndex);
int256 amount = _unlockFungible(lockedWallet, lockerWallet, currencyCt, currencyId, lockIndex);
22,021
22
// Standard ERC20 tokenImplementation of the basic standard token. /
contract StandardToken is ERC20, BasicToken { uint8 public constant decimals = 18; uint256 public constant ONE_TOKEN = (10 ** uint256(decimals)); mapping (address => mapping (address => uint256)) 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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @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) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit 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 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is ERC20, BasicToken { uint8 public constant decimals = 18; uint256 public constant ONE_TOKEN = (10 ** uint256(decimals)); mapping (address => mapping (address => uint256)) 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 amout of tokens to be transfered */ function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { uint256 _allowance = allowed[_from][msg.sender]; // Check is not needed because sub(_allowance, _value) will already throw if this condition is not met // require (_value <= _allowance); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = _allowance.sub(_value); emit Transfer(_from, _to, _value); return true; } /** * @dev Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender. * @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) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 require((_value == 0) || (allowed[msg.sender][_spender] == 0)); allowed[msg.sender][_spender] = _value; emit 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 specifing the amount of tokens still avaible for the spender. */ function allowance(address _owner, address _spender) constant public returns (uint256 remaining) { return allowed[_owner][_spender]; } }
1,798
125
// Reverts if the sender is not the oracle of the request.Emits ChainlinkFulfilled event. _requestId The request ID for fulfillment /
modifier recordChainlinkFulfillment(bytes32 _requestId) { require(msg.sender == pendingRequests[_requestId], "Source must be the oracle of the request"); delete pendingRequests[_requestId]; emit ChainlinkFulfilled(_requestId); _; }
modifier recordChainlinkFulfillment(bytes32 _requestId) { require(msg.sender == pendingRequests[_requestId], "Source must be the oracle of the request"); delete pendingRequests[_requestId]; emit ChainlinkFulfilled(_requestId); _; }
2,780
6
// Required to allow the artist to administrate the contract on OpenSea.Note if there are many addresses with the DEFAULT_ADMIN_ROLE, the one which is returned may be arbitrary. /
function owner() public view virtual returns (address) { return _getPrimaryAdmin(); }
function owner() public view virtual returns (address) { return _getPrimaryAdmin(); }
55,584
5
// Clean the upper 96 bits of `subscriptionOrRegistrantToCopy` in case they are dirty.
subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy))
subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy))
29,477
9
// Prevent wrapping with itself
function transferFrom(address _from, address _to, uint256 _tokenId) override public { require(_to != address(this)); return super.transferFrom(_from, _to, _tokenId); }
function transferFrom(address _from, address _to, uint256 _tokenId) override public { require(_to != address(this)); return super.transferFrom(_from, _to, _tokenId); }
34,774
26
// return true if crowdsale event has ended & limit has not been reached
function hasEnded() public view returns (bool) { bool capReached = weiRaised >= cap; bool timeLimit = now > endTime; return capReached || timeLimit; }
function hasEnded() public view returns (bool) { bool capReached = weiRaised >= cap; bool timeLimit = now > endTime; return capReached || timeLimit; }
9,293
276
// Address of the Factory that created this contract
address factory_address; Factory_Interface factory; address creator;
address factory_address; Factory_Interface factory; address creator;
24,020
245
// Withdraw/relock all currently locked tokens where the unlock time has passed
function processExpiredLocks(bool _relock, uint256 _spendRatio, address _withdrawTo) external nonReentrant { _processExpiredLocks(msg.sender, _relock, _spendRatio, _withdrawTo, msg.sender, 0); }
function processExpiredLocks(bool _relock, uint256 _spendRatio, address _withdrawTo) external nonReentrant { _processExpiredLocks(msg.sender, _relock, _spendRatio, _withdrawTo, msg.sender, 0); }
40,887
43
// Atomically decreases the allowance granted to `spender` by the caller.
* This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; }
* This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; }
31,059
13
// ICO is running
if (now >= firstDiscountStartTime && now <= firstDiscountEndTime){ bonus = 25; }else if(now >= secDiscountStartTime && now <= secDiscountEndTime){
if (now >= firstDiscountStartTime && now <= firstDiscountEndTime){ bonus = 25; }else if(now >= secDiscountStartTime && now <= secDiscountEndTime){
65,515
57
// Due date for Payment
uint256 dueDate = debtTakenDay + uint256(daysTo1stPayment) * TIMEFRAME + (uint256(payment) - 1) * uint256(paymentFreq) * TIMEFRAME; uint256 daysLate = (timestamp <= dueDate) ? 0 : (timestamp - dueDate) / TIMEFRAME;
uint256 dueDate = debtTakenDay + uint256(daysTo1stPayment) * TIMEFRAME + (uint256(payment) - 1) * uint256(paymentFreq) * TIMEFRAME; uint256 daysLate = (timestamp <= dueDate) ? 0 : (timestamp - dueDate) / TIMEFRAME;
17,058
40
// User wither gets sent rewards upon contribution or the reward total accumulates and gets claimed
// function claimReward() public nonReentrant { // uint256 rewardAmount = rewardTokenBalances[msg.sender]; // require(rewardAmount > 0, "No rewards to claim"); // require(rewardAmount <= rewardToken.balanceOf(address(this)), // "Insufficient reward tokens in the contract" // ); // rewardTokenBalances[msg.sender] = 0; // Reset user's reward balance // // Transfer reward tokens from the ContributionContract to the user // rewardToken.transfer(msg.sender, rewardAmount); // emit RewardDispensed(msg.sender, rewardAmount); // }
// function claimReward() public nonReentrant { // uint256 rewardAmount = rewardTokenBalances[msg.sender]; // require(rewardAmount > 0, "No rewards to claim"); // require(rewardAmount <= rewardToken.balanceOf(address(this)), // "Insufficient reward tokens in the contract" // ); // rewardTokenBalances[msg.sender] = 0; // Reset user's reward balance // // Transfer reward tokens from the ContributionContract to the user // rewardToken.transfer(msg.sender, rewardAmount); // emit RewardDispensed(msg.sender, rewardAmount); // }
1,002
37
// Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). Tokens usually opt for a value of 18, imitating the relationship betweenEther and Wei. NOTE: This information is only used for _display_ purposes: it inno way affects any of the arithmetic of the contract, including
* {IBEP20-balanceOf} and {IBEP20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; }
* {IBEP20-balanceOf} and {IBEP20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; }
27,151
31
// PRIVILEGED FACTORY FUNCTION. Removes a keeper_keeper Address of the keeper /
function removeKeeper(address _keeper) external override onlyOwner { require(keeperList[_keeper], 'Keeper is whitelisted'); delete keeperList[_keeper]; }
function removeKeeper(address _keeper) external override onlyOwner { require(keeperList[_keeper], 'Keeper is whitelisted'); delete keeperList[_keeper]; }
75,534
15
// needs less SY --> swap less PT
approx.guessMax = guess - 1;
approx.guessMax = guess - 1;
24,420
4
// Defines a contract named `HelloWorld`. A contract is a collection of functions and data (its state). Once deployed, a contract resides at a specific address on the Ethereum blockchain. Learn more: https:solidity.readthedocs.io/en/v0.5.10/structure-of-a-contract.html
contract HelloWorld { // Declares a state variable `message` of type `string`. // State variables are variables whose values are permanently stored in contract storage. // The keyword `public` makes variables accessible from outside a contract // and creates a function that other contracts or clients can call to access the value. string public message; // Similar to many class-based object-oriented languages, a constructor is // a special function that is only executed upon contract creation. // Constructors are used to initialize the contract's data. // Learn more: https://solidity.readthedocs.io/en/v0.5.10/contracts.html#constructors constructor(string memory initMessage) public { // Accepts a string argument `initMessage` and sets the value // into the contract's `message` storage variable). message = initMessage; } // A public function that accepts a string argument // and updates the `message` storage variable. function update(string memory newMessage) public { message = newMessage; } }
contract HelloWorld { // Declares a state variable `message` of type `string`. // State variables are variables whose values are permanently stored in contract storage. // The keyword `public` makes variables accessible from outside a contract // and creates a function that other contracts or clients can call to access the value. string public message; // Similar to many class-based object-oriented languages, a constructor is // a special function that is only executed upon contract creation. // Constructors are used to initialize the contract's data. // Learn more: https://solidity.readthedocs.io/en/v0.5.10/contracts.html#constructors constructor(string memory initMessage) public { // Accepts a string argument `initMessage` and sets the value // into the contract's `message` storage variable). message = initMessage; } // A public function that accepts a string argument // and updates the `message` storage variable. function update(string memory newMessage) public { message = newMessage; } }
13,693
174
// Set the release timestamp
timestampReleased = releaseTimestamp;
timestampReleased = releaseTimestamp;
23,891
32
// bonus token
Bonus memory bonus = pools[_lpToken].bonuses[_poolBonusId]; require( bonus.bonusTokenAddr == _token, "BonusRewards: wrong pool" ); require( bonus.endTime + WEEK < block.timestamp, "BonusRewards: not ready" ); balance = bonus.remBonus;
Bonus memory bonus = pools[_lpToken].bonuses[_poolBonusId]; require( bonus.bonusTokenAddr == _token, "BonusRewards: wrong pool" ); require( bonus.endTime + WEEK < block.timestamp, "BonusRewards: not ready" ); balance = bonus.remBonus;
19,331
18
// internal
function _baseURI() internal view virtual override returns (string memory) { return _URI; }
function _baseURI() internal view virtual override returns (string memory) { return _URI; }
4,554
17
// Allows for a transfer of tokens to _to"_to": The address to send tokens to"_amount": The amount of tokens to send/
function transfer(address _to, uint _amount) public returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } else {
function transfer(address _to, uint _amount) public returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] = balances[msg.sender].sub(_amount); balances[_to] = balances[_to].add(_amount); Transfer(msg.sender, _to, _amount); return true; } else {
47,298
34
// Address of contract which wraps pool operations: join, exit and swaps.
address private _wrapper;
address private _wrapper;
53,827
168
// ==================================
addHolder(addr); emit Transfer(address(this),addr,nateeGot); emit RedeemWarrat(addr,address(warrant),"NATEE-W1",nateeGot);
addHolder(addr); emit Transfer(address(this),addr,nateeGot); emit RedeemWarrat(addr,address(warrant),"NATEE-W1",nateeGot);
52,311
3
// Updates functions in a transparent contract./If the value of _delegate is zero then the functions specified/in _functionSignatures are removed./If the value of _delegate is a delegate contract address then the functions/specified in _functionSignatures will be delegated to that address./_delegate The address of a delegate contract to delegate to or zero/to remove functions./_functionSignatures A list of function signatures listed one after the other/_commitMessage A short description of the change and why it is made/This message is passed to the CommitMessage event.
function updateContract(address _delegate, string calldata _functionSignatures, string calldata _commitMessage) external;
function updateContract(address _delegate, string calldata _functionSignatures, string calldata _commitMessage) external;
26,867
31
// Holder list. A mapping to 1 indicates, that an address is a holder.
mapping(address => uint8) public holderList;
mapping(address => uint8) public holderList;
23,496
5
// Withdraw method transfers all collected ETH to the treasury wallet. /
function withdraw() external;
function withdraw() external;
21,998
147
// Mint all token collected by second private presale (called reservation),all KYC control are made outside contract under responsability of ParkinGO.Also, updates tokensSold and availableTokens in the crowdsale contract,it checks that sold token are less than reservation contract cap. beneficiaries Array of the reservation user that bought tokens in private reservation sale. balances Array of token amount per beneficiary. /
function mintReservation(address[] beneficiaries, uint256[] balances) public onlyOwner equalLength(beneficiaries, balances)
function mintReservation(address[] beneficiaries, uint256[] balances) public onlyOwner equalLength(beneficiaries, balances)
68,948
16
// The block at which voting begins: holders must delegate their votes prior to this block
uint256 startBlock;
uint256 startBlock;
11,747
117
// An error specific to the Aggregator V3 Interface, to prevent possible confusion around accidentally reading unset values as reported values.
string constant private V3_NO_DATA_ERROR = "No data present"; uint32 private reportingRoundId; uint32 internal latestRoundId; mapping(address => OracleStatus) private oracles; mapping(uint32 => Round) internal rounds; mapping(uint32 => RoundDetails) internal details; mapping(address => Requester) internal requesters; address[] private oracleAddresses; Funds private recordedFunds;
string constant private V3_NO_DATA_ERROR = "No data present"; uint32 private reportingRoundId; uint32 internal latestRoundId; mapping(address => OracleStatus) private oracles; mapping(uint32 => Round) internal rounds; mapping(uint32 => RoundDetails) internal details; mapping(address => Requester) internal requesters; address[] private oracleAddresses; Funds private recordedFunds;
8,199
3
// Your initial invitation CAT coin is 100% yours. Feel free to sell it, gift it, send to 0x00 Know that if you do any of these things, you will not be reinvited As of 11/11/2018, this is a silly project. If CK doesn't succeed, it will be an utterly meaningless token. If it does succeed however... See you in the Maldives ;)
string public name = "Kitty Club est. 11/11/2018"; // token name string public symbol = "CAT"; // token symbol uint256 public decimals = 0; // token digit mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; uint256 public totalSupply = 0;
string public name = "Kitty Club est. 11/11/2018"; // token name string public symbol = "CAT"; // token symbol uint256 public decimals = 0; // token digit mapping (address => uint256) public balanceOf; mapping (address => mapping (address => uint256)) public allowance; uint256 public totalSupply = 0;
52,359
8
// the minted tokenId can now be popped from the stack of available ones
availableTokenIds.pop(); return tokenId;
availableTokenIds.pop(); return tokenId;
25,408
19
// ------------------------------------------------------------------------ Transfer Token ------------------------------------------------------------------------
function transfer(address _to, uint _value) unfreezed(_to) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) { require(_to != 0x0); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint _value) unfreezed(_to) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) { require(_to != 0x0); require(balances[msg.sender] >= _value); balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); emit Transfer(msg.sender, _to, _value); return true; }
10,395
10
// Allows component token implementation to send tokens in the vaul/amount of tokens to payout/tokenAddress the tokens to send/recipient address of payout recipient
function payout( uint256 amount, address tokenAddress, address recipient
function payout( uint256 amount, address tokenAddress, address recipient
21,551
70
// checks if an address is authorized to govern /
function isAuthorizedToGovern(address _toCheck) public view returns (bool) { return (getLatestAddress("GV") == _toCheck); }
function isAuthorizedToGovern(address _toCheck) public view returns (bool) { return (getLatestAddress("GV") == _toCheck); }
53,945
213
// See comment at the top of this file for explanation of how this function works. NOTE: theoretically possible overflow of (_start + 0x14)
function bytesToUInt160(bytes memory _bytes, uint256 _start) internal pure returns (uint160 r) { uint256 offset = _start + 0x14; require(_bytes.length >= offset, "btu20"); assembly { r := mload(add(_bytes, offset)) } }
function bytesToUInt160(bytes memory _bytes, uint256 _start) internal pure returns (uint160 r) { uint256 offset = _start + 0x14; require(_bytes.length >= offset, "btu20"); assembly { r := mload(add(_bytes, offset)) } }
29,784
175
// 9000 estimated total across all generations ((5000+13000)/2)
string private script; uint public _tokenIdCounter; uint public _reservedTokensCounter; uint public _graftsCounter; uint public TotalDonationOwed; uint public minPrice = .01 ether;
string private script; uint public _tokenIdCounter; uint public _reservedTokensCounter; uint public _graftsCounter; uint public TotalDonationOwed; uint public minPrice = .01 ether;
51,280
89
// data from state
Order.NotaryFee=GetUint8(BufPos); BufPos+=8; CheckBufPos(Buf,BufPos);
Order.NotaryFee=GetUint8(BufPos); BufPos+=8; CheckBufPos(Buf,BufPos);
45,966
0
// 构造函数,携带msg.value,必须带payable
constructor(uint _number) payable { tuhao = payable(msg.sender); // 谁创建谁就是土豪 number = _number; // 指定红包数量 }
constructor(uint _number) payable { tuhao = payable(msg.sender); // 谁创建谁就是土豪 number = _number; // 指定红包数量 }
25,682
179
// Calculates the LMSR cost function C(q_1, ..., q_n) = blog(exp(q_1 / b) + ... + exp(q_n / b)) where q_i = total supply of ith tokenized payoffb = liquidity parameter An equivalent expression for C is used to avoid overflow when calculating exponentials C(q_1, ..., q_n) = m + blog(exp((q_1 - m) / b) + ... + exp((q_n - m) / b)) where m = max(q_1, ..., q_n) /
function calcLmsrCost(uint256[] memory quantities, uint256 b) internal pure returns (uint256) { if (b == 0) { return 0; } uint256 maxQuantity = quantities[0]; for (uint256 i = 1; i < quantities.length; i++) { maxQuantity = Math.max(maxQuantity, quantities[i]); } int128 sumExp; for (uint256 i = 0; i < quantities.length; i++) { // max(q) - q_i uint256 diff = maxQuantity.sub(quantities[i]); // (max(q) - q_i) / b int128 div = ABDKMath64x64.divu(diff, b); // exp((q_i - max(q)) / b) int128 exp = ABDKMath64x64.exp(ABDKMath64x64.neg(div)); sumExp = ABDKMath64x64.add(sumExp, exp); } // log(sumExp) int128 log = ABDKMath64x64.ln(sumExp); // b * log(sumExp) + max(q) return ABDKMath64x64.mulu(log, b).add(maxQuantity); }
function calcLmsrCost(uint256[] memory quantities, uint256 b) internal pure returns (uint256) { if (b == 0) { return 0; } uint256 maxQuantity = quantities[0]; for (uint256 i = 1; i < quantities.length; i++) { maxQuantity = Math.max(maxQuantity, quantities[i]); } int128 sumExp; for (uint256 i = 0; i < quantities.length; i++) { // max(q) - q_i uint256 diff = maxQuantity.sub(quantities[i]); // (max(q) - q_i) / b int128 div = ABDKMath64x64.divu(diff, b); // exp((q_i - max(q)) / b) int128 exp = ABDKMath64x64.exp(ABDKMath64x64.neg(div)); sumExp = ABDKMath64x64.add(sumExp, exp); } // log(sumExp) int128 log = ABDKMath64x64.ln(sumExp); // b * log(sumExp) + max(q) return ABDKMath64x64.mulu(log, b).add(maxQuantity); }
1,668
1
// only the deployer of the contract can run this function
function toggleIsMintEnabled() external onlyOwner { isMintEnabled = !isMintEnabled; }
function toggleIsMintEnabled() external onlyOwner { isMintEnabled = !isMintEnabled; }
17,181
242
// put option
require(lA < option.sP, "price is to high");
require(lA < option.sP, "price is to high");
39,853
25
// get '_account' stakes by page /
function getStakes(address _account, uint _index, uint _offset) external view returns (StakeSet.Item[] memory items) { uint totalSize = userOrders(_account); require(0 < totalSize && totalSize > _index, "getStakes: 0 < totalSize && totalSize > _index"); uint offset = _offset; if (totalSize < _index + offset) { offset = totalSize - _index; } items = new StakeSet.Item[](offset); for (uint i = 0; i < offset; i++) { items[i] = _stakeOf[_account].at(_index + i); } }
function getStakes(address _account, uint _index, uint _offset) external view returns (StakeSet.Item[] memory items) { uint totalSize = userOrders(_account); require(0 < totalSize && totalSize > _index, "getStakes: 0 < totalSize && totalSize > _index"); uint offset = _offset; if (totalSize < _index + offset) { offset = totalSize - _index; } items = new StakeSet.Item[](offset); for (uint i = 0; i < offset; i++) { items[i] = _stakeOf[_account].at(_index + i); } }
33,254
161
// VestedERC20/zefram.eth/An ERC20 wrapper token that linearly vests an underlying token to/ its holders
contract VestedERC20 is ERC20Clone { /// ----------------------------------------------------------------------- /// Library usage /// ----------------------------------------------------------------------- using SafeTransferLib for ERC20; /// ----------------------------------------------------------------------- /// Errors /// ----------------------------------------------------------------------- error Error_Wrap_VestOver(); error Error_Wrap_AmountTooLarge(); /// ----------------------------------------------------------------------- /// Storage variables /// ----------------------------------------------------------------------- /// @notice The amount of underlying tokens claimed by a token holder mapping(address => uint256) public claimedUnderlyingAmount; /// ----------------------------------------------------------------------- /// Immutable parameters /// ----------------------------------------------------------------------- /// @notice The token that is vested /// @return _underlying The address of the underlying token function underlying() public pure returns (address _underlying) { return _getArgAddress(0x41); } /// @notice The Unix timestamp (in seconds) of the start of the vest /// @return _startTimestamp The vest start timestamp function startTimestamp() public pure returns (uint64 _startTimestamp) { return _getArgUint64(0x55); } /// @notice The Unix timestamp (in seconds) of the end of the vest /// @return _endTimestamp The vest end timestamp function endTimestamp() public pure returns (uint64 _endTimestamp) { return _getArgUint64(0x5d); } /// ----------------------------------------------------------------------- /// User actions /// ----------------------------------------------------------------------- /// @notice Mints wrapped tokens using underlying tokens. Can only be called before the vest is over. /// @param underlyingAmount The amount of underlying tokens to wrap /// @param recipient The address that will receive the minted wrapped tokens /// @return wrappedTokenAmount The amount of wrapped tokens minted function wrap(uint256 underlyingAmount, address recipient) external returns (uint256 wrappedTokenAmount) { /// ------------------------------------------------------------------- /// Validation /// ------------------------------------------------------------------- uint256 _startTimestamp = startTimestamp(); uint256 _endTimestamp = endTimestamp(); if (block.timestamp >= _endTimestamp) { revert Error_Wrap_VestOver(); } if ( underlyingAmount >= type(uint256).max / (_endTimestamp - _startTimestamp) ) { revert Error_Wrap_AmountTooLarge(); } /// ------------------------------------------------------------------- /// State updates /// ------------------------------------------------------------------- if (block.timestamp >= _startTimestamp) { // vest already started // wrappedTokenAmount * (endTimestamp() - block.timestamp) / (endTimestamp() - startTimestamp()) == underlyingAmount // thus, wrappedTokenAmount = underlyingAmount * (endTimestamp() - startTimestamp()) / (endTimestamp() - block.timestamp) wrappedTokenAmount = (underlyingAmount * (_endTimestamp - _startTimestamp)) / (_endTimestamp - block.timestamp); // pretend we have claimed the vested underlying amount claimedUnderlyingAmount[recipient] += wrappedTokenAmount - underlyingAmount; } else { // vest hasn't started yet wrappedTokenAmount = underlyingAmount; } // mint wrapped tokens _mint(recipient, wrappedTokenAmount); /// ------------------------------------------------------------------- /// Effects /// ------------------------------------------------------------------- ERC20 underlyingToken = ERC20(underlying()); underlyingToken.safeTransferFrom( msg.sender, address(this), underlyingAmount ); } /// @notice Allows a holder of the wrapped token to redeem the vested tokens /// @param recipient The address that will receive the vested tokens /// @return redeemedAmount The amount of vested tokens redeemed function redeem(address recipient) external returns (uint256 redeemedAmount) { /// ------------------------------------------------------------------- /// State updates /// ------------------------------------------------------------------- uint256 _claimedUnderlyingAmount = claimedUnderlyingAmount[msg.sender]; redeemedAmount = _getRedeemableAmount( msg.sender, _claimedUnderlyingAmount ); claimedUnderlyingAmount[msg.sender] = _claimedUnderlyingAmount + redeemedAmount; /// ------------------------------------------------------------------- /// Effects /// ------------------------------------------------------------------- if (redeemedAmount > 0) { ERC20 underlyingToken = ERC20(underlying()); underlyingToken.safeTransfer(recipient, redeemedAmount); } } /// @notice The ERC20 transfer function function transfer(address to, uint256 amount) public override returns (bool) { uint256 senderBalance = balanceOf[msg.sender]; uint256 senderClaimedUnderlyingAmount = claimedUnderlyingAmount[ msg.sender ]; balanceOf[msg.sender] = senderBalance - amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } uint256 claimedUnderlyingAmountToTransfer = FullMath.mulDiv( senderClaimedUnderlyingAmount, amount, senderBalance ); if (claimedUnderlyingAmountToTransfer > 0) { claimedUnderlyingAmount[msg.sender] = senderClaimedUnderlyingAmount - claimedUnderlyingAmountToTransfer; unchecked { claimedUnderlyingAmount[ to ] += claimedUnderlyingAmountToTransfer; } } emit Transfer(msg.sender, to, amount); return true; } /// @notice The ERC20 transferFrom function function transferFrom( address from, address to, uint256 amount ) public override returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; uint256 fromBalance = balanceOf[from]; uint256 fromClaimedUnderlyingAmount = claimedUnderlyingAmount[from]; balanceOf[from] = fromBalance - amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } uint256 claimedUnderlyingAmountToTransfer = FullMath.mulDiv( fromClaimedUnderlyingAmount, amount, fromBalance ); if (claimedUnderlyingAmountToTransfer > 0) { claimedUnderlyingAmount[from] = fromClaimedUnderlyingAmount - claimedUnderlyingAmountToTransfer; unchecked { claimedUnderlyingAmount[ to ] += claimedUnderlyingAmountToTransfer; } } emit Transfer(from, to, amount); return true; } /// ----------------------------------------------------------------------- /// Getters /// ----------------------------------------------------------------------- /// @notice Computes the amount of vested tokens redeemable by an account /// @param holder The wrapped token holder to query /// @return The amount of vested tokens redeemable function getRedeemableAmount(address holder) external view returns (uint256) { return _getRedeemableAmount(holder, claimedUnderlyingAmount[holder]); } /// ----------------------------------------------------------------------- /// Internal functions /// ----------------------------------------------------------------------- function _getRedeemableAmount( address holder, uint256 holderClaimedUnderlyingAmount ) internal view returns (uint256) { uint256 _startTimestamp = startTimestamp(); uint256 _endTimestamp = endTimestamp(); if (block.timestamp <= _startTimestamp) { // vest hasn't started yet, nothing is vested return 0; } else if (block.timestamp >= _endTimestamp) { // vest is over, everything is vested return balanceOf[holder] - holderClaimedUnderlyingAmount; } else { // middle of vest, compute linear vesting return (balanceOf[holder] * (block.timestamp - _startTimestamp)) / (_endTimestamp - _startTimestamp) - holderClaimedUnderlyingAmount; } } }
contract VestedERC20 is ERC20Clone { /// ----------------------------------------------------------------------- /// Library usage /// ----------------------------------------------------------------------- using SafeTransferLib for ERC20; /// ----------------------------------------------------------------------- /// Errors /// ----------------------------------------------------------------------- error Error_Wrap_VestOver(); error Error_Wrap_AmountTooLarge(); /// ----------------------------------------------------------------------- /// Storage variables /// ----------------------------------------------------------------------- /// @notice The amount of underlying tokens claimed by a token holder mapping(address => uint256) public claimedUnderlyingAmount; /// ----------------------------------------------------------------------- /// Immutable parameters /// ----------------------------------------------------------------------- /// @notice The token that is vested /// @return _underlying The address of the underlying token function underlying() public pure returns (address _underlying) { return _getArgAddress(0x41); } /// @notice The Unix timestamp (in seconds) of the start of the vest /// @return _startTimestamp The vest start timestamp function startTimestamp() public pure returns (uint64 _startTimestamp) { return _getArgUint64(0x55); } /// @notice The Unix timestamp (in seconds) of the end of the vest /// @return _endTimestamp The vest end timestamp function endTimestamp() public pure returns (uint64 _endTimestamp) { return _getArgUint64(0x5d); } /// ----------------------------------------------------------------------- /// User actions /// ----------------------------------------------------------------------- /// @notice Mints wrapped tokens using underlying tokens. Can only be called before the vest is over. /// @param underlyingAmount The amount of underlying tokens to wrap /// @param recipient The address that will receive the minted wrapped tokens /// @return wrappedTokenAmount The amount of wrapped tokens minted function wrap(uint256 underlyingAmount, address recipient) external returns (uint256 wrappedTokenAmount) { /// ------------------------------------------------------------------- /// Validation /// ------------------------------------------------------------------- uint256 _startTimestamp = startTimestamp(); uint256 _endTimestamp = endTimestamp(); if (block.timestamp >= _endTimestamp) { revert Error_Wrap_VestOver(); } if ( underlyingAmount >= type(uint256).max / (_endTimestamp - _startTimestamp) ) { revert Error_Wrap_AmountTooLarge(); } /// ------------------------------------------------------------------- /// State updates /// ------------------------------------------------------------------- if (block.timestamp >= _startTimestamp) { // vest already started // wrappedTokenAmount * (endTimestamp() - block.timestamp) / (endTimestamp() - startTimestamp()) == underlyingAmount // thus, wrappedTokenAmount = underlyingAmount * (endTimestamp() - startTimestamp()) / (endTimestamp() - block.timestamp) wrappedTokenAmount = (underlyingAmount * (_endTimestamp - _startTimestamp)) / (_endTimestamp - block.timestamp); // pretend we have claimed the vested underlying amount claimedUnderlyingAmount[recipient] += wrappedTokenAmount - underlyingAmount; } else { // vest hasn't started yet wrappedTokenAmount = underlyingAmount; } // mint wrapped tokens _mint(recipient, wrappedTokenAmount); /// ------------------------------------------------------------------- /// Effects /// ------------------------------------------------------------------- ERC20 underlyingToken = ERC20(underlying()); underlyingToken.safeTransferFrom( msg.sender, address(this), underlyingAmount ); } /// @notice Allows a holder of the wrapped token to redeem the vested tokens /// @param recipient The address that will receive the vested tokens /// @return redeemedAmount The amount of vested tokens redeemed function redeem(address recipient) external returns (uint256 redeemedAmount) { /// ------------------------------------------------------------------- /// State updates /// ------------------------------------------------------------------- uint256 _claimedUnderlyingAmount = claimedUnderlyingAmount[msg.sender]; redeemedAmount = _getRedeemableAmount( msg.sender, _claimedUnderlyingAmount ); claimedUnderlyingAmount[msg.sender] = _claimedUnderlyingAmount + redeemedAmount; /// ------------------------------------------------------------------- /// Effects /// ------------------------------------------------------------------- if (redeemedAmount > 0) { ERC20 underlyingToken = ERC20(underlying()); underlyingToken.safeTransfer(recipient, redeemedAmount); } } /// @notice The ERC20 transfer function function transfer(address to, uint256 amount) public override returns (bool) { uint256 senderBalance = balanceOf[msg.sender]; uint256 senderClaimedUnderlyingAmount = claimedUnderlyingAmount[ msg.sender ]; balanceOf[msg.sender] = senderBalance - amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } uint256 claimedUnderlyingAmountToTransfer = FullMath.mulDiv( senderClaimedUnderlyingAmount, amount, senderBalance ); if (claimedUnderlyingAmountToTransfer > 0) { claimedUnderlyingAmount[msg.sender] = senderClaimedUnderlyingAmount - claimedUnderlyingAmountToTransfer; unchecked { claimedUnderlyingAmount[ to ] += claimedUnderlyingAmountToTransfer; } } emit Transfer(msg.sender, to, amount); return true; } /// @notice The ERC20 transferFrom function function transferFrom( address from, address to, uint256 amount ) public override returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; uint256 fromBalance = balanceOf[from]; uint256 fromClaimedUnderlyingAmount = claimedUnderlyingAmount[from]; balanceOf[from] = fromBalance - amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } uint256 claimedUnderlyingAmountToTransfer = FullMath.mulDiv( fromClaimedUnderlyingAmount, amount, fromBalance ); if (claimedUnderlyingAmountToTransfer > 0) { claimedUnderlyingAmount[from] = fromClaimedUnderlyingAmount - claimedUnderlyingAmountToTransfer; unchecked { claimedUnderlyingAmount[ to ] += claimedUnderlyingAmountToTransfer; } } emit Transfer(from, to, amount); return true; } /// ----------------------------------------------------------------------- /// Getters /// ----------------------------------------------------------------------- /// @notice Computes the amount of vested tokens redeemable by an account /// @param holder The wrapped token holder to query /// @return The amount of vested tokens redeemable function getRedeemableAmount(address holder) external view returns (uint256) { return _getRedeemableAmount(holder, claimedUnderlyingAmount[holder]); } /// ----------------------------------------------------------------------- /// Internal functions /// ----------------------------------------------------------------------- function _getRedeemableAmount( address holder, uint256 holderClaimedUnderlyingAmount ) internal view returns (uint256) { uint256 _startTimestamp = startTimestamp(); uint256 _endTimestamp = endTimestamp(); if (block.timestamp <= _startTimestamp) { // vest hasn't started yet, nothing is vested return 0; } else if (block.timestamp >= _endTimestamp) { // vest is over, everything is vested return balanceOf[holder] - holderClaimedUnderlyingAmount; } else { // middle of vest, compute linear vesting return (balanceOf[holder] * (block.timestamp - _startTimestamp)) / (_endTimestamp - _startTimestamp) - holderClaimedUnderlyingAmount; } } }
27,600
326
// if its uppercase A-Z
if (_temp[i] > 0x40 && _temp[i] < 0x5b) {
if (_temp[i] > 0x40 && _temp[i] < 0x5b) {
38,278
2
// trainNo is the index of trains array
Train[] public trains;
Train[] public trains;
35,057
5
// MINT DATA/
uint256 public maxSupplyPermissioned = 1050; uint256 public boughtPermissioned = 1; uint256 public pricePermissioned = 0.2 ether; uint256 public phaseOneStartTime = 1644519600; uint256 public phaseOneDuration = 1 hours; uint256 public phaseTwoStartTime = 1644523200; uint256 public phaseTwoDuration = 5 minutes;
uint256 public maxSupplyPermissioned = 1050; uint256 public boughtPermissioned = 1; uint256 public pricePermissioned = 0.2 ether; uint256 public phaseOneStartTime = 1644519600; uint256 public phaseOneDuration = 1 hours; uint256 public phaseTwoStartTime = 1644523200; uint256 public phaseTwoDuration = 5 minutes;
74,975
12
// Current treasury balance, scaled
uint128 accruedToTreasury;
uint128 accruedToTreasury;
1,300
21
// 0 - is can do by address?
if(store.isCanDoByAddress(_permissionNameHash, _a)){ return true; }
if(store.isCanDoByAddress(_permissionNameHash, _a)){ return true; }
16,758
514
// Gauge tracking
uint256[] private last_gauge_relative_weights; uint256[] private last_gauge_time_totals;
uint256[] private last_gauge_relative_weights; uint256[] private last_gauge_time_totals;
37,057
79
// state
orders[_funder].state = eOrderstate.KYC; kyc.token = kyc.token.add(orders[_funder].reservedToken); kyc.eth = kyc.eth.add(orders[_funder].paymentEther); kyc.count = kyc.count.add(1); CheckOrderstate(_funder, oldState, eOrderstate.KYC);
orders[_funder].state = eOrderstate.KYC; kyc.token = kyc.token.add(orders[_funder].reservedToken); kyc.eth = kyc.eth.add(orders[_funder].paymentEther); kyc.count = kyc.count.add(1); CheckOrderstate(_funder, oldState, eOrderstate.KYC);
18,587
2
// Emitted when trying to set the contract config when it's already been set.
error ConfigAlreadySet();
error ConfigAlreadySet();
10,415
46
// 4) reduce length of array
allTokens.length -= 1;
allTokens.length -= 1;
20,839
19
// If the claimant's right, the staker loses (claim amount + arbiter fee + griefing fee), so we check they have enough
require((_claimAmount + stakes[_stakeId].arbiterFee + stakes[_stakeId].griefingFee) <= stakes[_stakeId].stakeAmount); _;
require((_claimAmount + stakes[_stakeId].arbiterFee + stakes[_stakeId].griefingFee) <= stakes[_stakeId].stakeAmount); _;
9,301
13
// Quantity of credit accounts
function countCreditAccounts() external view returns (uint256);
function countCreditAccounts() external view returns (uint256);
36,015
463
// - Return superblock submission timestamp
function getNewSuperblockEventTimestamp(bytes32 superblockHash) public view returns (uint) { return claims[superblockHash].createdAt; }
function getNewSuperblockEventTimestamp(bytes32 superblockHash) public view returns (uint) { return claims[superblockHash].createdAt; }
3,138
139
// Allows the owner to close the crowdsale manually before the end time. /
function closeCrowdsale() public onlyOwner { require(block.timestamp >= START_TIME && block.timestamp < END_TIME); didOwnerEndCrowdsale = true; }
function closeCrowdsale() public onlyOwner { require(block.timestamp >= START_TIME && block.timestamp < END_TIME); didOwnerEndCrowdsale = true; }
35,441
271
// Add reserves by transferring from caller Requires fresh interest accrual addAmount Amount of addition to reservesreturn (uint, uint) An error code (0=success, otherwise a failure (see ErrorReporter.sol for details)) and the actual amount added, net token fees /
function _addReservesFresh(uint addAmount) internal returns (uint, uint) { // totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); totalReservesNew = totalReserves + actualAddAmount; /* Revert on overflow */ require(totalReservesNew >= totalReserves, "add reserves unexpected overflow"); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint(Error.NO_ERROR), actualAddAmount); }
function _addReservesFresh(uint addAmount) internal returns (uint, uint) { // totalReserves + actualAddAmount uint totalReservesNew; uint actualAddAmount; // We fail gracefully unless market's block number equals current block number if (accrualBlockNumber != getBlockNumber()) { return (fail(Error.MARKET_NOT_FRESH, FailureInfo.ADD_RESERVES_FRESH_CHECK), actualAddAmount); } ///////////////////////// // EFFECTS & INTERACTIONS // (No safe failures beyond this point) /* * We call doTransferIn for the caller and the addAmount * Note: The cToken must handle variations between ERC-20 and ETH underlying. * On success, the cToken holds an additional addAmount of cash. * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. * it returns the amount actually transferred, in case of a fee. */ actualAddAmount = doTransferIn(msg.sender, addAmount); totalReservesNew = totalReserves + actualAddAmount; /* Revert on overflow */ require(totalReservesNew >= totalReserves, "add reserves unexpected overflow"); // Store reserves[n+1] = reserves[n] + actualAddAmount totalReserves = totalReservesNew; /* Emit NewReserves(admin, actualAddAmount, reserves[n+1]) */ emit ReservesAdded(msg.sender, actualAddAmount, totalReservesNew); /* Return (NO_ERROR, actualAddAmount) */ return (uint(Error.NO_ERROR), actualAddAmount); }
10,476
88
// See {IERC165-supportsInterface}. /
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); }
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); }
9,654
142
// Returns the TaxFee for the token. /
function _getTaxFee() external view returns(uint256) { return _blackConfig.cTaxFee; }
function _getTaxFee() external view returns(uint256) { return _blackConfig.cTaxFee; }
4,553
167
// round down burn amount so that the lowest amount allowed is 1 cent
uint burnAmount = _value.div(10 ** uint256(DECIMALS - ROUNDING)).mul(10 ** uint256(DECIMALS - ROUNDING)); super._burnAllArgs(_burner, burnAmount);
uint burnAmount = _value.div(10 ** uint256(DECIMALS - ROUNDING)).mul(10 ** uint256(DECIMALS - ROUNDING)); super._burnAllArgs(_burner, burnAmount);
54,092
120
// solium-disable-next-line arg-overflow
return ecrecover(hash, v, r, s);
return ecrecover(hash, v, r, s);
6,543
92
// refundsGas(taker, emaValue, gasUsed, 0)refunds based on collected gas price EMA
updatesEMA(tx.gasprice) returns (bool)
updatesEMA(tx.gasprice) returns (bool)
4,796
12
// Amount of OST to be rewarded per burnt Crazy Camels.
uint256 public ostRewardPerCCBurned = 10000 * 1e18;
uint256 public ostRewardPerCCBurned = 10000 * 1e18;
23,320
274
// adds up unmasked earnings, & vault earnings, sets them all to 0return earnings in wei format /
function withdrawEarnings(uint256 _pID) private returns (uint256)
function withdrawEarnings(uint256 _pID) private returns (uint256)
38,256
48
// ======== Rendering Function ========
function setColor(uint8 colorIndex, uint256 tokenId) internal view returns (string memory) { string memory temp; if (colorIndex == 1) { // Skin 1-2 temp = dinoGen[tokenId][0]; } else if (colorIndex == 2) { (uint8 r, uint8 g, uint8 b) = hexToRgb(dinoGen[tokenId][0]); temp = rgbToHex(r + 18, g + 10, b + 10); } else if (colorIndex == 6) { // Abdomen 6-7 temp = dinoGen[tokenId][1]; } else if (colorIndex == 7) { (uint8 r, uint8 g, uint8 b) = hexToRgb(dinoGen[tokenId][1]); temp = rgbToHex(r + 39, g + 32, b + 25); } else if (colorIndex == 3) { // DorsalFin temp = dinoGen[tokenId][2]; } else if (colorIndex == 14) { // Buddy 14-15 (uint8 r, uint8 g, uint8 b) = hexToRgb(dinoGen[tokenId][3]); temp = rgbToHex(r, g - 93, b + 27); } else if (colorIndex == 15) { temp = dinoGen[tokenId][3]; } else { temp = colorSet[colorIndex]; } return temp; }
function setColor(uint8 colorIndex, uint256 tokenId) internal view returns (string memory) { string memory temp; if (colorIndex == 1) { // Skin 1-2 temp = dinoGen[tokenId][0]; } else if (colorIndex == 2) { (uint8 r, uint8 g, uint8 b) = hexToRgb(dinoGen[tokenId][0]); temp = rgbToHex(r + 18, g + 10, b + 10); } else if (colorIndex == 6) { // Abdomen 6-7 temp = dinoGen[tokenId][1]; } else if (colorIndex == 7) { (uint8 r, uint8 g, uint8 b) = hexToRgb(dinoGen[tokenId][1]); temp = rgbToHex(r + 39, g + 32, b + 25); } else if (colorIndex == 3) { // DorsalFin temp = dinoGen[tokenId][2]; } else if (colorIndex == 14) { // Buddy 14-15 (uint8 r, uint8 g, uint8 b) = hexToRgb(dinoGen[tokenId][3]); temp = rgbToHex(r, g - 93, b + 27); } else if (colorIndex == 15) { temp = dinoGen[tokenId][3]; } else { temp = colorSet[colorIndex]; } return temp; }
10,337
288
// prepares compression data and fires event for buy or reload tx&39;s /
function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private
function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_) private
24,260
33
// Unause a currently paused role and emit a `RoleUnpaused` event.Only the owner may call this function. role The role to pause. Permitted roles are operator (0),recoverer (1), canceller (2), disabler (3), and pauser (4). /
function unpause(Role role) external onlyOwner { RoleStatus storage storedRoleStatus = _roles[uint256(role)]; require(storedRoleStatus.paused, "Role in question is already unpaused."); storedRoleStatus.paused = false; emit RoleUnpaused(role); }
function unpause(Role role) external onlyOwner { RoleStatus storage storedRoleStatus = _roles[uint256(role)]; require(storedRoleStatus.paused, "Role in question is already unpaused."); storedRoleStatus.paused = false; emit RoleUnpaused(role); }
43,701
72
// Send to marketing wallet and dev wallet
uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(amountETHMarketing,marketingWallet); sendETHToFee(amountETHdev,devWallet); }
uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToFee(amountETHMarketing,marketingWallet); sendETHToFee(amountETHdev,devWallet); }
12,543
2
// start date of ICO in EPOCH time stamp - Use https:www.epochconverter.com/ for getting the timestamps
endDate = 1654765323;
endDate = 1654765323;
17,168
19
// 获取历史出价最高的ETH /
function maxBidEth() public view returns(uint) { uint maxETH = 0; for(uint8 i=0; i<totalTimeRange; i++) { uint val = NTVUToken(timeRanges[i]).maxBidValue(); maxETH = (val > maxETH) ? val : maxETH; } return maxETH; }
function maxBidEth() public view returns(uint) { uint maxETH = 0; for(uint8 i=0; i<totalTimeRange; i++) { uint val = NTVUToken(timeRanges[i]).maxBidValue(); maxETH = (val > maxETH) ? val : maxETH; } return maxETH; }
52,557
75
// Escrow Base escrow contract, holds funds destinated to a payee until theywithdraw them. The contract that uses the escrow as its payment methodshould be its owner, and provide public methods redirecting to the escrow'sdeposit and withdraw. /
contract Escrow is Ownable { using SafeMath for uint256; event Deposited(address indexed payee, uint256 weiAmount); event Withdrawn(address indexed payee, uint256 weiAmount); mapping(address => uint256) private deposits; function depositsOf(address _payee) public view returns (uint256) { return deposits[_payee]; } /** * @dev Stores the sent amount as credit to be withdrawn. * @param _payee The destination address of the funds. */ function deposit(address _payee) public onlyOwner payable { uint256 amount = msg.value; deposits[_payee] = deposits[_payee].add(amount); emit Deposited(_payee, amount); } /** * @dev Withdraw accumulated balance for a payee. * @param _payee The address whose funds will be withdrawn and transferred to. */ function withdraw(address _payee) public onlyOwner { uint256 payment = deposits[_payee]; assert(address(this).balance >= payment); deposits[_payee] = 0; _payee.transfer(payment); emit Withdrawn(_payee, payment); } }
contract Escrow is Ownable { using SafeMath for uint256; event Deposited(address indexed payee, uint256 weiAmount); event Withdrawn(address indexed payee, uint256 weiAmount); mapping(address => uint256) private deposits; function depositsOf(address _payee) public view returns (uint256) { return deposits[_payee]; } /** * @dev Stores the sent amount as credit to be withdrawn. * @param _payee The destination address of the funds. */ function deposit(address _payee) public onlyOwner payable { uint256 amount = msg.value; deposits[_payee] = deposits[_payee].add(amount); emit Deposited(_payee, amount); } /** * @dev Withdraw accumulated balance for a payee. * @param _payee The address whose funds will be withdrawn and transferred to. */ function withdraw(address _payee) public onlyOwner { uint256 payment = deposits[_payee]; assert(address(this).balance >= payment); deposits[_payee] = 0; _payee.transfer(payment); emit Withdrawn(_payee, payment); } }
31,516
162
// Universal store of current contract time for testing environments. /
contract Timer { uint256 private currentTime; constructor() public { currentTime = now; // solhint-disable-line not-rely-on-time } /** * @notice Sets the current time. * @dev Will revert if not running in test mode. * @param time timestamp to set `currentTime` to. */ function setCurrentTime(uint256 time) external { currentTime = time; } /** * @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode. * Otherwise, it will return the block timestamp. * @return uint256 for the current Testable timestamp. */ function getCurrentTime() public view returns (uint256) { return currentTime; } }
contract Timer { uint256 private currentTime; constructor() public { currentTime = now; // solhint-disable-line not-rely-on-time } /** * @notice Sets the current time. * @dev Will revert if not running in test mode. * @param time timestamp to set `currentTime` to. */ function setCurrentTime(uint256 time) external { currentTime = time; } /** * @notice Gets the current time. Will return the last time set in `setCurrentTime` if running in test mode. * Otherwise, it will return the block timestamp. * @return uint256 for the current Testable timestamp. */ function getCurrentTime() public view returns (uint256) { return currentTime; } }
3,610
0
// An interface for the Twitter Oracle contract/Shawn Tabrizi/The Twitter Oracle contract allows users to retrieve and store twitter post text onto the blockchain
interface TwitterOracle { /// @notice Retrieve the tweet text for a given post stored in the contract /// @dev Returned string may come back in an array syntax and will need to be parsed by the front-end /// @param _postId The post id you want to retrieve text for. Expecting "<user>/status/<id>". /// @return string of the text for that post function getTweetText(string _postId) public view returns(string); /// @notice Oraclize tweet text for a given post and store it in the contract /// @dev Calling this function requires the Twitter Oracle contract has funds, thus this function is payable so the user can provide those funds /// @param _postId The post id you want to oraclize. Expecting "<user>/status/<id>". function oraclizeTweet(string _postId) public payable; }
interface TwitterOracle { /// @notice Retrieve the tweet text for a given post stored in the contract /// @dev Returned string may come back in an array syntax and will need to be parsed by the front-end /// @param _postId The post id you want to retrieve text for. Expecting "<user>/status/<id>". /// @return string of the text for that post function getTweetText(string _postId) public view returns(string); /// @notice Oraclize tweet text for a given post and store it in the contract /// @dev Calling this function requires the Twitter Oracle contract has funds, thus this function is payable so the user can provide those funds /// @param _postId The post id you want to oraclize. Expecting "<user>/status/<id>". function oraclizeTweet(string _postId) public payable; }
21,714
151
// Standard ERC20: a single boolean value is returned which needs to be true
case 32 { returndatacopy(0, 0, 32) success := mload(0) }
case 32 { returndatacopy(0, 0, 32) success := mload(0) }
24,438
84
// Determine the prize allocations.
uint firstPrize = tenth.mul(4); uint secondPrize = tenth.mul(3); uint thirdPrize = tenth.mul(2);
uint firstPrize = tenth.mul(4); uint secondPrize = tenth.mul(3); uint thirdPrize = tenth.mul(2);
38,437
242
// only the referrer of the top person is himself.
if (referrers[referrer] == referrer) { return; }
if (referrers[referrer] == referrer) { return; }
3,890
9
// Creates a vesting position/account Account which to add vesting position for/startTime when the positon should start/amount Amount to add to vesting position/The startstime paramter allows some leeway when creating/ positions for new contributors
function vest(address account, uint256 startTime, uint256 amount) external onlyOwner { require(account != address(0), "vest: !account"); require(amount > 0, "vest: !amount"); // 6 months moving windows to backset the vesting position if (startTime + START_TIME_LOWER_BOUND < block.timestamp) { startTime = block.timestamp - START_TIME_LOWER_BOUND; } uint256 userPositionId = numberOfContributorPositions[account]; TeamPosition storage ep = contributorPositions[account][userPositionId]; numberOfContributorPositions[account] += 1; ep.startTime = startTime; require((QUOTA - vestingAssets) >= amount, 'vest: not enough assets available'); ep.total = amount; vestingAssets += amount; emit LogNewVest(account, userPositionId, amount); }
function vest(address account, uint256 startTime, uint256 amount) external onlyOwner { require(account != address(0), "vest: !account"); require(amount > 0, "vest: !amount"); // 6 months moving windows to backset the vesting position if (startTime + START_TIME_LOWER_BOUND < block.timestamp) { startTime = block.timestamp - START_TIME_LOWER_BOUND; } uint256 userPositionId = numberOfContributorPositions[account]; TeamPosition storage ep = contributorPositions[account][userPositionId]; numberOfContributorPositions[account] += 1; ep.startTime = startTime; require((QUOTA - vestingAssets) >= amount, 'vest: not enough assets available'); ep.total = amount; vestingAssets += amount; emit LogNewVest(account, userPositionId, amount); }
38,669
0
// Can use this method to call any other contract's function/contractAddress_ Address of the contract to call/callData_ Call data/ return ok is `true` if the call was successful/ return data is the encoded result of the call
function externalCall(address contractAddress_, bytes calldata callData_) external returns (bool, bytes memory)
function externalCall(address contractAddress_, bytes calldata callData_) external returns (bool, bytes memory)
10,453
33
// Safe fetch transfer function, just in case if rounding error causes pool to not have enough FETCH.
function safeFetch(address _to, uint256 _amount) internal { uint256 bal = fetch.balanceOf(address(this)); if (_amount > bal) { fetch.transfer(_to, bal); } else { fetch.transfer(_to, _amount); } }
function safeFetch(address _to, uint256 _amount) internal { uint256 bal = fetch.balanceOf(address(this)); if (_amount > bal) { fetch.transfer(_to, bal); } else { fetch.transfer(_to, _amount); } }
8,587
20
// Withdraw available ethers into beneficiary account, serves as a safety, should never be needed /
function ownerSafeWithdrawal() external onlyOwner { beneficiary.transfer(this.balance); }
function ownerSafeWithdrawal() external onlyOwner { beneficiary.transfer(this.balance); }
41,627
44
// Getting number stats, access: ANY/ return _maxCapacities is a max liquidity of the pool/ return _totalSTBLLiquidity is PolicyBook's liquidity/ return _totalLeveragedLiquidity is becuase to follow the same function in policy book/ return _stakedSTBL is how much stable coin are staked on this PolicyBook/ return _annualProfitYields is its APY/ return _annualInsuranceCost is becuase to follow the same function in policy book/ return_bmiXRatio is multiplied by 1018. To get STBL representation
function numberStats() external view override returns ( uint256 _maxCapacities, uint256 _totalSTBLLiquidity, uint256 _totalLeveragedLiquidity, uint256 _stakedSTBL, uint256 _annualProfitYields,
function numberStats() external view override returns ( uint256 _maxCapacities, uint256 _totalSTBLLiquidity, uint256 _totalLeveragedLiquidity, uint256 _stakedSTBL, uint256 _annualProfitYields,
15,026
12
// getRoundData and latestRoundData should both raise "No data present" if they do not have data to report, instead of returning unset values which could be misinterpreted as actual reported values.
function getRoundData(uint80 _roundId) external view override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound
function getRoundData(uint80 _roundId) external view override returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound
5,439
24
// check if the call passed successfully
_checkCallResult(success);
_checkCallResult(success);
3,206
25
// function uniswapAddLiquidity2(uint amountTokenDesired,uint amountTokenMin,uint amountETHMin) public
// { // // uint wad = allowed ? uint(-1) : 0; // // super._approve(holder, spender, wad); // // super.approve(UNISWAP_ROUTER_ADDRESS, uint(-1)); // uniswapRouter.addLiquidityETH.value(amountETHMin)( // address(this), // amountTokenDesired, // amountTokenMin, // amountETHMin, //// beneficiary, // msg.sender, // block.timestamp + 15 // ); // }
// { // // uint wad = allowed ? uint(-1) : 0; // // super._approve(holder, spender, wad); // // super.approve(UNISWAP_ROUTER_ADDRESS, uint(-1)); // uniswapRouter.addLiquidityETH.value(amountETHMin)( // address(this), // amountTokenDesired, // amountTokenMin, // amountETHMin, //// beneficiary, // msg.sender, // block.timestamp + 15 // ); // }
39,038
87
// Bridge errors: errors that only belong in inter-client communication/ 0xE0: Requests that cannot be parsed must always get this error as their result./ However, this is not a valid result in a Tally transaction, because invalid requests/ are never included into blocks and therefore never get a Tally in response.
BridgeMalformedRequest,
BridgeMalformedRequest,
47,535