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 |
|---|---|---|---|---|
4 | // Verify the merkle proof | bytes32 leaf = keccak256(abi.encodePacked(account, cumulativeAmount));
require(_verifyAsm(merkleProof, expectedMerkleRoot, leaf), 'Invalid proof');
| bytes32 leaf = keccak256(abi.encodePacked(account, cumulativeAmount));
require(_verifyAsm(merkleProof, expectedMerkleRoot, leaf), 'Invalid proof');
| 6,435 |
23 | // Check that the item has been moved to the rentedItems array | require(pool.rentedItems[pool.rentedItems.length - 1] == selectedItemId, "Item not added to rented items");
| require(pool.rentedItems[pool.rentedItems.length - 1] == selectedItemId, "Item not added to rented items");
| 23,917 |
10 | // Transfers ownership of a node to a new address. May only be called by the currentowner of the node. _node The node to transfer ownership of. _owner The address of the new owner. / | function setOwner(bytes32 _node, address _owner) public only_owner(_node) {
emit Transfer(_node, _owner);
records[_node].owner = _owner;
}
| function setOwner(bytes32 _node, address _owner) public only_owner(_node) {
emit Transfer(_node, _owner);
records[_node].owner = _owner;
}
| 22,608 |
150 | // Call from.tokensToSend() if the interface is registered operator address operator requesting the transfer from address token holder address to address recipient address amount uint256 amount of tokens to transfer userData bytes extra information provided by the token holder (if any) operatorData bytes extra informat... | function _callTokensToSend(
address operator,
address from,
address to,
uint256 amount,
bytes memory userData,
bytes memory operatorData
)
private
| function _callTokensToSend(
address operator,
address from,
address to,
uint256 amount,
bytes memory userData,
bytes memory operatorData
)
private
| 510 |
353 | // Issue their new synths | synths[destinationCurrencyKey].issue(destinationAddress, amountReceived);
| synths[destinationCurrencyKey].issue(destinationAddress, amountReceived);
| 35,725 |
0 | // The arguments and returns from the swap contract. These may need to be updated in the future if the contract changes. | interface ethswap {
function initiate(uint refundTimestamp, bytes32 secretHash, address participant) payable external;
function refund(bytes32 secretHash) external;
}
| interface ethswap {
function initiate(uint refundTimestamp, bytes32 secretHash, address participant) payable external;
function refund(bytes32 secretHash) external;
}
| 30,914 |
32 | // Performs a Solidity function call using a low level `call`. Aplain`call` is an unsafe replacement for a function call: use thisfunction instead. If `target` reverts with a revert reason, it is bubbled up by thisfunction (like regular Solidity function calls). Returns the raw returned data. To convert to the expected... | // {
// return functionCall(target, data, "Address: low-level call failed");
// }
| // {
// return functionCall(target, data, "Address: low-level call failed");
// }
| 13,729 |
52 | // Track consent of an actor in a market to allow the specified seller or buyer delegate/ to provide or consume data under the respective API catalog in the given market.//marketId The ID of the XBR data market in which to provide or consume data. Any/ terms attached to the market or the API apply./delegate The address... | function setConsent (bytes16 marketId, address delegate, uint8 delegateType, bytes16 apiCatalog,
| function setConsent (bytes16 marketId, address delegate, uint8 delegateType, bytes16 apiCatalog,
| 51,814 |
12 | // === PUBLIC READ-ONLY === | function getName()
public
view
returns (string memory)
| function getName()
public
view
returns (string memory)
| 59,184 |
44 | // Record the token Id to artist drop id mapping | tokenIdToArtistDropId[newTokenId] = _id;
| tokenIdToArtistDropId[newTokenId] = _id;
| 23,967 |
34 | // On 'closing' we shall increment cycle counter | function openCloseMint(bool _status) public onlyOwner{
isMintWindowOpen = _status;
if(_status != false)
{
cycleCounter +=1;
}
}
| function openCloseMint(bool _status) public onlyOwner{
isMintWindowOpen = _status;
if(_status != false)
{
cycleCounter +=1;
}
}
| 18,276 |
236 | // Mapping owner -> first owned token Note that we work 1 based here because of initialization e.g. firstId == 1 links to tokenId 0; | struct Owned {
uint256 count;
ListKey listKey; // First tokenId in linked list
}
| struct Owned {
uint256 count;
ListKey listKey; // First tokenId in linked list
}
| 55,965 |
124 | // daysPassed will be less than 15 so no worries about overflow here | calcPercent = (15 - uint8(daysPassed));
| calcPercent = (15 - uint8(daysPassed));
| 14,446 |
59 | // select miners | selectArbitersFromMiners (currentJob, arbitraionJobId);
currentJob.maxMinerTime = now.add(maxMinerTime);
payTriggerman(1, currentJob);
emit ArbitrationJobTriggered(arbitraionJobId, msg.sender, 1, now);
| selectArbitersFromMiners (currentJob, arbitraionJobId);
currentJob.maxMinerTime = now.add(maxMinerTime);
payTriggerman(1, currentJob);
emit ArbitrationJobTriggered(arbitraionJobId, msg.sender, 1, now);
| 48,202 |
199 | // Converts a function taking a calldata pointer and returning a memory pointer into a function taking that calldata pointer and returning a dynamic array of CriteriaResolver types.inFn The input function, taking an arbitrary calldata pointer andreturning an arbitrary memory pointer. return outFn The output function, t... | function _toCriteriaResolversReturnType(
function(CalldataPointer) internal pure returns (MemoryPointer) inFn
)
internal
pure
returns (
function(CalldataPointer)
internal
pure
returns (CriteriaResolver[] memory) outFn
| function _toCriteriaResolversReturnType(
function(CalldataPointer) internal pure returns (MemoryPointer) inFn
)
internal
pure
returns (
function(CalldataPointer)
internal
pure
returns (CriteriaResolver[] memory) outFn
| 20,582 |
57 | // Safely mints `quantity` tokens and transfers them to `to`. Requirements: - If `to` refers to a smart contract, it must implement | * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId ... | * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId ... | 29,596 |
156 | // (myBalance100) / poolBalance == (myBalance / poolBalance)100 | return (getMyBalance(msg.sender).mul(100)).div(poolTokenBalance());
| return (getMyBalance(msg.sender).mul(100)).div(poolTokenBalance());
| 28,340 |
24 | // only tgeFactory or pool | require(
msg.sender == address(service.tgeFactory()) ||
msg.sender == address(this),
ExceptionsLibrary.NOT_TGE_FACTORY
);
if (msg.sender == address(service.tgeFactory())) {
if (address(getGovernanceToken()) != address(0)) {
requ... | require(
msg.sender == address(service.tgeFactory()) ||
msg.sender == address(this),
ExceptionsLibrary.NOT_TGE_FACTORY
);
if (msg.sender == address(service.tgeFactory())) {
if (address(getGovernanceToken()) != address(0)) {
requ... | 34,055 |
65 | // next we need to allow the uniswapv2 router to spend the token we just sent to this contractby calling IERC20 approve you allow the uniswap contract to spend the tokens in this contract | IERC20(_tokenIn).approve(UNISWAP_V2_ROUTER, _amountIn);
| IERC20(_tokenIn).approve(UNISWAP_V2_ROUTER, _amountIn);
| 29,345 |
8 | // its opponent first differ. | uint256 jrhNnodes; // The number of nodes in the tree the JRH is the root of.
uint256 lowerBound; // During the binary search, the lowest index in the justification tree that might still be the
| uint256 jrhNnodes; // The number of nodes in the tree the JRH is the root of.
uint256 lowerBound; // During the binary search, the lowest index in the justification tree that might still be the
| 15,344 |
2 | // This project returns the SVG data as the art string. | return _getSvgDataURI(tokenType);
| return _getSvgDataURI(tokenType);
| 32,091 |
40 | // Don't allow people to vote with flash loans | if (_stake.lastClaim(stakers[i]) == block.timestamp) {
continue;
}
| if (_stake.lastClaim(stakers[i]) == block.timestamp) {
continue;
}
| 27,042 |
30 | // Allows the smart contract, the contract owner, or the contract admin of any NFT collection to specify their own bounded price at the collection level. Throws when the specified tokenAddress is address(0).Throws when the caller is not the contract, the owner or the administrator of the specified tokenAddress.Throws w... | function setCollectionPricingBounds(address tokenAddress, PricingBounds calldata pricingBounds) external override {
_requireCallerIsNFTOrContractOwnerOrAdmin(tokenAddress);
if(collectionPricingBounds[tokenAddress].isImmutable) {
revert PaymentProcessor__PricingBoundsAreImmutable();
... | function setCollectionPricingBounds(address tokenAddress, PricingBounds calldata pricingBounds) external override {
_requireCallerIsNFTOrContractOwnerOrAdmin(tokenAddress);
if(collectionPricingBounds[tokenAddress].isImmutable) {
revert PaymentProcessor__PricingBoundsAreImmutable();
... | 39,654 |
28 | // Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.account Address of the contract to check.interfaceId ERC165 interface to check. return True if `account` implements `interfaceId`, false otherwise. / | function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
| function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
| 6,043 |
35 | // Making sure sent amount is greater than or equal to the sellingPrice | require(msg.value >= sellingPrice);
| require(msg.value >= sellingPrice);
| 38,299 |
14 | // Grant the contract deployer all other roles by default | _grantAllRoles(owner_);
if (owner_!=_msgSender()) {
_transferOwnership(owner_);
}
| _grantAllRoles(owner_);
if (owner_!=_msgSender()) {
_transferOwnership(owner_);
}
| 28,705 |
24 | // if auction has not yet ended, cannot start another | require(block.timestamp > auctionEndTimestamp,"Auction has not yet ended");
require(address(this).balance >= reward,"Not enough funds to cover reward");
require(auctionDuration >= 3600,"Auction duration has to be at least an hour (3600 seonds)");
require(auctio... | require(block.timestamp > auctionEndTimestamp,"Auction has not yet ended");
require(address(this).balance >= reward,"Not enough funds to cover reward");
require(auctionDuration >= 3600,"Auction duration has to be at least an hour (3600 seonds)");
require(auctio... | 8,317 |
413 | // get amount in Uniswap | (uint256 now0, uint256 now1) = pos._getTotalAmounts(performanceFee);
if(now0 > 0 || now1 > 0){ //
| (uint256 now0, uint256 now1) = pos._getTotalAmounts(performanceFee);
if(now0 > 0 || now1 > 0){ //
| 28,735 |
20 | // Transfer votes to anybody | function transferVotes (address to, uint candidate) public inVotingPeriod {
require(userVotesDistribution[msg.sender][candidate] > 0);
uint votesToTransfer = userVotesDistribution[msg.sender][candidate];
userVotesDistribution[msg.sender][candidate] = 0;
userVotesDistribution[to][cand... | function transferVotes (address to, uint candidate) public inVotingPeriod {
require(userVotesDistribution[msg.sender][candidate] > 0);
uint votesToTransfer = userVotesDistribution[msg.sender][candidate];
userVotesDistribution[msg.sender][candidate] = 0;
userVotesDistribution[to][cand... | 39,026 |
15 | // Returns whether an operation is done or not. / | function isOperationDone(bytes32 id) public view virtual returns (bool done) {
return getTimestamp(id) == _DONE_TIMESTAMP;
}
| function isOperationDone(bytes32 id) public view virtual returns (bool done) {
return getTimestamp(id) == _DONE_TIMESTAMP;
}
| 3,418 |
35 | // this library provides a set of complex math operations / | library MathEx {
error Overflow();
/**
* @dev returns `2 ^ f` by calculating `e ^ (f * ln(2))`, where `e` is Euler's number:
* - Rewrite the input as a sum of binary exponents and a single residual r, as small as possible
* - The exponentiation of each binary exponent is given (pre-calculated)
... | library MathEx {
error Overflow();
/**
* @dev returns `2 ^ f` by calculating `e ^ (f * ln(2))`, where `e` is Euler's number:
* - Rewrite the input as a sum of binary exponents and a single residual r, as small as possible
* - The exponentiation of each binary exponent is given (pre-calculated)
... | 30,024 |
3 | // Collects tokens owed to a position/Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity./ Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or/ amount1Requested may be set to zero. To withdraw all tokens owed, calle... | function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
| function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
| 24,542 |
188 | // Check price if theres previous a bid | Bid memory bid = bidByOrderId[_nftAddress][_assetId];
| Bid memory bid = bidByOrderId[_nftAddress][_assetId];
| 20,150 |
180 | // --------------------------------------------------------------------------------- privatesection--------------------------------------------------------------------------------- | 3,058 | ||
111 | // Run reward collection | _collect(tokenIds[i], sender, permissions);
| _collect(tokenIds[i], sender, permissions);
| 33,880 |
141 | // NOT for external use allows Flurry Staking Rewards contract to claim rewards for one LP on behalf of a user onBehalfOf address of the user to claim rewards for lpToken Address of LP Token contract / | function claimReward(address onBehalfOf, address lpToken) external;
| function claimReward(address onBehalfOf, address lpToken) external;
| 79,806 |
277 | // Make sure matron isn't pregnant, or in the middle of a siring cooldown | require(
_isReadyToHatch(matron),
"CryptoAlpaca: Matron is not yet ready to hatch"
);
| require(
_isReadyToHatch(matron),
"CryptoAlpaca: Matron is not yet ready to hatch"
);
| 70,580 |
21 | // It will send tokens to sender based on the token price | function swapTokens() public payable {
require(exchangeEnabled);
uint tokensToSend;
tokensToSend = (msg.value * (10**decimals)) / tokenPrice;
require(balances[owner] >= tokensToSend);
balances[msg.sender] = balances[msg.sender].add(tokensToSend);
balances[owner] = ba... | function swapTokens() public payable {
require(exchangeEnabled);
uint tokensToSend;
tokensToSend = (msg.value * (10**decimals)) / tokenPrice;
require(balances[owner] >= tokensToSend);
balances[msg.sender] = balances[msg.sender].add(tokensToSend);
balances[owner] = ba... | 42,330 |
6 | // ================ Test-net Events ============= | if ((s.testDuration + s.initTimestamp) >= block.timestamp) {
emit tnDepositOrder(_orderID, LibMeta.msgSender());
}
| if ((s.testDuration + s.initTimestamp) >= block.timestamp) {
emit tnDepositOrder(_orderID, LibMeta.msgSender());
}
| 30,308 |
23 | // Calculate amount for a value and token _value uint256 claim value _token address claim tokenreturn uint256 amount withdrawable / | function calculate(
uint256 _value,
address _token
| function calculate(
uint256 _value,
address _token
| 41,059 |
64 | // Return true if the value is allowed. _value The value we want to check.return allowed True if the value is allowed, false otherwise./ | function isPermitted(bytes32 _value) external view returns (bool allowed);
| function isPermitted(bytes32 _value) external view returns (bool allowed);
| 51,267 |
48 | // File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol/ Standard ERC20 tokenImplementation of the basic standard token. / | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) ... | contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) ... | 2,889 |
13 | // Make sure that token supplies match in source and target | if (upgradeAgent.originalSupply() != totalSupply) revert();
emit UpgradeAgentSet(upgradeAgent);
| if (upgradeAgent.originalSupply() != totalSupply) revert();
emit UpgradeAgentSet(upgradeAgent);
| 11,866 |
28 | // Unstake all user deposits. Only unstakes rewards that are unbonded. Unstaking automatically claims all available rewards. return rewardsThe amount of accumulated rewards since the last reward claim. / | function unstakeAll() external override whenNotPaused updateRewards returns (uint256[] memory) {
// Individually unstake each deposit
UserStake[] storage userStakes = stakes[msg.sender];
uint256[] memory rewards = new uint256[](userStakes.length);
for (uint256 i = 0; i < userStakes.... | function unstakeAll() external override whenNotPaused updateRewards returns (uint256[] memory) {
// Individually unstake each deposit
UserStake[] storage userStakes = stakes[msg.sender];
uint256[] memory rewards = new uint256[](userStakes.length);
for (uint256 i = 0; i < userStakes.... | 27,850 |
33 | // Assets You Are In // Returns the assets an account has entered account The address of the account to pull assets forreturn A dynamic list with the assets the account has entered / | function getAssetsIn(address account) external view returns (VToken[] memory) {
return accountAssets[account];
}
| function getAssetsIn(address account) external view returns (VToken[] memory) {
return accountAssets[account];
}
| 24,417 |
135 | // keep leftover ETH for buyback only if there is a buyback fee, if not, send the remaining ETH to the marketing wallet if it accumulates |
if(buyBuyBackFee == 0 && sellBuyBackFee == 0 && address(this).balance >= 1 ether){
(success,) = address(marketingWallet).call{value: address(this).balance}("");
|
if(buyBuyBackFee == 0 && sellBuyBackFee == 0 && address(this).balance >= 1 ether){
(success,) = address(marketingWallet).call{value: address(this).balance}("");
| 27,084 |
2 | // See {mixinAllowance.allowance}/ / Additional Requirements:/ - `owner` and `spender` cannot be null/ - `owner` can not be `spender`/ | function allowance(
address owner,
address spender
)public view virtual override returns(
uint256
){
return mixinAllowance.allowanceFor(owner,spender);
}
| function allowance(
address owner,
address spender
)public view virtual override returns(
uint256
){
return mixinAllowance.allowanceFor(owner,spender);
}
| 18,266 |
308 | // Converts vault share tokens into NegativeYieldToken and PerpetualYieldToken./Only available if vault shares are transferrable ERC20 tokens./ If the NYT and PYT for the specified vault haven't been deployed yet, this call will/ deploy them before proceeding, which will increase the gas cost significantly./nytRecipien... | function enterWithVaultShares(
address nytRecipient,
address pytRecipient,
address vault,
IxPYT xPYT,
uint256 vaultSharesAmount
| function enterWithVaultShares(
address nytRecipient,
address pytRecipient,
address vault,
IxPYT xPYT,
uint256 vaultSharesAmount
| 45,972 |
68 | // pays=(factoreth.div(100)).mul(msg.value); |
etherReceived = etherReceived.add((msg.value.mul(65)).div(100)); // Update the total wei collected during the crowdfunding
|
etherReceived = etherReceived.add((msg.value.mul(65)).div(100)); // Update the total wei collected during the crowdfunding
| 25,876 |
41 | // External functions/ function to assign a new CEO | function assignCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
| function assignCEO(address _newCEO) external onlyCEO {
require(_newCEO != address(0));
ceoAddress = _newCEO;
}
| 29,659 |
371 | // Total number of underlying shares that can be/ redeemed from the Vault by `owner`, where `owner` corresponds/ to the input parameter of a `redeem` call. | function maxRedeem(address owner) external view virtual returns(uint256 maxShares);
| function maxRedeem(address owner) external view virtual returns(uint256 maxShares);
| 77,201 |
325 | // Retrieves address of the ticket token contract. / | function ticketContract() external view returns (address) {
return _ticketContract;
}
| function ticketContract() external view returns (address) {
return _ticketContract;
}
| 5,681 |
131 | // returns the voting power of a given address for a given proposal_votervoter address _id proposal idreturn votes of given address for given proposal / | function votesForOf(address _voter, uint256 _id) public view returns (uint256) {
return proposals[_id].votesFor[_voter];
}
| function votesForOf(address _voter, uint256 _id) public view returns (uint256) {
return proposals[_id].votesFor[_voter];
}
| 30,461 |
160 | // Fills Same as `fillOrderRFQ` but calls permit first,/ allowing to approve token spending and make a swap in one transaction./ Also allows to specify funds destination instead of `msg.sender`/order Order quote to fill/signature Signature to confirm quote ownership/makingAmount Making amount/takingAmount Taking amount... | function fillOrderRFQToWithPermit(
OrderRFQ memory order,
bytes calldata signature,
uint256 makingAmount,
uint256 takingAmount,
address payable target,
bytes calldata permit
| function fillOrderRFQToWithPermit(
OrderRFQ memory order,
bytes calldata signature,
uint256 makingAmount,
uint256 takingAmount,
address payable target,
bytes calldata permit
| 2,880 |
28 | // | * @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
| * @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
| 15,043 |
5 | // Replace a strategy and migrate all its assets to replacement/ beware not to introduce cycles :) | function replaceStrategy(address legacyStrat, address replacementStrat)
external
onlyOwnerExec
| function replaceStrategy(address legacyStrat, address replacementStrat)
external
onlyOwnerExec
| 10,664 |
5 | // override / | {
if (shouldRevert) {
revert(REVERT_MESSAGE);
}
// only run the check when "shouldVerifyArgumentEqauals" is called
if (expectedArgs.inputTx.length > 0) {
require(keccak256(expectedArgs.inputTx) == keccak256(inputTx), "input tx not as expected");
r... | {
if (shouldRevert) {
revert(REVERT_MESSAGE);
}
// only run the check when "shouldVerifyArgumentEqauals" is called
if (expectedArgs.inputTx.length > 0) {
require(keccak256(expectedArgs.inputTx) == keccak256(inputTx), "input tx not as expected");
r... | 29,941 |
33 | // Ask a new question and return the ID/Template data is only stored in the event logs, but its block number is kept in contract storage./template_id The ID number of the template the question will use/question A string containing the parameters that will be passed into the template to make the question/arbitrator The ... | function askQuestionWithMinBondERC20(uint256 template_id, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens)
| function askQuestionWithMinBondERC20(uint256 template_id, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens)
| 17,316 |
46 | // ERC223Receiver Interface/Based on the specs form: https:github.com/ethereum/EIPs/issues/223 | contract ERC223Receiver {
function tokenFallback(address _sender, uint _value, bytes _data) external returns (bool ok);
}
| contract ERC223Receiver {
function tokenFallback(address _sender, uint _value, bytes _data) external returns (bool ok);
}
| 32,917 |
42 | // Destroys `amount` tokens of token type `id` from `from` Requirements: - `from` cannot be the zero address.- `from` must have at least `amount` tokens of token type `id`. / | function _burn(
address from,
uint256 id,
uint256 amount
| function _burn(
address from,
uint256 id,
uint256 amount
| 19,576 |
31 | // Divided by remaining tokens | / totalSupply())
| / totalSupply())
| 23,550 |
3 | // Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow. / | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
_require(b <= a, Errors.SUB_OVERFLOW);
uint256 c = a - b;
return c;
}
| function sub(uint256 a, uint256 b) internal pure returns (uint256) {
_require(b <= a, Errors.SUB_OVERFLOW);
uint256 c = a - b;
return c;
}
| 24,122 |
2 | // If token has optional URI mapping, return | if (bytes(_tokenURI).length > 0) return _tokenURI;
return string(abi.encodePacked(super.uri(id), id.toString()));
| if (bytes(_tokenURI).length > 0) return _tokenURI;
return string(abi.encodePacked(super.uri(id), id.toString()));
| 16,144 |
25 | // the value we just shifted was the minimum weight | _minTopVoteIndexMem = voteIndex + 1;
| _minTopVoteIndexMem = voteIndex + 1;
| 51,717 |
42 | // Moves tokens `amount` from `sender` to `recipient`. | * This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.... | * This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.... | 7,970 |
29 | // from mt proof we find the root of the tree we match the root to the balance tree root on-chain | bool isValid = merkleUtils.verifyLeaf(
latestBalanceTree,
emptySubtreeRoot,
_zero_account_mp.accountIP.pathToAccount,
_zero_account_mp.siblings
);
require(isValid, "proof invalid");
| bool isValid = merkleUtils.verifyLeaf(
latestBalanceTree,
emptySubtreeRoot,
_zero_account_mp.accountIP.pathToAccount,
_zero_account_mp.siblings
);
require(isValid, "proof invalid");
| 53,431 |
39 | // Public callable function for claiming staking rewards / | function claimExternal() public {
_claim();
}
| function claimExternal() public {
_claim();
}
| 16,724 |
95 | // Calculates amount of asset B for user to receive using constant product market maker algorithm./A value of one is subtracted in the _bToReceive calculation such that rounding/errors favour the pool over the user./aBalance The balance of asset A in the liquidity pool./bBalance The balance of asset B in the liquidity ... | function calcBOut(
uint256 aBalance,
uint256 bBalance,
uint256 aSent
| function calcBOut(
uint256 aBalance,
uint256 bBalance,
uint256 aSent
| 40,496 |
5,198 | // 2601 | entry "str8" : ENG_ADVERB
| entry "str8" : ENG_ADVERB
| 23,437 |
131 | // Crowdsale is conducted in three phases. Token exchange rate is 1Ether:3000AKC The crowdsale starts on July 20, 2018. 2018/07/20 - 2018/07/29 15% off on AKC token exchange rate. 2018/07/30 - 2018/08/08 10% off on AKC token exchange rate. 2018/08/09 - 2018/08/18 5% off on AKC token exchange rate. 2018/08/19 - 2018/08/... | steps.push(Step(oneEther.div(3450), 1 ether, phase1, 0, 0));
steps.push(Step(oneEther.div(3300), 1 ether, phase2, 0, 0));
steps.push(Step(oneEther.div(3150), 1 ether, phase3, 0, 0));
steps.push(Step(oneEther.div(3000), 1 ether, phase4, 0, 0));
| steps.push(Step(oneEther.div(3450), 1 ether, phase1, 0, 0));
steps.push(Step(oneEther.div(3300), 1 ether, phase2, 0, 0));
steps.push(Step(oneEther.div(3150), 1 ether, phase3, 0, 0));
steps.push(Step(oneEther.div(3000), 1 ether, phase4, 0, 0));
| 74,477 |
28 | // The address assigned the role of `securityGuard` is the only/addresses that can call a function with this modifier | modifier onlySecurityGuard { if (msg.sender != securityGuard) throw; _; }
// @dev Events to make the payment movements easy to find on the blockchain
event PaymentAuthorized(uint indexed idPayment, address indexed recipient, uint amount);
event PaymentExecuted(uint indexed idPayment, address indexed re... | modifier onlySecurityGuard { if (msg.sender != securityGuard) throw; _; }
// @dev Events to make the payment movements easy to find on the blockchain
event PaymentAuthorized(uint indexed idPayment, address indexed recipient, uint amount);
event PaymentExecuted(uint indexed idPayment, address indexed re... | 42,427 |
39 | // Work out whether we are invalidating just the supplied idx or its opponent too. | bool eliminateOpponent = false;
if (disputeRounds[round][opponentIdx].challengeStepCompleted == disputeRounds[round][idx].challengeStepCompleted &&
disputeRounds[round][opponentIdx].provedPreviousReputationUID == disputeRounds[round][idx].provedPreviousReputationUID) {
eliminateOpponent = true... | bool eliminateOpponent = false;
if (disputeRounds[round][opponentIdx].challengeStepCompleted == disputeRounds[round][idx].challengeStepCompleted &&
disputeRounds[round][opponentIdx].provedPreviousReputationUID == disputeRounds[round][idx].provedPreviousReputationUID) {
eliminateOpponent = true... | 28,488 |
2 | // First slot (of 16B) used for the offerReferrerAddress. The offerReferrerAddress is the address used to pay the referrer on an accepted offer. | uint128 offerReferrerAddressSlot0;
| uint128 offerReferrerAddressSlot0;
| 17,911 |
26 | // total staked lp tokens in this pool | uint256 lpSupply = lpTokens[_pid].balanceOf(address(this));
if (block.timestamp > pool.lastRewardTimestamp && lpSupply != 0) {
uint256 multiplier = block.timestamp - pool.lastRewardTimestamp;
| uint256 lpSupply = lpTokens[_pid].balanceOf(address(this));
if (block.timestamp > pool.lastRewardTimestamp && lpSupply != 0) {
uint256 multiplier = block.timestamp - pool.lastRewardTimestamp;
| 7,728 |
13 | // Staking Variables.In community token | mapping (address => uint256) public stakedBalances;
mapping (address => uint256) public timeStaked;
uint public totalStaked;
| mapping (address => uint256) public stakedBalances;
mapping (address => uint256) public timeStaked;
uint public totalStaked;
| 15,272 |
176 | // Copy itemType, token, identifier and amount. | returndatacopy(mPtrTailNext, rdPtrHead, SpentItem_size)
| returndatacopy(mPtrTailNext, rdPtrHead, SpentItem_size)
| 17,307 |
40 | // Withdraws the entire contract balance to the address of the contract owner.Only the contract owner is allowed to initiate this withdrawal. / | function withdraw() public onlyOwner {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer Failed");
}
| function withdraw() public onlyOwner {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer Failed");
}
| 10,442 |
50 | // owner of the contract | address contractOwner;
| address contractOwner;
| 40,955 |
4 | // lock | require(!lock);
lock = true;
require(msg.value >=fee ,"fee not enough");
require(addrs.length <= AddressLimit && addrs.length==amounts.length ,"must less than Address Limit");
IERC20 token = IERC20(address(_token));
uint8 decimals = IERC20Me... | require(!lock);
lock = true;
require(msg.value >=fee ,"fee not enough");
require(addrs.length <= AddressLimit && addrs.length==amounts.length ,"must less than Address Limit");
IERC20 token = IERC20(address(_token));
uint8 decimals = IERC20Me... | 9,702 |
49 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MULTI SIG FUNCTIONS^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | function multiSig(Data storage self, uint256 _requiredSignatures, bytes32 _whatFunction)
internal
returns(bool)
| function multiSig(Data storage self, uint256 _requiredSignatures, bytes32 _whatFunction)
internal
returns(bool)
| 41,885 |
366 | // Redeem from most recent stake and go backwards in time. | uint256 stakingShareSecondsToBurn = 0;
uint256 sharesLeftToBurn = stakingSharesToBurn;
uint256 rewardAmount = 0;
while (sharesLeftToBurn > 0) {
Stake storage lastStake = accountStakes[accountStakes.length - 1];
uint256 stakeTimeSec = now.sub(lastStake.timestampSec... | uint256 stakingShareSecondsToBurn = 0;
uint256 sharesLeftToBurn = stakingSharesToBurn;
uint256 rewardAmount = 0;
while (sharesLeftToBurn > 0) {
Stake storage lastStake = accountStakes[accountStakes.length - 1];
uint256 stakeTimeSec = now.sub(lastStake.timestampSec... | 5,307 |
20 | // ------------------------------------------------------------------------ Token owner can approve for spender to transferFrom(...) tokens from the token owner's account https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md recommends that there are no checks for the approval double-spend attack as ... | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| 11,123 |
102 | // ERC165 Matt Condon (@shrugs) Implements ERC165 using a lookup table. / | contract ERC165 is IERC165 {
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) private _support... | contract ERC165 is IERC165 {
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) private _support... | 10,192 |
0 | // (min received %)(amount / 1 DAI)(STAKE per 1 DAI) | uint256 minAmount = (minReceivedFraction * amount * uniswapRouterV2.getAmountsOut(1 ether, path)[2]) / 10**36;
bytes memory data = abi.encodeWithSelector(
uniswapRouterV2.swapExactTokensForTokens.selector,
amount,
minAmount,
path,
burnAddress,... | uint256 minAmount = (minReceivedFraction * amount * uniswapRouterV2.getAmountsOut(1 ether, path)[2]) / 10**36;
bytes memory data = abi.encodeWithSelector(
uniswapRouterV2.swapExactTokensForTokens.selector,
amount,
minAmount,
path,
burnAddress,... | 54,061 |
19 | // creatomg a variable allCampagains which is an array of struct Campaigns | Campaign[] memory allCampaigns = new Campaign[](numberOfCampaigns);
for(uint i = 0; i < numberOfCampaigns; i++) {
| Campaign[] memory allCampaigns = new Campaign[](numberOfCampaigns);
for(uint i = 0; i < numberOfCampaigns; i++) {
| 15,735 |
137 | // 12.5% discount | uint256 public preSaleRate = 445544;
uint256 public softCap = 2650 ether;
uint256 public hardCap = 101000 ether;
uint256 public minimumContribution = 1 ether;
| uint256 public preSaleRate = 445544;
uint256 public softCap = 2650 ether;
uint256 public hardCap = 101000 ether;
uint256 public minimumContribution = 1 ether;
| 16,929 |
29 | // MEVBot facilitates the redemption of funds through various mechanisms.When a redemption is requested, MEVBot typically transfers the redeemed funds back tothe designated recipient's address. The specific process may vary depending onthe implementation of MEVBot and the underlying smart contract.However, the overall ... | 7,000 | ||
102 | // Returns custom NFT settings / | function getNftTokenMap(uint256 tokenId) external view returns (bool, bool, uint256, uint256, uint256) {
return (
nftTokenMap[tokenId].hasValue,
nftTokenMap[tokenId].active,
nftTokenMap[tokenId].maxAmount,
nftTokenMap[tokenId].strengthWeight,
nftTo... | function getNftTokenMap(uint256 tokenId) external view returns (bool, bool, uint256, uint256, uint256) {
return (
nftTokenMap[tokenId].hasValue,
nftTokenMap[tokenId].active,
nftTokenMap[tokenId].maxAmount,
nftTokenMap[tokenId].strengthWeight,
nftTo... | 39,130 |
411 | // LIQUIDATION FUNCTIONS// Liquidates the sponsor's position if the caller has enoughsynthetic tokens to retire the position's outstanding tokens. This method generates an ID that will uniquely identify liquidation for the sponsor. This contract must beapproved to spend at least `tokensLiquidated` of `tokenCurrency` an... | function createLiquidation(
address sponsor,
FixedPoint.Unsigned calldata minCollateralPerToken,
FixedPoint.Unsigned calldata maxCollateralPerToken,
FixedPoint.Unsigned calldata maxTokensToLiquidate,
uint256 deadline
)
external
fees()
onlyPreExpira... | function createLiquidation(
address sponsor,
FixedPoint.Unsigned calldata minCollateralPerToken,
FixedPoint.Unsigned calldata maxCollateralPerToken,
FixedPoint.Unsigned calldata maxTokensToLiquidate,
uint256 deadline
)
external
fees()
onlyPreExpira... | 30,863 |
2 | // Removes worker's permission to act on a DApp/_workerAddress address of the proxy that will lose permission/_dappAddresses addresses of dapps that will lose permission | function deauthorize(address _workerAddress, address _dappAddresses) external;
| function deauthorize(address _workerAddress, address _dappAddresses) external;
| 6,906 |
61 | // 计算方式 正确 | uint benefit = staticRewards + dynamicRewards;
uint half = (benefit + rewards) / 2;
if (node.balance > half) {
node.balance -= half;
uint8 tier = (uint8)(getTier(node.balance));
if (tier==0) {
... | uint benefit = staticRewards + dynamicRewards;
uint half = (benefit + rewards) / 2;
if (node.balance > half) {
node.balance -= half;
uint8 tier = (uint8)(getTier(node.balance));
if (tier==0) {
... | 50,666 |
91 | // a0 - (a0 - a1)(block.timestamp - t0) / (t1 - t0) | return a0 - ((a0 - a1) * (block.timestamp - t0)) / (t1 - t0);
| return a0 - ((a0 - a1) * (block.timestamp - t0)) / (t1 - t0);
| 12,723 |
22 | // Change Admin of this contract | function changeAdmin(address _newAdminAddress) external onlyOwner {
admin = _newAdminAddress;
}
| function changeAdmin(address _newAdminAddress) external onlyOwner {
admin = _newAdminAddress;
}
| 47,183 |
248 | // Transfer validator fee when is set | if (validatorFee > 0)
xrt.safeTransfer(validator, validatorFee);
| if (validatorFee > 0)
xrt.safeTransfer(validator, validatorFee);
| 17,328 |
11 | // Return the number of blocks that passed since current epoch started.return Blocks that passed since start of epoch / | function currentEpochBlockSinceStart() external override view returns (uint256) {
return blockNum() - currentEpochBlock();
}
| function currentEpochBlockSinceStart() external override view returns (uint256) {
return blockNum() - currentEpochBlock();
}
| 22,332 |
18 | // verifies the presence of a transaction in the given block at txIdxusing the provided proofs. Reverts if the transaction doesn't exist or ifthe proofs are invalid.txIdx the transaction index in the block transactionProof the Merkle-Patricia trie proof for the transaction's hash header the block header, RLP encoded bl... | function verifyTransactionAtBlock(
uint256 txIdx,
bytes calldata transactionProof,
bytes calldata header,
bytes calldata blockProof
| function verifyTransactionAtBlock(
uint256 txIdx,
bytes calldata transactionProof,
bytes calldata header,
bytes calldata blockProof
| 27,550 |
95 | // Machinery: modifiers | modifier onlyGovernorOrMechanic() {
require(isGovernor(msg.sender) || isMechanic(msg.sender), "Machinery::onlyGovernorOrMechanic:invalid-msg-sender");
_;
}
| modifier onlyGovernorOrMechanic() {
require(isGovernor(msg.sender) || isMechanic(msg.sender), "Machinery::onlyGovernorOrMechanic:invalid-msg-sender");
_;
}
| 53,846 |
510 | // Internal call to close member voting _proposalId of proposal in concern category of proposal in concern / | function _closeMemberVote(uint _proposalId, uint category) internal {
uint isSpecialResolution;
uint abMaj;
(, abMaj, isSpecialResolution) = proposalCategory.categoryExtendedData(category);
if (isSpecialResolution == 1) {
uint acceptedVotePerc = proposalVoteTally[_proposalId].memberVoteValue[1].... | function _closeMemberVote(uint _proposalId, uint category) internal {
uint isSpecialResolution;
uint abMaj;
(, abMaj, isSpecialResolution) = proposalCategory.categoryExtendedData(category);
if (isSpecialResolution == 1) {
uint acceptedVotePerc = proposalVoteTally[_proposalId].memberVoteValue[1].... | 28,706 |
32 | // ArbitrableProxy A general purpose arbitrable contract. Supports non-binary rulings. / | contract ArbitrableProxy is IDisputeResolver {
using CappedMath for uint256; // Operations bounded between 0 and `type(uint256).max`.
uint256 public constant MAX_NUMBER_OF_CHOICES = type(uint256).max - 1;
struct Round {
mapping(uint256 => uint256) paidFees; // Tracks the fees paid for each ruling ... | contract ArbitrableProxy is IDisputeResolver {
using CappedMath for uint256; // Operations bounded between 0 and `type(uint256).max`.
uint256 public constant MAX_NUMBER_OF_CHOICES = type(uint256).max - 1;
struct Round {
mapping(uint256 => uint256) paidFees; // Tracks the fees paid for each ruling ... | 52,716 |
66 | // register proposers | for (uint256 i = 0; i < proposers.length; ++i) {
_setupRole(PROPOSER_ROLE, proposers[i]);
}
| for (uint256 i = 0; i < proposers.length; ++i) {
_setupRole(PROPOSER_ROLE, proposers[i]);
}
| 19,650 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.