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
|
---|---|---|---|---|
146 | // tokenId => total votes collected to open this closed portal | mapping(uint256 => uint256) public votesTotalOpen;
| mapping(uint256 => uint256) public votesTotalOpen;
| 55,253 |
18 | // credit to this contract first, and then transfer to receiver only if callOnOFTReceived() succeeds | if (!credited) {
amount = _creditTo(_srcChainId, address(this), amount);
creditedPackets[_srcChainId][_srcAddress][_nonce] = true;
}
| if (!credited) {
amount = _creditTo(_srcChainId, address(this), amount);
creditedPackets[_srcChainId][_srcAddress][_nonce] = true;
}
| 17,931 |
1 | // in the event of "re-recording", this is basically an edit or update | require(msg.sender == owner, "CorruptionsFAQ: not owner");
emit Record(topic, content);
| require(msg.sender == owner, "CorruptionsFAQ: not owner");
emit Record(topic, content);
| 9,808 |
36 | // remainding funds sent to beneficiary_beneficiary address to receive the remainder funds from liquidator wallet/ | function claimRemainder(address _beneficiary) external onlyManager onlyClaimRemainder onlyEnabled onlyValidAddress(_beneficiary) {
ended = true;
liquidationWallet.depositRemaindingFunds(_beneficiary);
}
| function claimRemainder(address _beneficiary) external onlyManager onlyClaimRemainder onlyEnabled onlyValidAddress(_beneficiary) {
ended = true;
liquidationWallet.depositRemaindingFunds(_beneficiary);
}
| 17,182 |
141 | // 利率乘余额 | uint256 balance = mulScalarTruncate(exchangeRate, accountTokens[owner]);
return balance;
| uint256 balance = mulScalarTruncate(exchangeRate, accountTokens[owner]);
return balance;
| 49,835 |
10 | // Add monies to pot | devFee = devFee + (msg.value / 100);
uint256 toAdd = msg.value - devFee;
hourPot = hourPot + (toAdd / 3);
dayPot = dayPot + (toAdd / 3);
weekPot = weekPot + (toAdd - ((toAdd/3) + (toAdd/3)));
| devFee = devFee + (msg.value / 100);
uint256 toAdd = msg.value - devFee;
hourPot = hourPot + (toAdd / 3);
dayPot = dayPot + (toAdd / 3);
weekPot = weekPot + (toAdd - ((toAdd/3) + (toAdd/3)));
| 36,797 |
13 | // Payout protocol fee | remainingProfit = _handleProtocolFeePayout(remainingProfit, ask.askCurrency);
if (_finder != address(0)) {
uint256 findersFee = (remainingProfit * ask.findersFeeBps) / 10000;
_handleOutgoingTransfer(_finder, findersFee, ask.askCurrency, USE_ALL_GAS_FLAG);
remainingProfit = remainingProfit - findersFee;
}
| remainingProfit = _handleProtocolFeePayout(remainingProfit, ask.askCurrency);
if (_finder != address(0)) {
uint256 findersFee = (remainingProfit * ask.findersFeeBps) / 10000;
_handleOutgoingTransfer(_finder, findersFee, ask.askCurrency, USE_ALL_GAS_FLAG);
remainingProfit = remainingProfit - findersFee;
}
| 37,980 |
1 | // deposit This method will enable root key holders to deposit eth intothe trust. This method operates as a payabletransaction where the message's value parameter is what is deposited.keyId the ID of the key that the depositor is using. token the address of the ERC20 token contract. amount the amount to deposit / | function deposit(uint256 keyId, address token, uint256 amount) external;
| function deposit(uint256 keyId, address token, uint256 amount) external;
| 14,866 |
31 | // approves proposed driveronly participants can call this function / | function approveDriver() public isParticipant {
require(!driverVotes[msg.sender], "You already voted");
taxiDriver.approvalState += 1;
driverVotes[msg.sender] = true;
}
| function approveDriver() public isParticipant {
require(!driverVotes[msg.sender], "You already voted");
taxiDriver.approvalState += 1;
driverVotes[msg.sender] = true;
}
| 13,029 |
8 | // 等级 | uint32 level;
| uint32 level;
| 3,535 |
186 | // bool withinEthCap = ethCap >= (msg.value + mainWeiRaised); | bool withinEthCap = ((ethCap.sub(mainWeiRaised))>0);
bool goldPeriodValid=true;
if(transStartTime <= (startTime + goldListPeriod)){
goldPeriodValid=(goldList[msg.sender])&&(goldListContribution[msg.sender]+msg.value <= goldPeriodCap);
goldListPeriodFlag=true;
}
| bool withinEthCap = ((ethCap.sub(mainWeiRaised))>0);
bool goldPeriodValid=true;
if(transStartTime <= (startTime + goldListPeriod)){
goldPeriodValid=(goldList[msg.sender])&&(goldListContribution[msg.sender]+msg.value <= goldPeriodCap);
goldListPeriodFlag=true;
}
| 49,822 |
0 | // Function to mint tokens/_to The address that will receive the minted tokens./_value The amount of tokens to mint./_tokenIdtoken identifer./ return A boolean that indicates if the operation was successful. | function mint(
address _to,
uint256 _value,
uint256 _tokenId
)
public
onlyMinter
whenNotPaused
returns (bool)
| function mint(
address _to,
uint256 _value,
uint256 _tokenId
)
public
onlyMinter
whenNotPaused
returns (bool)
| 23,542 |
1 | // default fallback function to prevent from sending ether to the contract / | receive() external payable {
revert("fallback revert");
}
| receive() external payable {
revert("fallback revert");
}
| 23,159 |
0 | // initial tokens generation for the liquidity | _initialSupply = 500000000*10**9;
_totalSupply = _totalSupply.add(_initialSupply);
_balances[_msgSender()] = _balances[_msgSender()].add(_initialSupply);
emit Transfer(address(0), _msgSender(), _totalSupply);
| _initialSupply = 500000000*10**9;
_totalSupply = _totalSupply.add(_initialSupply);
_balances[_msgSender()] = _balances[_msgSender()].add(_initialSupply);
emit Transfer(address(0), _msgSender(), _totalSupply);
| 28,946 |
116 | // module:reputation Voting power of an `account` at a specific `blockNumber`. Note: this can be implemented in a number of ways, for example by reading the delegated balance from one (ormultiple), {ERC20Votes} tokens. / | function getVotes(address account, uint256 blockNumber)
| function getVotes(address account, uint256 blockNumber)
| 40,573 |
10 | // try to choose a sacrifice in an already full stage (finalize a stage) | tryFinalizeStage();
| tryFinalizeStage();
| 50,921 |
610 | // NOTE: We don't use SafeMath (or similar) in this function because _currentBank max is equal ~ 20000000 finney, _totalBattles is guaranteed to be > 0 and <= 400, and (tournamentOwnersCut + tournamentIncentiveCut) <= 10000 (see the require() statement in the Tournament constructor). The result of this function is always guaranteed to be <= _reward. return _currentBank(10000 - tournamentOwnersCut - _incentiveCut)_result / 10000 / _totalBattles; | return _currentBank * _contenderResult / _totalBattles;
| return _currentBank * _contenderResult / _totalBattles;
| 41,074 |
186 | // Get quasar info. / | function quasarInfo(uint256 id) external view override returns (uint128 mintBlock, IERC20 stakeToken, uint256 amount, uint256 campaignID) {
mintBlock = _stars[id].mintBlock;
stakeToken = _quasars[id].stakeToken;
amount = _quasars[id].amount;
campaignID = _quasars[id].campaignID;
}
| function quasarInfo(uint256 id) external view override returns (uint128 mintBlock, IERC20 stakeToken, uint256 amount, uint256 campaignID) {
mintBlock = _stars[id].mintBlock;
stakeToken = _quasars[id].stakeToken;
amount = _quasars[id].amount;
campaignID = _quasars[id].campaignID;
}
| 54,401 |
31 | // Emit event for Transfer | Transfer(_from, _to, _value);
return true;
| Transfer(_from, _to, _value);
return true;
| 29,775 |
11 | // hero.rarity = data.ReadUint8(1); | hero.rarity = data.ReadUint8(2);
| hero.rarity = data.ReadUint8(2);
| 46,539 |
13 | // boolthrowIfLRCIsInsuffcient, | uint8[] vList,
bytes32[] rList,
bytes32[] sList)
| uint8[] vList,
bytes32[] rList,
bytes32[] sList)
| 63 |
46 | // Make the proposal fail if the new total number of shares & loot exceeds the limit | if (totalSupply.add(proposal.sharesRequested).add(proposal.lootRequested) > MAX_GUILD_BOUND) {
didPass = false;
}
| if (totalSupply.add(proposal.sharesRequested).add(proposal.lootRequested) > MAX_GUILD_BOUND) {
didPass = false;
}
| 26,970 |
490 | // Record the reward payment in our recentFeePeriods. snxAmount The amount of SNX tokens. / | function _recordRewardPayment(uint snxAmount) internal returns (uint) {
// Don't assign to the parameter
uint remainingToAllocate = snxAmount;
uint rewardPaid;
// Start at the oldest period and record the amount, moving to newer periods
// until we've exhausted the amount.
// The condition checks for overflow because we're going to 0 with an unsigned int.
for (uint i = FEE_PERIOD_LENGTH - 1; i < FEE_PERIOD_LENGTH; i--) {
uint toDistribute =
_recentFeePeriodsStorage(i).rewardsToDistribute.sub(_recentFeePeriodsStorage(i).rewardsClaimed);
if (toDistribute > 0) {
// Take the smaller of the amount left to claim in the period and the amount we need to allocate
uint amountInPeriod = toDistribute < remainingToAllocate ? toDistribute : remainingToAllocate;
_recentFeePeriodsStorage(i).rewardsClaimed = _recentFeePeriodsStorage(i).rewardsClaimed.add(amountInPeriod);
remainingToAllocate = remainingToAllocate.sub(amountInPeriod);
rewardPaid = rewardPaid.add(amountInPeriod);
// No need to continue iterating if we've recorded the whole amount;
if (remainingToAllocate == 0) return rewardPaid;
// We've exhausted feePeriods to distribute and no rewards remain in last period
// User last to claim would in this scenario have their remainder slashed
// due to rounding up of PreciseDecimal
if (i == 0 && remainingToAllocate > 0) {
remainingToAllocate = 0;
}
}
}
return rewardPaid;
}
| function _recordRewardPayment(uint snxAmount) internal returns (uint) {
// Don't assign to the parameter
uint remainingToAllocate = snxAmount;
uint rewardPaid;
// Start at the oldest period and record the amount, moving to newer periods
// until we've exhausted the amount.
// The condition checks for overflow because we're going to 0 with an unsigned int.
for (uint i = FEE_PERIOD_LENGTH - 1; i < FEE_PERIOD_LENGTH; i--) {
uint toDistribute =
_recentFeePeriodsStorage(i).rewardsToDistribute.sub(_recentFeePeriodsStorage(i).rewardsClaimed);
if (toDistribute > 0) {
// Take the smaller of the amount left to claim in the period and the amount we need to allocate
uint amountInPeriod = toDistribute < remainingToAllocate ? toDistribute : remainingToAllocate;
_recentFeePeriodsStorage(i).rewardsClaimed = _recentFeePeriodsStorage(i).rewardsClaimed.add(amountInPeriod);
remainingToAllocate = remainingToAllocate.sub(amountInPeriod);
rewardPaid = rewardPaid.add(amountInPeriod);
// No need to continue iterating if we've recorded the whole amount;
if (remainingToAllocate == 0) return rewardPaid;
// We've exhausted feePeriods to distribute and no rewards remain in last period
// User last to claim would in this scenario have their remainder slashed
// due to rounding up of PreciseDecimal
if (i == 0 && remainingToAllocate > 0) {
remainingToAllocate = 0;
}
}
}
return rewardPaid;
}
| 29,475 |
56 | // Checks max transaction limit | checkTxLimit(sender, amount);
| checkTxLimit(sender, amount);
| 28,357 |
33 | // This is used to change the deadline of tokenDeposit | function ChangeDeadline(uint256 time) public onlyOwner {
deadline = time;
}
| function ChangeDeadline(uint256 time) public onlyOwner {
deadline = time;
}
| 4,635 |
4 | // Returns the rebuilt hash obtained by traversing a Merklee tree upfrom `leaf` using `proof`. A `proof` is valid if and only if the rebuilthash matches the root of the tree. When processing the proof, the pairsof leafs & pre-images are assumed to be sorted. _Available since v4.4._ / | function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
| function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
| 8,109 |
65 | // 1) Amount of invested tokens; 1) Сумма вложенных токенов; | Deposit = deposit[_address].div(decimals);
| Deposit = deposit[_address].div(decimals);
| 40,026 |
9 | // transfer tokens | function transfer(address _to, uint _value) returns (bool success){
if(balances[msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]){
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
else{
return false;
}
}
| function transfer(address _to, uint _value) returns (bool success){
if(balances[msg.sender] >= _value
&& _value > 0
&& balances[_to] + _value > balances[_to]){
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
else{
return false;
}
}
| 21,384 |
20 | // ERC2981 - Get royalty information for token/_salePrice Sale price for the token | function royaltyInfo(
uint256,
uint256 _salePrice
| function royaltyInfo(
uint256,
uint256 _salePrice
| 984 |
31 | // Wallet Addresses Public | address public _lottoWallet;
address public _marketWallet;
address public _solidityWallet;
address public _pancakeRouterAddress;
address public _gameWinner;
| address public _lottoWallet;
address public _marketWallet;
address public _solidityWallet;
address public _pancakeRouterAddress;
address public _gameWinner;
| 35,504 |
512 | // A user needs to pay a fixed ETH withdrawal fee, set by the protocol. | uint withdrawalFeeETH = S.loopring.forcedWithdrawalFee();
| uint withdrawalFeeETH = S.loopring.forcedWithdrawalFee();
| 44,141 |
230 | // Legacy extension interface identifiers | * {IERC165-supportsInterface} needs to return 'true' for this interface
* in order backwards compatible with older creator contracts
*/
bytes4 constant internal LEGACY_EXTENSION_INTERFACE = 0x7005caad;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) {
return interfaceId == LEGACY_EXTENSION_INTERFACE
|| super.supportsInterface(interfaceId);
}
| * {IERC165-supportsInterface} needs to return 'true' for this interface
* in order backwards compatible with older creator contracts
*/
bytes4 constant internal LEGACY_EXTENSION_INTERFACE = 0x7005caad;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) {
return interfaceId == LEGACY_EXTENSION_INTERFACE
|| super.supportsInterface(interfaceId);
}
| 41,877 |
198 | // IHandler is a generalized interface for all the liquidity managers/Contains all necessary methods that should be available in liquidity manager contracts | interface IHandler {
struct DepositParams {
address sender;
address exchangeAddress;
address token0;
address token1;
uint256 amount0Desired;
uint256 amount1Desired;
}
struct WithdrawParams {
bool pilotToken;
bool wethToken;
address exchangeAddress;
uint256 liquidity;
uint256 tokenId;
}
struct CollectParams {
bool pilotToken;
bool wethToken;
address exchangeAddress;
uint256 tokenId;
}
function createPair(
address _token0,
address _token1,
bytes calldata data
) external;
function deposit(
address token0,
address token1,
address sender,
uint256 amount0,
uint256 amount1,
uint256 shares,
bytes calldata data
)
external
returns (
uint256 amount0Base,
uint256 amount1Base,
uint256 amount0Range,
uint256 amount1Range,
uint256 mintedTokenId
);
function withdraw(
bool pilotToken,
bool wethToken,
uint256 liquidity,
uint256 tokenId,
bytes calldata data
) external;
function getReserves(
address token0,
address token1,
bytes calldata data
)
external
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
);
function collect(
bool pilotToken,
bool wethToken,
uint256 tokenId,
bytes calldata data
) external payable;
}
| interface IHandler {
struct DepositParams {
address sender;
address exchangeAddress;
address token0;
address token1;
uint256 amount0Desired;
uint256 amount1Desired;
}
struct WithdrawParams {
bool pilotToken;
bool wethToken;
address exchangeAddress;
uint256 liquidity;
uint256 tokenId;
}
struct CollectParams {
bool pilotToken;
bool wethToken;
address exchangeAddress;
uint256 tokenId;
}
function createPair(
address _token0,
address _token1,
bytes calldata data
) external;
function deposit(
address token0,
address token1,
address sender,
uint256 amount0,
uint256 amount1,
uint256 shares,
bytes calldata data
)
external
returns (
uint256 amount0Base,
uint256 amount1Base,
uint256 amount0Range,
uint256 amount1Range,
uint256 mintedTokenId
);
function withdraw(
bool pilotToken,
bool wethToken,
uint256 liquidity,
uint256 tokenId,
bytes calldata data
) external;
function getReserves(
address token0,
address token1,
bytes calldata data
)
external
returns (
uint256 shares,
uint256 amount0,
uint256 amount1
);
function collect(
bool pilotToken,
bool wethToken,
uint256 tokenId,
bytes calldata data
) external payable;
}
| 10,683 |
99 | // Internal function for updating fallback gas price value._gasPrice new value for the gas price, zero gas price is allowed./ | function _setGasPrice(uint256 _gasPrice) internal {
uintStorage[GAS_PRICE] = _gasPrice;
emit GasPriceChanged(_gasPrice);
}
| function _setGasPrice(uint256 _gasPrice) internal {
uintStorage[GAS_PRICE] = _gasPrice;
emit GasPriceChanged(_gasPrice);
}
| 32,977 |
0 | // Start time of each phase (Unix timestamp) | mapping (MintingPhase => uint256) public phaseStartTime;
| mapping (MintingPhase => uint256) public phaseStartTime;
| 1,473 |
337 | // copy 32 bytes into scratch space | returndatacopy(0x0, 0x0, 0x20)
| returndatacopy(0x0, 0x0, 0x20)
| 35,073 |
348 | // all silver ether | if (dial2 == 1 && dial3 == 1)
return 250;
| if (dial2 == 1 && dial3 == 1)
return 250;
| 27,758 |
94 | // New - Logic changed - [Allow for any position shifting] [Finds Max Add Amounts] | function _mintPosition(
uint256 amt0Desired,
uint256 amt1Desired,
int24 tickDist,
address to,
bool isDouble,
uint256 min0,
uint256 min1
)
internal
| function _mintPosition(
uint256 amt0Desired,
uint256 amt1Desired,
int24 tickDist,
address to,
bool isDouble,
uint256 min0,
uint256 min1
)
internal
| 35,805 |
42 | // dnsDomains: base domains for contacting galaxiesdnsDomains[0] is primary, the others are used as fallbacks | string[3] public dnsDomains;
| string[3] public dnsDomains;
| 19,498 |
165 | // 债券到期, 投资人取回本金和收益 | function withdrawPrincipalAndInterestCb(address who, uint256 id)
external
auth
returns (uint256)
| function withdrawPrincipalAndInterestCb(address who, uint256 id)
external
auth
returns (uint256)
| 36,095 |