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 |
|---|---|---|---|---|
10 | // Governance message is invalid (e.g., deserialization error). Signature: 0x97363b35 | error InvalidGovernanceMessage();
| error InvalidGovernanceMessage();
| 25,519 |
9 | // checks for requested epoch | require (_getEpochId() > epochId, "This epoch is in the future");
require(epochId <= numberOfEpochs, "Maximum number of epochs is 12");
require (lastEpochIdHarvested[msg.sender].add(1) == epochId, "Harvest in order");
uint userReward = _harvest(epochId);
if (userReward > 0) {
... | require (_getEpochId() > epochId, "This epoch is in the future");
require(epochId <= numberOfEpochs, "Maximum number of epochs is 12");
require (lastEpochIdHarvested[msg.sender].add(1) == epochId, "Harvest in order");
uint userReward = _harvest(epochId);
if (userReward > 0) {
... | 35,241 |
54 | // Investing all underlying. / | function investedUnderlyingBalance() public view returns (uint256) {
return
Gauge(pool).balanceOf(address(this)).add(
IERC20(underlying).balanceOf(address(this))
);
}
| function investedUnderlyingBalance() public view returns (uint256) {
return
Gauge(pool).balanceOf(address(this)).add(
IERC20(underlying).balanceOf(address(this))
);
}
| 35,662 |
26 | // Reveal a previously committed bug. bugId The ID of the bug commitment bugDescription The description of the bug / | function revealBug(uint256 bugId, string bugDescription, uint256 nonce) public returns (bool) {
address hunter = msg.sender;
uint256 bountyId = bountyData.getBugCommitBountyId(bugId);
// the bug commit exists, and the committer is the hunter
require(bountyData.getBugCommitCommitter(bugId) == hunter);... | function revealBug(uint256 bugId, string bugDescription, uint256 nonce) public returns (bool) {
address hunter = msg.sender;
uint256 bountyId = bountyData.getBugCommitBountyId(bugId);
// the bug commit exists, and the committer is the hunter
require(bountyData.getBugCommitCommitter(bugId) == hunter);... | 53,089 |
382 | // Ensure assetData length is valid | require(
assetData.length > 3,
"LENGTH_GREATER_THAN_3_REQUIRED"
);
| require(
assetData.length > 3,
"LENGTH_GREATER_THAN_3_REQUIRED"
);
| 42,274 |
35 | // just in case | function recoverEth() external onlyOwner {
payable(owner).transfer(address(this).balance);
}
| function recoverEth() external onlyOwner {
payable(owner).transfer(address(this).balance);
}
| 43,261 |
9 | // Address to number of mints | mapping(address => uint256) public mintsPerAddress;
| mapping(address => uint256) public mintsPerAddress;
| 29,950 |
144 | // Modifier to make a function callable only when the contract is paused. / | modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
| modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
| 7,034 |
55 | // No distribnution | IMintableERC20(udt).mint(_referrer, tokensToDistribute - devReward);
IMintableERC20(udt).mint(owner(), devReward);
| IMintableERC20(udt).mint(_referrer, tokensToDistribute - devReward);
IMintableERC20(udt).mint(owner(), devReward);
| 35,631 |
666 | // discount to pay fully in erc20 token (Mona), assumed to always be to 1 decimal place i.e. 20 = 2.0% | uint256 public discountToPayERC20 = 20;
| uint256 public discountToPayERC20 = 20;
| 13,705 |
187 | // Dolphin referral contract address. | IDolphinReferral public DolphinReferral;
| IDolphinReferral public DolphinReferral;
| 8,420 |
65 | // Lets a contract admin update the platform fee recipient and bps | function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps)
external
onlyRole(DEFAULT_ADMIN_ROLE)
| function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps)
external
onlyRole(DEFAULT_ADMIN_ROLE)
| 6,397 |
23 | // ----------------- total counts ----------------- / | function countTotalStake() public view returns (uint _totalStake) {
_totalStake = totalStake + totalStakingAmount.mul((block.timestamp).sub(lastUpdateTime));
}
| function countTotalStake() public view returns (uint _totalStake) {
_totalStake = totalStake + totalStakingAmount.mul((block.timestamp).sub(lastUpdateTime));
}
| 27,933 |
37 | // Update CID | tokenIdListToCID[_tokenId] = _newCID;
| tokenIdListToCID[_tokenId] = _newCID;
| 51,590 |
187 | // Adds a given asset to the list of collateral markets. This operation is impossible to reverse. Note: this will not add the asset if it already exists. / | function addCollateralMarket(address asset) internal {
for (uint256 i = 0; i < collateralMarkets.length; i++) {
if (collateralMarkets[i] == asset) {
return;
}
}
collateralMarkets.push(asset);
}
| function addCollateralMarket(address asset) internal {
for (uint256 i = 0; i < collateralMarkets.length; i++) {
if (collateralMarkets[i] == asset) {
return;
}
}
collateralMarkets.push(asset);
}
| 26,048 |
260 | // check tokens left | uint256 tokenAmount = tokensLeft();
| uint256 tokenAmount = tokensLeft();
| 25,985 |
14 | // by convention, we assume that all growth before a tick was initialized happened _below_ the tick | if (tick <= tickCurrent) {
info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;
info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;
info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;
info.tickCumulativeOutside = tickCumulativ... | if (tick <= tickCurrent) {
info.feeGrowthOutside0X128 = feeGrowthGlobal0X128;
info.feeGrowthOutside1X128 = feeGrowthGlobal1X128;
info.secondsPerLiquidityOutsideX128 = secondsPerLiquidityCumulativeX128;
info.tickCumulativeOutside = tickCumulativ... | 35,693 |
1 | // Subtracts two integers, returns 0 on underflow. / | function subCap(uint _a, uint _b) internal pure returns (uint) {
if (_b > _a)
return 0;
else
return _a - _b;
}
| function subCap(uint _a, uint _b) internal pure returns (uint) {
if (_b > _a)
return 0;
else
return _a - _b;
}
| 40,612 |
28 | // Give an account access to this role. / | function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
| function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
| 2,552 |
95 | // / | abstract contract ERC20Allowlistable is ERC20Flaggable, Ownable {
uint8 private constant TYPE_DEFAULT = 0x0;
uint8 private constant TYPE_ALLOWLISTED = 0x1;
uint8 private constant TYPE_FORBIDDEN = 0x2;
uint8 private constant TYPE_POWERLISTED = 0x4;
uint8 private constant FLAG_INDEX_ALLOWLIST = 20;
uint8 pr... | abstract contract ERC20Allowlistable is ERC20Flaggable, Ownable {
uint8 private constant TYPE_DEFAULT = 0x0;
uint8 private constant TYPE_ALLOWLISTED = 0x1;
uint8 private constant TYPE_FORBIDDEN = 0x2;
uint8 private constant TYPE_POWERLISTED = 0x4;
uint8 private constant FLAG_INDEX_ALLOWLIST = 20;
uint8 pr... | 67,571 |
62 | // Bird's BDelegate Interface/ | contract BDelegateInterface is BDelegationStorage {
/**
* @notice Called by the delegator on a delegate to initialize it for duty
* @dev Should revert if any issues arise which make it unfit for delegation
* @param data The encoded bytes data for any initialization
*/
function _becomeImpleme... | contract BDelegateInterface is BDelegationStorage {
/**
* @notice Called by the delegator on a delegate to initialize it for duty
* @dev Should revert if any issues arise which make it unfit for delegation
* @param data The encoded bytes data for any initialization
*/
function _becomeImpleme... | 17,284 |
184 | // Check cash balance | IERC20 tokenContract=IERC20(token);
uint256 cashBal = tokenContract.balanceOf(address(this));
if (cashBal < tokenAmount) {
uint256 diff = tokenAmount.sub(cashBal);
IController(getController()).harvest(diff);
tokenAmount=tokenContract.balanceOf(address(this));
}
| IERC20 tokenContract=IERC20(token);
uint256 cashBal = tokenContract.balanceOf(address(this));
if (cashBal < tokenAmount) {
uint256 diff = tokenAmount.sub(cashBal);
IController(getController()).harvest(diff);
tokenAmount=tokenContract.balanceOf(address(this));
}
| 4,884 |
24 | // call super method | treasuryCoreContract.transferRewardAmount(
to,
recordId,
contributionId,
rewardGovernance,
rewardCommunity
);
| treasuryCoreContract.transferRewardAmount(
to,
recordId,
contributionId,
rewardGovernance,
rewardCommunity
);
| 23,479 |
84 | // Called by operator to pause child contract. The contractmust already be paused. / | function unpause() public onlyOperatorOrTraderOrSystem whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
| function unpause() public onlyOperatorOrTraderOrSystem whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
| 76,000 |
268 | // If not burning to target, then burning requires that the minimum stake time has elapsed. | require(_canBurnSynths(from), "Minimum stake time not reached");
| require(_canBurnSynths(from), "Minimum stake time not reached");
| 7,289 |
15 | // Add the applicant | applicants[msg.sender] = Applicant(name, age, resumeHash, msg.sender);
| applicants[msg.sender] = Applicant(name, age, resumeHash, msg.sender);
| 20,420 |
0 | // Throws if called by any account other than a minter/ | modifier onlyMinters() {
require(minters[msg.sender] == true, "minters only");
_;
}
| modifier onlyMinters() {
require(minters[msg.sender] == true, "minters only");
_;
}
| 36,480 |
357 | // Credit line terms | address public override borrower;
uint256 public currentLimit;
uint256 public override maxLimit;
uint256 public override interestApr;
uint256 public override paymentPeriodInDays;
uint256 public override termInDays;
uint256 public override principalGracePeriodInDays;
uint256 public override lateFeeApr;
| address public override borrower;
uint256 public currentLimit;
uint256 public override maxLimit;
uint256 public override interestApr;
uint256 public override paymentPeriodInDays;
uint256 public override termInDays;
uint256 public override principalGracePeriodInDays;
uint256 public override lateFeeApr;
| 53,851 |
431 | // Checks if the account should be allowed to transfer tokens in the given market gToken The market to verify the transfer against src The account which sources the tokens dst The account which receives the tokens transferTokens The number of gTokens to transferreturn 0 if the transfer is allowed, otherwise a semi-opaq... | function transferAllowed(address gToken, address src, address dst, uint transferTokens) external returns (uint) {
// Pausing is a very serious situation - we revert to sound the alarms
require(!transferGuardianPaused, "transfer is paused");
// Currently the only consideration is whether or ... | function transferAllowed(address gToken, address src, address dst, uint transferTokens) external returns (uint) {
// Pausing is a very serious situation - we revert to sound the alarms
require(!transferGuardianPaused, "transfer is paused");
// Currently the only consideration is whether or ... | 45,396 |
16 | // Verify the other signer | bytes32 operationHash = keccak256(
abi.encodePacked(
getNetworkId(),
toAddress,
value,
data,
expireTime,
sequenceId
)
);
| bytes32 operationHash = keccak256(
abi.encodePacked(
getNetworkId(),
toAddress,
value,
data,
expireTime,
sequenceId
)
);
| 48,397 |
12 | // A mapping of all beneficiaries | mapping(address => Beneficiary) beneficiaries;
| mapping(address => Beneficiary) beneficiaries;
| 54,855 |
34 | // Note: can be made external into a utility contract (used for deployment) | function getResolverAddressesRequired()
external
view
returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
| function getResolverAddressesRequired()
external
view
returns (bytes32[MAX_ADDRESSES_FROM_RESOLVER] memory addressesRequired)
| 30,325 |
8 | // See {ERC20-_mint}. //Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). | function _mint(address _to, uint256 _amount) internal virtual onlyOwner override {
require(ERC20.totalSupply() + _amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(_to, _amount);
}
| function _mint(address _to, uint256 _amount) internal virtual onlyOwner override {
require(ERC20.totalSupply() + _amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(_to, _amount);
}
| 18,123 |
175 | // The SUSHI TOKEN! | SushiToken public sushi;
| SushiToken public sushi;
| 11,189 |
47 | // Returns Minted TokenID / | function readMintedTokenID(uint ArtistID, uint TicketID) external view returns (uint)
| function readMintedTokenID(uint ArtistID, uint TicketID) external view returns (uint)
| 21,342 |
12 | // this safely mints an NFT to the _holder address at the current counter index newItemID./_safeMint ensures that the receiver address can receive and handle ERC721s - which is either a normal wallet, or a smart contract that has implemented ERC721 receiver | _safeMint(_holder, newItemId);
| _safeMint(_holder, newItemId);
| 19,477 |
65 | // 3 | ReserveManagerQueue[_address] = block.number.add(
blocksNeededForQueue.mul(2)
);
| ReserveManagerQueue[_address] = block.number.add(
blocksNeededForQueue.mul(2)
);
| 37,192 |
11 | // EIP-20 token decimals for this token / | uint8 public decimals;
| uint8 public decimals;
| 4,736 |
15 | // require approved minter |
_mintBatch(_to, _tokenIds, _values, _data);
|
_mintBatch(_to, _tokenIds, _values, _data);
| 30,537 |
68 | // The cut contract takes from the share sales of an approved company. price is in wei | function _computeSalesCut(uint _price)
pure
internal
| function _computeSalesCut(uint _price)
pure
internal
| 44,351 |
142 | // solium-disable-next-line security/no-tx-origin | require(tx.origin == msg.sender, "Must be EOA");
Liquidation memory liquidation = liquidations[_integration];
address bAsset = liquidation.bAsset;
require(bAsset != address(0), "Liquidation does not exist");
require(block.timestamp > liquidation.lastTriggered.add(interval), "M... | require(tx.origin == msg.sender, "Must be EOA");
Liquidation memory liquidation = liquidations[_integration];
address bAsset = liquidation.bAsset;
require(bAsset != address(0), "Liquidation does not exist");
require(block.timestamp > liquidation.lastTriggered.add(interval), "M... | 53,554 |
202 | // ^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/ / | function _checkRole(bytes32 role, address account) internal view {
if(!hasRole(role, account)) {
revert(string(abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHe... | function _checkRole(bytes32 role, address account) internal view {
if(!hasRole(role, account)) {
revert(string(abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHe... | 9,922 |
94 | // update globalHarvestLastUpdateTime | info.globalHarvestLastUpdateTime = block.timestamp;
| info.globalHarvestLastUpdateTime = block.timestamp;
| 25,224 |
35 | // 4. Update user's stat 4.1 update purchase per window per user 4.2 update purchase per address | _updatePurchasePerUser(msg.sender, _purchaseableAmount);
_updateUserPurchaseWindow(msg.sender, _purchaseableAmount);
| _updatePurchasePerUser(msg.sender, _purchaseableAmount);
_updateUserPurchaseWindow(msg.sender, _purchaseableAmount);
| 39,988 |
174 | // Establish direct path between tokens. | (address[] memory path, uint256[] memory amounts) = _createPathAndAmounts(
address(tokenProvided), tokenReceived, false
);
| (address[] memory path, uint256[] memory amounts) = _createPathAndAmounts(
address(tokenProvided), tokenReceived, false
);
| 42,007 |
118 | // Rebalance collateral and debt in Maker.Based on defined risk parameter either borrow more DAI from Maker orpayback some DAI in Maker. It will try to mitigate risk of liquidation.Anyone can call it except when paused. / | function rebalanceCollateral() external onlyKeeper {
_rebalanceCollateral();
}
| function rebalanceCollateral() external onlyKeeper {
_rebalanceCollateral();
}
| 21,962 |
64 | // When token.balanceOf(this) < fork.allAmount, get token from LP | if (IERC20(tokenAddress).balanceOf(address(this)) < forkAllAmount) {
uint256 diffAmount = forkAllAmount -
IERC20(tokenAddress).balanceOf(address(this));
| if (IERC20(tokenAddress).balanceOf(address(this)) < forkAllAmount) {
uint256 diffAmount = forkAllAmount -
IERC20(tokenAddress).balanceOf(address(this));
| 47,707 |
31 | // Wrapper around OpenZeppelin's UpgradeabilityProxy contract.Permissions proxy upgrade logic to Audius Governance contract. Any logic contract that has a signature clash with this proxy contract will be unable to call those functions Please ensure logic contract functions do not share a signature with any functions de... | contract AudiusAdminUpgradeabilityProxy is UpgradeabilityProxy {
address private proxyAdmin;
string private constant ERROR_ONLY_ADMIN = (
"AudiusAdminUpgradeabilityProxy: Caller must be current proxy admin"
);
/**
* @notice Sets admin address for future upgrades
* @param _logic - addr... | contract AudiusAdminUpgradeabilityProxy is UpgradeabilityProxy {
address private proxyAdmin;
string private constant ERROR_ONLY_ADMIN = (
"AudiusAdminUpgradeabilityProxy: Caller must be current proxy admin"
);
/**
* @notice Sets admin address for future upgrades
* @param _logic - addr... | 43,727 |
53 | // we can't give people infinite ethereum | if (tokenSupply_ > 0) {
| if (tokenSupply_ > 0) {
| 70,761 |
304 | // Determine the prior number of votes for an account as of a block number Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check blockNumber The block number to get the vote balance atreturn The number of votes the account had as ... | function getPriorVotes(address account, uint blockNumber) external view returns (uint96) {
require(blockNumber < block.number, "HAT::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First... | function getPriorVotes(address account, uint blockNumber) external view returns (uint96) {
require(blockNumber < block.number, "HAT::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First... | 1,047 |
20 | // | struct Device {
bytes32 secondaryPublicKeyHash;
bytes32 tertiaryPublicKeyHash;
address contractAddress;
bytes32 hardwareManufacturer;
bytes32 hardwareModel;
bytes32 hardwareSerial;
bytes32 hardwareConfig;
uint256 kongAmount;
bool mintable;
}
| struct Device {
bytes32 secondaryPublicKeyHash;
bytes32 tertiaryPublicKeyHash;
address contractAddress;
bytes32 hardwareManufacturer;
bytes32 hardwareModel;
bytes32 hardwareSerial;
bytes32 hardwareConfig;
uint256 kongAmount;
bool mintable;
}
| 27,710 |
12 | // Returns an account's deposits. These can be either a contract's funds, or a relay manager's revenue. | function balanceOf(address target) external view returns (uint256);
| function balanceOf(address target) external view returns (uint256);
| 40,937 |
26 | // Upgradable by the owner./ | function _authorizeUpgrade(address /*newImplementation*/ ) internal view override {
_onlyOwner();
}
| function _authorizeUpgrade(address /*newImplementation*/ ) internal view override {
_onlyOwner();
}
| 16,861 |
45 | // Remove a funded function functionPosition The position of the funded function in fundedFunctions / | function removeFundedFunction(uint256 functionPosition) internal {
require(both(functionPosition <= latestFundedFunction, functionPosition > 0), "RewardAdjusterBundler/invalid-position");
FundedFunction memory fundedFunction = fundedFunctions[functionPosition];
require(addedFunction[fundedF... | function removeFundedFunction(uint256 functionPosition) internal {
require(both(functionPosition <= latestFundedFunction, functionPosition > 0), "RewardAdjusterBundler/invalid-position");
FundedFunction memory fundedFunction = fundedFunctions[functionPosition];
require(addedFunction[fundedF... | 23,141 |
142 | // | //function symbol() public view virtual returns (string memory) {
// return "UP";
//}
| //function symbol() public view virtual returns (string memory) {
// return "UP";
//}
| 23,326 |
44 | // In dst chain order will start from 0-NotSet | if (orderState.status != OrderTakeStatus.NotSet) revert IncorrectOrderStatus();
orderState.status = OrderTakeStatus.SentCancel;
| if (orderState.status != OrderTakeStatus.NotSet) revert IncorrectOrderStatus();
orderState.status = OrderTakeStatus.SentCancel;
| 13,473 |
128 | // Calculates the next value of an specific distribution index, with validations currentIndex Current index of the distribution emissionPerSecond Representing the total rewards distributed per second per asset unit, on the distribution lastUpdateTimestamp Last moment this distribution was updated totalBalance of tokens... | ) internal view returns (uint256) {
if (
emissionPerSecond == 0 ||
totalBalance == 0 ||
lastUpdateTimestamp == block.timestamp ||
lastUpdateTimestamp >= DISTRIBUTION_END
) {
return currentIndex;
}
uint256 currentTimestamp =
block.timestamp > DISTRIBUTION_END ? DIST... | ) internal view returns (uint256) {
if (
emissionPerSecond == 0 ||
totalBalance == 0 ||
lastUpdateTimestamp == block.timestamp ||
lastUpdateTimestamp >= DISTRIBUTION_END
) {
return currentIndex;
}
uint256 currentTimestamp =
block.timestamp > DISTRIBUTION_END ? DIST... | 31,383 |
9 | // Modifier throws if called by any account other than the pendingOwner. | modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "UNAUTHORIZED");
_;
}
| modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "UNAUTHORIZED");
_;
}
| 3,435 |
24 | // return list of addresses permitted to transmit reports to this contract The list will match the order used to specify the transmitter during setConfig / | function transmitters() external view returns (address[] memory) {
return s_transmitters;
}
| function transmitters() external view returns (address[] memory) {
return s_transmitters;
}
| 5,249 |
84 | // Only one plan will be active at the time of a hack--return cover amount from then. | if (_hackTime >= plan.startTime && _hackTime < plan.endTime) {
for(uint256 j = 0; j< plan.length; j++){
bytes32 key = _hashKey(_user, uint256(i), j);
if(IStakeManager(getModule("STAKE")).protocolAddress(protocolPlan[key].protocolId) == _protocol){
... | if (_hackTime >= plan.startTime && _hackTime < plan.endTime) {
for(uint256 j = 0; j< plan.length; j++){
bytes32 key = _hashKey(_user, uint256(i), j);
if(IStakeManager(getModule("STAKE")).protocolAddress(protocolPlan[key].protocolId) == _protocol){
... | 84,715 |
13 | // TRANSFER LOGIC / |
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
|
function transfer(address recipient, uint256 amount)
public
override
returns (bool)
| 952 |
2 | // Views |
function getMostPremium()
public
override
view
returns (address, uint256)
{
|
function getMostPremium()
public
override
view
returns (address, uint256)
{
| 1,675 |
4 | // log the event | logger.Log(address(this), msg.sender, "ExchangeSell", abi.encode(wrapper, exData.srcAddr, exData.destAddr, exData.srcAmount, destAmount));
| logger.Log(address(this), msg.sender, "ExchangeSell", abi.encode(wrapper, exData.srcAddr, exData.destAddr, exData.srcAmount, destAmount));
| 46,929 |
6 | // Get the amount of unsold tokens allocated to this contract; / | function getTokensLeft() public view returns (uint) {
return token.allowance(owner, address(this));
}
| function getTokensLeft() public view returns (uint) {
return token.allowance(owner, address(this));
}
| 32,570 |
35 | // https:github.com/provable-things/ethereum-api/blob/master/provableAPI_0.6.sol | function _uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
whi... | function _uint2str(uint _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint j = _i;
uint len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint k = len;
whi... | 79,099 |
77 | // This internal function is equivalent to {transfer}, and can be used toe.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.- `sender` must have a balance of at least `amount`. / | function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender... | function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender... | 11,715 |
194 | // wait 3 blocks to avoid flash loans | require((_lastCall[msg.sender] + MIN_DELAY) <= block.number, "action too soon - please wait a few more blocks");
| require((_lastCall[msg.sender] + MIN_DELAY) <= block.number, "action too soon - please wait a few more blocks");
| 16,624 |
405 | // SPDX-License-Identifier: MIT/ Token Geyser A smart-contract based mechanism to distribute tokens over time, inspired loosely by Compound and Uniswap.Distribution tokens are added to a locked pool in the contract and become unlocked over time according to a once-configurable unlock schedule. Once unlocked, they are a... | contract TokenGeyser is IStaking, IStakeWithNFT, Ownable {
using SafeMath for uint256;
event Staked(
address indexed user,
uint256 amount,
uint256 total,
bytes data
);
event Unstaked(
address indexed user,
uint256 amount,
uint256 total,
by... | contract TokenGeyser is IStaking, IStakeWithNFT, Ownable {
using SafeMath for uint256;
event Staked(
address indexed user,
uint256 amount,
uint256 total,
bytes data
);
event Unstaked(
address indexed user,
uint256 amount,
uint256 total,
by... | 9,592 |
24 | // Returns the maximum number of nfts supported to be listed in this LendPool / | function getMaxNumberOfNfts() external view returns (uint256);
| function getMaxNumberOfNfts() external view returns (uint256);
| 24,251 |
9 | // Randomly set secretNumber with a value between 1 and 10 | secretNumber = uint8(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 10 + 1;
| secretNumber = uint8(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 10 + 1;
| 11,789 |
125 | // Return the withdrawal fee for a given amount of TokenA and TokenBfeeA := amountAfeeRatefeeB := amountBfeeRate / | function feeAFeeBForTokenATokenB(
uint256 amountA,
uint256 amountB,
uint256 feeRate
| function feeAFeeBForTokenATokenB(
uint256 amountA,
uint256 amountB,
uint256 feeRate
| 24,819 |
54 | // solhint-disable-next-line no-inline-assembly | assembly { size := extcodesize(account) }
| assembly { size := extcodesize(account) }
| 295 |
122 | // fallback function to receives ETH. | receive() external payable {
// calls `buyTokens()`
buyTokens();
}
| receive() external payable {
// calls `buyTokens()`
buyTokens();
}
| 22,048 |
107 | // Transfer tokens to this contract | IERC20(token).safeTransferFrom(msg.sender, address(locker), _amount);
| IERC20(token).safeTransferFrom(msg.sender, address(locker), _amount);
| 21,283 |
85 | // After iterating through all the nOutcomes bit positions, we should be left with 0. Otherwise, it means that other higher bits were set. | if (!(winningOutcomeIndexFlagsCopy == 0)) revert OutcomeIndexOutOfRange();
| if (!(winningOutcomeIndexFlagsCopy == 0)) revert OutcomeIndexOutOfRange();
| 22,404 |
78 | // check to see if this repo exists | if(orgsById[orgId].servicesById[serviceId].serviceId == bytes32(0x0)) {
found = false;
return;
}
| if(orgsById[orgId].servicesById[serviceId].serviceId == bytes32(0x0)) {
found = false;
return;
}
| 45,700 |
95 | // set's marketing address / | function setMarketingFeeAddress(address payable wallet) external onlyOwner {
marketingAddress = wallet;
}
| function setMarketingFeeAddress(address payable wallet) external onlyOwner {
marketingAddress = wallet;
}
| 21,468 |
155 | // Convert boolean value into bytes b The boolean valuereturnConverted bytes array/ | function WriteBool(bool b) internal pure returns (bytes memory) {
bytes memory buff;
assembly{
buff := mload(0x40)
mstore(buff, 1)
switch iszero(b)
case 1 {
mstore(add(buff, 0x20), shl(248, 0x00))
| function WriteBool(bool b) internal pure returns (bytes memory) {
bytes memory buff;
assembly{
buff := mload(0x40)
mstore(buff, 1)
switch iszero(b)
case 1 {
mstore(add(buff, 0x20), shl(248, 0x00))
| 29,021 |
148 | // The total number of burned FAIR tokens, excluding tokens burned from a `Sell` action in the DAT. | uint public burnedSupply;
| uint public burnedSupply;
| 7,788 |
613 | // delete token from previous owner | _deleteOwnershipRecord(_tokenId);
| _deleteOwnershipRecord(_tokenId);
| 18,417 |
478 | // Fills the input ExchangeV2 order. The `makerFeeAssetData` must be equal to EXCHANGE_V2_ORDER_ID (0x770501f8)./Returns false if the transaction would otherwise revert./order Order struct containing order specifications./takerAssetFillAmount Desired amount of takerAsset to sell./signature Proof that order has been cre... | function _fillV2OrderNoThrow(
LibOrder.Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
internal
returns (LibFillResults.FillResults memory fillResults)
| function _fillV2OrderNoThrow(
LibOrder.Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
internal
returns (LibFillResults.FillResults memory fillResults)
| 37,163 |
93 | // Safely transfers the ownership of a given token ID to another address If the target address is a contract, it must implement `onERC721Received`, which is called upon a safe transfer, and return the magic value `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`; otherwise, the transfer is reverted. Requir... | function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
public
canTransfer(_tokenId)
| function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes _data
)
public
canTransfer(_tokenId)
| 6,595 |
141 | // Reserved for future expansion | int256[98] private _reserved;
| int256[98] private _reserved;
| 83,527 |
24 | // checks that Node has correct data | require(params.ip != 0x0 && !nodesIPCheck[params.ip], "IP address is zero or is not available");
require(!nodesNameCheck[keccak256(abi.encodePacked(params.name))], "Name is already registered");
require(params.port > 0, "Port is zero");
require(from == _publicKeyToAddress(params.publicKe... | require(params.ip != 0x0 && !nodesIPCheck[params.ip], "IP address is zero or is not available");
require(!nodesNameCheck[keccak256(abi.encodePacked(params.name))], "Name is already registered");
require(params.port > 0, "Port is zero");
require(from == _publicKeyToAddress(params.publicKe... | 26,983 |
109 | // Full ERC721 TokenThis implementation includes all the required and some optional functionality of the ERC721 standardMoreover, it includes approve all functionality using operator terminology / | contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
bytes4 private constant InterfaceId_ERC721Enumerable = 0x780e9d63;
/**
* 0x780e9d63 ===
* bytes4(keccak256('totalSupply()')) ^
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
* bytes4(keccak256('t... | contract ERC721Token is SupportsInterfaceWithLookup, ERC721BasicToken, ERC721 {
bytes4 private constant InterfaceId_ERC721Enumerable = 0x780e9d63;
/**
* 0x780e9d63 ===
* bytes4(keccak256('totalSupply()')) ^
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
* bytes4(keccak256('t... | 65,424 |
44 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first r... | function approve(address _spender, uint256 _value) onlyPayloadSize(2) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) onlyPayloadSize(2) public returns (bool) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| 13,623 |
32 | // require(capitalRequirement <= initialMint, "Insufficient capital"); |
BinaryOptionMarket market =
BinaryOptionMarketFactory(binaryOptionMarketFactory).createMarket(
msg.sender,
resolver,
oracleKey,
strikePrice,
[maturity, expiry],
initialMint,
[fees.poolFee... |
BinaryOptionMarket market =
BinaryOptionMarketFactory(binaryOptionMarketFactory).createMarket(
msg.sender,
resolver,
oracleKey,
strikePrice,
[maturity, expiry],
initialMint,
[fees.poolFee... | 16,591 |
13 | // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. | sender := and(mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff)
| sender := and(mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff)
| 11,254 |
119 | // Protocols that staking is allowed for. We may not allow all NFTs. | mapping (address => bool) public allowedProtocol;
mapping (address => uint64) public override protocolId;
mapping (uint64 => address) public override protocolAddress;
uint64 protocolCount;
| mapping (address => bool) public allowedProtocol;
mapping (address => uint64) public override protocolId;
mapping (uint64 => address) public override protocolAddress;
uint64 protocolCount;
| 51,007 |
8 | // Modifiers | modifier onlyTokenManager() { if(msg.sender != tokenManager) throw; _; }
modifier onlyCrowdsaleManager() { if(msg.sender != crowdsaleManager) throw; _; }
/*/
* Events
/*/
event LogBuy(address indexed owner, uint etherWeiIncoming, uint tokensSold);
event LogBurn(address indexed owner, ... | modifier onlyTokenManager() { if(msg.sender != tokenManager) throw; _; }
modifier onlyCrowdsaleManager() { if(msg.sender != crowdsaleManager) throw; _; }
/*/
* Events
/*/
event LogBuy(address indexed owner, uint etherWeiIncoming, uint tokensSold);
event LogBurn(address indexed owner, ... | 3,177 |
5 | // calculate the maximum quantity of base assets which may be deposited on behalf of given receiver receiver recipient of shares resulting from depositreturn maxAssets maximum asset deposit amount / | function maxDeposit(address receiver)
| function maxDeposit(address receiver)
| 37,707 |
101 | // Randomly select training indexes | while(t_index < training_partition.length) {
uint random_index = uint(sha256(block.blockhash(block.number-block_i))) % array_length;
training_partition[t_index] = array[random_index];
array[random_index] = array[array_length-1];
array_length--;
block_i++;
t_index++;
}
| while(t_index < training_partition.length) {
uint random_index = uint(sha256(block.blockhash(block.number-block_i))) % array_length;
training_partition[t_index] = array[random_index];
array[random_index] = array[array_length-1];
array_length--;
block_i++;
t_index++;
}
| 17,488 |
58 | // after the claiming operation succeeds | userToNonce[_user] += 1;
| userToNonce[_user] += 1;
| 20,452 |
17 | // Thrown if the deposit amount is zero. | error ZeroAmount();
| error ZeroAmount();
| 8,241 |
14 | // Returns the scaling factor for one of the Pool's tokens. Reverts if `token` is not a token registered by thePool. / | function _scalingFactor(IERC20 token) internal view virtual override returns (uint256) {
// prettier-ignore
if (token == _token0) { return _scalingFactor0; }
else if (token == _token1) { return _scalingFactor1; }
else if (token == _token2) { return _scalingFactor2; }
else if ... | function _scalingFactor(IERC20 token) internal view virtual override returns (uint256) {
// prettier-ignore
if (token == _token0) { return _scalingFactor0; }
else if (token == _token1) { return _scalingFactor1; }
else if (token == _token2) { return _scalingFactor2; }
else if ... | 21,841 |
1 | // is every thing okay..? | require(campaign.deadline <block.timestamp, "The deadline should be a date in future.");
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;... | require(campaign.deadline <block.timestamp, "The deadline should be a date in future.");
campaign.owner = _owner;
campaign.title = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;... | 25,650 |
32 | // Emitted when someone cancels a signature | event SignatureCancelled(address indexed signer, bytes sig);
| event SignatureCancelled(address indexed signer, bytes sig);
| 4,862 |
24 | // Since this is a UUPS Upgradable contract, use deployUUPSProxy | deployUUPSProxy(
"ProjectToken",
abi.encodeWithSelector(
ProjectToken.initialize.selector,
this,
name_,
description_,
symbol_,
maxSupply_,
isFixedSupply_,
| deployUUPSProxy(
"ProjectToken",
abi.encodeWithSelector(
ProjectToken.initialize.selector,
this,
name_,
description_,
symbol_,
maxSupply_,
isFixedSupply_,
| 16,331 |
8 | // Amount of votes that holder has./sender_ address of the holder./ return number of votes. | function votesOf(address sender_) external view returns (uint256);
| function votesOf(address sender_) external view returns (uint256);
| 10,700 |
256 | // Retrieves the value of a storage slot. _contract Address of the contract to query. _key 32 byte key of the storage slot.return _value 32 byte storage slot value. / | function _getContractStorage(
address _contract,
bytes32 _key
)
internal
returns (
bytes32 _value
)
| function _getContractStorage(
address _contract,
bytes32 _key
)
internal
returns (
bytes32 _value
)
| 28,045 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.