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 |
|---|---|---|---|---|
114 | // if claim is for 721 transfer NFT between buyer and bidder | IERC721(claims[claimId].nftContract).transferFrom(claims[claimId].owner, claims[claimId].sender, claims[claimId].tokenId);
| IERC721(claims[claimId].nftContract).transferFrom(claims[claimId].owner, claims[claimId].sender, claims[claimId].tokenId);
| 26,559 |
185 | // reward for the lucky ticket holder | uint256 luckyFunds = SafeMath.sub(lotto.reward, triggererFunds);
| uint256 luckyFunds = SafeMath.sub(lotto.reward, triggererFunds);
| 36,073 |
98 | // The callback function of ChainLink Oracle when theRandom Number Generation is completed. An event is firedto notify the same and the randomResult is saved. | * Emits an {RandomNumberGenerated} event indicating the random number is
* generated by the Oracle.
*
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness)
internal
override
{
randomResult = randomness;
isRandomNumberGenerated = true;
em... | * Emits an {RandomNumberGenerated} event indicating the random number is
* generated by the Oracle.
*
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness)
internal
override
{
randomResult = randomness;
isRandomNumberGenerated = true;
em... | 37,023 |
134 | // Define Start + End Index | uint256 startIndex = 0;
uint256 endIndex = mintingFeeBracket.length - 1;
uint256 middleIndex = endIndex / 2;
if (cash <= mintingFeeBracket[middleIndex]) {
endIndex = middleIndex;
} else {
| uint256 startIndex = 0;
uint256 endIndex = mintingFeeBracket.length - 1;
uint256 middleIndex = endIndex / 2;
if (cash <= mintingFeeBracket[middleIndex]) {
endIndex = middleIndex;
} else {
| 48,945 |
225 | // Check that tokenId was not transferred by `_beforeTokenTransfer` hook | require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer from incorrect owner"
);
| require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer from incorrect owner"
);
| 29,694 |
13 | // Deduct the difference between the newly scheduled withdrawals and the older withdrawals so we can charge them fees before they leave | uint256 withdrawAmountDiff =
queuedWithdrawBeforeFee > params.lastQueuedWithdrawAmount
? queuedWithdrawBeforeFee.sub(
params.lastQueuedWithdrawAmount
)
: 0;
balanceForVaultFees = currentBalance
... | uint256 withdrawAmountDiff =
queuedWithdrawBeforeFee > params.lastQueuedWithdrawAmount
? queuedWithdrawBeforeFee.sub(
params.lastQueuedWithdrawAmount
)
: 0;
balanceForVaultFees = currentBalance
... | 26,732 |
18 | // return jackpot to contract creator if no purchases or claims in 30 days. | function killme() public payable onlyContractOwner {
require(now > lastAction + 30 days);
seedAmount = 0;
jackpotBalance = 0;
contractOwner.transfer(jackpotBalance);
}
| function killme() public payable onlyContractOwner {
require(now > lastAction + 30 days);
seedAmount = 0;
jackpotBalance = 0;
contractOwner.transfer(jackpotBalance);
}
| 11,581 |
127 | // Sunday, 4 July 2021 г., 23:59:00 | require(now >= endICODate + 94608000);
token.transfer(walletE, paymentSizeE);
completedE[order] = true;
| require(now >= endICODate + 94608000);
token.transfer(walletE, paymentSizeE);
completedE[order] = true;
| 45,916 |
26 | // Withdraw/tranche Tranche of the share/amount The amount to deposit | function withdraw(uint256 tranche, uint256 amount) external {
uint256 rebalanceSize = fund.getRebalanceSize();
_checkpoint(rebalanceSize);
_userCheckpoint(msg.sender, rebalanceSize);
_availableBalances[msg.sender][tranche] = _availableBalances[msg.sender][tranche].sub(
am... | function withdraw(uint256 tranche, uint256 amount) external {
uint256 rebalanceSize = fund.getRebalanceSize();
_checkpoint(rebalanceSize);
_userCheckpoint(msg.sender, rebalanceSize);
_availableBalances[msg.sender][tranche] = _availableBalances[msg.sender][tranche].sub(
am... | 28,496 |
237 | // call compoundMonitorProxy which will call users DSProxy to call compSubProxy and subscribe to strategy system with same data call to compSubProxy will also unsub the user from this automation | compoundMonitorProxy.callExecute(
userProxy,
address(compSubProxy),
abi.encodeWithSelector(ICompSubProxy.subToCompAutomation.selector, newSubInfo)
);
| compoundMonitorProxy.callExecute(
userProxy,
address(compSubProxy),
abi.encodeWithSelector(ICompSubProxy.subToCompAutomation.selector, newSubInfo)
);
| 37,532 |
26 | // Unequip the previous skill | uint256 previousSkillId = characterEquips[characterTokenId]
.equippedSkill;
if (
(previousSkillId != 0 && previousSkillId != 9999) ||
(previousSkillId == 0 && skillId != 9999)
) {
battleSkills.safeTransferFrom(
address(this),
... | uint256 previousSkillId = characterEquips[characterTokenId]
.equippedSkill;
if (
(previousSkillId != 0 && previousSkillId != 9999) ||
(previousSkillId == 0 && skillId != 9999)
) {
battleSkills.safeTransferFrom(
address(this),
... | 9,607 |
6 | // Exodus Treasury V1 | ITreasuryV1 internal immutable treasuryV1 = ITreasuryV1(0x31F8Cc382c9898b273eff4e0b7626a6987C846E8);
| ITreasuryV1 internal immutable treasuryV1 = ITreasuryV1(0x31F8Cc382c9898b273eff4e0b7626a6987C846E8);
| 17,199 |
129 | // Handled in main function | if (compareAttrib(attrib, "d") || compareAttrib(attrib, "points") || compareAttrib(attrib, "values") || compareAttrib(attrib, 'transform')) {
return (idx + 2, outputIdx);
}
| if (compareAttrib(attrib, "d") || compareAttrib(attrib, "points") || compareAttrib(attrib, "values") || compareAttrib(attrib, 'transform')) {
return (idx + 2, outputIdx);
}
| 74,387 |
14 | // admin pay gas for user | function topupCollateralByAdmin(
uint lid,
uint256 amount,
bytes32 offchain
)
public
onlyAdmin
| function topupCollateralByAdmin(
uint lid,
uint256 amount,
bytes32 offchain
)
public
onlyAdmin
| 43,218 |
70 | // Set new router | function set_New_Router_Address(address newRouter) public onlyOwner() {
IUniswapV2Router02 _newPCSRouter = IUniswapV2Router02(newRouter);
uniswapV2Router = _newPCSRouter;
}
| function set_New_Router_Address(address newRouter) public onlyOwner() {
IUniswapV2Router02 _newPCSRouter = IUniswapV2Router02(newRouter);
uniswapV2Router = _newPCSRouter;
}
| 5,625 |
154 | // provides in depth details about rewards of the holder. Accuracy of future projection is not guaranteed./NB! explanation does not consider auto-locking/at is a timestamp (current or future) to calculate rewards/ return details of rewards, see RewardExplained | function explainReward(address holder, uint32 at) external view returns (RewardExplained memory);
| function explainReward(address holder, uint32 at) external view returns (RewardExplained memory);
| 44,332 |
231 | // offset time inaccuracy when checking update expiration date | uint public m_leeway = 900; // 15 minutes is the limit for miners
| uint public m_leeway = 900; // 15 minutes is the limit for miners
| 48,450 |
32 | // - Return claim status | function getClaimDecided(bytes32 superblockHash) external view returns (bool) {
return claims[superblockHash].decided;
}
| function getClaimDecided(bytes32 superblockHash) external view returns (bool) {
return claims[superblockHash].decided;
}
| 15,715 |
23 | // Team Withdraw Function | function withdrawTeam() public onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0);
_widthdraw(a1, balance.mul(25).div(100)); // Justin
_widthdraw(a2, balance.mul(25).div(100)); // Dontblink
_widthdraw(a3, balance.mul(25).div(100)); // Skelligore
... | function withdrawTeam() public onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0);
_widthdraw(a1, balance.mul(25).div(100)); // Justin
_widthdraw(a2, balance.mul(25).div(100)); // Dontblink
_widthdraw(a3, balance.mul(25).div(100)); // Skelligore
... | 19,899 |
262 | // Attempt to redeem the underlying balance from the dToken contract. | (bool ok, bytes memory data) = dToken.call(abi.encodeWithSelector(
| (bool ok, bytes memory data) = dToken.call(abi.encodeWithSelector(
| 52,739 |
123 | // Is Asset Burning Active | bool public canBurn;
| bool public canBurn;
| 50,867 |
178 | // no fyDai transferred, because initial fyDai deposit is entirely virtual | dai.transferFrom(msg.sender, address(this), daiIn);
_mint(msg.sender, daiIn);
emit Liquidity(maturity, msg.sender, msg.sender, -toInt256(daiIn), 0, toInt256(daiIn));
return daiIn;
| dai.transferFrom(msg.sender, address(this), daiIn);
_mint(msg.sender, daiIn);
emit Liquidity(maturity, msg.sender, msg.sender, -toInt256(daiIn), 0, toInt256(daiIn));
return daiIn;
| 12,411 |
61 | // newBorrowAmount = borrowAmount10^18 / (10^18 - (interestRateinitialLoanDuration10^18 / (3153600010^20))) | newBorrowAmount = borrowAmount
.mul(WEI_PRECISION)
.div(
SafeMath.sub(WEI_PRECISION,
interestRate
.mul(initialLoanDuration)
.mul(WEI_PRECISION)
.div(31536000 * WEI_PERCENT_PRECISIO... | newBorrowAmount = borrowAmount
.mul(WEI_PRECISION)
.div(
SafeMath.sub(WEI_PRECISION,
interestRate
.mul(initialLoanDuration)
.mul(WEI_PRECISION)
.div(31536000 * WEI_PERCENT_PRECISIO... | 7,764 |
486 | // Sets the stored oracle contract with the address resolved by ENS This may be called on its own as long as `useChainlinkWithENS` has been called previously / | function updateChainlinkOracleWithENS() internal {
bytes32 oracleSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME));
ENSResolver resolver = ENSResolver(s_ens.resolver(oracleSubnode));
setChainlinkOracle(resolver.addr(oracleSubnode));
}
| function updateChainlinkOracleWithENS() internal {
bytes32 oracleSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME));
ENSResolver resolver = ENSResolver(s_ens.resolver(oracleSubnode));
setChainlinkOracle(resolver.addr(oracleSubnode));
}
| 12,822 |
188 | // Overwrite parent implementation to add locked verification | function burn (uint256 amount) public override isNotLocked(msg.sender, msg.sender) {
super.burn(amount);
}
| function burn (uint256 amount) public override isNotLocked(msg.sender, msg.sender) {
super.burn(amount);
}
| 51,520 |
1,512 | // Taken fromhttps:github.com/opengsn/forwarder/blob/master/contracts/Forwarder.sol and adapted to work locally Main change is removing interface inheritance and adding a some debugging niceities | contract TestForwarder {
using ECDSA for bytes32;
struct ForwardRequest {
address from;
address to;
uint256 value;
uint256 gas;
uint256 nonce;
bytes data;
}
string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data";
string p... | contract TestForwarder {
using ECDSA for bytes32;
struct ForwardRequest {
address from;
address to;
uint256 value;
uint256 gas;
uint256 nonce;
bytes data;
}
string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data";
string p... | 73,056 |
133 | // Provides information about the current execution context, including thesender of the transaction and its data. While these are generally availablevia msg.sender and msg.data, they should not be accessed in such a directmanner, since when dealing with meta-transactions the account sending andpaying for execution may ... | abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
| abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
| 90 |
19 | // Calculates the expected harvest reward from third partyreturn Expected reward to collect in WOLF / | function calculateHarvestWolfRewards() external view returns (uint256) {
uint256 amount = IMasterChef(masterchef).pendingWolf(0, address(this));
amount = amount.add(available());
uint256 currentCallFee = amount.mul(callFee).div(10000);
return currentCallFee;
}
| function calculateHarvestWolfRewards() external view returns (uint256) {
uint256 amount = IMasterChef(masterchef).pendingWolf(0, address(this));
amount = amount.add(available());
uint256 currentCallFee = amount.mul(callFee).div(10000);
return currentCallFee;
}
| 34,145 |
31 | // variables that help track where in the refund loop we are in. | mapping(address => uint) private advertiserRefundRequestsIndex;
uint private lastProccessedIndex = 0;
| mapping(address => uint) private advertiserRefundRequestsIndex;
uint private lastProccessedIndex = 0;
| 51,397 |
27 | // The basics of a proxy read call Note that msg.sender in the underlying will always be the address of this contract. | assembly {
calldatacopy(0, 0, calldatasize)
| assembly {
calldatacopy(0, 0, calldatasize)
| 9,336 |
2 | // Check the last exchange rate without any state changes./data Usually abi encoded, implementation specific data that contains information and arguments to & about the oracle./ For example:/ (string memory collateralSymbol, string memory assetSymbol, uint256 division) = abi.decode(data, (string, string, uint256));/ re... | function peek(bytes calldata data) external view returns (bool success, uint256 rate);
| function peek(bytes calldata data) external view returns (bool success, uint256 rate);
| 10,356 |
54 | // Cancel game by ID and return money to game creator. No fee. | function _cancelGame(uint256 gameId) internal {
GameData memory data = gamesData[gameId];
if (data.stage != Stages.WaitForOpponent) revert IncorrectGameStage();
uint256 amount = gamesData[gameId].gameBalance;
data.gameBalance = 0;
data.stage = Stages.Done;
data.act... | function _cancelGame(uint256 gameId) internal {
GameData memory data = gamesData[gameId];
if (data.stage != Stages.WaitForOpponent) revert IncorrectGameStage();
uint256 amount = gamesData[gameId].gameBalance;
data.gameBalance = 0;
data.stage = Stages.Done;
data.act... | 5,965 |
90 | // Returns active raffles. / | function fetchRaffles() public view returns (MarketItem[] memory) {
uint currentIndex = 0;
// Initialize array
MarketItem[] memory items = new MarketItem[](_onRaffle.current());
// Fill array
for (uint i = 0; i < _itemIds.current(); i++) {
if (idToMarketItem[i + 1].onSale && idToMarketItem[i + 1].typeIt... | function fetchRaffles() public view returns (MarketItem[] memory) {
uint currentIndex = 0;
// Initialize array
MarketItem[] memory items = new MarketItem[](_onRaffle.current());
// Fill array
for (uint i = 0; i < _itemIds.current(); i++) {
if (idToMarketItem[i + 1].onSale && idToMarketItem[i + 1].typeIt... | 25,327 |
87 | // Check hash equals the last commitment in array | if (hash != _transaction.commitments[_transaction.commitments.length - 1])
return (false, "Invalid Withdraw Note");
| if (hash != _transaction.commitments[_transaction.commitments.length - 1])
return (false, "Invalid Withdraw Note");
| 17,331 |
101 | // Verify splits add up | require(tReward == burnAmount.add(amt1).add(amt2).add(amt3).add(amt4), "mismatch");
return (tReward, amt1, amt2, amt3, amt4, burnAmount);
| require(tReward == burnAmount.add(amt1).add(amt2).add(amt3).add(amt4), "mismatch");
return (tReward, amt1, amt2, amt3, amt4, burnAmount);
| 33,424 |
129 | // add token to trader list | _addToken(address(_destination));
| _addToken(address(_destination));
| 28,884 |
123 | // start next round | rID_++;
_rID++;
round_[_rID].strt = now;
round_[_rID].end = now.add(rndInit_);
round_[_rID].pot = _res;
return (_eventData_);
| rID_++;
_rID++;
round_[_rID].strt = now;
round_[_rID].end = now.add(rndInit_);
round_[_rID].pot = _res;
return (_eventData_);
| 6,946 |
0 | // Set up items | items.initialize(address(new AttackItemsStats()), address(new DefenseItemsStats()), address(new SpellItemsStats()), address(new BuffItemsStats()), address(new BossDropsStats()), address(0));
items.setEntropy(uint256(keccak256(abi.encode("ITEMS_ENTROPY"))));
items.setAuth(address(meta), true);
... | items.initialize(address(new AttackItemsStats()), address(new DefenseItemsStats()), address(new SpellItemsStats()), address(new BuffItemsStats()), address(new BossDropsStats()), address(0));
items.setEntropy(uint256(keccak256(abi.encode("ITEMS_ENTROPY"))));
items.setAuth(address(meta), true);
... | 3,409 |
3 | // Returns EIP2612 Permit message hash. Used to construct EIP2612/ signature provided to `permit` function. | bytes32 public constant override PERMIT_TYPEHASH =
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
);
| bytes32 public constant override PERMIT_TYPEHASH =
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
);
| 2,136 |
25 | // if there is any stake on stack, delete the stack | if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender];
| if(transferIns[msg.sender].length > 0) delete transferIns[msg.sender];
| 25,443 |
112 | // Protection to not have too much reserved from any single vault. | if (_newPercentReserved > 3300) {
percentReserved = 3300;
} else {
| if (_newPercentReserved > 3300) {
percentReserved = 3300;
} else {
| 67,431 |
125 | // Deprecated, use {ERC721-_burn} instead.account owner of the token to burntokenId uint256 ID of the token being burnedamount uint256 amount of supply being burned/ |
function _burn(address account, uint256 tokenId, uint256 amount) internal virtual {
require(_exists(tokenId), "ERC1155Metadata: burn query for nonexistent token");
require(account != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenT... |
function _burn(address account, uint256 tokenId, uint256 amount) internal virtual {
require(_exists(tokenId), "ERC1155Metadata: burn query for nonexistent token");
require(account != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenT... | 22,207 |
11 | // market owner allowed to chainge marketplace state _state new market state / | function changeMarketState(bool _state) public onlyAdmin() {
require(marktState != _state, "Sorry, this is the current state!!");
marktState = _state;
emit marketStateChanged(_state);
}
| function changeMarketState(bool _state) public onlyAdmin() {
require(marktState != _state, "Sorry, this is the current state!!");
marktState = _state;
emit marketStateChanged(_state);
}
| 9,681 |
62 | // Flag that says if chain is active - num of active validators > 0 && first block was already mined | bool active;
| bool active;
| 18,493 |
108 | // contract gets 10% of the token to generate LP token and Marketing Budget fasecontract will sell token over the first 200 sells to generate maximum LP and BNB | uint256 injectBalance=_circulatingSupply-deployerBalance;
_balances[address(this)]=injectBalance;
emit Transfer(address(0), address(this),injectBalance);
| uint256 injectBalance=_circulatingSupply-deployerBalance;
_balances[address(this)]=injectBalance;
emit Transfer(address(0), address(this),injectBalance);
| 33,477 |
1 | // Public functions //Calculates the net cost for executing a given trade./market Market contract/outcomeTokenAmounts Amounts of outcome tokens to buy from the market. If an amount is negative, represents an amount to sell to the market./ return Net cost of trade. If positive, represents amount of collateral which woul... | function calcNetCost(Market market, int[] outcomeTokenAmounts)
public
view
returns (int netCost)
| function calcNetCost(Market market, int[] outcomeTokenAmounts)
public
view
returns (int netCost)
| 4,865 |
10 | // Standard math utilities missing in the Solidity language. / | library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uin... | library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uin... | 1,441 |
6 | // Modifications:1. Update Solidity version from 0.8.0 to 0.7.6. Version 0.8.0 was usedas base because this contract was added to OZ repo after version 0.8.0. Contract module which provides access control mechanism, wherethere is an account (an owner) that can be granted exclusive access tospecific functions. By defaul... | * can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(
address in... | * can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(
address in... | 18,458 |
67 | // emit Newbie(msg.sender); | }
| }
| 77,912 |
286 | // Increase recipient DVD balance | IDvd(dvd).mint(recipient, returnedDVD);
| IDvd(dvd).mint(recipient, returnedDVD);
| 19,243 |
65 | // 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;
}
| 23,051 |
83 | // Creates and begins a new auction._tokenId - ID of token to auction, sender must be owner._startingPrice - Price of item (in wei) at beginning of auction._endingPrice - Price of item (in wei) at end of auction._duration - Length of auction (in seconds)._seller - Seller, if not the message sender | function createAuction(
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration,
address _seller
)
external
{
| function createAuction(
uint256 _tokenId,
uint256 _startingPrice,
uint256 _endingPrice,
uint256 _duration,
address _seller
)
external
{
| 23,994 |
2 | // allows owner to change itself at any time | function setOwner(address owner_) public {
require(msg.sender == owner, 'SDFeeToSetter::setOwner: not allowed');
owner = owner_;
}
| function setOwner(address owner_) public {
require(msg.sender == owner, 'SDFeeToSetter::setOwner: not allowed');
owner = owner_;
}
| 43,460 |
7 | // returns the last time the reward was modified or periodFinish if the reward has ended | function lastTimeRewardApplicable(address token) public view returns (uint) {
return Math.min(block.timestamp, periodFinish[token]);
}
| function lastTimeRewardApplicable(address token) public view returns (uint) {
return Math.min(block.timestamp, periodFinish[token]);
}
| 14,566 |
95 | // Returns the configured delay for a given swap interval/If none was configured, then it will return half the given swap interval/_swapInterval The swap interval to check/ return _delay The configured delay | function delay(uint32 _swapInterval) external view returns (uint32 _delay);
| function delay(uint32 _swapInterval) external view returns (uint32 _delay);
| 16,907 |
31 | // transfers an amount from a user to the destination reserve_reserve the address of the reserve where the amount is being transferred_user the address of the user from where the transfer is happening_amount the amount being transferred/ | {
if (_reserve != EthAddressLib.ethAddress()) {
require(msg.value == 0, "User is sending ETH along with the ERC20 transfer.");
ERC20(_reserve).safeTransferFrom(_user, address(this), _amount);
} else {
require(msg.value >= _amount, "The amount and the value sent t... | {
if (_reserve != EthAddressLib.ethAddress()) {
require(msg.value == 0, "User is sending ETH along with the ERC20 transfer.");
ERC20(_reserve).safeTransferFrom(_user, address(this), _amount);
} else {
require(msg.value >= _amount, "The amount and the value sent t... | 39,859 |
148 | // Starting from the head of orderbook, find a proper position to insert order | function _insertOrderFromHead(Context memory ctx, bool isBuy, Order memory order,
| function _insertOrderFromHead(Context memory ctx, bool isBuy, Order memory order,
| 33,039 |
9 | // Get token URI. In case of delayed reveal we give user the json of the placeholer metadata./tokenId token ID | function tokenURI(uint tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, "/", tokenId.toSt... | function tokenURI(uint tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, "/", tokenId.toSt... | 19,268 |
13 | // XXX: function() external payable { } | receive() external payable { }
| receive() external payable { }
| 13,958 |
33 | // | * @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| * @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
| 28 |
23 | // Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),Reverts with custom message when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remain... | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| 736 |
9 | // Mapping of User Address to Staker info | mapping(address => Staker) public stakers;
| mapping(address => Staker) public stakers;
| 318 |
140 | // src/Base64.sol/ pragma solidity ^0.8.7; / | library Base64 {
bytes internal constant TABLE =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/// @notice Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (... | library Base64 {
bytes internal constant TABLE =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/// @notice Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (... | 13,193 |
31 | // dev Aprove the passed address to spend the specified amount of tokens on beahlf of msg.sender. param _spender The address which will spend the funds. param _value The amount of tokens to be spent./ | function approve(address _spender, uint _value) {
//To change the approve amount you first have to reduce the addresses
// allowance to zero by calling approve(_spender, 0) if if it not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/is... | function approve(address _spender, uint _value) {
//To change the approve amount you first have to reduce the addresses
// allowance to zero by calling approve(_spender, 0) if if it not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/is... | 27,340 |
157 | // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes) | require(uint256(s).add(32) <= signatures.length, "Invalid contract signature location: length not present");
| require(uint256(s).add(32) <= signatures.length, "Invalid contract signature location: length not present");
| 25,680 |
95 | // Change partner address _nftAddress Token maket fee address _tokenCreaterAddress Partner addressOnly partner can change their share address / | function changeTokenCreaterAddress(
address _nftAddress,
| function changeTokenCreaterAddress(
address _nftAddress,
| 17,921 |
0 | // Default Reasons | {
MutualConsent,
MaterialBreach,
AtWill,
// Rage Termination Options
LegalCompulsion,
CrimesOfMoralTurpitude,
Bankruptcy,
Dissolution,
Insolvency,
CounterPartyMalfeasance,
LossControlOfPrivateKeys
}
| {
MutualConsent,
MaterialBreach,
AtWill,
// Rage Termination Options
LegalCompulsion,
CrimesOfMoralTurpitude,
Bankruptcy,
Dissolution,
Insolvency,
CounterPartyMalfeasance,
LossControlOfPrivateKeys
}
| 29,017 |
204 | // Withdraw the max available inactive funds, and send to the specified recipient.This is less gas-efficient than querying the max via eth_call and calling withdrawStake(). recipientThe address that should receive the funds. return The withdrawn amount. / | function withdrawMaxStake(
address recipient
)
external
nonReentrant
returns (uint256)
| function withdrawMaxStake(
address recipient
)
external
nonReentrant
returns (uint256)
| 43,863 |
39 | // Returns bucket and subindex for reading manager data from the packed array mapping. / | function _getManagerDataIndices(uint256 index) private pure returns (uint256 bucket, uint256 subindex) {
bucket = index >> 3; // index / 8
subindex = index & 7; // index % 8
}
| function _getManagerDataIndices(uint256 index) private pure returns (uint256 bucket, uint256 subindex) {
bucket = index >> 3; // index / 8
subindex = index & 7; // index % 8
}
| 1,671 |
4 | // Shape calculator. | contract ShapeCalculator2 {
/// @dev Calculates a rectangle's surface and perimeter.
/// @param w Width of the rectangle.
/// @param h Height of the rectangle.
/// @return s The calculated surface.
/// @return p The calculated perimeter.
function rectangle(uint w, uint h) returns (uint s, uint p... | contract ShapeCalculator2 {
/// @dev Calculates a rectangle's surface and perimeter.
/// @param w Width of the rectangle.
/// @param h Height of the rectangle.
/// @return s The calculated surface.
/// @return p The calculated perimeter.
function rectangle(uint w, uint h) returns (uint s, uint p... | 19,194 |
5 | // Returns the information of an army 부대의 정보를 반환합니다. | function getArmyInfo(uint armyId) view external returns (
uint unitKind,
uint unitCount,
uint knightItemId,
uint col,
uint row,
address owner,
uint createTime
);
| function getArmyInfo(uint armyId) view external returns (
uint unitKind,
uint unitCount,
uint knightItemId,
uint col,
uint row,
address owner,
uint createTime
);
| 32,006 |
152 | // Loop for all staking slots base on support stake token list | for (uint256 t = 0; t < _stakeholders.length; t += 1) {
Stake storage _stake = _userStakes[_stakeholders[t]];
if (_stake.expiredAt > 0 && timestamp > _stake.expiredAt) {
emit RewardDistributeIgnore(
_stake.stakeholder,
_stake.expiredAt,
timestamp
);
| for (uint256 t = 0; t < _stakeholders.length; t += 1) {
Stake storage _stake = _userStakes[_stakeholders[t]];
if (_stake.expiredAt > 0 && timestamp > _stake.expiredAt) {
emit RewardDistributeIgnore(
_stake.stakeholder,
_stake.expiredAt,
timestamp
);
| 34,408 |
198 | // Verifies that the caller is the Vault, Governor, or Strategist. / | modifier onlyVaultOrGovernorOrStrategist() {
require(
msg.sender == address(this) ||
msg.sender == strategistAddr ||
isGovernor(),
"Caller is not the Vault, Governor, or Strategist"
);
_;
}
| modifier onlyVaultOrGovernorOrStrategist() {
require(
msg.sender == address(this) ||
msg.sender == strategistAddr ||
isGovernor(),
"Caller is not the Vault, Governor, or Strategist"
);
_;
}
| 66,508 |
2 | // this implementation reads restriction messages from storage@inheritdoc IERC1404 / | function messageForTransferRestriction(uint8 restrictionCode)
public
view
override
returns (string memory)
| function messageForTransferRestriction(uint8 restrictionCode)
public
view
override
returns (string memory)
| 10,867 |
2 | // Copy msg.data. We take full control of memory in this inline assembly block because it will not return to Solidity code. We overwrite the Solidity scratch pad at memory position 0. | calldatacopy(0, 0, calldatasize())
| calldatacopy(0, 0, calldatasize())
| 1,163 |
31 | // Unsafe version of _executeVote that assumes you have already checked if the vote can be executed/ | function _unsafeExecuteVote(uint256 _voteId) internal {
Vote storage vote_ = votes[_voteId];
vote_.executed = true;
bytes memory input = new bytes(0); // TODO: Consider input for voting scripts
runScript(vote_.executionScript, input, new address[](0));
emit ExecuteVote(_vo... | function _unsafeExecuteVote(uint256 _voteId) internal {
Vote storage vote_ = votes[_voteId];
vote_.executed = true;
bytes memory input = new bytes(0); // TODO: Consider input for voting scripts
runScript(vote_.executionScript, input, new address[](0));
emit ExecuteVote(_vo... | 18,921 |
152 | // A Secondary contract can only be used by its primary account (the one that created it). / | contract Secondary {
address private _primary;
/**
* @dev Emitted when the primary contract changes.
*/
event PrimaryTransferred(
address recipient
);
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor () internal ... | contract Secondary {
address private _primary;
/**
* @dev Emitted when the primary contract changes.
*/
event PrimaryTransferred(
address recipient
);
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor () internal ... | 9,041 |
81 | // Take liquidity fee | if(_liquidityFee != 0){
uint256 liquidityFee = amount.mul(_liquidityFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(liquidityFee);
_reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(liquidityFee.mul(rate));
_liquidityFee... | if(_liquidityFee != 0){
uint256 liquidityFee = amount.mul(_liquidityFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(liquidityFee);
_reflectionBalance[address(this)] = _reflectionBalance[address(this)].add(liquidityFee.mul(rate));
_liquidityFee... | 24,299 |
42 | // Simulates a call to `batchSwap`, returning an array of Vault asset deltas. Calls to `swap` cannot besimulated directly, but an equivalent `batchSwap` call can and will yield the exact same result. Each element in the array corresponds to the asset at the same index, and indicates the number of tokens (or ETH)the Vau... | function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] memory swaps,
IAsset[] memory assets,
FundManagement memory funds
) external returns (int256[] memory assetDeltas);
| function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] memory swaps,
IAsset[] memory assets,
FundManagement memory funds
) external returns (int256[] memory assetDeltas);
| 22,870 |
16 | // Storage of the student's id in an array | revisions[_subject].push(_student_id);
| revisions[_subject].push(_student_id);
| 50,257 |
109 | // Updates bond manager address/_bondManager new bond manager | function setBondManager(address _bondManager) public onlyOperator {
require(
address(bondManager) != _bondManager,
"TokenManager: bondManager with this address already set"
);
deleteTokenAdmin(address(bondManager));
addTokenAdmin(_bondManager);
bondMan... | function setBondManager(address _bondManager) public onlyOperator {
require(
address(bondManager) != _bondManager,
"TokenManager: bondManager with this address already set"
);
deleteTokenAdmin(address(bondManager));
addTokenAdmin(_bondManager);
bondMan... | 25,161 |
147 | // Burn tokens of given token id for each (_ids[i], _amounts[i]) pair _from The address to burn tokens from _idsArray of token ids to burn _amountsArray of the amount to be burned / | function _batchBurn(
address _from,
uint256[] memory _ids,
uint256[] memory _amounts
| function _batchBurn(
address _from,
uint256[] memory _ids,
uint256[] memory _amounts
| 8,123 |
163 | // Return all of the markets The automatic getter may be used to access an individual market.return The list of market addresses / | function getAllMarkets() public view returns (CToken[] memory) {
return allMarkets;
}
| function getAllMarkets() public view returns (CToken[] memory) {
return allMarkets;
}
| 37,260 |
29 | // Prevent users from creating a deposit transaction where this address is the message sender on L2. Because this is checked here, we do not need to check again in `finalizeWithdrawalTransaction`. | require(
_tx.target != address(this),
"OptimismPortal: you cannot send messages to the portal contract"
);
| require(
_tx.target != address(this),
"OptimismPortal: you cannot send messages to the portal contract"
);
| 25,613 |
22 | // Returns all the relevant information about a specific token._tokenId The tokenId of the token of interest. | function getToken(uint256 _tokenId) public view returns (
string tokenName,
address owner
| function getToken(uint256 _tokenId) public view returns (
string tokenName,
address owner
| 20,259 |
86 | // Adds x and y, assuming they are both fixed point with 18 decimals. | function addd(uint256 x, uint256 y) internal pure returns (uint256) {
return x.add(y);
}
| function addd(uint256 x, uint256 y) internal pure returns (uint256) {
return x.add(y);
}
| 2,435 |
14 | // line 3 -proof of arbitrage opportunity | uint256 public arbitragePot;
| uint256 public arbitragePot;
| 16,415 |
302 | // Set gun type for that specific item | _setGunType(newItemId, gunType);
_totalByType[gunType] += 1;
return newItemId;
| _setGunType(newItemId, gunType);
_totalByType[gunType] += 1;
return newItemId;
| 20,133 |
22 | // See {ICreatorCore-setBaseTokenURI}. / | function setBaseTokenURI(string calldata uri_) external override adminRequired {
_setBaseTokenURI(uri_);
}
| function setBaseTokenURI(string calldata uri_) external override adminRequired {
_setBaseTokenURI(uri_);
}
| 27,101 |
174 | // Store references to the old context | _oldActiveContract = executionContext.ovmActiveContract;
_oldMsgSender = executionContext.ovmMsgSender;
| _oldActiveContract = executionContext.ovmActiveContract;
_oldMsgSender = executionContext.ovmMsgSender;
| 30,933 |
5 | // Set antiAbuseOracleAddresses Only callable by Governance address _antiAbuseOracleAddresses - values of new anti abuse oracle addresses / | function setAntiAbuseOracleAddresses(address[] calldata _antiAbuseOracleAddresses) external {
_requireIsInitialized();
require(msg.sender == governanceAddress, ERROR_ONLY_GOVERNANCE);
antiAbuseOracleAddresses = _antiAbuseOracleAddresses;
}
| function setAntiAbuseOracleAddresses(address[] calldata _antiAbuseOracleAddresses) external {
_requireIsInitialized();
require(msg.sender == governanceAddress, ERROR_ONLY_GOVERNANCE);
antiAbuseOracleAddresses = _antiAbuseOracleAddresses;
}
| 42,490 |
10 | // Return total amount of MKR that is currently held by Syndicate | function getMKRBalance() external view returns (uint256 mkr);
| function getMKRBalance() external view returns (uint256 mkr);
| 48,947 |
3 | // Info of each MCV2 user./ `amount` LP token amount the user has provided./ `rewardDebt` The amount of SAM entitled to the user. | struct UserInfo {
uint256 amount;
int256 rewardDebt;
uint256 releaseTime;
uint256 lockAmount;
}
| struct UserInfo {
uint256 amount;
int256 rewardDebt;
uint256 releaseTime;
uint256 lockAmount;
}
| 16,874 |
177 | // This function is when the borrower accepts a lender's offer, to validate the lender's signature that thelender provided off-chain to verify that it did indeed made such offer._offer - The offer struct containing:- loanERC20Denomination: The address of the ERC20 contract of the currency being used as principal/intere... | function isValidLenderSignature(LoanData.Offer memory _offer, LoanData.Signature memory _signature)
external
view
returns (bool)
| function isValidLenderSignature(LoanData.Offer memory _offer, LoanData.Signature memory _signature)
external
view
returns (bool)
| 59,538 |
0 | // Information pertaining to bond market | struct BondMarket {
address owner; // market owner. sends payout tokens, receives quote tokens (defaults to creator)
ERC20 payoutToken; // token to pay depositors with
ERC20 quoteToken; // token to accept as payment
address callbackAddr; // address to call for any operations on bond ... | struct BondMarket {
address owner; // market owner. sends payout tokens, receives quote tokens (defaults to creator)
ERC20 payoutToken; // token to pay depositors with
ERC20 quoteToken; // token to accept as payment
address callbackAddr; // address to call for any operations on bond ... | 40,384 |
271 | // Mint NFT's at current index. / | function reserveNFTs(uint amount, address _addr) public onlyOwner {
uint supply = totalSupply();
uint i;
for (i = 0; i < amount; i++) {
_safeMint(_addr, supply + i);
}
}
| function reserveNFTs(uint amount, address _addr) public onlyOwner {
uint supply = totalSupply();
uint i;
for (i = 0; i < amount; i++) {
_safeMint(_addr, supply + i);
}
}
| 14,243 |
13 | // See {IPool-setWithdrawalCredentials}. / | function setWithdrawalCredentials(bytes32 _withdrawalCredentials) external override onlyAdmin {
withdrawalCredentials = _withdrawalCredentials;
emit WithdrawalCredentialsUpdated(_withdrawalCredentials);
}
| function setWithdrawalCredentials(bytes32 _withdrawalCredentials) external override onlyAdmin {
withdrawalCredentials = _withdrawalCredentials;
emit WithdrawalCredentialsUpdated(_withdrawalCredentials);
}
| 72,662 |
147 | // bytes4(keccak256('totalSupply()')) == 0x18160dddbytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 / | bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
| bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
| 10,662 |
152 | // The block number when distribution to the DAO starts | uint256 public daoStartBlock;
| uint256 public daoStartBlock;
| 17,321 |
10 | // MAX_SUPPLY = MAX_INT256 / MAX_RATE | uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
| uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
| 26,403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.