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
31
// Checks whether NFTs can be revealed in the given execution context.
function _canReveal() internal view virtual returns (bool) { return msg.sender == owner(); }
function _canReveal() internal view virtual returns (bool) { return msg.sender == owner(); }
3,122
11
// So we don't select the same entry twice: Move the last wallet into the position that we just selected Decrease possible num wallets to select
_inputWallets[index] = _inputWallets[numWallets - 1]; numWallets--;
_inputWallets[index] = _inputWallets[numWallets - 1]; numWallets--;
9,453
17
// event
emit LogDeposit(_user, safeSub(msg.value, ethRemain), dptAmount);
emit LogDeposit(_user, safeSub(msg.value, ethRemain), dptAmount);
50,802
147
// Data that encodes the logic we have to perform inside the flash loan
struct MyCustomData { address supplyToken; uint256 supplyAmount; address borrowToken; uint256 borrowAmount; bool increasePosition; bytes exchangeDataBeforePosition; bytes exchangeDataAfterPosition; }
struct MyCustomData { address supplyToken; uint256 supplyAmount; address borrowToken; uint256 borrowAmount; bool increasePosition; bytes exchangeDataBeforePosition; bytes exchangeDataAfterPosition; }
39,075
299
// Is i(th) token enabled?
if(isEnabled) {
if(isEnabled) {
15,123
126
// Internal function that burns an amount of the token of a given account./ Update magnifiedDividendCorrections to keep dividends unchanged./account The account whose tokens will be burnt./value The amount that will be burnt.
function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add((magnifiedDividendPerShare.mul(value)).toInt256Safe() ); }
function _burn(address account, uint256 value) internal override { super._burn(account, value); magnifiedDividendCorrections[account] = magnifiedDividendCorrections[account] .add((magnifiedDividendPerShare.mul(value)).toInt256Safe() ); }
4,600
179
// https:eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
_status = _NOT_ENTERED;
36
13
// convert to 0
path[1] = WAVAX; path[2] = USDT; _router = PANGO_ROUTER; uint[] memory amountsOutToken = _router.getAmountsOut(amount, path); uint amountOutToken = amountsOutToken[amountsOutToken.length - 1]; _router.swapExactTokensForTokens(amount, amountOutToken, path, address(this), block.timestamp); liquidityAmounts[0] = amountOutToken;
path[1] = WAVAX; path[2] = USDT; _router = PANGO_ROUTER; uint[] memory amountsOutToken = _router.getAmountsOut(amount, path); uint amountOutToken = amountsOutToken[amountsOutToken.length - 1]; _router.swapExactTokensForTokens(amount, amountOutToken, path, address(this), block.timestamp); liquidityAmounts[0] = amountOutToken;
24,448
72
// Allows the Owner to add contract to mapping of contract addresses.
* Emits a {ContractUpgraded} event. * * Requirements: * * - New address is non-zero. * - Contract is not already added. * - Contract address contains code. */ function setContractsAddress(string calldata contractsName, address newContractsAddress) external onlyOwner { // check newContractsAddress is not equal to zero require(newContractsAddress != address(0), "New address is equal zero"); // create hash of contractsName bytes32 contractId = keccak256(abi.encodePacked(contractsName)); // check newContractsAddress is not equal the previous contract's address require(contracts[contractId] != newContractsAddress, "Contract is already added"); require(newContractsAddress.isContract(), "Given contract address does not contain code"); // add newContractsAddress to mapping of actual contract addresses contracts[contractId] = newContractsAddress; emit ContractUpgraded(contractsName, newContractsAddress); }
* Emits a {ContractUpgraded} event. * * Requirements: * * - New address is non-zero. * - Contract is not already added. * - Contract address contains code. */ function setContractsAddress(string calldata contractsName, address newContractsAddress) external onlyOwner { // check newContractsAddress is not equal to zero require(newContractsAddress != address(0), "New address is equal zero"); // create hash of contractsName bytes32 contractId = keccak256(abi.encodePacked(contractsName)); // check newContractsAddress is not equal the previous contract's address require(contracts[contractId] != newContractsAddress, "Contract is already added"); require(newContractsAddress.isContract(), "Given contract address does not contain code"); // add newContractsAddress to mapping of actual contract addresses contracts[contractId] = newContractsAddress; emit ContractUpgraded(contractsName, newContractsAddress); }
55,086
15
// Transfer ownership to new address. Caller must be deployer. Leaves old deployer authorized /
function transferOwnership(address payable adr) public onlyOwner { owner = adr; emit OwnershipTransferred(adr); }
function transferOwnership(address payable adr) public onlyOwner { owner = adr; emit OwnershipTransferred(adr); }
10,629
10
// PRIVATE
function _update( uint256 balance0, uint256 balance1, uint112 reserve0_, uint112 reserve1_
function _update( uint256 balance0, uint256 balance1, uint112 reserve0_, uint112 reserve1_
29,225
65
// Assuming user already approved transfer, transfer first to this contract
if (!Token(_tokenGet).transferFrom(msg.sender, this, totalValue)) { revert(); }
if (!Token(_tokenGet).transferFrom(msg.sender, this, totalValue)) { revert(); }
31,067
170
// The function updates the statistics of price sheets/ It calculates from priceInfo to the newest that is effective./ Different from `_statOneBlock()`, it may cross multiple blocks.
function _stat(MiningV1Data.State storage state, address token) external
function _stat(MiningV1Data.State storage state, address token) external
26,659
97
// MUST throw if _tokenID does not represent an NFT but if it is not NFT, owner is address(0) which means it is impossible because msg.sender is a nonzero address
require(msg.sender != _to); address prevApprovedAddress = artworkIdToTransferApproved[_tokenId]; _approveTransfer(_tokenId, _to);
require(msg.sender != _to); address prevApprovedAddress = artworkIdToTransferApproved[_tokenId]; _approveTransfer(_tokenId, _to);
37,173
314
// Returns the number of NFTs owned by `__owner`. NFTs assigned to the zero address areconsidered invalid, and this function throws for queries about the zero address. __owner Address for whom to query the balance.return Balance of _owner. /
function balanceOf( address __owner )
function balanceOf( address __owner )
22,105
27
// store in the blockNumber memory location in `metadata`
add(metadata, MEMORY_OFFSET_referenceBlockNumber),
add(metadata, MEMORY_OFFSET_referenceBlockNumber),
29,618
26
// check sufficient allowance
require( _value <= allowed[_from][msg.sender], "Value informed is invalid" ); require( isTransferValid(_from, _to, _value), "Invalid Transfer Operation" );
require( _value <= allowed[_from][msg.sender], "Value informed is invalid" ); require( isTransferValid(_from, _to, _value), "Invalid Transfer Operation" );
11,906
723
// Returns the address of a registered token./ tokenID The token's ID in this exchanges./ return tokenAddress The token's address
function getTokenAddress( uint16 tokenID ) external virtual view returns (address tokenAddress);
function getTokenAddress( uint16 tokenID ) external virtual view returns (address tokenAddress);
53,279
139
// overrides transfer function to meet tokenomics of BULL
function _transfer(address sender, address recipient, uint256 amount) internal virtual override { if (recipient == BURN_ADDRESS) { super._transfer(sender, recipient, amount); } else { // 1% of every transfer burnt uint256 burnAmount = amount.mul(1).div(100); // 99% of transfer sent to recipient uint256 sendAmount = amount.sub(burnAmount); require(amount == sendAmount + burnAmount, "BULL::transfer: Burn value invalid"); super._transfer(sender, BURN_ADDRESS, burnAmount); super._transfer(sender, recipient, sendAmount); amount = sendAmount; } }
function _transfer(address sender, address recipient, uint256 amount) internal virtual override { if (recipient == BURN_ADDRESS) { super._transfer(sender, recipient, amount); } else { // 1% of every transfer burnt uint256 burnAmount = amount.mul(1).div(100); // 99% of transfer sent to recipient uint256 sendAmount = amount.sub(burnAmount); require(amount == sendAmount + burnAmount, "BULL::transfer: Burn value invalid"); super._transfer(sender, BURN_ADDRESS, burnAmount); super._transfer(sender, recipient, sendAmount); amount = sendAmount; } }
22,050
17
// Updates the address of the price oracle. newPriceOracle The address of the new PriceOracle /
function setPriceOracle(address newPriceOracle) external;
function setPriceOracle(address newPriceOracle) external;
20,376
22
// 第一阶段开始时间
uint256 public stepOneStartTime;
uint256 public stepOneStartTime;
34,550
330
// initializes the contract and its parents /
function __Upgradeable_init() internal onlyInitializing { __AccessControl_init(); __Upgradeable_init_unchained(); }
function __Upgradeable_init() internal onlyInitializing { __AccessControl_init(); __Upgradeable_init_unchained(); }
35,188
0
// TODO mutations maximum number of random mutations per chromatid
uint8 public constant R = 5;
uint8 public constant R = 5;
11,233
3
// uint variable utilized to identify type of user 1 for admins 2 for shop owners 3 for regular shoppers
mapping (address => uint) public userType;
mapping (address => uint) public userType;
4,011
92
// freeze HXY tokens to contract from ref bonus (till maxSupply reached)
function FreezeRefFreeMint(uint amt, address ref) internal
function FreezeRefFreeMint(uint amt, address ref) internal
2,895
5
// Update mappings
delete titleIdToTokenIndex[titleId]; _burn(msg.sender, _id);
delete titleIdToTokenIndex[titleId]; _burn(msg.sender, _id);
5,637
165
// add funds
uint256 streamId = stream.getStreamId(msg.sender, StreamTypeVoting); require(streamId > 0, "not valid stream id"); xdex.approve(address(stream), pending); stream.fundsToStream(streamId, pending);
uint256 streamId = stream.getStreamId(msg.sender, StreamTypeVoting); require(streamId > 0, "not valid stream id"); xdex.approve(address(stream), pending); stream.fundsToStream(streamId, pending);
36,765
10
// swap fromToken -> CADT
uint256 tokensBought = _fillQuote(fromToken, CADT, toInvest, swapTarget, swapData);
uint256 tokensBought = _fillQuote(fromToken, CADT, toInvest, swapTarget, swapData);
56,075
27
// create token details
CarbonTrackerDetails storage trackerData = _trackerData[trackerId]; trackerData.trackee = trackee; _track(trackerId,inIds,inAmounts,outIds,outAmounts,trackerIds); super._mint(msg.sender,trackerId);
CarbonTrackerDetails storage trackerData = _trackerData[trackerId]; trackerData.trackee = trackee; _track(trackerId,inIds,inAmounts,outIds,outAmounts,trackerIds); super._mint(msg.sender,trackerId);
51,673
131
// Switch reward distribution temporarily, notify reward, switch it back
address prevRewardDistribution = INoMintRewardPool(distributionPool).rewardDistribution(); IRewardDistributionSwitcher(distributionSwitcher).setPoolRewardDistribution(distributionPool, address(this));
address prevRewardDistribution = INoMintRewardPool(distributionPool).rewardDistribution(); IRewardDistributionSwitcher(distributionSwitcher).setPoolRewardDistribution(distributionPool, address(this));
9,713
15
// ---------------------------------------------------------------------------- requires enough gas for execution ----------------------------------------------------------------------------
function() public payable { buyTokens(); }
function() public payable { buyTokens(); }
41,384
48
// An event for tracking the creation of an item group.
event ItemGroupCreated(uint256 itemGroupId, uint256 itemGroupSize, address indexed creator);
event ItemGroupCreated(uint256 itemGroupId, uint256 itemGroupSize, address indexed creator);
39,452
22
// 设置全局锁仓接口:无论任何账户,在锁仓情况向都不能进行交易是否在锁仓状态下开启owner用户和admin用户的权限 /
contract Lockable is Ownable { using SafeMath for uint; bool public lockStatus = false; mapping (address => bool) accountLockStatus; mapping (address => uint) lockStatistic; event Lock(address); event UnLock(address); event AccountLocked(address, bool); /* 条件验证:非锁仓状态 : 条件: 全局未锁仓,*/ modifier unLocked() { if (lockStatus){ revert(); } if (accountLockStatus[msg.sender]){ revert(); } _; } /* 条件验证:锁仓状态 */ modifier inLocked() { if (lockStatus){ if (accountLockStatus[msg.sender]){ revert(); } } _; } /* 设置锁仓 */ function lock() onlyOwner unLocked public returns (bool) { lockStatus = true; emit Lock(msg.sender); return true; } /* 解锁 */ function unlock() onlyOwner inLocked public returns (bool) { lockStatus = false; emit UnLock(msg.sender); return true; } /* 查询全局锁状态*/ function getLockStatus() validAddress public view returns (bool){ return lockStatus; } /* 锁定指定账户 */ function lockAccount(address _account) onlyOwner public returns (bool) { require(address(0) != _account); accountLockStatus[_account] = true; emit AccountLocked(_account, true); return true; } /* 解锁指定账户 */ function unlockAccount(address _account) onlyOwner public returns (bool) { require(address(0) != _account); accountLockStatus[_account] = false; emit AccountLocked(_account, false); return true; } /* 查询指定账户单独锁定的状态,不返回全局锁 */ function getAccountLockStatus(address _account) validAddress public view returns (bool){ require(address(0) != _account); return accountLockStatus[_account]; } /* 锁定指定账户的指定数量的JR */ function lockCount(address _account, uint _count) public { require(address(0) != _account); lockStatistic[_account] = lockStatistic[_account].add(_count); } /* 解锁指定账户的指定数量JR */ function unlockCount(address _account, uint _count) public { require(address(0) != _account); lockStatistic[_account] = lockStatistic[_account].sub(_count); } }
contract Lockable is Ownable { using SafeMath for uint; bool public lockStatus = false; mapping (address => bool) accountLockStatus; mapping (address => uint) lockStatistic; event Lock(address); event UnLock(address); event AccountLocked(address, bool); /* 条件验证:非锁仓状态 : 条件: 全局未锁仓,*/ modifier unLocked() { if (lockStatus){ revert(); } if (accountLockStatus[msg.sender]){ revert(); } _; } /* 条件验证:锁仓状态 */ modifier inLocked() { if (lockStatus){ if (accountLockStatus[msg.sender]){ revert(); } } _; } /* 设置锁仓 */ function lock() onlyOwner unLocked public returns (bool) { lockStatus = true; emit Lock(msg.sender); return true; } /* 解锁 */ function unlock() onlyOwner inLocked public returns (bool) { lockStatus = false; emit UnLock(msg.sender); return true; } /* 查询全局锁状态*/ function getLockStatus() validAddress public view returns (bool){ return lockStatus; } /* 锁定指定账户 */ function lockAccount(address _account) onlyOwner public returns (bool) { require(address(0) != _account); accountLockStatus[_account] = true; emit AccountLocked(_account, true); return true; } /* 解锁指定账户 */ function unlockAccount(address _account) onlyOwner public returns (bool) { require(address(0) != _account); accountLockStatus[_account] = false; emit AccountLocked(_account, false); return true; } /* 查询指定账户单独锁定的状态,不返回全局锁 */ function getAccountLockStatus(address _account) validAddress public view returns (bool){ require(address(0) != _account); return accountLockStatus[_account]; } /* 锁定指定账户的指定数量的JR */ function lockCount(address _account, uint _count) public { require(address(0) != _account); lockStatistic[_account] = lockStatistic[_account].add(_count); } /* 解锁指定账户的指定数量JR */ function unlockCount(address _account, uint _count) public { require(address(0) != _account); lockStatistic[_account] = lockStatistic[_account].sub(_count); } }
29,651
18
// Simulates redeem resultreturn assets Assets amount that will be obtained from the redeem with given paramsreturn redeemFee Fee for a redeem with given params sender Supposed redeem transaction sender address shares Supposed shares amount receiver Supposed assets receiver address owner Supposed shares owner /
function onRedeem(
function onRedeem(
5,615
27
// sweeps the money back out of expired chores that nobody did/ assumes onlyParents are a team and share money and don't care if one sweeps vs another/_auctionId - the expired auction to sweep.
function sweepExpiredAuction(uint256 _auctionId) public onlyParents stopInEmergency{ require(_auctionId <= auctionCount, "this auction doesn't exist"); require(auctions[_auctionId].startedAt != 0, "already been claimed"); require(block.timestamp - auctions[_auctionId].startedAt > duration, "you're too early, there's still opportunity for the kids"); require(auctions[_auctionId].buyer == address(0), "someone else already got (bid/swept) to this one"); auctions[_auctionId].buyer = msg.sender; auctions[_auctionId].startedAt = 0; auctions[_auctionId].bidAmount = 0; //not necessary but for completeness? auctions[_auctionId].seller.transfer(auctions[_auctionId].price); //send the original buyer her money back. // event AuctionSwept (uint256 auctionId, uint256 price, address sweeper); emit AuctionSwept(_auctionId, auctions[_auctionId].price, msg.sender); }
function sweepExpiredAuction(uint256 _auctionId) public onlyParents stopInEmergency{ require(_auctionId <= auctionCount, "this auction doesn't exist"); require(auctions[_auctionId].startedAt != 0, "already been claimed"); require(block.timestamp - auctions[_auctionId].startedAt > duration, "you're too early, there's still opportunity for the kids"); require(auctions[_auctionId].buyer == address(0), "someone else already got (bid/swept) to this one"); auctions[_auctionId].buyer = msg.sender; auctions[_auctionId].startedAt = 0; auctions[_auctionId].bidAmount = 0; //not necessary but for completeness? auctions[_auctionId].seller.transfer(auctions[_auctionId].price); //send the original buyer her money back. // event AuctionSwept (uint256 auctionId, uint256 price, address sweeper); emit AuctionSwept(_auctionId, auctions[_auctionId].price, msg.sender); }
8,442
6
// ---------------------------------------------------------------------------- ERC Token Standard 20 Interface https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md ----------------------------------------------------------------------------
contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
contract ERC20Interface { function totalSupply() public constant returns (uint); function balanceOf(address tokenOwner) public constant returns (uint balance); function allowance(address tokenOwner, address spender) public constant returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); }
2,790
36
// get the difference
uint256 balanceDiff = balanceAfter - balanceBefore;
uint256 balanceDiff = balanceAfter - balanceBefore;
30,055
24
// emit a Warning if we're not approved to transfer nftAddress /
function _checkTokenApproval() internal { CombMeme nftContract = CombMeme(nftAddress); if (!nftContract.isApprovedForAll(owner(), address(this))) { emit Warning("Lootbox contract is not approved for trading collectible by:", owner()); } }
function _checkTokenApproval() internal { CombMeme nftContract = CombMeme(nftAddress); if (!nftContract.isApprovedForAll(owner(), address(this))) { emit Warning("Lootbox contract is not approved for trading collectible by:", owner()); } }
1,309
67
// See {ERC2981-_setDefaultRoyalty}. /
function setDefaultRoyalty( address receiver, uint96 feeNumerator ) external onlyOwner { _setDefaultRoyalty(receiver, feeNumerator); }
function setDefaultRoyalty( address receiver, uint96 feeNumerator ) external onlyOwner { _setDefaultRoyalty(receiver, feeNumerator); }
19,121
13
// Transfer Token B from user to contract
variantToken.safeTransferFrom(msg.sender, address(this), amount);
variantToken.safeTransferFrom(msg.sender, address(this), amount);
42,240
40
// Can be called once by super owner. /
function unlock() onlyOwner public { require(locked); locked = false; emit Unlock(); }
function unlock() onlyOwner public { require(locked); locked = false; emit Unlock(); }
9,193
280
// Check if certain token id is exists. /
function exists(uint256 _tokenId) public view returns (bool) { return _exists(_tokenId); }
function exists(uint256 _tokenId) public view returns (bool) { return _exists(_tokenId); }
3,837
14
// Array with all the corresponding id's for each ERC721 token in the vault.
uint256[] public erc721TokenIds;
uint256[] public erc721TokenIds;
15,054
7
// Plug new core to the pool.lpAddress address of previously registered LPbeaconCore address of deployed core contract /
function _plugCore(address lpAddress, address beaconCore) internal { address azuroBetAddress = address(new BeaconProxy(beaconAzuroBet, "")); IAzuroBet azuroBet = IAzuroBet(azuroBetAddress); address coreAddress = address(new BeaconProxy(beaconCore, "")); ICore core = ICore(coreAddress); core.initialize(azuroBetAddress, lpAddress); core.transferOwnership(msg.sender); azuroBet.initialize(coreAddress); azuroBet.transferOwnership(msg.sender); ILP(lpAddress).addCore(coreAddress); }
function _plugCore(address lpAddress, address beaconCore) internal { address azuroBetAddress = address(new BeaconProxy(beaconAzuroBet, "")); IAzuroBet azuroBet = IAzuroBet(azuroBetAddress); address coreAddress = address(new BeaconProxy(beaconCore, "")); ICore core = ICore(coreAddress); core.initialize(azuroBetAddress, lpAddress); core.transferOwnership(msg.sender); azuroBet.initialize(coreAddress); azuroBet.transferOwnership(msg.sender); ILP(lpAddress).addCore(coreAddress); }
9,065
1
// The timestamp at which release ends
uint256 public endTimestamp;
uint256 public endTimestamp;
5,821
502
// maps function selectors to the facets that execute the functions. and maps the selectors to their position in the selectorSlots array. func selector => address facet, selector position
mapping(bytes4 => bytes32) facets;
mapping(bytes4 => bytes32) facets;
61,888
200
// Set correct size of returned array solhint-disable-next-line no-inline-assembly
assembly { mstore(array, moduleCount) }
assembly { mstore(array, moduleCount) }
26,729
159
// Pays Oracle fees in ETH to the store. To be used by contracts whose margin currency is ETH. /
function payOracleFees() external payable;
function payOracleFees() external payable;
5,504
176
// miime: Deposit the sending ETH on buying Hash calculation is expensive, so it is implemented here.
if (msg.value > 0) { depositInternal(orderInfo.orderHash, takerAddress, msg.value); }
if (msg.value > 0) { depositInternal(orderInfo.orderHash, takerAddress, msg.value); }
8,750
39
// Safe cast is not required on the times since MAX_SCHEDULED_TIME_IN_THE_FUTURE confirms the max is in range until 2106. Checking the endTime implicitly ensures that the startTime is also not too far in the future.
uint32(startTime), uint32(endTime) ); (auctionInfo.limitPerAccount, auctionInfo.totalAvailableSupply, auctionInfo.seller) = ( limitPerAccount.toUint16(),
uint32(startTime), uint32(endTime) ); (auctionInfo.limitPerAccount, auctionInfo.totalAvailableSupply, auctionInfo.seller) = ( limitPerAccount.toUint16(),
10,019
1
// ADMIN
function updateParameterAdmin(address newParameterAdmin) public { require(newParameterAdmin != address(0), "zero"); require(msg.sender == superAdmin); parameterAdmin = newParameterAdmin; }
function updateParameterAdmin(address newParameterAdmin) public { require(newParameterAdmin != address(0), "zero"); require(msg.sender == superAdmin); parameterAdmin = newParameterAdmin; }
31,320
37
// Returns whether `tokenId_` exists.
function _exists(uint256 tokenId_) internal view virtual returns (bool) { return tokenId_ < _owners.length && _owners[tokenId_] != address(0); }
function _exists(uint256 tokenId_) internal view virtual returns (bool) { return tokenId_ < _owners.length && _owners[tokenId_] != address(0); }
7,981
205
// Don't take in more collateral than the pool ceiling for this token allows
require(freeCollatBalance(col_idx).add(collateral_amount) <= pool_ceilings[col_idx], "Pool ceiling");
require(freeCollatBalance(col_idx).add(collateral_amount) <= pool_ceilings[col_idx], "Pool ceiling");
62,218
45
// Check tokens did not expire
require (now <= expirationDate);
require (now <= expirationDate);
11,529
11
// safe because `p < q` hence `_unsafeSub(p, q) > 0`
return (_unsafeSub(p, q) - 1, q);
return (_unsafeSub(p, q) - 1, q);
13,523
17
// Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _value uint256 the amount of tokens to be transferred /
function transferFrom( address _from, address _to, uint256 _value ) public returns (bool)
function transferFrom( address _from, address _to, uint256 _value ) public returns (bool)
10,063
10
// Executes either a delegatecall or a call with provided parameters/to Destination address./value Ether value./data Data payload./operation Operation type./txGas Gas to send for executing the meta transaction/ return success boolean flag indicating if the call succeeded
function _exec( address to, uint256 value, bytes memory data, Enum.Operation operation, uint256 txGas
function _exec( address to, uint256 value, bytes memory data, Enum.Operation operation, uint256 txGas
23,755
120
// Notify the reward already claimed for the current period
function notifyReward(address _token) external { _notifyReward(_token); _distributeSDT(); }
function notifyReward(address _token) external { _notifyReward(_token); _distributeSDT(); }
22,415
193
// Reserves amunt
uint256 private availableReserves;
uint256 private availableReserves;
22,002
7
// then we pass this to the strategy contract to withdraw the correct % of LP tokens (I think??)
uint beforeBal = usdc.balanceOf(address(this)); deltaNeutral.close(msg.sender, amountShares); uint afterBal = usdc.balanceOf(address(this)); _burn(msg.sender, amountShares);
uint beforeBal = usdc.balanceOf(address(this)); deltaNeutral.close(msg.sender, amountShares); uint afterBal = usdc.balanceOf(address(this)); _burn(msg.sender, amountShares);
38,900
478
// Destroy tokens
tokenCurrency.safeTransferFrom(msg.sender, address(this), tokensLiquidated.rawValue); tokenCurrency.burn(tokensLiquidated.rawValue);
tokenCurrency.safeTransferFrom(msg.sender, address(this), tokensLiquidated.rawValue); tokenCurrency.burn(tokensLiquidated.rawValue);
5,823
15
// returns info list of ALL claims
function allClaims(uint256 offset, uint256 limit) external view returns (AllClaimInfo[] memory _allClaimsInfo);
function allClaims(uint256 offset, uint256 limit) external view returns (AllClaimInfo[] memory _allClaimsInfo);
47,383
281
// Updates the api uri of a FRight tokenReconstructs and saves the uri from the FRight metadatameta : Metadata of a FRight id/
function _updateTokenURI(Metadata storage meta) private { string memory _tokenURI = ExtendedStrings.strConcat( ExtendedStrings.strConcat("f/", ExtendedStrings.address2str(meta.baseAssetAddress), "/", ExtendedStrings.uint2str(meta.baseAssetId), "/"), ExtendedStrings.strConcat(ExtendedStrings.uint2str(meta.endTime), "/", ExtendedStrings.bool2str(meta.isExclusive), "/"), ExtendedStrings.strConcat(ExtendedStrings.uint2str(meta.maxISupply), "/", ExtendedStrings.uint2str(meta.circulatingISupply) , "/", ExtendedStrings.uint2str(meta.version)) ); _setTokenURI(meta.tokenId, _tokenURI); }
function _updateTokenURI(Metadata storage meta) private { string memory _tokenURI = ExtendedStrings.strConcat( ExtendedStrings.strConcat("f/", ExtendedStrings.address2str(meta.baseAssetAddress), "/", ExtendedStrings.uint2str(meta.baseAssetId), "/"), ExtendedStrings.strConcat(ExtendedStrings.uint2str(meta.endTime), "/", ExtendedStrings.bool2str(meta.isExclusive), "/"), ExtendedStrings.strConcat(ExtendedStrings.uint2str(meta.maxISupply), "/", ExtendedStrings.uint2str(meta.circulatingISupply) , "/", ExtendedStrings.uint2str(meta.version)) ); _setTokenURI(meta.tokenId, _tokenURI); }
8,055
46
// Transfer from sender to another accountto Destination addressvalue Amount of azwietokens to send/
function transfer(address to, uint256 value) public onlyWhenTransferAllowed validDestination(to) returns (bool) { return super.transfer(to, value); }
function transfer(address to, uint256 value) public onlyWhenTransferAllowed validDestination(to) returns (bool) { return super.transfer(to, value); }
44,940
83
// step 4.c: add the selected trait to the accumulated layers
fenotype[i] = genotype[genotypeIndex];
fenotype[i] = genotype[genotypeIndex];
51,748
167
// See {IERC777-operatorBurn}. Emits {Burned} and {IERC20-Transfer} events. /
function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public virtual override { require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder"); _burn(account, amount, data, operatorData); }
function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public virtual override { require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder"); _burn(account, amount, data, operatorData); }
2,855
0
// Information stored for each address
mapping (address => uint256) public _burntBalances; mapping (address => uint256) public _unclaimedBalances; mapping (address => uint256) public _timeOfLastBurnChange;
mapping (address => uint256) public _burntBalances; mapping (address => uint256) public _unclaimedBalances; mapping (address => uint256) public _timeOfLastBurnChange;
14,389
53
// if no balance found just skip
if (erc20Balance == 0) { continue; }
if (erc20Balance == 0) { continue; }
51,127
661
// [Batched] version of {burn}.Requirements:- `_ids` and `_amounts` must have the same length. /
function burnBatch( address _account, uint256[] memory _ids, uint256[] memory _amounts ) external onlyPermit { require(_account != address(0), Errors.VL_ZERO_ADDR_1155); require(_ids.length == _amounts.length, Errors.VL_INPUT_ERROR); address operator = _msgSender();
function burnBatch( address _account, uint256[] memory _ids, uint256[] memory _amounts ) external onlyPermit { require(_account != address(0), Errors.VL_ZERO_ADDR_1155); require(_ids.length == _amounts.length, Errors.VL_INPUT_ERROR); address operator = _msgSender();
39,635
25
// all functions related to food
contract FoodStore is OwnerBase { /// event event Bought(address buyer, uint32 bundles); event ContractUpgrade(address newContract); // Set in case the core contract is broken and an upgrade is required address public newContractAddress; // Price (in wei) for food uint public price = 10 finney; /// @notice function FoodStore() public { // the creator of the contract is the initial CEO ceoAddress = msg.sender; cooAddress = msg.sender; cfoAddress = msg.sender; } /// @notice customer buy food /// @param _bundles The num of food function buyFood(uint32 _bundles) external payable whenNotPaused returns (bool) { require(newContractAddress == address(0)); uint cost = _bundles * price; require(msg.value >= cost); // Return the funds. uint fundsExcess = msg.value - cost; if (fundsExcess > 1 finney) { msg.sender.transfer(fundsExcess); } emit Bought(msg.sender, _bundles); return true; } /// @dev Used to mark the smart contract as upgraded. /// @param _v2Address new address function upgradeContract(address _v2Address) external onlyCOO whenPaused { newContractAddress = _v2Address; emit ContractUpgrade(_v2Address); } // @dev Allows the CEO to capture the balance available to the contract. function withdrawBalance() external onlyCFO { address tmp = address(this); cfoAddress.transfer(tmp.balance); } }
contract FoodStore is OwnerBase { /// event event Bought(address buyer, uint32 bundles); event ContractUpgrade(address newContract); // Set in case the core contract is broken and an upgrade is required address public newContractAddress; // Price (in wei) for food uint public price = 10 finney; /// @notice function FoodStore() public { // the creator of the contract is the initial CEO ceoAddress = msg.sender; cooAddress = msg.sender; cfoAddress = msg.sender; } /// @notice customer buy food /// @param _bundles The num of food function buyFood(uint32 _bundles) external payable whenNotPaused returns (bool) { require(newContractAddress == address(0)); uint cost = _bundles * price; require(msg.value >= cost); // Return the funds. uint fundsExcess = msg.value - cost; if (fundsExcess > 1 finney) { msg.sender.transfer(fundsExcess); } emit Bought(msg.sender, _bundles); return true; } /// @dev Used to mark the smart contract as upgraded. /// @param _v2Address new address function upgradeContract(address _v2Address) external onlyCOO whenPaused { newContractAddress = _v2Address; emit ContractUpgrade(_v2Address); } // @dev Allows the CEO to capture the balance available to the contract. function withdrawBalance() external onlyCFO { address tmp = address(this); cfoAddress.transfer(tmp.balance); } }
17,623
3
// Check if an account has this role.return bool /
function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; }
function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; }
6,665
47
// the exchangeRate was scaled by 1e8, if 1e8 otoken can take out 1 USDC, the exchangeRate is currently 1e8 we want to return: how much USDC units can be taken out by 1 (1e8 units) oToken
uint256 collateralDecimals = uint256(ERC20Interface(collateral).decimals()); return cashValueInCollateral.toScaledUint(collateralDecimals, true);
uint256 collateralDecimals = uint256(ERC20Interface(collateral).decimals()); return cashValueInCollateral.toScaledUint(collateralDecimals, true);
22,344
79
// Gets the value of the current allowance specifed for that account. _owner: The account sending the funds. _spender: The account that will receive the funds. returnuint256: representing the amount the spender can spend/
function allowance(
function allowance(
1,652
41
// message unnecessarily. For custom revert reasons use {trySub}. Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow. /
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; }
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; }
1,794
16
// _bonusEndBlock The block when rewards will end
function setBonusEndBlock(uint256 _bonusEndBlock) external onlyOwner { require(_bonusEndBlock > block.number, 'new bonus end block must be greater than current'); bonusEndBlock = _bonusEndBlock; emit LogUpdatePool(bonusEndBlock, rewardPerBlock); }
function setBonusEndBlock(uint256 _bonusEndBlock) external onlyOwner { require(_bonusEndBlock > block.number, 'new bonus end block must be greater than current'); bonusEndBlock = _bonusEndBlock; emit LogUpdatePool(bonusEndBlock, rewardPerBlock); }
25,222
21
// Code generated by protoc-gen-sol. DO NOT EDIT. source: entity.proto
pragma solidity ^0.5.0;
pragma solidity ^0.5.0;
25,213
139
// Performs a swap with a single Pool. If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokenstaken from the Pool, which must be greater than or equal to `limit`. If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amount of tokenssent to the Pool, which must be less than or equal to `limit`. Internal Balance usage and the recipient are determined by the `funds` struct. Emits a `Swap` event. /
function swap(
function swap(
26,433
68
// Transfers the ownership of an NFT from one address to another address/Throws unless `msg.sender` is the current owner, an authorized/operator, or the approved address for this NFT. Throws if `_from` is/not the current owner. Throws if `_to` is the zero address. Throws if/`_tokenId` is not a valid NFT. When transfer is complete, this function/checks if `_to` is a smart contract (code size > 0). If so, it calls/`onERC721Received` on `_to` and throws if the return value is not/`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`./_from The current owner of the NFT/_to The new owner/_tokenId The NFT to transfer/_data Additional data with no specified format, sent in call
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) external payable{ require(msg.sender == CaDataContract.ownerOf(_tokenId) || ownerOperators[CaDataContract.atomOwner(_tokenId)][msg.sender] == true || msg.sender == tokenApprovals[_tokenId]); require(_from == CaDataContract.ownerOf(_tokenId) && _to != 0x0); require(_tokenId < totalSupply()); _transfer(_from, _to, _tokenId); if(_isContract(_to)) { require(ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) == ERC721_RECEIVED); } }
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes _data) external payable{ require(msg.sender == CaDataContract.ownerOf(_tokenId) || ownerOperators[CaDataContract.atomOwner(_tokenId)][msg.sender] == true || msg.sender == tokenApprovals[_tokenId]); require(_from == CaDataContract.ownerOf(_tokenId) && _to != 0x0); require(_tokenId < totalSupply()); _transfer(_from, _to, _tokenId); if(_isContract(_to)) { require(ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data) == ERC721_RECEIVED); } }
26,209
173
// Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (_mint), /
function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < currentIndex; }
function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < currentIndex; }
33,341
7
// allowance : Check approved balance /
function allowance(address tokenOwner, address spender) virtual override public view returns (uint remaining) { return allowed[tokenOwner][spender]; }
function allowance(address tokenOwner, address spender) virtual override public view returns (uint remaining) { return allowed[tokenOwner][spender]; }
24,927
88
// transfer payment to all upline from current upline
transferLevelPayment(userUpline, 1); emit RegisterUserEvent(msg.sender, userAddresses[referrerUniqueID], now);
transferLevelPayment(userUpline, 1); emit RegisterUserEvent(msg.sender, userAddresses[referrerUniqueID], now);
16,429
14
// Returns X BankX = 1 USD
function bankx_price() public view returns (uint256) { return pool_price(PriceChoice.BankX); }
function bankx_price() public view returns (uint256) { return pool_price(PriceChoice.BankX); }
36,298
7
// @who 拍卖品所属账户, 接收卖出的资产退回@rve 接收拍卖收益的账户(received)@oam 被拍卖的资产数量(out amount)@iam 预期收益资产数量(in amount)@bid 起拍价@oss 被拍卖的资产地址@iss 收益资产地址(QIAN)
function auction(address who, address rve, address oss, uint256 oam, address iss, uint256 iam, uint256 bid)
function auction(address who, address rve, address oss, uint256 oam, address iss, uint256 iam, uint256 bid)
22,767
38
// Claim pending rewards from pool. This function leaves LP tokens staked./Rewards are received directly.
function claim(uint256 pid) external stakingStarted { _updatePool(pid, 0); PoolInfo storage poolInfo = _poolInfo[pid]; UserInfo storage userInfo = _userInfo[pid][_msgSender()]; uint256 pending = ((userInfo.amount * poolInfo.accSTRFPerShare) / ACC_STRF_PRECISION) - userInfo.rewardDebt; // We want to update storage variables before tranferring tokens userInfo.rewardDebt = (userInfo.amount * poolInfo.accSTRFPerShare) / ACC_STRF_PRECISION; if (pending > 0) { // Transfer STRF rewards to user _STRFToken.mint(_msgSender(), pending); } emit Claimed(_msgSender(), pid, pending); }
function claim(uint256 pid) external stakingStarted { _updatePool(pid, 0); PoolInfo storage poolInfo = _poolInfo[pid]; UserInfo storage userInfo = _userInfo[pid][_msgSender()]; uint256 pending = ((userInfo.amount * poolInfo.accSTRFPerShare) / ACC_STRF_PRECISION) - userInfo.rewardDebt; // We want to update storage variables before tranferring tokens userInfo.rewardDebt = (userInfo.amount * poolInfo.accSTRFPerShare) / ACC_STRF_PRECISION; if (pending > 0) { // Transfer STRF rewards to user _STRFToken.mint(_msgSender(), pending); } emit Claimed(_msgSender(), pid, pending); }
3,197
55
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
_balances[account] += amount;
11,175
202
// Triggered when the contract has been initialized or reinitialized. /
event Initialized(uint8 version);
event Initialized(uint8 version);
50,044
82
// If the snipeStep is 0, then all proceeds go to the owner.
if (snipeStep == 0) { snipeStep++; snipePrice = snipePriceTable(snipeStep); snipe(tokenOwner, msg.sender, 1); (bool sent,) = payable(tokenOwner).call{ value: msg.value }("");
if (snipeStep == 0) { snipeStep++; snipePrice = snipePriceTable(snipeStep); snipe(tokenOwner, msg.sender, 1); (bool sent,) = payable(tokenOwner).call{ value: msg.value }("");
63,399
167
// Returns if a darknode was in the registered state last epoch.
function isRegisteredInPreviousEpoch(address _darknodeID) public view returns (bool) { return isRegisteredInEpoch(_darknodeID, previousEpoch); }
function isRegisteredInPreviousEpoch(address _darknodeID) public view returns (bool) { return isRegisteredInEpoch(_darknodeID, previousEpoch); }
33,825
37
// Transfers ownership of the contract to a new account (`newOwner`). /
function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
function _transferOwnership(address newOwner) internal { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; }
1,796
5
// hashed final metadata: keccak256(abi.encodePacked(_baseTokenURI)
bytes32 public immutable METADATA_HASH;
bytes32 public immutable METADATA_HASH;
29,946
12
// Emitted when the ACO Pool underlying price percentage adjust has been changed. previousUnderlyingPriceAdjustPercentage Value of the previous ACO Pool underlying price percentage adjust. newUnderlyingPriceAdjustPercentage Value of the new ACO Pool underlying price percentage adjust. /
event SetAcoPoolUnderlyingPriceAdjustPercentage(uint256 indexed previousUnderlyingPriceAdjustPercentage, uint256 indexed newUnderlyingPriceAdjustPercentage);
event SetAcoPoolUnderlyingPriceAdjustPercentage(uint256 indexed previousUnderlyingPriceAdjustPercentage, uint256 indexed newUnderlyingPriceAdjustPercentage);
25,980
5
// Try defining a separate function for owner and check if that is more efficient.
function getBalance() public view returns(uint) { if (msg.sender == owner()) { return address(this).balance; } return record[msg.sender].balance; }
function getBalance() public view returns(uint) { if (msg.sender == owner()) { return address(this).balance; } return record[msg.sender].balance; }
16,544
45
// Returns true if `operator` is approved to transfer ``account``'s tokens. See {setApprovalForAll}. /
function isApprovedForAll(address account, address operator)
function isApprovedForAll(address account, address operator)
25,878
87
// (bool tmpSuccess,) = payable(liquidityAddress).call{value: amountETH}(""); payable(liquidityAddress).transfer(amountETH);
_sendFeeETH(amountETH, amountToSwap);
_sendFeeETH(amountETH, amountToSwap);
29,351
55
// Public entry point for purchasing an edition on behalf of someone else Reverts if edition is invalid Reverts if payment not provided in full Reverts if edition is sold out Reverts if edition is not active or available /
function purchaseTo(address _to, uint256 _editionNumber) public payable whenNotPaused onlyRealEdition(_editionNumber) onlyActiveEdition(_editionNumber) onlyAvailableEdition(_editionNumber) onlyPurchaseDuringWindow(_editionNumber)
function purchaseTo(address _to, uint256 _editionNumber) public payable whenNotPaused onlyRealEdition(_editionNumber) onlyActiveEdition(_editionNumber) onlyAvailableEdition(_editionNumber) onlyPurchaseDuringWindow(_editionNumber)
32,080
7
// 查询新增锁定记录方式
function newDepositInfoMode(address _address) public view returns(uint256,bool) { uint256 length = depositInfo[_address].length; if (length == 0 ){ return (0,true); } uint256 index = 0; bool isNew = true; for (uint256 id = 0; id < length; id++) { if(depositInfo[_address][id].number == 0){ index = id; isNew = false; break; } } return (index,isNew); }
function newDepositInfoMode(address _address) public view returns(uint256,bool) { uint256 length = depositInfo[_address].length; if (length == 0 ){ return (0,true); } uint256 index = 0; bool isNew = true; for (uint256 id = 0; id < length; id++) { if(depositInfo[_address][id].number == 0){ index = id; isNew = false; break; } } return (index,isNew); }
13,153
193
// Update reward vairables for all pools. Be careful of gas spending!
function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } }
function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } }
5,263
6
// Populate the mapping for the 7th position characters
characterToTokenId[7][ "A" ] = 68445932870634034197578742840855993260306374816100593216701034676906857859072; characterToTokenId[7][ "B" ] = 68445932870634034197578742840855993260306374816100593216701034676906866247680; characterToTokenId[7][ "C" ] = 68445932870634034197578742840855993260306374816100593216701034676906874636288; characterToTokenId[7][
characterToTokenId[7][ "A" ] = 68445932870634034197578742840855993260306374816100593216701034676906857859072; characterToTokenId[7][ "B" ] = 68445932870634034197578742840855993260306374816100593216701034676906866247680; characterToTokenId[7][ "C" ] = 68445932870634034197578742840855993260306374816100593216701034676906874636288; characterToTokenId[7][
17,439
190
// emits when a new script is created
event NewScript( uint indexed scriptId, string name, string scriptCode, address creator, bool publicSale, bool whitelistSale, bool locked, bool isSealed, uint16 currentSupply,
event NewScript( uint indexed scriptId, string name, string scriptCode, address creator, bool publicSale, bool whitelistSale, bool locked, bool isSealed, uint16 currentSupply,
32,072
4
// Set comptroller's oracle to newOracle
oracle = _oracle;
oracle = _oracle;
8,147