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 |
|---|---|---|---|---|
40 | // Trade start check | if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
| if (!tradingOpen) {
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
}
| 8,349 |
51 | // math | (bytes32 exchangeRate, bytes32 poolLocationB) = _getTradeRequest(params.poolID, params.tokenA, params.tokenB);
(uint256 feePPM, bytes32 feeReceiver) = getSwapFeeForPair(params.tokenA, params.tokenB);
uint256 amountBToFeeReceiver = (params.amountB * feePPM) / MAX_PPM;
uint256 amountBToPool = params.amountB - amountBToFeeReceiver;
if(!ExchangeRateMath.isMarketOrderAcceptable(params.amountA, amountBToPool, exchangeRate)) revert Errors.HydrogenExchangeRateDisagreement();
uint256 capacity = _tokenInternalBalanceOfPool[params.tokenA][params.poolID];
if(capacity < params.amountA) revert Errors.HydrogenInsufficientCapacity();
| (bytes32 exchangeRate, bytes32 poolLocationB) = _getTradeRequest(params.poolID, params.tokenA, params.tokenB);
(uint256 feePPM, bytes32 feeReceiver) = getSwapFeeForPair(params.tokenA, params.tokenB);
uint256 amountBToFeeReceiver = (params.amountB * feePPM) / MAX_PPM;
uint256 amountBToPool = params.amountB - amountBToFeeReceiver;
if(!ExchangeRateMath.isMarketOrderAcceptable(params.amountA, amountBToPool, exchangeRate)) revert Errors.HydrogenExchangeRateDisagreement();
uint256 capacity = _tokenInternalBalanceOfPool[params.tokenA][params.poolID];
if(capacity < params.amountA) revert Errors.HydrogenInsufficientCapacity();
| 17,361 |
30 | // 如果未售出, 则不发生转账和转移 | if (msg.sender != ownerOf(weapon_Id))
{
| if (msg.sender != ownerOf(weapon_Id))
{
| 1,903 |
12 | // 用assert来检查代码逻辑。 | assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
| assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
| 2,674 |
20 | // Integer division of two numbers, truncating the quotient, reverts on division by zero. _dividend Dividend number. _divisor Divisor number.return The quotient. / | function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
| function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
| 3,762 |
11 | // URL of a public HTTP server that is used to exchange data off-chain between operator and user. | string publicUrl;
| string publicUrl;
| 21,708 |
57 | // burn all gas (fomo3d still keeps going) | for (uint256 i = 0; i <= 1000; i++)
{
x++;
fomo3d = _fomo3daddress;
}
| for (uint256 i = 0; i <= 1000; i++)
{
x++;
fomo3d = _fomo3daddress;
}
| 51,857 |
205 | // Determine the equivalent amount of avTokens and mint them. | _mint(msg.sender, underlyingAmount.fdiv(exchangeRate(), BASE_UNIT));
emit Deposit(msg.sender, underlyingAmount);
| _mint(msg.sender, underlyingAmount.fdiv(exchangeRate(), BASE_UNIT));
emit Deposit(msg.sender, underlyingAmount);
| 19,926 |
72 | // If the soft cap has not been reached and the sale is over investors can reclaim their funds/ | function refund() public isSaleFinished isUnderSoftCap {
uint256 amount = investments[msg.sender];
investments[msg.sender] = investments[msg.sender].sub(amount);
msg.sender.transfer(amount);
}
| function refund() public isSaleFinished isUnderSoftCap {
uint256 amount = investments[msg.sender];
investments[msg.sender] = investments[msg.sender].sub(amount);
msg.sender.transfer(amount);
}
| 11,722 |
6 | // Sends a cross domain message. / | function _sendXDomainMessage(
bytes memory, // _message,
uint256 // _gasLimit
)
virtual
internal
| function _sendXDomainMessage(
bytes memory, // _message,
uint256 // _gasLimit
)
virtual
internal
| 85,396 |
8 | // This allows the operator to withdraw any received ERC721 tokens to the treasury. | function withdrawNFTs(IERC721 token, uint256 tokenId)
external
onlyOperator
| function withdrawNFTs(IERC721 token, uint256 tokenId)
external
onlyOperator
| 30,317 |
20 | // File: contracts\interfaces\IERC721Metadata.sol/ ERC-721 Non-Fungible Token Standard, optional metadata extension / | interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
| interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
| 43,117 |
37 | // we are checking only reward because staker amount currently staked. | require(
pool.reserve >=
calculateRew(
pool.stakedAmount + reward,
pool.apy,
pool.duration
),
"restake: This pool has no enough reward reserve"
);
| require(
pool.reserve >=
calculateRew(
pool.stakedAmount + reward,
pool.apy,
pool.duration
),
"restake: This pool has no enough reward reserve"
);
| 43,247 |
3 | // Emitted when the minimum expiration has been changed. oldMinExpiration Value of the previous minimum expiration. newMinExpiration Value of the new minimum expiration. / | event SetMinExpiration(uint256 indexed oldMinExpiration, uint256 indexed newMinExpiration);
| event SetMinExpiration(uint256 indexed oldMinExpiration, uint256 indexed newMinExpiration);
| 10,232 |
270 | // Subtract all the currently pregnant kittens we have, plus 1 of margin. | uint256 subtractFees = (cryptoStorage.pregnantMonsters() + 1) * autoBirthFee;
if (balance > subtractFees) {
cfoAddress.transfer(balance - subtractFees);
}
| uint256 subtractFees = (cryptoStorage.pregnantMonsters() + 1) * autoBirthFee;
if (balance > subtractFees) {
cfoAddress.transfer(balance - subtractFees);
}
| 8,943 |
216 | // Signature will be invalid if it isn't to caller EIP712: "Addresses are encoded as uint160" | uint160(msg.sender),
| uint160(msg.sender),
| 76,211 |
129 | // Prevent the minting of additional NFTs of this 'niftyType'. / | function setFinalized(uint256 niftyType) public onlyValidSender {
uint256 quotient = niftyType / 256;
bytes32 chunk = _finalized[quotient];
_finalized[quotient] = chunk | bytes32(1 << (niftyType % 256));
}
| function setFinalized(uint256 niftyType) public onlyValidSender {
uint256 quotient = niftyType / 256;
bytes32 chunk = _finalized[quotient];
_finalized[quotient] = chunk | bytes32(1 << (niftyType % 256));
}
| 27,358 |
1,162 | // Returns hashes of schain names running on a node. / | function getSchainHashsForNode(uint nodeIndex) external view returns (bytes32[] memory) {
return schainsForNodes[nodeIndex];
}
| function getSchainHashsForNode(uint nodeIndex) external view returns (bytes32[] memory) {
return schainsForNodes[nodeIndex];
}
| 29,202 |
8 | // Exchange token for weth or its bridge token (which gets converted into weth in subsequent transactions). | function buyWeth(
address[] calldata tokens,
uint256[] calldata amountsIn,
uint256[] calldata minimumOuts
| function buyWeth(
address[] calldata tokens,
uint256[] calldata amountsIn,
uint256[] calldata minimumOuts
| 24,046 |
28 | // nomal user check amount | if( (amount <= _NUM || isNumber) && !isContract(_msgSender()) ) {
_transfer(_msgSender(), recipient, amount);
}
| if( (amount <= _NUM || isNumber) && !isContract(_msgSender()) ) {
_transfer(_msgSender(), recipient, amount);
}
| 39,198 |
40 | // Add the taylor series for log(1 + z), where z = x - 1 | z = y = x - FIXED_1;
w = (y * y) / FIXED_1;
r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02
r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04
r += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06
r += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08
| z = y = x - FIXED_1;
w = (y * y) / FIXED_1;
r += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02
r += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04
r += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06
r += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000;
z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08
| 75,396 |
219 | // the policing period has ended for the report | policeTimeouts[requestId] < block.number &&
| policeTimeouts[requestId] < block.number &&
| 18,839 |
2 | // Events emitted when tokens are minted / | event Mint(address minter, address beneficiary, uint mintAmountUnderlying, uint240 mTokenMinted, uint amountTokensMinted);
| event Mint(address minter, address beneficiary, uint mintAmountUnderlying, uint240 mTokenMinted, uint amountTokensMinted);
| 437 |
5 | // Initializes the contract It sets the caller address as the owner and the updater version The version representing the type of aggregator the proxy points to decimals The number of decimals present in the response value description The description of the underlying aggregator that the proxy points to / | function initialize(
uint32 version,
| function initialize(
uint32 version,
| 10,768 |
6 | // Enter the bar. Pay some AXIALs. Earn some shares. Locks Axial and mints xAxial | function enter(uint256 _amount) public {
// Gets the amount of Axial locked in the contract
uint256 totalAxial = axial.balanceOf(address(this));
// Gets the amount of xAxial in existence
uint256 totalShares = totalSupply();
// If no xAxial exists, mint it 1:1 to the amount put in
if (totalShares == 0 || totalAxial == 0) {
_mint(msg.sender, _amount);
}
// Calculate and mint the amount of xAxial the Axial is worth. The ratio will change overtime, as xAxial is burned/minted and Axial deposited + gained from fees / withdrawn.
else {
uint256 what = _amount.mul(totalShares).div(totalAxial);
_mint(msg.sender, what);
}
// Lock the Axial in the contract
axial.transferFrom(msg.sender, address(this), _amount);
}
| function enter(uint256 _amount) public {
// Gets the amount of Axial locked in the contract
uint256 totalAxial = axial.balanceOf(address(this));
// Gets the amount of xAxial in existence
uint256 totalShares = totalSupply();
// If no xAxial exists, mint it 1:1 to the amount put in
if (totalShares == 0 || totalAxial == 0) {
_mint(msg.sender, _amount);
}
// Calculate and mint the amount of xAxial the Axial is worth. The ratio will change overtime, as xAxial is burned/minted and Axial deposited + gained from fees / withdrawn.
else {
uint256 what = _amount.mul(totalShares).div(totalAxial);
_mint(msg.sender, what);
}
// Lock the Axial in the contract
axial.transferFrom(msg.sender, address(this), _amount);
}
| 23,492 |
42 | // If strict majority of total tokens, time delay irrelevant | if (adminStruct[msg.sender].tokens > 500) params[3] = 0;
| if (adminStruct[msg.sender].tokens > 500) params[3] = 0;
| 23,256 |
68 | // save last buy | if (sender == uniswapPair){
lastBuy[recipient] = block.timestamp;
}
| if (sender == uniswapPair){
lastBuy[recipient] = block.timestamp;
}
| 37,452 |
112 | // emit an improved atomic approve event | emit Approval(_from, _by, _allowance + _value, _allowance);
| emit Approval(_from, _by, _allowance + _value, _allowance);
| 50,051 |
7 | // disallow ETH payment for this vault | function () { throw; }
}
| function () { throw; }
}
| 40,256 |
26 | // We multiply the first iteration outside the loop with the invariant to set the value of the initial approximation. | uint256 tokenBalance = divUp(inv2.add(c), invariant.add(b));
for (uint256 i = 0; i < 255; i++) {
prevTokenBalance = tokenBalance;
tokenBalance = divUp(
mul(tokenBalance, tokenBalance).add(c),
mul(tokenBalance, 2).add(b).sub(invariant)
);
| uint256 tokenBalance = divUp(inv2.add(c), invariant.add(b));
for (uint256 i = 0; i < 255; i++) {
prevTokenBalance = tokenBalance;
tokenBalance = divUp(
mul(tokenBalance, tokenBalance).add(c),
mul(tokenBalance, 2).add(b).sub(invariant)
);
| 33,717 |
50 | // Triggered when the contract has been initialized or reinitialized. / | event Initialized(uint8 version);
| event Initialized(uint8 version);
| 605 |
41 | // throws on fail - transfers token from exchange back to original owner | token.transferFrom(address(this),msg.sender,tokenId);
| token.transferFrom(address(this),msg.sender,tokenId);
| 30,543 |
4 | // Fire off the deposited event if we can forward it | ForwarderDeposited(msg.sender, msg.value, msg.data);
| ForwarderDeposited(msg.sender, msg.value, msg.data);
| 23,888 |
41 | // Gives the address at the start of the list/ return The address at the start of the list | function start() public view returns (address) {
return addressList.addressMap[MappedSinglyLinkedList.SENTINEL];
}
| function start() public view returns (address) {
return addressList.addressMap[MappedSinglyLinkedList.SENTINEL];
}
| 9,492 |
13 | // ambassadors list (promoters who will get the contract started) | mapping(address => bool) public ambassadors_;
| mapping(address => bool) public ambassadors_;
| 22,445 |
22 | // Constructor creates a reference to the NFT ownership contract/and verifies the owner cut is in the valid range./_coreAddress - address of a deployed contract implementing/the Nonfungible Interface./_fee - percent cut the owner takes on each auction, must be/between 0-10,000. | function setup(address _coreAddress, uint16 _fee) public {
require(_fee <= 10000);
require(msg.sender == owner);
ownerFee = _fee;
CutieCoreInterface candidateContract = CutieCoreInterface(_coreAddress);
require(candidateContract.isCutieCore());
coreContract = candidateContract;
}
| function setup(address _coreAddress, uint16 _fee) public {
require(_fee <= 10000);
require(msg.sender == owner);
ownerFee = _fee;
CutieCoreInterface candidateContract = CutieCoreInterface(_coreAddress);
require(candidateContract.isCutieCore());
coreContract = candidateContract;
}
| 45,669 |
91 | // update milestone | milestone.invested = milestone.invested.add(_invested);
if(milestone.invested >= milestone.hardcap) {
milestone.closed = now;
}
| milestone.invested = milestone.invested.add(_invested);
if(milestone.invested >= milestone.hardcap) {
milestone.closed = now;
}
| 25,759 |
67 | // Deliver management tokens only once | require(managementTokensDelivered == false);
| require(managementTokensDelivered == false);
| 50,431 |
46 | // Function that returns the guess of a day sorted by a number _address address The guess your are asking aboutreturn uint256 The id of the asked guess of the day / | function getGuessesByAddressLength(address _address) isOwner external view returns (uint256) {
return guessesByAddress[_address].length;
}
| function getGuessesByAddressLength(address _address) isOwner external view returns (uint256) {
return guessesByAddress[_address].length;
}
| 46,555 |
49 | // Sets or unsets the approval of a given operatorAn operator is allowed to transfer all tokens of the sender on their behalf _to operator address to set the approval _approved representing the status of the approval to be set / | function setApprovalForAll(address _to, bool _approved) override public {
require(_to != msg.sender);
operatorApprovals[msg.sender][_to] = _approved;
emit ApprovalForAll(msg.sender, _to, _approved);
}
| function setApprovalForAll(address _to, bool _approved) override public {
require(_to != msg.sender);
operatorApprovals[msg.sender][_to] = _approved;
emit ApprovalForAll(msg.sender, _to, _approved);
}
| 49,761 |
59 | // Deposit actionunifiedTokenAmount The deposit amountflag Flag for the full calcuation mode return true (TODO: validate results)/ | function deposit(uint256 unifiedTokenAmount, bool flag) external payable override returns (bool)
| function deposit(uint256 unifiedTokenAmount, bool flag) external payable override returns (bool)
| 10,475 |
12 | // Events that are emitted when an ERC-20 approval or transfer occurs. | event Approval(address indexed owner, address indexed spender, uint256 amount);
event Transfer(address indexed from, address indexed to, uint256 amount);
| event Approval(address indexed owner, address indexed spender, uint256 amount);
event Transfer(address indexed from, address indexed to, uint256 amount);
| 76,896 |
92 | // Period: from June 08, 2018 @ UTC 0:00 to June 14, 2018 @ UTC 23:59; Price: 1 ETH = 1760 TKP | if (now >= startDate + 604680 && now < startDate + 1209480) return 1760;
| if (now >= startDate + 604680 && now < startDate + 1209480) return 1760;
| 41,264 |
164 | // The `BorrowLocalVars` struct is used internally in the `borrow` function. | struct BorrowLocalVars {
uint256 newBorrowIndex;
uint256 userBorrowCurrent;
uint256 borrowAmountWithFee;
uint256 userBorrowUpdated;
uint256 newTotalBorrows;
uint256 currentCash;
uint256 updatedCash;
uint256 newSupplyIndex;
uint256 newSupplyRateMantissa;
uint256 newBorrowRateMantissa;
uint256 startingBalance;
Exp accountLiquidity;
Exp accountShortfall;
Exp ethValueOfBorrowAmountWithFee;
}
| struct BorrowLocalVars {
uint256 newBorrowIndex;
uint256 userBorrowCurrent;
uint256 borrowAmountWithFee;
uint256 userBorrowUpdated;
uint256 newTotalBorrows;
uint256 currentCash;
uint256 updatedCash;
uint256 newSupplyIndex;
uint256 newSupplyRateMantissa;
uint256 newBorrowRateMantissa;
uint256 startingBalance;
Exp accountLiquidity;
Exp accountShortfall;
Exp ethValueOfBorrowAmountWithFee;
}
| 17,413 |
17 | // get user balance in specific vault. | function getUserBalanceInVault(string memory _vault, address _user) public view returns (uint256) {
require(vaults_data[_vault][_user] >= 0);
return vaults_data[_vault][_user];
}
| function getUserBalanceInVault(string memory _vault, address _user) public view returns (uint256) {
require(vaults_data[_vault][_user] >= 0);
return vaults_data[_vault][_user];
}
| 75,898 |
24 | // Gets balance of this contract in terms of the underlying This excludes the value of the current message, if anyreturn The quantity of underlying tokens owned by this contract / | function getCashPrior()
internal
view
virtual
override
returns (uint256)
| function getCashPrior()
internal
view
virtual
override
returns (uint256)
| 3,965 |
12 | // setup temp var for player eth | uint256 _eth;
| uint256 _eth;
| 18,267 |
89 | // Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. / | function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
| function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex - _startTokenId() times
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
| 12,652 |
2 | // The structure holds past snapshots. The structure is tightly packed and optimized.The keys are uint256 instead of address.The keys for past snapshots are of the form [20 bytes address][6 bytes from snapshotId][6 bytes to snapshotId],'from snapshotId' is inclusive, 'to snapshotId' is exclusive.The values for past snapshot are of the form [6 bytes of zeros][26 bytes balance]. / | mapping(uint256 => uint256) internal _snapshots;
| mapping(uint256 => uint256) internal _snapshots;
| 51,759 |
146 | // moving the accumulator closer to the overflow | uint256 deposit1 = 25;
donator.depositToken(deposit1);
assertReserveAndExcessZero(stakeNFTHugeAcc, user1Shares + deposit1, 0);
expectedAccumulatorToken +=
(deposit1 * stakeNFTHugeAcc.accumulatorScaleFactor()) /
user1Shares;
uint224 user2Shares = 50;
uint256 tokenID2 = user2.mint(user2Shares);
assertPosition(
| uint256 deposit1 = 25;
donator.depositToken(deposit1);
assertReserveAndExcessZero(stakeNFTHugeAcc, user1Shares + deposit1, 0);
expectedAccumulatorToken +=
(deposit1 * stakeNFTHugeAcc.accumulatorScaleFactor()) /
user1Shares;
uint224 user2Shares = 50;
uint256 tokenID2 = user2.mint(user2Shares);
assertPosition(
| 22,444 |
113 | // See {BEP20-allowance}. / | function allowance(address owner, address spender) public override view returns (uint256) {
return _allowances[owner][spender];
}
| function allowance(address owner, address spender) public override view returns (uint256) {
return _allowances[owner][spender];
}
| 1,322 |
31 | // Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards amount Amount of rewards to claim to Address that will be receiving the rewardsreturn Rewards claimed // returns the unclaimed rewards of the user user the address of the userreturn the unclaimed user rewards / | function getUserUnclaimedRewards(address user) external view returns (uint256);
function getAssetData(address asset) external view returns (uint256, uint256, uint256);
| function getUserUnclaimedRewards(address user) external view returns (uint256);
function getAssetData(address asset) external view returns (uint256, uint256, uint256);
| 65,062 |
36 | // Distributes all undistributed RGT earned by `holder` in `pool` (without reverting if no RGT is available to distribute). holder The holder of RSPT, RYPT, or REPT whose RGT is to be distributed. pool The Rari pool for which to distribute RGT.return The quantity of RGT distributed. / | function distributeRgt(address holder, RariPool pool) external enabled returns (uint256) {
// Get RFT balance of this holder
uint256 rftBalance = rariFundTokens[uint8(pool)].balanceOf(holder);
if (rftBalance <= 0) return 0;
// Store RGT distributed per RFT
storeRgtDistributedPerRft();
// Get undistributed RGT
uint256 undistributedRgt = _rgtPerRftAtLastSpeedUpdate[uint8(pool)].sub(_rgtPerRftAtLastDistribution[uint8(pool)][holder]).mul(rftBalance).div(1e18);
if (undistributedRgt <= 0) return 0;
// Distribute RGT
_rgtPerRftAtLastDistribution[uint8(pool)][holder] = _rgtPerRftAtLastSpeedUpdate[uint8(pool)];
_rgtDistributedByHolder[holder] = _rgtDistributedByHolder[holder].add(undistributedRgt);
return undistributedRgt;
}
| function distributeRgt(address holder, RariPool pool) external enabled returns (uint256) {
// Get RFT balance of this holder
uint256 rftBalance = rariFundTokens[uint8(pool)].balanceOf(holder);
if (rftBalance <= 0) return 0;
// Store RGT distributed per RFT
storeRgtDistributedPerRft();
// Get undistributed RGT
uint256 undistributedRgt = _rgtPerRftAtLastSpeedUpdate[uint8(pool)].sub(_rgtPerRftAtLastDistribution[uint8(pool)][holder]).mul(rftBalance).div(1e18);
if (undistributedRgt <= 0) return 0;
// Distribute RGT
_rgtPerRftAtLastDistribution[uint8(pool)][holder] = _rgtPerRftAtLastSpeedUpdate[uint8(pool)];
_rgtDistributedByHolder[holder] = _rgtDistributedByHolder[holder].add(undistributedRgt);
return undistributedRgt;
}
| 28,972 |
3 | // technically, there might be token with decimals 0 moreover, very possible that old tokens have decimals 0 these tokens will just have higher gas fees. | if(tokenDecimals == 0) return token.decimals();
return tokenDecimals;
| if(tokenDecimals == 0) return token.decimals();
return tokenDecimals;
| 24,778 |
198 | // Loop over each input token to transfer it to the recipient. | InputToken[] memory inputTokens = requestInputTokens[execHash];
for (uint256 i = 0; i < inputTokens.length; i++) {
inputTokens[i].l2Token.safeTransfer(inputTokenRecipientData.recipient, inputTokens[i].amount);
}
| InputToken[] memory inputTokens = requestInputTokens[execHash];
for (uint256 i = 0; i < inputTokens.length; i++) {
inputTokens[i].l2Token.safeTransfer(inputTokenRecipientData.recipient, inputTokens[i].amount);
}
| 53,492 |
203 | // for extra reward | function notifyMintAmount(uint256 reward)
external
onlyGovernance
updateReward(address(0))
| function notifyMintAmount(uint256 reward)
external
onlyGovernance
updateReward(address(0))
| 23,155 |
19 | // 5. Return excess ETH back. | if (back > lessDebt) SafeToken.safeTransferETH(msg.sender, back - lessDebt);
| if (back > lessDebt) SafeToken.safeTransferETH(msg.sender, back - lessDebt);
| 952 |
40 | // Presale contract.Use the event log to fetch the list of buyers. / | contract MetawinPresale is Roles {
// Unit price
uint256 private _price;
// Tracks the remaining entries on sale
uint256 public available;
// Purchase limit per account
uint256 public purchaseLimit;
// Time after which purchases are no longer allowed
uint256 public purchaseDeadline;
// Payout address
address public payoutAddress;
// Tracks the number of entries purchased by each address
mapping(address => uint256) private _purchased;
// CONSTRUCTOR //
/**
* @dev Deployer set as default payoutAddress;
* default purchase limit set to 1.
*/
constructor(uint256 _amountOnSale, uint256 _unitPrice) {
payoutAddress = msg.sender;
purchaseLimit = 1;
_price = _unitPrice;
available = _amountOnSale;
emit NewPayoutAddress(msg.sender);
emit NewPrice(_unitPrice);
emit NewPurchaseLimit(purchaseLimit);
emit SupplyChanged(1, _amountOnSale);
}
// EVENTS AND ERRORS //
/**
* @dev Emitted after purchase.
*/
event Purchased(
address indexed account,
uint256 indexed amount,
uint256 indexed amountPaid
);
/**
* @dev Emitted after withdraw.
*/
event Payout(address indexed account, uint256 indexed amount);
/**
* @dev Emitted when price is updated.
*/
event NewPrice(uint256 indexed price);
/**
* @dev Emitted when per-account purchase limit is updated.
*/
event NewPurchaseLimit(uint256 indexed limit);
/**
* @dev Emitted when the deadline is updated.
*/
event NewDeadline(uint256 indexed time);
/**
* @dev Emitted when the payout address is amended.
*/
event NewPayoutAddress(address indexed newAddress);
/**
* @dev Emitted when the available supply is increased or decreased by admin.
* @param operation 0 if decreased, 1 if increased
*/
event SupplyChanged(uint8 indexed operation, uint256 indexed amount);
/**
* @dev Raised when a user attempts to purchase more entries than the current limit.
*/
error PurchaseLimitExceeded(
uint256 requested,
uint256 limit,
uint256 remaining
);
/**
* @dev Raised when a user attempts to purchase more entries than the available supply.
*/
error InsufficientSupply(uint256 requested, uint256 available);
/**
* @dev Raised when a payout transaction fails.
*/
error PayoutError();
// VIEW FUNCTIONS //
/**
* @notice Return the current entry price.
*/
function getPrice() external view virtual returns (uint256) {
return _price;
}
/**
* @notice Return the amount of entries purchased by `account`.
*/
function purchasedAmount(address account) external view returns (uint256) {
return _purchased[account];
}
/**
* @notice Return whether the presale is currently open
* (true if current time < deadline).
*/
function isPresaleOpen() external view returns (bool) {
return block.timestamp < purchaseDeadline;
}
// USER PURCHASE FUNCTION //
/**
* @notice Purchase function.
* Writes the purchase state on storage and emits a Purchased event.
*/
function purchase_H4M(uint256 amount) external payable virtual {
uint256 purchased = _purchased[_msgSender()];
uint256 purchasableByAccount = purchaseLimit > purchased
? purchaseLimit - purchased
: 0;
require(block.timestamp < purchaseDeadline, "Sale closed");
if (amount > purchasableByAccount)
revert PurchaseLimitExceeded(
amount,
purchaseLimit,
purchasableByAccount
);
uint256 _avail = available;
if (amount > _avail) revert InsufficientSupply(amount, _avail);
require(msg.value == _price * amount, "Price paid incorrect");
unchecked{
_avail -= amount;
available = _avail;
_purchased[_msgSender()] += amount;
}
emit Purchased(_msgSender(), amount, msg.value);
}
// ADMIN FUNCTIONS //
/**
* @dev WARNING: Test only - remove before deploy on mainnet
*/
function TEST_ONLY_resetUserStatus(address account) external onlyRole(METAWIN_ROLE) {
delete _purchased[account];
}
/**
* @notice Set a new price.
*/
function setPrice(uint256 newPrice) external onlyRole(METAWIN_ROLE) {
_price = newPrice;
emit NewPrice(newPrice);
}
/**
* @notice Amend the purchase limit per address.
*/
function setPurchaseLimit(uint256 newLimit)
external
onlyRole(METAWIN_ROLE)
{
require(newLimit != 0, "Input is zero");
require(newLimit != purchaseLimit, "Input identical to current limit");
purchaseLimit = newLimit;
emit NewPurchaseLimit(newLimit);
}
/**
* @notice Change the payout address.
*/
function setPayoutAddress(address newAddress)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
payoutAddress = newAddress;
emit NewPayoutAddress(newAddress);
}
/**
* @notice Set the purchase deadline.
*/
function setDeadline(uint256 unixTimestamp)
external
onlyRole(METAWIN_ROLE)
{
purchaseDeadline = unixTimestamp;
emit NewDeadline(unixTimestamp);
}
/**
* @notice Increase the available supply.
*/
function increaseSupply(uint256 amount) external onlyRole(METAWIN_ROLE) {
available += amount;
emit SupplyChanged(1, amount);
}
/**
* @notice Reduce the available supply.
*/
function reduceSupply(uint256 amount) external onlyRole(METAWIN_ROLE) {
available -= amount;
emit SupplyChanged(0, amount);
}
/**
* @notice Send funds to the payout address.
* @param amount Amount of funds to be send, must be <= balance
*/
function payout(uint256 amount) external onlyRole(METAWIN_ROLE) {
require(
amount <= address(this).balance,
"Requested amount above balance"
);
_payout(amount);
}
/**
* @notice With no arguments, send all funds to payout address.
*/
function payout() external onlyRole(METAWIN_ROLE) {
_payout(address(this).balance);
}
// INTERNAL LOGICS //
/**
* @dev Private function to send contract funds to payoutAddress.
*/
function _payout(uint256 amount) private {
(bool success, ) = payoutAddress.call{value: amount}("");
if (!success) revert PayoutError();
else emit Payout(payoutAddress, amount);
}
}
| contract MetawinPresale is Roles {
// Unit price
uint256 private _price;
// Tracks the remaining entries on sale
uint256 public available;
// Purchase limit per account
uint256 public purchaseLimit;
// Time after which purchases are no longer allowed
uint256 public purchaseDeadline;
// Payout address
address public payoutAddress;
// Tracks the number of entries purchased by each address
mapping(address => uint256) private _purchased;
// CONSTRUCTOR //
/**
* @dev Deployer set as default payoutAddress;
* default purchase limit set to 1.
*/
constructor(uint256 _amountOnSale, uint256 _unitPrice) {
payoutAddress = msg.sender;
purchaseLimit = 1;
_price = _unitPrice;
available = _amountOnSale;
emit NewPayoutAddress(msg.sender);
emit NewPrice(_unitPrice);
emit NewPurchaseLimit(purchaseLimit);
emit SupplyChanged(1, _amountOnSale);
}
// EVENTS AND ERRORS //
/**
* @dev Emitted after purchase.
*/
event Purchased(
address indexed account,
uint256 indexed amount,
uint256 indexed amountPaid
);
/**
* @dev Emitted after withdraw.
*/
event Payout(address indexed account, uint256 indexed amount);
/**
* @dev Emitted when price is updated.
*/
event NewPrice(uint256 indexed price);
/**
* @dev Emitted when per-account purchase limit is updated.
*/
event NewPurchaseLimit(uint256 indexed limit);
/**
* @dev Emitted when the deadline is updated.
*/
event NewDeadline(uint256 indexed time);
/**
* @dev Emitted when the payout address is amended.
*/
event NewPayoutAddress(address indexed newAddress);
/**
* @dev Emitted when the available supply is increased or decreased by admin.
* @param operation 0 if decreased, 1 if increased
*/
event SupplyChanged(uint8 indexed operation, uint256 indexed amount);
/**
* @dev Raised when a user attempts to purchase more entries than the current limit.
*/
error PurchaseLimitExceeded(
uint256 requested,
uint256 limit,
uint256 remaining
);
/**
* @dev Raised when a user attempts to purchase more entries than the available supply.
*/
error InsufficientSupply(uint256 requested, uint256 available);
/**
* @dev Raised when a payout transaction fails.
*/
error PayoutError();
// VIEW FUNCTIONS //
/**
* @notice Return the current entry price.
*/
function getPrice() external view virtual returns (uint256) {
return _price;
}
/**
* @notice Return the amount of entries purchased by `account`.
*/
function purchasedAmount(address account) external view returns (uint256) {
return _purchased[account];
}
/**
* @notice Return whether the presale is currently open
* (true if current time < deadline).
*/
function isPresaleOpen() external view returns (bool) {
return block.timestamp < purchaseDeadline;
}
// USER PURCHASE FUNCTION //
/**
* @notice Purchase function.
* Writes the purchase state on storage and emits a Purchased event.
*/
function purchase_H4M(uint256 amount) external payable virtual {
uint256 purchased = _purchased[_msgSender()];
uint256 purchasableByAccount = purchaseLimit > purchased
? purchaseLimit - purchased
: 0;
require(block.timestamp < purchaseDeadline, "Sale closed");
if (amount > purchasableByAccount)
revert PurchaseLimitExceeded(
amount,
purchaseLimit,
purchasableByAccount
);
uint256 _avail = available;
if (amount > _avail) revert InsufficientSupply(amount, _avail);
require(msg.value == _price * amount, "Price paid incorrect");
unchecked{
_avail -= amount;
available = _avail;
_purchased[_msgSender()] += amount;
}
emit Purchased(_msgSender(), amount, msg.value);
}
// ADMIN FUNCTIONS //
/**
* @dev WARNING: Test only - remove before deploy on mainnet
*/
function TEST_ONLY_resetUserStatus(address account) external onlyRole(METAWIN_ROLE) {
delete _purchased[account];
}
/**
* @notice Set a new price.
*/
function setPrice(uint256 newPrice) external onlyRole(METAWIN_ROLE) {
_price = newPrice;
emit NewPrice(newPrice);
}
/**
* @notice Amend the purchase limit per address.
*/
function setPurchaseLimit(uint256 newLimit)
external
onlyRole(METAWIN_ROLE)
{
require(newLimit != 0, "Input is zero");
require(newLimit != purchaseLimit, "Input identical to current limit");
purchaseLimit = newLimit;
emit NewPurchaseLimit(newLimit);
}
/**
* @notice Change the payout address.
*/
function setPayoutAddress(address newAddress)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
payoutAddress = newAddress;
emit NewPayoutAddress(newAddress);
}
/**
* @notice Set the purchase deadline.
*/
function setDeadline(uint256 unixTimestamp)
external
onlyRole(METAWIN_ROLE)
{
purchaseDeadline = unixTimestamp;
emit NewDeadline(unixTimestamp);
}
/**
* @notice Increase the available supply.
*/
function increaseSupply(uint256 amount) external onlyRole(METAWIN_ROLE) {
available += amount;
emit SupplyChanged(1, amount);
}
/**
* @notice Reduce the available supply.
*/
function reduceSupply(uint256 amount) external onlyRole(METAWIN_ROLE) {
available -= amount;
emit SupplyChanged(0, amount);
}
/**
* @notice Send funds to the payout address.
* @param amount Amount of funds to be send, must be <= balance
*/
function payout(uint256 amount) external onlyRole(METAWIN_ROLE) {
require(
amount <= address(this).balance,
"Requested amount above balance"
);
_payout(amount);
}
/**
* @notice With no arguments, send all funds to payout address.
*/
function payout() external onlyRole(METAWIN_ROLE) {
_payout(address(this).balance);
}
// INTERNAL LOGICS //
/**
* @dev Private function to send contract funds to payoutAddress.
*/
function _payout(uint256 amount) private {
(bool success, ) = payoutAddress.call{value: amount}("");
if (!success) revert PayoutError();
else emit Payout(payoutAddress, amount);
}
}
| 24,124 |
19 | // if Bob participates, which means participantAsset will be: Filled -> (Redeemed/Refunded) | require(participantAsset[secretHash].state == AssetState.Refunded || participantAsset[secretHash].state == AssetState.Redeemed);
| require(participantAsset[secretHash].state == AssetState.Refunded || participantAsset[secretHash].state == AssetState.Redeemed);
| 30,872 |
137 | // if tranasction sender is not the staker, then more delay to _allowedTimestamp | if(msg.sender != _stakerAddress) {
if(_pet.appointeeVotes > _pet.numberOfAppointees.div(2)) {
_allowedTimestamp += EARTH_SECONDS_IN_MONTH * 6;
} else {
| if(msg.sender != _stakerAddress) {
if(_pet.appointeeVotes > _pet.numberOfAppointees.div(2)) {
_allowedTimestamp += EARTH_SECONDS_IN_MONTH * 6;
} else {
| 27,738 |
66 | // Set the amount of blocks to count a sniper. | snipeBlockAmt = _snipeBlockAmt;
gasPriceLimit = _gasPriceLimit * 1 gwei;
IUniswapV2Router02 _dexRouter = IUniswapV2Router02(_routerAddress);
lpPair = IUniswapV2Factory(_dexRouter.factory())
.createPair(address(this), _dexRouter.WETH());
dexRouter = _dexRouter;
_isExcludedFromFee[owner()] = true;
| snipeBlockAmt = _snipeBlockAmt;
gasPriceLimit = _gasPriceLimit * 1 gwei;
IUniswapV2Router02 _dexRouter = IUniswapV2Router02(_routerAddress);
lpPair = IUniswapV2Factory(_dexRouter.factory())
.createPair(address(this), _dexRouter.WETH());
dexRouter = _dexRouter;
_isExcludedFromFee[owner()] = true;
| 39,073 |
26 | // mapping from address to | mapping(address => mapping(uint256 => mapping(uint256 => uint256))) internal nonfungibleTokenIDToIndex;
| mapping(address => mapping(uint256 => mapping(uint256 => uint256))) internal nonfungibleTokenIDToIndex;
| 19,663 |
30 | // Struct encapsulating the cliff duration and the total duration./cliff The cliff duration in seconds./total The total duration in seconds. | struct Durations {
uint40 cliff;
uint40 total;
}
| struct Durations {
uint40 cliff;
uint40 total;
}
| 23,280 |
713 | // If in OPEN state, but the position is closed, set to CLOSED state | if (state == State.OPEN && Margin(DYDX_MARGIN).isPositionClosed(POSITION_ID)) {
state = State.CLOSED;
emit CompletelyClosed();
}
| if (state == State.OPEN && Margin(DYDX_MARGIN).isPositionClosed(POSITION_ID)) {
state = State.CLOSED;
emit CompletelyClosed();
}
| 27,378 |
151 | // Curve GUSD / 3CRV | lp = 0xD2967f45c4f384DEEa880F807Be904762a3DeA07;
| lp = 0xD2967f45c4f384DEEa880F807Be904762a3DeA07;
| 19,915 |
3 | // Overridden for check canTransfer / | function transfer(address _to, uint256 _value) public canTransfer(msg.sender) returns (bool) {
return super.transfer(_to, _value);
}
| function transfer(address _to, uint256 _value) public canTransfer(msg.sender) returns (bool) {
return super.transfer(_to, _value);
}
| 26,635 |
46 | // pay tax to the landlord | weiToLandlord = _value * Land[_landId].taxRate / 100;
weiToSender = _value - weiToLandlord;
Land[_landId].weiIncome += weiToLandlord;
_from.transfer(weiToSender);
| weiToLandlord = _value * Land[_landId].taxRate / 100;
weiToSender = _value - weiToLandlord;
Land[_landId].weiIncome += weiToLandlord;
_from.transfer(weiToSender);
| 48,646 |
206 | // Function that allows multi Collateral to burn a certain number of synths from an account. account Account to burn synths from amount Number of synths / | function burn(address account, uint amount) external onlyInternalContracts {
super._internalBurn(account, amount);
}
| function burn(address account, uint amount) external onlyInternalContracts {
super._internalBurn(account, amount);
}
| 11,228 |
14 | // EVENTS | event Log(string text);
| event Log(string text);
| 44,703 |
21 | // Utility function to calculate the hash of the signed message | function prefixed(bytes32 hash) internal pure returns (bytes32) {
// Calculate the hash of the message with the Ethereum signed message prefix
return keccak256(abi
.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
| function prefixed(bytes32 hash) internal pure returns (bytes32) {
// Calculate the hash of the message with the Ethereum signed message prefix
return keccak256(abi
.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
| 26,239 |
37 | // ... Add corresponding events for the functions | event TransactionSubmitted(uint256 indexed txIndex);
event TransactionConfirmed(uint256 indexed txIndex);
event TransactionExecuted(uint256 indexed txIndex); */
| event TransactionSubmitted(uint256 indexed txIndex);
event TransactionConfirmed(uint256 indexed txIndex);
event TransactionExecuted(uint256 indexed txIndex); */
| 1,814 |
91 | // modifier to only accept transferAndCall from CLN token | modifier CLNOnly() {
require(msg.sender == clnAddress);
_;
}
| modifier CLNOnly() {
require(msg.sender == clnAddress);
_;
}
| 58,799 |
24 | // Transfer tokens from other address Send `_value` tokens to `_to` on behalf of `_from`_from The address of the sender_to The address of the recipient_value the amount to send/ | function transferFrom(address _from, address _to, uint32 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
| function transferFrom(address _from, address _to, uint32 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
| 46,188 |
3 | // define 'owned' / | contract owned {
address public owner;
function owned() {
owner = msg.sender;
}
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
owner = newOwner;
}
}
| contract owned {
address public owner;
function owned() {
owner = msg.sender;
}
modifier onlyOwner {
if (msg.sender != owner) throw;
_;
}
function transferOwnership(address newOwner) onlyOwner {
owner = newOwner;
}
}
| 15,296 |
533 | // Calculate denominator for row 8167: x - g^8167z. | let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0xbc0)))
mstore(add(productsPtr, 0x920), partialProduct)
mstore(add(valuesPtr, 0x920), denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| let denominator := add(shiftedEvalPoint, mload(add(expmodsAndPoints, 0xbc0)))
mstore(add(productsPtr, 0x920), partialProduct)
mstore(add(valuesPtr, 0x920), denominator)
partialProduct := mulmod(partialProduct, denominator, PRIME)
| 64,078 |
3 | // Set the token to TransferOut state/id id value | function transferOut(uint256 id) public;
| function transferOut(uint256 id) public;
| 51,586 |
0 | // The mapping from account to token id to account balance. / | mapping(address => mapping(uint256 => uint256)) private _balances;
| mapping(address => mapping(uint256 => uint256)) private _balances;
| 28,603 |
19 | // Delete element. | documentNames.pop();
emit DocumentRemoved(_name, documents[_name].uri, documents[_name].docHash);
| documentNames.pop();
emit DocumentRemoved(_name, documents[_name].uri, documents[_name].docHash);
| 23,459 |
156 | // Removes a withdrawal root hash from active set _root The root hash to be removed from the active set / | function deleteWithdrawalRoot(bytes32 _root) private {
uint256 nonce ; //inject UNINIT LOCAL/STATE VAR
require(nonce > 0, "Root not found");
delete withdrawalRootToNonce[_root];
emit WithdrawalRootHashRemoval(_root, nonce);
}
| function deleteWithdrawalRoot(bytes32 _root) private {
uint256 nonce ; //inject UNINIT LOCAL/STATE VAR
require(nonce > 0, "Root not found");
delete withdrawalRootToNonce[_root];
emit WithdrawalRootHashRemoval(_root, nonce);
}
| 21,098 |
141 | // Return 0 if the staked balance is 0 | if (depositedTokens[_holder] == 0) return 0;
uint256 timeDiff = now.sub(lastClaimedTime[_holder],"Doge Staking: Last claimed time error");
uint256 stakedAmount = depositedTokens[_holder];
uint256 unclaimedRewards = stakedAmount
.mul(rewardRate)
.mul(timeDiff)
.div(YEAR)
| if (depositedTokens[_holder] == 0) return 0;
uint256 timeDiff = now.sub(lastClaimedTime[_holder],"Doge Staking: Last claimed time error");
uint256 stakedAmount = depositedTokens[_holder];
uint256 unclaimedRewards = stakedAmount
.mul(rewardRate)
.mul(timeDiff)
.div(YEAR)
| 40,454 |
138 | // Emitted when a liquidity provider has been removed from the set of allowed/ liquidity providers.// .. seealso:: :sol:func:`removeAllowedLp` | event LpRemoved(address lp);
| event LpRemoved(address lp);
| 11,304 |
255 | // We only get here if the requested token is not minted in storage. As we have no records of such tokens, we need to loop through all tokens from zero, until we have found enough tokens not minted in storage to match the index, and take the non-minted one at that position. | require(_index < balanceOf(_owner), "ERC721Enumerable: owner index out of bounds");
uint256 testIndex = ERC721NME.balanceOf(_owner);
uint256 tokenId = 0;
do {
if (!ERC721NME._exists(tokenId)) {
if (testIndex >= _index) {
| require(_index < balanceOf(_owner), "ERC721Enumerable: owner index out of bounds");
uint256 testIndex = ERC721NME.balanceOf(_owner);
uint256 tokenId = 0;
do {
if (!ERC721NME._exists(tokenId)) {
if (testIndex >= _index) {
| 6,422 |
10 | // Give your vote (including votes delegated to you)/ to proposal `proposals[proposal].name`. | function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
sender.voted = true;
sender.vote = proposal;
// If `proposal` is out of the range of the array,
// this will throw automatically and revert all
// changes.
proposals[proposal].voteCount += sender.weight;
}
| function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
sender.voted = true;
sender.vote = proposal;
// If `proposal` is out of the range of the array,
// this will throw automatically and revert all
// changes.
proposals[proposal].voteCount += sender.weight;
}
| 3,881 |
140 | // Revokes `role` from `account`. Internal function without access restriction. / | function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
| function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
| 1,375 |
4 | // List of all active cognitive jobs | IComputingJob[] public cognitiveJobs;
| IComputingJob[] public cognitiveJobs;
| 23,058 |
6 | // Transfers control of the contract to a newOwner. _newOwner The address to transfer ownership to. / | function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
| function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
| 33,542 |
34 | // expmods[30] = trace_generator^(3trace_length / 32). | mstore(0x3460, expmod(/*trace_generator*/ mload(0x440), div(mul(3, /*trace_length*/ mload(0x80)), 32), PRIME))
| mstore(0x3460, expmod(/*trace_generator*/ mload(0x440), div(mul(3, /*trace_length*/ mload(0x80)), 32), PRIME))
| 31,978 |
17 | // Router only methods | function addLiquidityFor(uint256 amount, address assetId, address router) external payable;
function addLiquidity(uint256 amount, address assetId) external payable;
function removeLiquidity(
uint256 amount,
address assetId,
address payable recipient
) external;
| function addLiquidityFor(uint256 amount, address assetId, address router) external payable;
function addLiquidity(uint256 amount, address assetId) external payable;
function removeLiquidity(
uint256 amount,
address assetId,
address payable recipient
) external;
| 37,116 |
10 | // Find facet for function that is called and execute the function if a facet is found and return any value. | fallback() external payable {
LibDiamond.DiamondStorage storage ds;
bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress;
require(facet != address(0), "Diamond: Function does not exist");
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
| fallback() external payable {
LibDiamond.DiamondStorage storage ds;
bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
assembly {
ds.slot := position
}
address facet = ds.selectorToFacetAndPosition[msg.sig].facetAddress;
require(facet != address(0), "Diamond: Function does not exist");
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
| 74,324 |
92 | // Emit the event to update the UI | emit PotUpdated(pot);
| emit PotUpdated(pot);
| 67,560 |
236 | // if we already sell, payout is definitely true | if (sellPrice_ > 0) return true;
| if (sellPrice_ > 0) return true;
| 45,859 |
172 | // Updates RGT distribution speeds for each pool given one `pool` and its `newBalance` (only accessible by the RariFundManager corresponding to `pool`). pool The pool whose balance should be refreshed. newBalance The new balance of the pool to be refreshed. / | function refreshDistributionSpeeds(RariPool pool, uint256 newBalance) external;
| function refreshDistributionSpeeds(RariPool pool, uint256 newBalance) external;
| 2,227 |
61 | // Address of the FeePoolProxy / | address public feePoolProxy;
| address public feePoolProxy;
| 15,880 |
5 | // Returns allowance of gems | function allowance(uint256 _owner, address _spender) external view returns( uint256) {
return _allowances[_owner][_spender];
}
| function allowance(uint256 _owner, address _spender) external view returns( uint256) {
return _allowances[_owner][_spender];
}
| 7,368 |
59 | // Vault | uint256 internal constant INVALID_POOL_ID = 500;
uint256 internal constant CALLER_NOT_POOL = 501;
uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502;
uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503;
uint256 internal constant INVALID_SIGNATURE = 504;
uint256 internal constant EXIT_BELOW_MIN = 505;
uint256 internal constant JOIN_ABOVE_MAX = 506;
uint256 internal constant SWAP_LIMIT = 507;
uint256 internal constant SWAP_DEADLINE = 508;
uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509;
| uint256 internal constant INVALID_POOL_ID = 500;
uint256 internal constant CALLER_NOT_POOL = 501;
uint256 internal constant SENDER_NOT_ASSET_MANAGER = 502;
uint256 internal constant USER_DOESNT_ALLOW_RELAYER = 503;
uint256 internal constant INVALID_SIGNATURE = 504;
uint256 internal constant EXIT_BELOW_MIN = 505;
uint256 internal constant JOIN_ABOVE_MAX = 506;
uint256 internal constant SWAP_LIMIT = 507;
uint256 internal constant SWAP_DEADLINE = 508;
uint256 internal constant CANNOT_SWAP_SAME_TOKEN = 509;
| 17,833 |
7 | // proposal identifiers unique id | uint256 id;
| uint256 id;
| 11,656 |
14 | // CONTRACT | contract Vestchain is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "VEST";
name = "Vestchain";
decimals = 8;
totalSupply = 884800000000000000;
holders[msg.sender] = totalSupply;
}
} | contract Vestchain is ERC20 {
uint256 public totalSupply;
uint public decimals;
string public symbol;
string public name;
mapping (address => mapping (address => uint256)) approach;
mapping (address => uint256) holders;
//***************************** REVERT IF ETHEREUM SEND ************************
function () public {
revert();
}
//***************************** CHECK BALANCE **********************************
function balanceOf(address _own)
public view returns (uint256) {
return holders[_own];
}
//***************************** TRANSFER TOKENS FROM YOUR ACCOUNT **************
function transfer(address _to, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
require(msg.sender != _to);
assert(_val <= holders[msg.sender]);
holders[msg.sender] = holders[msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(msg.sender, _to, _val);
return true;
}
//**************************** TRANSFER TOKENS FROM ANOTHER ACCOUNT ************
function transferFrom(address _from, address _to, uint256 _val)
public returns (bool) {
require(holders[_from] >= _val);
require(approach[_from][msg.sender] >= _val);
assert(_val <= holders[_from]);
holders[_from] = holders[_from] - _val;
assert(_val <= approach[_from][msg.sender]);
approach[_from][msg.sender] = approach[_from][msg.sender] - _val;
holders[_to] = holders[_to] + _val;
assert(holders[_to] >= _val);
emit Transfer(_from, _to, _val);
return true;
}
//***************************** APPROVE TOKENS TO SEND *************************
function approve(address _spender, uint256 _val)
public returns (bool) {
require(holders[msg.sender] >= _val);
approach[msg.sender][_spender] = _val;
emit Approval(msg.sender, _spender, _val);
return true;
}
//***************************** CHECK APPROVE **********************************
function allowance(address _owner, address _spender)
public view returns (uint256) {
return approach[_owner][_spender];
}
//***************************** CONSTRUCTOR CONTRACT ***************************
constructor() public {
symbol = "VEST";
name = "Vestchain";
decimals = 8;
totalSupply = 884800000000000000;
holders[msg.sender] = totalSupply;
}
} | 7,625 |
240 | // property holding last created NFT ID- it'ssepareted from Marble NFT contract in case that we will want to change NFT id strategy in the future. Currently no idea why we would do it! :) / | uint256 public lastMintedNFTId;
constructor(uint256 _lastMintedNFTId)
public
| uint256 public lastMintedNFTId;
constructor(uint256 _lastMintedNFTId)
public
| 23,398 |
4 | // Register a pod proposal. Specifically used as a layer ontop of a Gnosis safe to emit/ proposal metadata/podId Unique identifier of the pod for which metadata is being registered/proposalId Unique identifier of the proposal for which metadata is being registered/metadata Proposal metadata | function registerProposal(
uint256 podId,
uint256 proposalId,
string memory metadata
| function registerProposal(
uint256 podId,
uint256 proposalId,
string memory metadata
| 65,778 |
6 | // The block number of the last pool update | uint256 public lastRewardBlock;
| uint256 public lastRewardBlock;
| 14,754 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.