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
22
// Give you 4 weeks after the effective date to complete the transfer.
uint32(block.timestamp + 5 weeks) );
uint32(block.timestamp + 5 weeks) );
11,122
22
// Check if a bidder is invited to Auction/Used in onlySellerOrBidder modifier and in require statements as check/ return true if invited, false if not/bidderAddress bidder address to check
function isInvitedBidder(address bidderAddress) private view returns (bool) { return bidders[bidderAddress].isInvited; }
function isInvitedBidder(address bidderAddress) private view returns (bool) { return bidders[bidderAddress].isInvited; }
14,408
89
// Sell
else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL;
else if (automatedMarketMakerPairs[to]) { removeAllFee(); _taxFee = _sellTaxFee; _liquidityFee = _sellLiquidityFee + _sellMarketingFee; buyOrSellSwitch = SELL;
514
296
// add an admin.Can only be called by contract owner. /
function approveAdmin(address admin) external;
function approveAdmin(address admin) external;
462
41
// require(_checkTp(_buildCheckTpTuple(data, trialPrice, leverage_10000)),"TradingCheckerFacet: takeProfit is not in the valid range");
require( checkSl(data.isLong, data.stopLoss, trialPrice), "TradingCheckerFacet: stopLoss is not in the valid range" ); if (data.isLong) {
require( checkSl(data.isLong, data.stopLoss, trialPrice), "TradingCheckerFacet: stopLoss is not in the valid range" ); if (data.isLong) {
30,420
133
// Find the tokenId for a given userreturn The tokenId of the NFT, else revert/
function getTokenIdFor( address _account ) external view hasValidKey(_account) returns (uint)
function getTokenIdFor( address _account ) external view hasValidKey(_account) returns (uint)
45,449
1
// Initial 4 stages
stageTimes.push(0 hours); stageTimes.push(24 hours); stageTimes.push(48 hours); stageTimes.push(72 hours);
stageTimes.push(0 hours); stageTimes.push(24 hours); stageTimes.push(48 hours); stageTimes.push(72 hours);
23,837
151
// See {IERC721Enumerable-tokenByIndex}. /
function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; }
function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; }
25,866
165
// RmaxP1 = min(TAD, RmaxP1) We need to bound this to the available channel deposit in order to not send tokens from other channels. The only case where TAD is smaller than RmaxP1 is when at least one balance proof is old.
participant1_amount = min(participant1_amount, total_available_deposit);
participant1_amount = min(participant1_amount, total_available_deposit);
14,902
269
// Constructs the ExpandedERC20. _tokenName The name which describes the new token. _tokenSymbol The ticker abbreviation of the name. Ideally < 5 chars. _tokenDecimals The number of decimals to define token precision. /
constructor( string memory _tokenName, string memory _tokenSymbol, uint8 _tokenDecimals
constructor( string memory _tokenName, string memory _tokenSymbol, uint8 _tokenDecimals
17,193
5
// ERC20Token - ERC20 base implementation /
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); 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 transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } }
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) internal allowed; function transfer(address _to, uint256 _value) public returns (bool) { require(_to != address(0)); 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 transferFrom(address _from, address _to, uint256 _value) public returns (bool) { require(_to != address(0)); require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value); balances[_to] = balances[_to].add(_value); balances[_from] = balances[_from].sub(_value); allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); emit Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) public view returns (uint256) { return balances[_owner]; } function approve(address _spender, uint256 _value) public returns (bool) { allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) public view returns (uint256) { return allowed[_owner][_spender]; } }
4,424
45
// start time must not be earlier than current time
require(_startTimestamp >= block.timestamp);
require(_startTimestamp >= block.timestamp);
46,157
207
// Allows extension to run logic during fund deactivation (destruct)/Unimplemented by default, may be overridden.
function deactivateForFund() external virtual override { return; }
function deactivateForFund() external virtual override { return; }
79,204
7
// veSOS Balance
uint256 _stakedSOS = 0; { uint256 totalSOS = vesosToken.getSOSPool(); uint256 totalShares = vesosToken.totalSupply(); uint256 _share = vesosToken.balanceOf(account); if (totalShares != 0) { _stakedSOS = _share * totalSOS / totalShares; }
uint256 _stakedSOS = 0; { uint256 totalSOS = vesosToken.getSOSPool(); uint256 totalShares = vesosToken.totalSupply(); uint256 _share = vesosToken.balanceOf(account); if (totalShares != 0) { _stakedSOS = _share * totalSOS / totalShares; }
32,551
44
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to] || (waivePurchaseFees && automatedMarketMakerPairs[from])) { takeFee = false; }
if(_isExcludedFromFees[from] || _isExcludedFromFees[to] || (waivePurchaseFees && automatedMarketMakerPairs[from])) { takeFee = false; }
6,931
121
// mapping for checking is Name busy
mapping (bytes32 => bool) public nodesNameCheck;
mapping (bytes32 => bool) public nodesNameCheck;
52,728
6
// Write the _preBytes data into the tempBytes memory 32 bytes at a time.
mstore(mc, mload(cc))
mstore(mc, mload(cc))
3,297
1
// _player;
BadAss instance = BadAss(_instance); if (instance.whoIsTheBadass() != instance.owner()) { instance.takeOwnerShip(keccak256(abi.encodePacked(temp))); if (instance.whoIsTheBadass() != instance.owner()) return true; }
BadAss instance = BadAss(_instance); if (instance.whoIsTheBadass() != instance.owner()) { instance.takeOwnerShip(keccak256(abi.encodePacked(temp))); if (instance.whoIsTheBadass() != instance.owner()) return true; }
31,392
193
// calculate ratio
uint ratio = settlePrice.sub(strikePrice) .mul(1e12) // mul by 1e12 here to avoid underflow .div(strikePrice);
uint ratio = settlePrice.sub(strikePrice) .mul(1e12) // mul by 1e12 here to avoid underflow .div(strikePrice);
41,888
1
// queried by others ({ERC165Checker}).For an implementation, see {ERC165}./ Returns true if this contract implements the interface defined by`interfaceId`. See the correspondingto learn more about how these ids are created. This function call must use less than 30 000 gas. /
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function supportsInterface(bytes4 interfaceId) external view returns (bool);
11,545
53
// a number ranging from 0 to 100
elapsedPeriods * vestingPercent
elapsedPeriods * vestingPercent
38,178
8
// ERC-20 standard token interface, as defined /
contract Token { function totalSupply() public view returns (uint256 supply); function balanceOf(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
contract Token { function totalSupply() public view returns (uint256 supply); function balanceOf(address _owner) public view returns (uint256 balance); function transfer(address _to, uint256 _value) public returns (bool success); function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); function approve(address _spender, uint256 _value) public returns (bool success); function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); }
6,106
258
// calculate gen share
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
15,888
17
// Calculate x + y.Revert on overflow.x signed 64.64-bit fixed point number y signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number /
function add (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); }
function add (int128 x, int128 y) internal pure returns (int128) { int256 result = int256(x) + y; require (result >= MIN_64x64 && result <= MAX_64x64); return int128 (result); }
55,172
379
// Check if Public Sale is Open
function isPublicSaleOpen() public view returns (bool) { return block.timestamp >= PUBLIC_SALE_START; }
function isPublicSaleOpen() public view returns (bool) { return block.timestamp >= PUBLIC_SALE_START; }
61,652
17
// Sets the tokenId's max supply value. /
function setTokenMaxSupply(uint256 id, uint256 maxSupply) external onlyOwner whenNotPaused
function setTokenMaxSupply(uint256 id, uint256 maxSupply) external onlyOwner whenNotPaused
20,959
24
// ECMUL, output to last 2 elements of `add_input`
success := staticcall(sub(gas, 2000), 7, mul_input, 0x60, mul_input, 0x40)
success := staticcall(sub(gas, 2000), 7, mul_input, 0x60, mul_input, 0x40)
11,740
22
// calls the NAV feed to update and store the current NAV/ return nav_ the current NAV
function calcUpdateNAV() external returns (uint256 nav_) { return navFeed.calcUpdateNAV(); }
function calcUpdateNAV() external returns (uint256 nav_) { return navFeed.calcUpdateNAV(); }
10,354
5
// SetStretegy that be able to executed by the worker.
function setStrategyOk(address[] calldata /*strats*/, bool /*isOk*/) external override {}
function setStrategyOk(address[] calldata /*strats*/, bool /*isOk*/) external override {}
9,993
143
// Interval of 1 to lastIndexUsed - 1
intA = intA.mod(lastIndexUsed - 1) + 1; intB = intB.mod(lastIndexUsed - 1) + 1; Entity memory entityA = indexToEntity[intA]; Entity memory entityB = indexToEntity[intB]; if (entityA._isValid && entityB._isValid) { addressToIndex[entityA._key] = intB; addressToIndex[entityB._key] = intA;
intA = intA.mod(lastIndexUsed - 1) + 1; intB = intB.mod(lastIndexUsed - 1) + 1; Entity memory entityA = indexToEntity[intA]; Entity memory entityB = indexToEntity[intB]; if (entityA._isValid && entityB._isValid) { addressToIndex[entityA._key] = intB; addressToIndex[entityB._key] = intA;
32,727
116
// |/ A distinct Uniform Resource Identifier (URI) for a given token. URIs are defined in RFC 3986. URIs are assumed to be deterministically generated based on token ID Token IDs are assumed to be represented in their hex format in URIsreturn URI string /
function uri(uint256 _id) public view returns (string memory) { return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json")); }
function uri(uint256 _id) public view returns (string memory) { return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json")); }
23,064
6
// Fulfill the request by:/ - calling back the data that the Oracle returned to the client contract/ - pay the DON for processing the request/Only callable by the Coordinator contract that is saved in the commitment/response response data from DON consensus/err error from DON consensus/juelsPerGas - current rate of juels/gas/costWithoutFulfillment - The cost of processing the request (in Juels of LINK ), without fulfillment/transmitter - The Node that transmitted the OCR report/commitment - The parameters of the request that must be held consistent between request and response time/ return fulfillResult -/ return callbackGasCostJuels -
function fulfill( bytes memory response, bytes memory err, uint96 juelsPerGas, uint96 costWithoutFulfillment, address transmitter, FunctionsResponse.Commitment memory commitment ) external returns (FunctionsResponse.FulfillResult, uint96);
function fulfill( bytes memory response, bytes memory err, uint96 juelsPerGas, uint96 costWithoutFulfillment, address transmitter, FunctionsResponse.Commitment memory commitment ) external returns (FunctionsResponse.FulfillResult, uint96);
12,744
78
// Returns the ClaimTopicsRegistry linked to the current IdentityRegistry. /
function getTopicsRegistry() public override view returns (IClaimTopicsRegistry){ return topicsRegistry; }
function getTopicsRegistry() public override view returns (IClaimTopicsRegistry){ return topicsRegistry; }
540
92
// Issue the tokens to the token sale smart contract itself, which will hold them for future refunds.
issueTokens(address(this), tokensToIssue);
issueTokens(address(this), tokensToIssue);
14,401
83
// See EIP 1155
function uri(uint256 _id) public view override returns (string memory) { return packs[_id].uri; }
function uri(uint256 _id) public view override returns (string memory) { return packs[_id].uri; }
21,075
104
// Delegates execution to the implementation contract It returns to the external caller whatever the implementation returns or forwards reverts data The raw data to delegatecallreturn The returned bytes from the delegatecall /
function delegateToImplementation(bytes memory data) public returns (bytes memory) { return delegateTo(implementation, data); }
function delegateToImplementation(bytes memory data) public returns (bytes memory) { return delegateTo(implementation, data); }
24,176
26
// 投票する/
function voteForProposal(uint256 _proposalId, bool yes) public onlyMember { require(proposalInfoes[_proposalId].proposalStatus==ProposalStatus.Voting,"Now can not vote."); require(checkVoted[_proposalId][msg.sender]==false,"Already voted."); votingInfoes[_proposalId].votingCount++; if (yes){ votingInfoes[_proposalId].yesCount++; } else{ votingInfoes[_proposalId].noCount++; } checkVoted[_proposalId][msg.sender] = true; emit VotedForProposal(msg.sender, _proposalId); }
function voteForProposal(uint256 _proposalId, bool yes) public onlyMember { require(proposalInfoes[_proposalId].proposalStatus==ProposalStatus.Voting,"Now can not vote."); require(checkVoted[_proposalId][msg.sender]==false,"Already voted."); votingInfoes[_proposalId].votingCount++; if (yes){ votingInfoes[_proposalId].yesCount++; } else{ votingInfoes[_proposalId].noCount++; } checkVoted[_proposalId][msg.sender] = true; emit VotedForProposal(msg.sender, _proposalId); }
2,971
7
// We re-use buyAmount next iteration, only assign if it is non zero
buyAmount = _buyAmount;
buyAmount = _buyAmount;
13,054
147
// Record the time the loan was closed
pynthLoans[i].timeClosed = block.timestamp;
pynthLoans[i].timeClosed = block.timestamp;
35,153
187
// This function transfers the nft from your address on the source chain to the same address on the destination chain
function traverseChains(uint16 _chainId, uint tokenId) public payable { require(msg.sender == ownerOf(tokenId), "You must own the token to traverse"); require(trustedRemoteLookup[_chainId].length > 0, "This chain is currently unavailable for travel"); // burn NFT, eliminating it from circulation on src chain _burn(tokenId); // abi.encode() the payload with the values to send bytes memory payload = abi.encode(msg.sender, tokenId); // encode adapterParams to specify more gas for the destination uint16 version = 1; bytes memory adapterParams = abi.encodePacked(version, gasForDestinationLzReceive); // get the fees we need to pay to LayerZero + Relayer to cover message delivery // you will be refunded for extra gas paid (uint messageFee, ) = endpoint.estimateFees(_chainId, address(this), payload, false, adapterParams); require(msg.value >= messageFee, "msg.value not enough to cover messageFee. Send gas for message fees"); endpoint.send{value: msg.value}( _chainId, // destination chainId trustedRemoteLookup[_chainId], // destination address of nft contract payload, // abi.encoded()'ed bytes payable(msg.sender), // refund address address(0x0), // 'zroPaymentAddress' unused for this adapterParams // txParameters ); }
function traverseChains(uint16 _chainId, uint tokenId) public payable { require(msg.sender == ownerOf(tokenId), "You must own the token to traverse"); require(trustedRemoteLookup[_chainId].length > 0, "This chain is currently unavailable for travel"); // burn NFT, eliminating it from circulation on src chain _burn(tokenId); // abi.encode() the payload with the values to send bytes memory payload = abi.encode(msg.sender, tokenId); // encode adapterParams to specify more gas for the destination uint16 version = 1; bytes memory adapterParams = abi.encodePacked(version, gasForDestinationLzReceive); // get the fees we need to pay to LayerZero + Relayer to cover message delivery // you will be refunded for extra gas paid (uint messageFee, ) = endpoint.estimateFees(_chainId, address(this), payload, false, adapterParams); require(msg.value >= messageFee, "msg.value not enough to cover messageFee. Send gas for message fees"); endpoint.send{value: msg.value}( _chainId, // destination chainId trustedRemoteLookup[_chainId], // destination address of nft contract payload, // abi.encoded()'ed bytes payable(msg.sender), // refund address address(0x0), // 'zroPaymentAddress' unused for this adapterParams // txParameters ); }
2,932
5,054
// 2528
entry "cloud-headed" : ENG_ADJECTIVE
entry "cloud-headed" : ENG_ADJECTIVE
19,140
72
// Default fee to burn is 5%
uint256 public feePercentage = 5; event Deposit( address indexed user, uint256 indexed poolId, uint256 amount ); event Withdraw( address indexed user,
uint256 public feePercentage = 5; event Deposit( address indexed user, uint256 indexed poolId, uint256 amount ); event Withdraw( address indexed user,
43,311
13
// Set mint fee/
function setMintFee(uint256 fee) external onlyOwner { emit MintFeeChanged(mintFee, fee); mintFee = fee; }
function setMintFee(uint256 fee) external onlyOwner { emit MintFeeChanged(mintFee, fee); mintFee = fee; }
32,900
101
// Owner dev fund
IERC20 naps = IERC20(0x66B3037aa8Dd64c3eF1AEE13a4D1F2509F672D1C); naps.safeTransferFrom(msg.sender,devfund,finalCost); spentNAPS[msg.sender] = spentNAPS[msg.sender].add(finalCost); NAPSlevel[msg.sender] = level; emit Boost(level);
IERC20 naps = IERC20(0x66B3037aa8Dd64c3eF1AEE13a4D1F2509F672D1C); naps.safeTransferFrom(msg.sender,devfund,finalCost); spentNAPS[msg.sender] = spentNAPS[msg.sender].add(finalCost); NAPSlevel[msg.sender] = level; emit Boost(level);
24,734
135
// we mint burned amount
MINT_COORDINATOR.mint(receiver, _tokenAmount * 10); // we do a 10x split
MINT_COORDINATOR.mint(receiver, _tokenAmount * 10); // we do a 10x split
55,086
19
// ---====== ADMINS ======---/ Get contract object by address /
mapping(address => Admin) public admins;
mapping(address => Admin) public admins;
8,761
49
// Withdraws all ether from this contract to wallet. /
function withdraw() onlyOwner external { wallet.transfer(address(this).balance); }
function withdraw() onlyOwner external { wallet.transfer(address(this).balance); }
14,772
0
// create an event
event CounterInc(uint counter);
event CounterInc(uint counter);
2,310
17
// Realistically, 264-1 is more than enough.
uint64 balance;
uint64 balance;
4,657
25
// retrieve _poolTokenAddress token balance per user per epoch
function _getUserBalancePerEpoch(address userAddress, uint128 epochId) internal view returns (uint){ return _staking.getEpochUserBalance(userAddress, _poolTokenAddress, _stakingEpochId(epochId)); }
function _getUserBalancePerEpoch(address userAddress, uint128 epochId) internal view returns (uint){ return _staking.getEpochUserBalance(userAddress, _poolTokenAddress, _stakingEpochId(epochId)); }
50,830
86
// Find the next edition number we can use
uint256 editionNumber = getNextAvailableEditionNumber(); require( kodaV2.createActiveEdition( editionNumber, 0x0, // _editionData - no edition data _params[5], //_editionType, _params[2], // _startDate, _params[3], //_endDate, _artist,
uint256 editionNumber = getNextAvailableEditionNumber(); require( kodaV2.createActiveEdition( editionNumber, 0x0, // _editionData - no edition data _params[5], //_editionType, _params[2], // _startDate, _params[3], //_endDate, _artist,
3,725
3
// Blueprint artist /
address public artist;
address public artist;
35,841
345
// Scaling the share, so we don't lose precision on division
for (uint256 i = 0; i < payees.length; i++) { uint256 scaledShares = shares_[i] * 10000; totalScaledShares += scaledShares; uint256 feeFromScaledShares = (scaledShares * feeBps) / 10000; uint256 scaledSharesMinusFee = scaledShares - feeFromScaledShares; totalScaledSharesMinusFee += scaledSharesMinusFee;
for (uint256 i = 0; i < payees.length; i++) { uint256 scaledShares = shares_[i] * 10000; totalScaledShares += scaledShares; uint256 feeFromScaledShares = (scaledShares * feeBps) / 10000; uint256 scaledSharesMinusFee = scaledShares - feeFromScaledShares; totalScaledSharesMinusFee += scaledSharesMinusFee;
19,261
30
// Sets the exit fee recipient on multiple existing pools. /
function setExitFeeRecipient(address[] calldata poolAddresses, address exitFeeRecipient) external onlyOwner { for (uint256 i = 0; i < poolAddresses.length; i++) { address poolAddress = poolAddresses[i]; require(_poolMeta[poolAddress].initialized, "ERR_POOL_NOT_FOUND"); // No not-null requirement - already in pool function. IIndexPool(poolAddress).setExitFeeRecipient(exitFeeRecipient); } }
function setExitFeeRecipient(address[] calldata poolAddresses, address exitFeeRecipient) external onlyOwner { for (uint256 i = 0; i < poolAddresses.length; i++) { address poolAddress = poolAddresses[i]; require(_poolMeta[poolAddress].initialized, "ERR_POOL_NOT_FOUND"); // No not-null requirement - already in pool function. IIndexPool(poolAddress).setExitFeeRecipient(exitFeeRecipient); } }
26,643
1
// @pseudo-public /
function createStash(string _stashName) onlyOwner returns (bool){ return _createStash(stringToBytes32(_stashName)); }
function createStash(string _stashName) onlyOwner returns (bool){ return _createStash(stringToBytes32(_stashName)); }
1,008
2
// 这是构造函数,只有当合约创建时运行
constructor() public { minter = msg.sender; }
constructor() public { minter = msg.sender; }
16,819
1,542
// 772
entry "shatterbrained" : ENG_ADJECTIVE
entry "shatterbrained" : ENG_ADJECTIVE
17,384
29
// function to set the minimal transaction amount only owner can call this function
function setMinPerTransaction(uint256 _minPerTransaction) external onlyOwner { require(_minPerTransaction <= maxPerUser, "Min per transaction must be less than max per user"); require(minPerTransaction != _minPerTransaction, "Same value already set"); emit SetMinPerTransaction(minPerTransaction, _minPerTransaction); minPerTransaction = _minPerTransaction; }
function setMinPerTransaction(uint256 _minPerTransaction) external onlyOwner { require(_minPerTransaction <= maxPerUser, "Min per transaction must be less than max per user"); require(minPerTransaction != _minPerTransaction, "Same value already set"); emit SetMinPerTransaction(minPerTransaction, _minPerTransaction); minPerTransaction = _minPerTransaction; }
41,030
7
// Returns the active state of the arena /
function getArenaActive() public view returns(bool) { return arenaActive; }
function getArenaActive() public view returns(bool) { return arenaActive; }
3,648
12
// Mints the trading bot NFT. Last step. Use 5 steps to create/initialize bot to avoid 'stack-too-deep' error. _index Index of the trading bot. /
function mintTradingBotNFT(uint256 _index) external;
function mintTradingBotNFT(uint256 _index) external;
34,523
85
// Add multiple addresses to the blacklist
function addMultipleToBlacklist(address[] memory accounts) external nonReentrant onlyOwner { for(uint i = 0; i < accounts.length; i++) { BlacklistLib.add(blacklist, accounts[i]); emit BlacklistAdded(accounts[i]); // Emitting the event for each address } }
function addMultipleToBlacklist(address[] memory accounts) external nonReentrant onlyOwner { for(uint i = 0; i < accounts.length; i++) { BlacklistLib.add(blacklist, accounts[i]); emit BlacklistAdded(accounts[i]); // Emitting the event for each address } }
28,583
53
// we can&39;t give people infinite ethereum
if (tokenSupply_ > 0) {
if (tokenSupply_ > 0) {
34,121
0
// private variables
Counters.Counter private _tokenIdCounter; string private _baseTokenURI; address private _minter;
Counters.Counter private _tokenIdCounter; string private _baseTokenURI; address private _minter;
31,102
48
// The rest are burnt
uint256 totalToBurn = totalToDeduct.mul(9).div(10); require(token.transfer(BURN_ADDRESS, calculateTotalWithDecimals(totalToBurn)), "Couldn't burn the tokens"); emit TokensBurnt(msg.sender, totalToBurn); totalStakes = totalStakes.sub(1); totalStaked = totalStaked.sub(stake.initialAmount); totalByLockup[stake.lockupPeriod] = totalByLockup[stake.lockupPeriod].sub(1); if (stake.compound) { totalCompounding = totalCompounding.sub(1);
uint256 totalToBurn = totalToDeduct.mul(9).div(10); require(token.transfer(BURN_ADDRESS, calculateTotalWithDecimals(totalToBurn)), "Couldn't burn the tokens"); emit TokensBurnt(msg.sender, totalToBurn); totalStakes = totalStakes.sub(1); totalStaked = totalStaked.sub(stake.initialAmount); totalByLockup[stake.lockupPeriod] = totalByLockup[stake.lockupPeriod].sub(1); if (stake.compound) { totalCompounding = totalCompounding.sub(1);
50,036
17
// Emitted when a proposal hash is created/committed.
event Commit( address indexed sender, uint256 indexed tokenId, bytes32[] hash, Header.Data header );
event Commit( address indexed sender, uint256 indexed tokenId, bytes32[] hash, Header.Data header );
35,755
82
// address private constant CAKE = 0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82; address private constant BUNNY = 0xC9849E6fdB743d08fAeE3E34dd2D1bc69EA11a51; address private constant WBNB = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c; address private constant BUSD = 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56; address private constant USDT = 0x55d398326f99059fF775485246999027B3197955; address private constant DAI = 0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3; address private constant USDC = 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d;
address public WBNB; IPancakeRouter02 public ROUTER; mapping(address => bool) private notFlip; address[] public tokens;
address public WBNB; IPancakeRouter02 public ROUTER; mapping(address => bool) private notFlip; address[] public tokens;
25,336
74
// token details
_NAME = _name; _SYMBOL = _symbol; _DECIMALS = 18; _DECIMALFACTOR = 10 ** _DECIMALS; _tTotal =1000 * _DECIMALFACTOR; _rTotal = (_MAX - (_MAX % _tTotal));
_NAME = _name; _SYMBOL = _symbol; _DECIMALS = 18; _DECIMALFACTOR = 10 ** _DECIMALS; _tTotal =1000 * _DECIMALFACTOR; _rTotal = (_MAX - (_MAX % _tTotal));
11,190
26
// update prices
currentPrice = sellingPrice; if(currentPrice >= stepLimit){ sellingPrice = (currentPrice * 120)/94; //adding commission amount //1.2/(1-0.06) }else{
currentPrice = sellingPrice; if(currentPrice >= stepLimit){ sellingPrice = (currentPrice * 120)/94; //adding commission amount //1.2/(1-0.06) }else{
37,496
64
// Halts token sales - Only callable by owner /
function haltTokenSales(bool _status) public onlyOwner { isHalted = _status; }
function haltTokenSales(bool _status) public onlyOwner { isHalted = _status; }
42,716
18
// 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
function add( uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate
48,662
22
// require(balances[msg.sender] >= amount1000000000000000000 );balances[msg.sender] -= amount1000000000000000000;balances[reciever] += amount1000000000000000000;
reciever.send(amount);
reciever.send(amount);
33,616
3
//
constructor(address _AggregatorAddr) public onlyOperator { //owner = msg.sender; priceFeed = AggregatorV3Interface(_AggregatorAddr); // CNY/USD (0xeF8A4aF35cd47424672E3C590aBD37FBB7A7759a) @MAINNET }
constructor(address _AggregatorAddr) public onlyOperator { //owner = msg.sender; priceFeed = AggregatorV3Interface(_AggregatorAddr); // CNY/USD (0xeF8A4aF35cd47424672E3C590aBD37FBB7A7759a) @MAINNET }
1,739
8
// bettors reveal their secret numbers, which are checked for validity against submitted hash/
function revealSecret(uint _secret) public{ //ensure that the checking entity has actually made a bet and that they are not resubmitting a secret require(bets[msg.sender].hash != 0 && bets[msg.sender].gotSecret == false); //check to make sure the time is after betting phase is over require(now < revealTimeOffset); // myhash=keccak256(_secret,msg.sender); //match the previously submitted hash to ensure that the bettor is honest require(bets[msg.sender].hash == keccak256(_secret,msg.sender)); //store secret and flag the user as submitted bets[msg.sender].secret = _secret; bets[msg.sender].gotSecret = true; secrets.push(_secret); //keep count of how many bets have been made, do it at this stage because if you don't submit an N value you lose your deposit numBettors++; }
function revealSecret(uint _secret) public{ //ensure that the checking entity has actually made a bet and that they are not resubmitting a secret require(bets[msg.sender].hash != 0 && bets[msg.sender].gotSecret == false); //check to make sure the time is after betting phase is over require(now < revealTimeOffset); // myhash=keccak256(_secret,msg.sender); //match the previously submitted hash to ensure that the bettor is honest require(bets[msg.sender].hash == keccak256(_secret,msg.sender)); //store secret and flag the user as submitted bets[msg.sender].secret = _secret; bets[msg.sender].gotSecret = true; secrets.push(_secret); //keep count of how many bets have been made, do it at this stage because if you don't submit an N value you lose your deposit numBettors++; }
50,572
46
// update the how many times this token was transfered
cryptoboy.numberOfTransfers += 1;
cryptoboy.numberOfTransfers += 1;
17,492
12
// Check and raise flags for any aggregator that has an equivalent CompoundOpen Oracle feed with a price deviation exceeding the configured setting. This contract must have write permissions on the Flags contract aggregators address[] memoryreturn address[] memory invalid aggregators /
function update(address[] memory aggregators) public returns (address[] memory) { address[] memory invalidAggregators = check(aggregators); s_flags.raiseFlags(invalidAggregators); return invalidAggregators; }
function update(address[] memory aggregators) public returns (address[] memory) { address[] memory invalidAggregators = check(aggregators); s_flags.raiseFlags(invalidAggregators); return invalidAggregators; }
4,644
26
// reports the balance of money market funds _principal is the balance with 2 decimals of precision _interest is the balance with 2 decimals of precisionreturn roundId of the new round data /
function reportBalance(uint256 _principal, uint256 _interest) external returns (uint80 roundId) { _checkOwner(); roundId = lastRoundId += 1; RoundData memory round = rounds[roundId]; if (round.answer != 0) revert RoundDataReported(); // decimals calculated as {decimals|8} + {token.decimals|6} - {principal & interest decimals|2} uint256 answer = FixedPointMathLib.mulDivDown(_principal + _interest, 1e12, token.totalSupply()); rounds[roundId] = RoundData(int256(answer), _interest, block.timestamp); // interest accrued in terms of SDYC (interest is 2 decimals, SDYC is 6 decimals) totalInterestAccrued += _interest * 1e4; emit BalanceReported(roundId, _principal, answer, block.timestamp); }
function reportBalance(uint256 _principal, uint256 _interest) external returns (uint80 roundId) { _checkOwner(); roundId = lastRoundId += 1; RoundData memory round = rounds[roundId]; if (round.answer != 0) revert RoundDataReported(); // decimals calculated as {decimals|8} + {token.decimals|6} - {principal & interest decimals|2} uint256 answer = FixedPointMathLib.mulDivDown(_principal + _interest, 1e12, token.totalSupply()); rounds[roundId] = RoundData(int256(answer), _interest, block.timestamp); // interest accrued in terms of SDYC (interest is 2 decimals, SDYC is 6 decimals) totalInterestAccrued += _interest * 1e4; emit BalanceReported(roundId, _principal, answer, block.timestamp); }
23,295
190
// Allows owner to change data store_dataStore Address of the token data store/
function changeDataStore(address _dataStore) external;
function changeDataStore(address _dataStore) external;
33,342
15
// Collect ERC20 from this contract Restricted to `TOKEN_SWEEPER_ROLE` tokenAddress address tokenAmount amount /
function sweepTokens(address tokenAddress, uint tokenAmount) external { require(hasRole(TOKEN_SWEEPER_ROLE, msg.sender), "sweepTokens::auth"); uint balance = IERC20(tokenAddress).balanceOf(address(this)); if (balance < tokenAmount) { tokenAmount = balance; } require(tokenAmount > 0, "sweepTokens::balance"); require(IERC20(tokenAddress).transfer(msg.sender, tokenAmount), "sweepTokens::transfer failed"); emit Sweep(msg.sender, tokenAddress, tokenAmount); }
function sweepTokens(address tokenAddress, uint tokenAmount) external { require(hasRole(TOKEN_SWEEPER_ROLE, msg.sender), "sweepTokens::auth"); uint balance = IERC20(tokenAddress).balanceOf(address(this)); if (balance < tokenAmount) { tokenAmount = balance; } require(tokenAmount > 0, "sweepTokens::balance"); require(IERC20(tokenAddress).transfer(msg.sender, tokenAmount), "sweepTokens::transfer failed"); emit Sweep(msg.sender, tokenAddress, tokenAmount); }
5,149
61
// We define the balances in terms of change from the the beginning of the epoch
int256 yAfterInt = yBeforeInt.sub(integral(xAfterInt.sub(xBeforeInt))); require(yAfterInt >= 0, 'IO_NEGATIVE_Y_BALANCE'); return uint256(yAfterInt).denormalize(yDecimals);
int256 yAfterInt = yBeforeInt.sub(integral(xAfterInt.sub(xBeforeInt))); require(yAfterInt >= 0, 'IO_NEGATIVE_Y_BALANCE'); return uint256(yAfterInt).denormalize(yDecimals);
52,626
28
// Reducer cannot be overwritten through this function
require(_key[0] != byte(38), "Prefix & is reserved for reducers");
require(_key[0] != byte(38), "Prefix & is reserved for reducers");
982
17
// Clear approvals from the previous owner
_approve(address(0), tokenId); amountTransferred += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId);
_approve(address(0), tokenId); amountTransferred += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId);
12,836
23
// Revert with an error if a payer is not included in the enumeration when removing. /
error PayerNotPresent();
error PayerNotPresent();
12,530
5
// Allows the current owner to transfer control of the contract to a newOwner. _newOwner The address to transfer ownership to. /
function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0), CANNOT_TRANSFER_TO_ZERO_ADDRESS); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0), CANNOT_TRANSFER_TO_ZERO_ADDRESS); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
5,299
9
// Calculate claimed and unclaimed stalk
uint256 newStalk = amount.mul(10000); uint256 unclaimedStalk = s.si.stalk.sub(s.si.increase.mul(C.getSeedsPerBean())); uint256 claimedStalk = s.s.stalk.sub(unclaimedStalk);
uint256 newStalk = amount.mul(10000); uint256 unclaimedStalk = s.si.stalk.sub(s.si.increase.mul(C.getSeedsPerBean())); uint256 claimedStalk = s.s.stalk.sub(unclaimedStalk);
33,700
206
// Calculates the funds value in deposit token (Ether) return The current total fund value/
function calculateFundValue() public override view returns (uint256) { uint256 ethBalance = address(this).balance; // If the fund only contains ether, return the funds ether balance if (tokenAddresses.length == 1) return ethBalance; // Otherwise, we get the value of all the other tokens in ether via exchangePortal // Calculate value for ERC20 address[] memory fromAddresses = new address[](tokenAddresses.length - 1); // Sub ETH uint256[] memory amounts = new uint256[](tokenAddresses.length - 1); uint index = 0; for (uint256 i = 1; i < tokenAddresses.length; i++) { fromAddresses[index] = tokenAddresses[i]; amounts[index] = IERC20(tokenAddresses[i]).balanceOf(address(this)); index++; } // Ask the Exchange Portal for the value of all the funds tokens in eth uint256 tokensValue = exchangePortal.getTotalValue( fromAddresses, amounts, address(ETH_TOKEN_ADDRESS) ); // Sum ETH + ERC20 return ethBalance + tokensValue; }
function calculateFundValue() public override view returns (uint256) { uint256 ethBalance = address(this).balance; // If the fund only contains ether, return the funds ether balance if (tokenAddresses.length == 1) return ethBalance; // Otherwise, we get the value of all the other tokens in ether via exchangePortal // Calculate value for ERC20 address[] memory fromAddresses = new address[](tokenAddresses.length - 1); // Sub ETH uint256[] memory amounts = new uint256[](tokenAddresses.length - 1); uint index = 0; for (uint256 i = 1; i < tokenAddresses.length; i++) { fromAddresses[index] = tokenAddresses[i]; amounts[index] = IERC20(tokenAddresses[i]).balanceOf(address(this)); index++; } // Ask the Exchange Portal for the value of all the funds tokens in eth uint256 tokensValue = exchangePortal.getTotalValue( fromAddresses, amounts, address(ETH_TOKEN_ADDRESS) ); // Sum ETH + ERC20 return ethBalance + tokensValue; }
3,905
3
// incentive on sender
address senderIncentive = incentiveContract[sender]; if (senderIncentive != address(0)) { IIncentive(senderIncentive).incentivize( sender, recipient, msg.sender, amount ); }
address senderIncentive = incentiveContract[sender]; if (senderIncentive != address(0)) { IIncentive(senderIncentive).incentivize( sender, recipient, msg.sender, amount ); }
63,015
45
// 已经投过票的管理员不允许再投
if(needToAddAdminInfoList[usrAddr].postedPeople[msg.sender]==123456789){ revert(); return; }
if(needToAddAdminInfoList[usrAddr].postedPeople[msg.sender]==123456789){ revert(); return; }
26,646
177
// 当调用Harvest时触发
event Harvest(address indexed token, uint amount, uint burned);
event Harvest(address indexed token, uint amount, uint burned);
37,431
32
// The Functions Router will perform the callback to the client contract
(FunctionsResponse.FulfillResult resultCode, uint96 callbackCostJuels) = _getRouter().fulfill( response, err, juelsPerGas, gasOverheadJuels + commitment.donFee, // costWithoutFulfillment msg.sender, commitment );
(FunctionsResponse.FulfillResult resultCode, uint96 callbackCostJuels) = _getRouter().fulfill( response, err, juelsPerGas, gasOverheadJuels + commitment.donFee, // costWithoutFulfillment msg.sender, commitment );
24,290
126
// Uses random number generator from timestamp. However, nobody should know what order addresses are stored due to shffle
uint randNum = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % lastEntryAllowed; Entity memory bigPrizeEligibleEntity = getEntity(randNum, false); while (bigPrizeEligibleEntity._isValid != true) {
uint randNum = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % lastEntryAllowed; Entity memory bigPrizeEligibleEntity = getEntity(randNum, false); while (bigPrizeEligibleEntity._isValid != true) {
32,715
13
// Returns the multiplication of two unsigned integers, reverting onoverflow. Counterpart to Solidity's `` operator. Requirements:- Multiplication cannot overflow. /
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; }
17,122
76
// get estimated amountOut
function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
29,393
63
// Reset the bought tokens to zero.
_boughtTokens = 0;
_boughtTokens = 0;
25,608
205
// Configures invalidTokensForSacrifices /
function configureInvalidTokensForSacrifices( uint256[] calldata _tokenIds, bool _invalid
function configureInvalidTokensForSacrifices( uint256[] calldata _tokenIds, bool _invalid
32,462
16
// Linked List of Accounts (Smart Account ID => Account Address => AccountList).
mapping(uint64 => mapping(address => AccountList)) public accountList; // account => user address => list
mapping(uint64 => mapping(address => AccountList)) public accountList; // account => user address => list
43,621
0
// amount of each token specified in withdrawAmountsand burnAmount will define the upper limit of lp tokens to burn if set to 'false' this action will burn the whole burnAmountof lp tokens and withdrawAmounts will define the lower limitof each token to withdraw
bool useUnderlying; // some contracts take this additional parameter
bool useUnderlying; // some contracts take this additional parameter
38,419
4
// return r the sum of two points of G1 /
function plus( G1Point memory p1, G1Point memory p2
function plus( G1Point memory p1, G1Point memory p2
9,879
555
// check if the transmuter holds more funds than plantableThreshold
uint256 bal = IERC20Burnable(token).balanceOf(address(this)); uint256 marginVal = plantableThreshold.mul(plantableMargin).div(100); if (bal > plantableThreshold.add(marginVal)) { uint256 plantAmt = bal - plantableThreshold;
uint256 bal = IERC20Burnable(token).balanceOf(address(this)); uint256 marginVal = plantableThreshold.mul(plantableMargin).div(100); if (bal > plantableThreshold.add(marginVal)) { uint256 plantAmt = bal - plantableThreshold;
35,714
388
// how many nigels total
uint256 constant private nigelsAvailable = 10; constructor() Hashku( "Society of the Hourglass", "SOTH", "https://storage.hashku.com/api/soth/main/", "SOTH", 8888, 20, 30,
uint256 constant private nigelsAvailable = 10; constructor() Hashku( "Society of the Hourglass", "SOTH", "https://storage.hashku.com/api/soth/main/", "SOTH", 8888, 20, 30,
1,500
16
// require(CidBuyerIdToOfferId[cid][buyerId] == 0, "");
require( offers[CidBuyerIdToOfferId[cid][buyerId]].status != OfferStatus.Accepted && offers[CidBuyerIdToOfferId[cid][buyerId]].status != OfferStatus.Opened, "Offer already exist" ); offers[nextOfferId] = Offer( offers[CidBuyerIdToOfferId[cid][buyerId]].id + 1, buyerAccessString, "none",
require( offers[CidBuyerIdToOfferId[cid][buyerId]].status != OfferStatus.Accepted && offers[CidBuyerIdToOfferId[cid][buyerId]].status != OfferStatus.Opened, "Offer already exist" ); offers[nextOfferId] = Offer( offers[CidBuyerIdToOfferId[cid][buyerId]].id + 1, buyerAccessString, "none",
22,589