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
|
---|---|---|---|---|
120 | // Validation of an executed purchase. Observe state and use revert statements to undo rollback when validconditions are not met. beneficiary Address performing the token purchase weiAmount Value in wei involved in the purchase / | function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
// solhint-disable-previous-line no-empty-blocks
}
| function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
// solhint-disable-previous-line no-empty-blocks
}
| 9,152 |
2 | // Encode ERC-20 asset data into the format described in the AssetProxy contract specification./tokenAddress The address of the ERC-20 contract hosting the asset to be traded./ return AssetProxy-compliant data describing the asset. | function encodeERC20AssetData(address tokenAddress)
public
pure
returns (bytes memory assetData)
| function encodeERC20AssetData(address tokenAddress)
public
pure
returns (bytes memory assetData)
| 48,211 |
220 | // Ensure we got the right amount back. | uint256 v2BalAfter = IERC20(v2Vault).balanceOf(address(this));
require(v2BalAfter-v2BalBefore == count * 10**18, "Received less than expected v2");
migrationPair[v1VaultId] = v2Vault;
if (store.holdingsLength(v1VaultId) == 0) {
isFullyMigrated[v1VaultId] = true;
}
| uint256 v2BalAfter = IERC20(v2Vault).balanceOf(address(this));
require(v2BalAfter-v2BalBefore == count * 10**18, "Received less than expected v2");
migrationPair[v1VaultId] = v2Vault;
if (store.holdingsLength(v1VaultId) == 0) {
isFullyMigrated[v1VaultId] = true;
}
| 77,459 |
315 | // how many blocks are the functions locked for | uint256 private constant BLOCK_LOCK_COUNT = 6;
| uint256 private constant BLOCK_LOCK_COUNT = 6;
| 3,409 |
114 | // eat loss of precision effectively: (x / 2112)1e18 | purchasePrice = (priceAverageSell >> 112) * ONE;
| purchasePrice = (priceAverageSell >> 112) * ONE;
| 87,678 |
81 | // splits ERC-20 funds between 4JM, Particle DAO and artist, for a token purchased on collection `_collectionId`. possible DoS during splits is acknowledged, and mitigated byadmin-accepted artist payment addresses. / | function _splitFundsERC20(
uint256 _collectionId,
uint256 _totalPrice,
address _currencyAddress
| function _splitFundsERC20(
uint256 _collectionId,
uint256 _totalPrice,
address _currencyAddress
| 27,804 |
48 | // tokenId_inside => tokenId_outside | mapping(uint256 => uint256) public mirrorId2OriginId;
| mapping(uint256 => uint256) public mirrorId2OriginId;
| 1,891 |
12 | // Given a positive and negative delta lots value net out the raw liquiditydelta. / | returns (int128) {
unchecked {
// Original values are 96-bits, every possible difference will fit in signed-128 bits
return lotToNetLiq(incrLots) - lotToNetLiq(decrLots);
}
}
| returns (int128) {
unchecked {
// Original values are 96-bits, every possible difference will fit in signed-128 bits
return lotToNetLiq(incrLots) - lotToNetLiq(decrLots);
}
}
| 9,315 |
139 | // Returns the "virtual" fyToken balance, which is the real balance plus the pool token supply. | function _getFYTokenBalance() internal view returns (uint104) {
return (fyToken.balanceOf(address(this)) + _totalSupply).u104();
}
| function _getFYTokenBalance() internal view returns (uint104) {
return (fyToken.balanceOf(address(this)) + _totalSupply).u104();
}
| 29,438 |
1 | // keccak256("ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)") | bytes32
public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH = 0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8;
| bytes32
public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH = 0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8;
| 25,165 |
24 | // A mapping from pubkey to the sale amount from second sale. | mapping (bytes32 => uint) public saleAmounts;
| mapping (bytes32 => uint) public saleAmounts;
| 34,474 |
54 | // Claim all stream rewards on behalf of another user./account the user account address. | function claimAllOnBehalfOfAnotherUser(address account)
external
pausable(1)
onlyRole(CLAIM_ROLE)
| function claimAllOnBehalfOfAnotherUser(address account)
external
pausable(1)
onlyRole(CLAIM_ROLE)
| 2,358 |
4 | // The EIP-712 typehash for the approve struct used by the contract | bytes32 public constant APPROVE_TYPE_HASH = keccak256("Approve(address spender,uint256 rawAmount,uint256 nonce,uint256 expiry)");
| bytes32 public constant APPROVE_TYPE_HASH = keccak256("Approve(address spender,uint256 rawAmount,uint256 nonce,uint256 expiry)");
| 33,338 |
379 | // Return the precision-adjusted balances of all tokens in the pool self Swap struct to read fromreturn the pool balances "scaled" to the pool's precision, allowingthem to be more easily compared. / | function _xp(Swap storage self) internal view returns (uint256[] memory) {
return _xp(self.balances, self.tokenPrecisionMultipliers);
}
| function _xp(Swap storage self) internal view returns (uint256[] memory) {
return _xp(self.balances, self.tokenPrecisionMultipliers);
}
| 9,181 |
12 | // Count the number of groups of 7 bits We need this pre-processing step since Solidity doesn't allow dynamic memory resizing | uint64 tmp = n;
uint64 numBytes = 2;
while (tmp > 0x7F) {
tmp = tmp >> 7;
numBytes += 1;
}
| uint64 tmp = n;
uint64 numBytes = 2;
while (tmp > 0x7F) {
tmp = tmp >> 7;
numBytes += 1;
}
| 23,846 |
35 | // DetailedERC20 token The decimals are only for visualization purposes.All the operations are done using the smallest and indivisible token unit,just as on Ethereum all the operations are done in wei. / | contract DetailedERC20 is ERC20 {
string public name;
string public symbol;
uint8 public decimals;
constructor(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
}
| contract DetailedERC20 is ERC20 {
string public name;
string public symbol;
uint8 public decimals;
constructor(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
}
| 9,672 |
53 | // The total MUNFee generated | uint256 public totalMunFeeMined;
uint256 public munFeePrice;
uint256 public accomulatedRewards;
uint256 public pricePadding;
uint256 public timeToExitLiquidity;
| uint256 public totalMunFeeMined;
uint256 public munFeePrice;
uint256 public accomulatedRewards;
uint256 public pricePadding;
uint256 public timeToExitLiquidity;
| 26,932 |
22 | // βββββββββββββββββββββββββββββ/Allows users to mint long synthetic assets for a market. To prevent front-running these mints are executed on the next price update from the oracle./marketIndex An uint32 which uniquely identifies a market./amount Amount of payment tokens in that token's lowest denominationfor which to mint synthetic assets at next price. | function mintLong(
uint32 marketIndex,
uint256 pool,
uint224 amount
| function mintLong(
uint32 marketIndex,
uint256 pool,
uint224 amount
| 25,439 |
7 | // {token_id}:{blueprint} |
function split(bytes calldata blob)
internal
pure
returns (uint256, bytes memory)
{
int256 index = Bytes.indexOf(blob, ":", 0);
require(index >= 0, "Separator must exist");
|
function split(bytes calldata blob)
internal
pure
returns (uint256, bytes memory)
{
int256 index = Bytes.indexOf(blob, ":", 0);
require(index >= 0, "Separator must exist");
| 28,876 |
264 | // i is batch number | for (uint256 i = 0; i < _recipients.length; i++) {
| for (uint256 i = 0; i < _recipients.length; i++) {
| 2,319 |
19 | // Processes Bento tokens /Call swap for all pools that swap from this token/stream Streamed process program | function processInsideBento(uint256 stream) private {
address token = stream.readAddress();
uint8 num = stream.readUint8();
uint256 amountTotal = bentoBox.balanceOf(token, address(this));
unchecked {
if (amountTotal > 0) amountTotal -= 1; // slot undrain protection
for (uint256 i = 0; i < num; ++i) {
uint16 share = stream.readUint16();
uint256 amount = (amountTotal * share) / 65535;
amountTotal -= amount;
swap(stream, address(this), token, amount);
}
}
}
| function processInsideBento(uint256 stream) private {
address token = stream.readAddress();
uint8 num = stream.readUint8();
uint256 amountTotal = bentoBox.balanceOf(token, address(this));
unchecked {
if (amountTotal > 0) amountTotal -= 1; // slot undrain protection
for (uint256 i = 0; i < num; ++i) {
uint16 share = stream.readUint16();
uint256 amount = (amountTotal * share) / 65535;
amountTotal -= amount;
swap(stream, address(this), token, amount);
}
}
}
| 36,437 |
3 | // constants | uint constant public MAX_OWNER_COUNT = 8;
| uint constant public MAX_OWNER_COUNT = 8;
| 2,533 |
2 | // Emitted when contract admin deposits reward tokens. | event RewardTokensDepositedByAdmin(uint256 _amount);
| event RewardTokensDepositedByAdmin(uint256 _amount);
| 22,361 |
1 | // Version number of this contract / | function version() external pure returns (bytes32);
| function version() external pure returns (bytes32);
| 1,271 |
75 | // agreement accepted by act of reserving funds in this function | acceptAgreementInternal(investor);
| acceptAgreementInternal(investor);
| 33,931 |
29 | // Alias of sell() and withdraw(). / | function exit()
public
| function exit()
public
| 9,710 |
50 | // | function dexRequestTokensFromUser () external returns (bool success) {
// calculate remote allowance given to the contract on the senders address
// completed via the wallet
uint256 amountAllowed = _remoteToken.allowance(msg.sender, _dexAddress);
require(amountAllowed > 0, "No allowance has been set.");
uint256 amountBalance = _remoteToken.balanceOf(msg.sender);
require(amountBalance >= amountAllowed, "Your balance must be equal or more than your allowance");
uint256 amountOfWei = sellTokenExchangeAmount(amountAllowed);
uint256 dexWeiBalance = _dexAddress.balance;
uint256 dexTokenBalance = _remoteToken.balanceOf(_dexAddress);
require(dexWeiBalance >= amountOfWei, "Dex balance must be equal or more than your allowance");
_remoteTransferFrom(msg.sender, _dexAddress, amountAllowed);
_remoteToken.approve(_dexAddress, dexTokenBalance.add(amountAllowed));
// Send Ether back to user
msg.sender.transfer(amountOfWei);
emit TokensSold(msg.sender, amountAllowed, amountOfWei);
success = true;
}
| function dexRequestTokensFromUser () external returns (bool success) {
// calculate remote allowance given to the contract on the senders address
// completed via the wallet
uint256 amountAllowed = _remoteToken.allowance(msg.sender, _dexAddress);
require(amountAllowed > 0, "No allowance has been set.");
uint256 amountBalance = _remoteToken.balanceOf(msg.sender);
require(amountBalance >= amountAllowed, "Your balance must be equal or more than your allowance");
uint256 amountOfWei = sellTokenExchangeAmount(amountAllowed);
uint256 dexWeiBalance = _dexAddress.balance;
uint256 dexTokenBalance = _remoteToken.balanceOf(_dexAddress);
require(dexWeiBalance >= amountOfWei, "Dex balance must be equal or more than your allowance");
_remoteTransferFrom(msg.sender, _dexAddress, amountAllowed);
_remoteToken.approve(_dexAddress, dexTokenBalance.add(amountAllowed));
// Send Ether back to user
msg.sender.transfer(amountOfWei);
emit TokensSold(msg.sender, amountAllowed, amountOfWei);
success = true;
}
| 1,170 |
554 | // Return indicating whether this is a valid service type / | function serviceTypeIsValid(bytes32 _serviceType)
external view returns (bool)
| function serviceTypeIsValid(bytes32 _serviceType)
external view returns (bool)
| 56,081 |
17 | // The minimum of `a` and `b`. a a FixedPoint. b a FixedPoint.return the minimum of `a` and `b`. / | function min(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
return a.rawValue < b.rawValue ? a : b;
}
| function min(Unsigned memory a, Unsigned memory b) internal pure returns (Unsigned memory) {
return a.rawValue < b.rawValue ? a : b;
}
| 19,541 |
103 | // Mapping from token ID to approved address | mapping(uint256 => address) private _tokenApprovals;
| mapping(uint256 => address) private _tokenApprovals;
| 95 |
34 | // Changes the infinityNFTFee of the XfaiV0Core contract Only the owner of the XfaiV0Core contract can call this function _newLnftFee The new infinityNFTFee / | function changeInfinityNFTFee(uint _newLnftFee) external override onlyOwner {
require(lpFee + _newLnftFee <= MAX_FEE, 'XfaiV0Core: FEE_EXCEEDS_LIMIT');
infinityNFTFee = _newLnftFee;
emit InfinityNFTFeeChange(_newLnftFee);
}
| function changeInfinityNFTFee(uint _newLnftFee) external override onlyOwner {
require(lpFee + _newLnftFee <= MAX_FEE, 'XfaiV0Core: FEE_EXCEEDS_LIMIT');
infinityNFTFee = _newLnftFee;
emit InfinityNFTFeeChange(_newLnftFee);
}
| 33,273 |
41 | // Returns round epochs and bet information for a user that has participated user: user address cursor: cursor size: size / | function getUserRounds(
address user,
uint256 cursor,
uint256 size
)
external
view
returns (
uint256[] memory,
BetInfo[] memory,
| function getUserRounds(
address user,
uint256 cursor,
uint256 size
)
external
view
returns (
uint256[] memory,
BetInfo[] memory,
| 4,106 |
1,003 | // If token decimals > INTERNAL_TOKEN_PRECISION:on deposit: resulting dust will accumulate to protocolon withdraw: protocol may lose dust amount. However, withdraws are only calculated basedon a conversion from internal token precision to external token precision so therefore dustamounts cannot be specified for withdraws. If token decimals < INTERNAL_TOKEN_PRECISION then this will add zeros to the end of amount and will not result in dust. | if (token.decimals == Constants.INTERNAL_TOKEN_PRECISION) return amount;
return amount.mul(Constants.INTERNAL_TOKEN_PRECISION).div(token.decimals);
| if (token.decimals == Constants.INTERNAL_TOKEN_PRECISION) return amount;
return amount.mul(Constants.INTERNAL_TOKEN_PRECISION).div(token.decimals);
| 11,317 |
69 | // Refunds any ETH balance held by this contract to the `msg.sender`/Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps/ that use ether for the input amount | function refundETH() external payable;
| function refundETH() external payable;
| 8,214 |
88 | // currencyId /,/ incentiveRate /,/ assetArrayLength /, Restrict purchasing until some amount of time after the last initialized time to ensure that arbitrage opportunities are not available (by generating residuals and then immediately purchasing them at a discount) This is always relative to the last initialized time which is set at utc0 when initialized, not the reference time. Therefore we will always restrict residual purchase relative to initialization, not reference. This is safer, prevents an attack if someone forces residuals and then somehow prevents market initialization until the residual time buffer passes. | require(
blockTime >
lastInitializedTime.add(
uint256(uint8(parameters[Constants.RESIDUAL_PURCHASE_TIME_BUFFER])) * 1 hours
),
"Insufficient block time"
);
int256 notional =
BitmapAssetsHandler.getifCashNotional(nTokenAddress, cashGroup.currencyId, maturity);
| require(
blockTime >
lastInitializedTime.add(
uint256(uint8(parameters[Constants.RESIDUAL_PURCHASE_TIME_BUFFER])) * 1 hours
),
"Insufficient block time"
);
int256 notional =
BitmapAssetsHandler.getifCashNotional(nTokenAddress, cashGroup.currencyId, maturity);
| 3,406 |
202 | // Return the permissions flag that are associated with STO / | function getPermissions() public view returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](0);
return allPermissions;
}
| function getPermissions() public view returns(bytes32[]) {
bytes32[] memory allPermissions = new bytes32[](0);
return allPermissions;
}
| 18,927 |
68 | // No sufficiency check required as sub() will throw anyways | userData[poolId][user].stakeAmount = userData[poolId][user].stakeAmount.sub(amount);
poolData[poolId].totalStakeAmount = poolData[poolId].totalStakeAmount.sub(amount);
safeTransfer(poolInfos[poolId].poolToken, user, amount);
emit Unstaked(poolId, user, poolInfos[poolId].poolToken, amount);
| userData[poolId][user].stakeAmount = userData[poolId][user].stakeAmount.sub(amount);
poolData[poolId].totalStakeAmount = poolData[poolId].totalStakeAmount.sub(amount);
safeTransfer(poolInfos[poolId].poolToken, user, amount);
emit Unstaked(poolId, user, poolInfos[poolId].poolToken, amount);
| 6,994 |
48 | // Transfer the rest to the user | require(
stakeToken.transfer(msgSender(), amountLeft),
"XGTSTAKE-USER-TRANSFER-FAILED"
);
bytes4 _methodSelector =
IXGTGenerator(address(0)).tokensUnstaked.selector;
bytes memory data =
abi.encodeWithSelector(_methodSelector, _amount, msgSender());
bridge.requireToPassMessage(xgtGeneratorContract, data, 750000);
| require(
stakeToken.transfer(msgSender(), amountLeft),
"XGTSTAKE-USER-TRANSFER-FAILED"
);
bytes4 _methodSelector =
IXGTGenerator(address(0)).tokensUnstaked.selector;
bytes memory data =
abi.encodeWithSelector(_methodSelector, _amount, msgSender());
bridge.requireToPassMessage(xgtGeneratorContract, data, 750000);
| 30,145 |
43 | // Check if the curve is the zero curve. / | function isZeroCurve(uint x0, uint y0) internal pure
returns (bool isZero)
| function isZeroCurve(uint x0, uint y0) internal pure
returns (bool isZero)
| 46,888 |
242 | // only owner | function setBaseURI(string memory _newBaseURI) public onlyOwner() {
baseURI = _newBaseURI;
}
| function setBaseURI(string memory _newBaseURI) public onlyOwner() {
baseURI = _newBaseURI;
}
| 15,355 |
4 | // Set the allowance to the exact amount the user wants to transfer | require(token.approve(address(this), amount), "Token approval failed");
| require(token.approve(address(this), amount), "Token approval failed");
| 2,994 |
119 | // Friday, 5 July 2019 Π³., 23:59:00 | require(now >= endICODate + 31536000);
token.transfer(walletE, paymentSizeE);
completedE[order] = true;
| require(now >= endICODate + 31536000);
token.transfer(walletE, paymentSizeE);
completedE[order] = true;
| 46,245 |
243 | // updates masks for round and player when keys are boughtreturn dust left over / | function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys)
private
returns(uint256)
| function updateMasks(uint256 _rID, uint256 _pID, uint256 _gen, uint256 _keys)
private
returns(uint256)
| 3,089 |
12 | // otherwise just read from v1 oracle | address underlying = BErc20(bTokenAddress).underlying();
return v1PriceOracle.assetPrices(underlying);
| address underlying = BErc20(bTokenAddress).underlying();
return v1PriceOracle.assetPrices(underlying);
| 7,400 |
81 | // (proofPtr + 0x280) = note type (UXTO type, 0x01) | mstore(add(proofPtr, 0x280), 0x01) // note type
| mstore(add(proofPtr, 0x280), 0x01) // note type
| 19,261 |
26 | // _________________________________________________________CONSTRUCTOR/ Initializes contract with initial supply tokens to the creator of the contract / | function TokenMacroansy() public {
owner = msg.sender;
beneficiaryFunds = owner;
//totalSupplyStart = initialSupply * 10** uint256(decimals);
totalSupplyStart = 3999 * 10** uint256(decimals);
totalSupply = totalSupplyStart;
//
balanceOf[msg.sender] = totalSupplyStart;
Transfer(address(0), msg.sender, totalSupplyStart);
//
name = "TokenMacroansy";
symbol = "$BEE";
//
allowedIndividualShare = uint(1)*totalSupplyStart/100;
allowedPublicShare = uint(20)* totalSupplyStart/100;
//
//allowedFounderShare = uint(20)*totalSupplyStart/100;
//allowedPOOLShare = uint(9)* totalSupplyStart/100;
//allowedColdReserve = uint(41)* totalSupplyStart/100;
//allowedVCShare = uint(10)* totalSupplyStart/100;
}
| function TokenMacroansy() public {
owner = msg.sender;
beneficiaryFunds = owner;
//totalSupplyStart = initialSupply * 10** uint256(decimals);
totalSupplyStart = 3999 * 10** uint256(decimals);
totalSupply = totalSupplyStart;
//
balanceOf[msg.sender] = totalSupplyStart;
Transfer(address(0), msg.sender, totalSupplyStart);
//
name = "TokenMacroansy";
symbol = "$BEE";
//
allowedIndividualShare = uint(1)*totalSupplyStart/100;
allowedPublicShare = uint(20)* totalSupplyStart/100;
//
//allowedFounderShare = uint(20)*totalSupplyStart/100;
//allowedPOOLShare = uint(9)* totalSupplyStart/100;
//allowedColdReserve = uint(41)* totalSupplyStart/100;
//allowedVCShare = uint(10)* totalSupplyStart/100;
}
| 40,584 |
44 | // reset count of confirmations needed. | pending.yetNeeded = required;
| pending.yetNeeded = required;
| 38,610 |
15 | // set new Aave lending pool address_newAaveLendingPool Aave lending pool address | function setNewAaveLendingPool(address _newAaveLendingPool)
public
onlyOwner
| function setNewAaveLendingPool(address _newAaveLendingPool)
public
onlyOwner
| 6,634 |
0 | // Event of burn request | event Request(address issuer, bytes32 id);
| event Request(address issuer, bytes32 id);
| 34,755 |
3 | // set for iterating | jinglesOnSale.push(_jingleId);
positionOfJingle[_jingleId] = jinglesOnSale.length - 1;
| jinglesOnSale.push(_jingleId);
positionOfJingle[_jingleId] = jinglesOnSale.length - 1;
| 9,747 |
2 | // get last selectorSlot | selectorSlot = ds.selectorSlots[selectorCount / 8];
| selectorSlot = ds.selectorSlots[selectorCount / 8];
| 26,869 |
20 | // The constructor assigns the token name, symbols and decimals. / | constructor(string _name, string _symbol, uint8 _decimals) internal {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
| constructor(string _name, string _symbol, uint8 _decimals) internal {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
| 8,795 |
16 | // Withdraw appeal crowdfunding balance for given ruling option and for given rounds./Allows to withdraw any rewards or reimbursable fees after the dispute gets resolved for given positions at once./_disputeID The dispute ID as in arbitrator./_contributor Beneficiary of withdraw operation./positions [rounds][rulings]. | function withdrawFeesAndRewardsForGivenPositions(
uint256 _disputeID,
address payable _contributor,
uint256[][] calldata positions
) external virtual;
| function withdrawFeesAndRewardsForGivenPositions(
uint256 _disputeID,
address payable _contributor,
uint256[][] calldata positions
) external virtual;
| 24,709 |
31 | // account Target account.return Penalty rewards. / | function penalty(address account) public view returns (uint256) {
return _penaltyAmount[account];
}
| function penalty(address account) public view returns (uint256) {
return _penaltyAmount[account];
}
| 14,898 |
4 | // ζ°ε转ε符串 | function uint2str(uint num) internal pure returns (string) {
if (num == 0) return "0";
uint temp = num;
uint length = 0;
while (temp != 0){
length++;
temp /= 10;
}
bytes memory result = new bytes(length);
uint k = length - 1;
while (num != 0){
result[k--] = byte(48 + num % 10);
num /= 10;
}
return string(result);
}
| function uint2str(uint num) internal pure returns (string) {
if (num == 0) return "0";
uint temp = num;
uint length = 0;
while (temp != 0){
length++;
temp /= 10;
}
bytes memory result = new bytes(length);
uint k = length - 1;
while (num != 0){
result[k--] = byte(48 + num % 10);
num /= 10;
}
return string(result);
}
| 38,098 |
111 | // we can transfer the asset to the fund | uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this));
if (underlyingBalance > 0) {
IERC20(underlying).safeTransfer(
fund,
Math.min(underlyingAmount, underlyingBalance)
);
}
| uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this));
if (underlyingBalance > 0) {
IERC20(underlying).safeTransfer(
fund,
Math.min(underlyingAmount, underlyingBalance)
);
}
| 24,871 |
321 | // transfer given amount of given token to the caller / | function _transferToProvider(
Token token,
uint256 amount,
address provider
| function _transferToProvider(
Token token,
uint256 amount,
address provider
| 31,325 |
11 | // Sets the `name()` record for the reverse DID record associated withthe calling account. First updates the resolver to the default reverseresolver if necessary. name The name to set for this address.return The DID node hash of the reverse record. / | function setName(string memory name) public override returns (bytes32) {
return
setNameForAddr(
msg.sender,
msg.sender,
address(defaultResolver),
name
);
}
| function setName(string memory name) public override returns (bytes32) {
return
setNameForAddr(
msg.sender,
msg.sender,
address(defaultResolver),
name
);
}
| 34,102 |
50 | // Events / Emitted when owner force-allows transfers of tokens. | event AllowTransfer();
| event AllowTransfer();
| 39,433 |
66 | // Checks that caller is not a eoa.// This is used to prevent contracts from interacting. | modifier noContractAllowed() {
require(!address(msg.sender).isContract() && msg.sender == tx.origin, "Sorry we do not accept contract!");
_;
}
| modifier noContractAllowed() {
require(!address(msg.sender).isContract() && msg.sender == tx.origin, "Sorry we do not accept contract!");
_;
}
| 12,714 |
109 | // Selling | else if (
automatedMarketMakerPairs[to] &&
!_isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransactionAmount,
"Sell transfer amount exceeds the maxTransactionAmount."
);
} else if (!_isExcludedMaxTransactionAmount[to]) {
| else if (
automatedMarketMakerPairs[to] &&
!_isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransactionAmount,
"Sell transfer amount exceeds the maxTransactionAmount."
);
} else if (!_isExcludedMaxTransactionAmount[to]) {
| 49,427 |
384 | // gets the available liquidity in the reserve. The available liquidity is the balance of the core contract_reserve the reserve address return the available liquidity/ | function getReserveAvailableLiquidity(address _reserve) public view returns (uint256) {
uint256 balance = 0;
if (_reserve == EthAddressLib.ethAddress()) {
balance = address(this).balance;
} else {
balance = IERC20(_reserve).balanceOf(address(this));
}
return balance;
}
| function getReserveAvailableLiquidity(address _reserve) public view returns (uint256) {
uint256 balance = 0;
if (_reserve == EthAddressLib.ethAddress()) {
balance = address(this).balance;
} else {
balance = IERC20(_reserve).balanceOf(address(this));
}
return balance;
}
| 51,533 |
462 | // Increase account supply of specified token amount account The account to mint tokens for amount The amount of tokens to mintreturn true if successful / | function mint(address account, uint256 amount) external returns (bool);
| function mint(address account, uint256 amount) external returns (bool);
| 18,214 |
17 | // debt accrued is the sum of the current debt minus the sum of the debt at the last update | vars.totalDebtAccrued = vars
.currentVariableDebt
.add(vars.currentStableDebt)
.sub(vars.previousVariableDebt)
.sub(vars.previousStableDebt);
vars.amountToMint = vars.totalDebtAccrued.percentMul(vars.reserveFactor);
if (vars.amountToMint != 0) {
IAToken(reserve.aTokenAddress).mintToTreasury(vars.amountToMint, newLiquidityIndex);
| vars.totalDebtAccrued = vars
.currentVariableDebt
.add(vars.currentStableDebt)
.sub(vars.previousVariableDebt)
.sub(vars.previousStableDebt);
vars.amountToMint = vars.totalDebtAccrued.percentMul(vars.reserveFactor);
if (vars.amountToMint != 0) {
IAToken(reserve.aTokenAddress).mintToTreasury(vars.amountToMint, newLiquidityIndex);
| 29,906 |
197 | // MathBlocks, Primes/MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMNmdddddddddddddddddmNMMMMMMM MMMMMMMMMmhyssooooooooooooooooosyhNMMMMM MMMMMMMmyso+/::::::::::::::::::/osyMMMMM MMMMMMhys+::/+++++++++++++++++/:+syNMMMM MMMMNyso/:/+/::::+/:::/+:::::::+oshMMMMM MMMMMNdyyyyso/:++:/+:/+/:+syNMMMMMMMMMMM MMMMMMMMMhso/:/+/:++:/++-+symMMMMMMMMMMM MMMMMMMMdys+:/++:/++:/++:/+syNMMMMMMMMMM MMMMMMMNys+:/++/:+s+:/+++:/oydMMMMMMMMMM MMMMMMMMMmhyssyyhmMdhyssyydNMMMMMMMMMMMM MMMMMMMMMMMMMNMMMMMMMMMNMMMMMMMMMMMMMMMM/ | struct CoreData {
bool isPrime;
uint16 primeIndex;
uint8 primeFactorCount;
uint16[2] parents;
uint32 lastBred;
}
| struct CoreData {
bool isPrime;
uint16 primeIndex;
uint8 primeFactorCount;
uint16[2] parents;
uint32 lastBred;
}
| 26,082 |
19 | // Whether or not the voter supports the proposal | bool support;
| bool support;
| 25,586 |
13 | // round to make sure that we pass the target price | return
zeroForOne
? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)
: getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);
| return
zeroForOne
? getNextSqrtPriceFromAmount1RoundingDown(sqrtPX96, liquidity, amountOut, false)
: getNextSqrtPriceFromAmount0RoundingUp(sqrtPX96, liquidity, amountOut, false);
| 21,733 |
393 | // Remove `_value` network tokens and `_primordialValue` Primordial tokens from the system irreversibly _value The amount of network tokens to burn _primordialValue The amount of Primordial tokens to burnreturn true on success / | function burnTokens(uint256 _value, uint256 _primordialValue) public returns (bool success) {
require (super.burn(_value));
require (burnPrimordialToken(_primordialValue));
return true;
}
| function burnTokens(uint256 _value, uint256 _primordialValue) public returns (bool success) {
require (super.burn(_value));
require (burnPrimordialToken(_primordialValue));
return true;
}
| 32,585 |
4 | // A new address has be authorized or un-authorized to issue accounts | event AccountIssuerSet(address indexed issuer, bool authorized);
| event AccountIssuerSet(address indexed issuer, bool authorized);
| 493 |
26 | // These functions deal with verification of Merkle Tree proofs. The proofs can be generated using the JavaScript libraryNote: the hashing algorithm should be keccak256 and pair sorting should be enabled. See `test/utils/cryptography/MerkleProof.test.js` for some examples. WARNING: You should avoid using leaf values that are 64 bytes long prior tohashing, or use a hash function other than keccak256 for hashing leaves.This is because the concatenation of a sorted pair of internal nodes inthe merkle tree could be reinterpreted as a leaf value. / | library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
* consuming from one or the other at each step according to the instructions given by
* `proofFlags`.
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
| library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
* consuming from one or the other at each step according to the instructions given by
* `proofFlags`.
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
| 1,876 |
94 | // Allows the controller to burn tokens from a user account/May be overridden to provide more granular control over burning/_user Address of the holder account to burn tokens from/_amount Amount of tokens to burn | function controllerBurn(address _user, uint256 _amount) external;
| function controllerBurn(address _user, uint256 _amount) external;
| 46,114 |
5 | // Moves a `value` amount of tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event. / | function transfer(address to, uint256 value) external returns (bool);
| function transfer(address to, uint256 value) external returns (bool);
| 484 |
43 | // Check that the burn token is valid | BurnItem memory burnItem = burnRedeemInstance.burnSet[0].items[burnItemIndex];
| BurnItem memory burnItem = burnRedeemInstance.burnSet[0].items[burnItemIndex];
| 19,672 |
26 | // ONLY OWNER// Owner of this contract may change the addresses of associated contracts. _gymContract The address of the new KittyGym contract. _arenaContract The address of the new Arena contract. _specialContract The address of the new SpecialGym contract./ | {
if (_gymContract != 0) gymContract = _gymContract;
if (_specialContract != 0) specialContract = _specialContract;
if (_arenaContract != 0) arenaContract = _arenaContract;
}
| {
if (_gymContract != 0) gymContract = _gymContract;
if (_specialContract != 0) specialContract = _specialContract;
if (_arenaContract != 0) arenaContract = _arenaContract;
}
| 42,925 |
203 | // can later be changed with {transferOwnership}./ Initializes the contract. / | constructor (address o) internal {
_owner = o;
emit OwnershipTransferred(address(0), o);
}
| constructor (address o) internal {
_owner = o;
emit OwnershipTransferred(address(0), o);
}
| 36,264 |
22 | // lock duration for each voter stake by voter address | mapping(address => uint256) public voteLocks;
| mapping(address => uint256) public voteLocks;
| 25,625 |
170 | // Withdraws staked tokens from a pool.// The pool and stake MUST be updated before calling this function.//_poolIdThe pool to withdraw staked tokens from./_withdrawAmountThe number of tokens to withdraw. | function _withdraw(uint256 _poolId, uint256 _withdrawAmount) internal {
Pool.Data storage _pool = _pools.get(_poolId);
Stake.Data storage _stake = _stakes[msg.sender][_poolId];
_pool.totalDeposited = _pool.totalDeposited.sub(_withdrawAmount);
_stake.totalDeposited = _stake.totalDeposited.sub(_withdrawAmount);
_pool.token.safeTransfer(msg.sender, _withdrawAmount);
emit TokensWithdrawn(msg.sender, _poolId, _withdrawAmount);
}
| function _withdraw(uint256 _poolId, uint256 _withdrawAmount) internal {
Pool.Data storage _pool = _pools.get(_poolId);
Stake.Data storage _stake = _stakes[msg.sender][_poolId];
_pool.totalDeposited = _pool.totalDeposited.sub(_withdrawAmount);
_stake.totalDeposited = _stake.totalDeposited.sub(_withdrawAmount);
_pool.token.safeTransfer(msg.sender, _withdrawAmount);
emit TokensWithdrawn(msg.sender, _poolId, _withdrawAmount);
}
| 32,223 |
18 | // Trigger interest accrual and return the current borrow balance. | function borrowBalanceCurrent(uint positionId, address token) external returns (uint);
| function borrowBalanceCurrent(uint positionId, address token) external returns (uint);
| 54,084 |
117 | // {upgradeTo} and {upgradeToAndCall}. Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. ```solidityfunction _authorizeUpgrade(address) internal override onlyOwner {}``` / | function _authorizeUpgrade(address newImplementation) internal virtual;
uint256[50] private __gap;
| function _authorizeUpgrade(address newImplementation) internal virtual;
uint256[50] private __gap;
| 993 |
22 | // NOTE Add in V2 | function bloodThirst(uint256[] calldata ids, uint256 campaign_, uint256 sector_) external {
isPlayer();
for (uint256 index = 0; index < ids.length; index++) {
_actions(ids[index], 2, msg.sender, campaign_, sector_, false, false, false, 2);
}
}
| function bloodThirst(uint256[] calldata ids, uint256 campaign_, uint256 sector_) external {
isPlayer();
for (uint256 index = 0; index < ids.length; index++) {
_actions(ids[index], 2, msg.sender, campaign_, sector_, false, false, false, 2);
}
}
| 72,701 |
0 | // Validation of an incoming purchase. Use require statements to revert state when conditions are not met.Use super to concatenate validations.Adds the validation that the crowdsale must not be paused. _beneficiary Address performing the token purchase _weiAmount Value in wei involved in the purchase / | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused {
return super._preValidatePurchase(_beneficiary, _weiAmount);
}
| function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused {
return super._preValidatePurchase(_beneficiary, _weiAmount);
}
| 11,255 |
339 | // set as 0 if not in market CR = collateralRatio = collateralFactorMantissa | (,uint CR) = comptroller.markets(cTokens[i]);
info.weightedCollateralAmounts[i] = info.collateralAmounts[i] * CR / 1e18;
info.totalDebt += info.debtAmounts[i] * priceFeed[i] / 1e18;
info.totalCollateral += info.collateralAmounts[i] * priceFeed[i] / 1e18;
info.weightedCollateral += info.weightedCollateralAmounts[i] * priceFeed[i] / 1e18;
| (,uint CR) = comptroller.markets(cTokens[i]);
info.weightedCollateralAmounts[i] = info.collateralAmounts[i] * CR / 1e18;
info.totalDebt += info.debtAmounts[i] * priceFeed[i] / 1e18;
info.totalCollateral += info.collateralAmounts[i] * priceFeed[i] / 1e18;
info.weightedCollateral += info.weightedCollateralAmounts[i] * priceFeed[i] / 1e18;
| 38,486 |
4 | // Checks if an account is the Creator of a Proton-based NFT/contractAddressThe Address to the Contract of the Proton-based NFT to check/tokenIdThe Token ID of the Proton-based NFT to check/sender The Address of the Account to check/ return True if the account is the creator of the Proton-based NFT | function isTokenCreator(address contractAddress, uint256 tokenId, address sender) internal view virtual returns (bool) {
IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
address tokenCreator = tokenInterface.creatorOf(tokenId);
return (sender == tokenCreator);
}
| function isTokenCreator(address contractAddress, uint256 tokenId, address sender) internal view virtual returns (bool) {
IERC721Chargeable tokenInterface = IERC721Chargeable(contractAddress);
address tokenCreator = tokenInterface.creatorOf(tokenId);
return (sender == tokenCreator);
}
| 44,508 |
32 | // how long users have to wait before they can withdraw LP5760 blocks = 1 day40320 blocks = 1 week | uint public blockTime;
| uint public blockTime;
| 16,215 |
610 | // ERC721 upgradeable token linked to a physical asset, / | abstract contract ERC721PhysicalUpgradeable is Initializable, ERC721Upgradeable {
function __ERC721Physical_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721Physical_init_unchained();
}
function __ERC721Physical_init_unchained() internal initializer {
}
using StringsUpgradeable for uint256;
// Struct for minimum device information. String vars in struct are legacy and only for backwards compatibility.
struct Device {
string publicKeyHash;
string merkleRoot;
bytes32 publicKeyHashBytes;
bytes32 merkleRootBytes;
}
// The device registry.
address public _registryAddress;
// Optional mapping for device IDs and and device roots.
mapping(uint256 => Device) private _devices;
event UpdateRegistry(address registryAddress);
event DeviceSet(
uint256 tokenId,
bytes32 publicKeyHash,
bytes32 merkleRoot
);
/**
* @dev Get a deviceId for a given tokenId.
*/
function deviceId(uint256 tokenId) public view virtual returns(bytes32) {
require(_exists(tokenId), "Device ID query for nonexistant token");
bytes32 _deviceId = _devices[tokenId].publicKeyHashBytes;
return _deviceId;
}
/**
* @dev Get a deviceRoot for a given tokenId.
*/
function deviceRoot(uint256 tokenId) public view virtual returns(bytes32) {
require(_exists(tokenId), "Device root query for nonexistant token");
bytes32 _deviceRoot = _devices[tokenId].merkleRootBytes;
return _deviceRoot;
}
/**
* @dev Optional: Get a tokenId for a given publicKeyHash.
*/
function tokenByDevice(bytes32 publicKeyHash) public view virtual returns(uint256) {
require(_exists(_tokensWithDevices[publicKeyHash]), "Token query for nonexistant device");
uint256 tokenId = _tokensWithDevices[publicKeyHash];
return tokenId;
}
/**
* @dev Set token-wide registry address.
*/
function _setRegistryAddress(address registryAddress) internal virtual {
_registryAddress = registryAddress;
emit UpdateRegistry(_registryAddress);
}
/**
* @dev Set a deviceRoot for a given tokenId.
*/
function _setDevice(uint256 tokenId, bytes32 publicKeyHash, bytes32 merkleRoot) internal virtual {
require(_exists(tokenId), "Device set called for nonexistant token");
require(_tokensWithDevices[publicKeyHash] == 0 || _tokensWithDevices[publicKeyHash] == tokenId, "Device already set for another token");
_devices[tokenId].publicKeyHashBytes = publicKeyHash;
_devices[tokenId].merkleRootBytes = merkleRoot;
_tokensWithDevices[publicKeyHash] = tokenId;
emit DeviceSet(tokenId, publicKeyHash, merkleRoot);
}
function _burn(uint256 tokenId) internal virtual override {
super._burn(tokenId);
if (_devices[tokenId].publicKeyHashBytes.length != 0) {
delete _devices[tokenId];
delete _tokensWithDevices[_devices[tokenId].publicKeyHashBytes];
}
}
// Verify gap?
uint256[46] private __gap;
// Optional mapping from token ID to device publicKeyHashes
mapping(bytes32 => uint256) private _tokensWithDevices;
}
| abstract contract ERC721PhysicalUpgradeable is Initializable, ERC721Upgradeable {
function __ERC721Physical_init() internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721Physical_init_unchained();
}
function __ERC721Physical_init_unchained() internal initializer {
}
using StringsUpgradeable for uint256;
// Struct for minimum device information. String vars in struct are legacy and only for backwards compatibility.
struct Device {
string publicKeyHash;
string merkleRoot;
bytes32 publicKeyHashBytes;
bytes32 merkleRootBytes;
}
// The device registry.
address public _registryAddress;
// Optional mapping for device IDs and and device roots.
mapping(uint256 => Device) private _devices;
event UpdateRegistry(address registryAddress);
event DeviceSet(
uint256 tokenId,
bytes32 publicKeyHash,
bytes32 merkleRoot
);
/**
* @dev Get a deviceId for a given tokenId.
*/
function deviceId(uint256 tokenId) public view virtual returns(bytes32) {
require(_exists(tokenId), "Device ID query for nonexistant token");
bytes32 _deviceId = _devices[tokenId].publicKeyHashBytes;
return _deviceId;
}
/**
* @dev Get a deviceRoot for a given tokenId.
*/
function deviceRoot(uint256 tokenId) public view virtual returns(bytes32) {
require(_exists(tokenId), "Device root query for nonexistant token");
bytes32 _deviceRoot = _devices[tokenId].merkleRootBytes;
return _deviceRoot;
}
/**
* @dev Optional: Get a tokenId for a given publicKeyHash.
*/
function tokenByDevice(bytes32 publicKeyHash) public view virtual returns(uint256) {
require(_exists(_tokensWithDevices[publicKeyHash]), "Token query for nonexistant device");
uint256 tokenId = _tokensWithDevices[publicKeyHash];
return tokenId;
}
/**
* @dev Set token-wide registry address.
*/
function _setRegistryAddress(address registryAddress) internal virtual {
_registryAddress = registryAddress;
emit UpdateRegistry(_registryAddress);
}
/**
* @dev Set a deviceRoot for a given tokenId.
*/
function _setDevice(uint256 tokenId, bytes32 publicKeyHash, bytes32 merkleRoot) internal virtual {
require(_exists(tokenId), "Device set called for nonexistant token");
require(_tokensWithDevices[publicKeyHash] == 0 || _tokensWithDevices[publicKeyHash] == tokenId, "Device already set for another token");
_devices[tokenId].publicKeyHashBytes = publicKeyHash;
_devices[tokenId].merkleRootBytes = merkleRoot;
_tokensWithDevices[publicKeyHash] = tokenId;
emit DeviceSet(tokenId, publicKeyHash, merkleRoot);
}
function _burn(uint256 tokenId) internal virtual override {
super._burn(tokenId);
if (_devices[tokenId].publicKeyHashBytes.length != 0) {
delete _devices[tokenId];
delete _tokensWithDevices[_devices[tokenId].publicKeyHashBytes];
}
}
// Verify gap?
uint256[46] private __gap;
// Optional mapping from token ID to device publicKeyHashes
mapping(bytes32 => uint256) private _tokensWithDevices;
}
| 63,769 |
31 | // Fetches the unclaimed proceeds of a user/user The address of the user whose unclaimed proceeds are to be fetched/ return The Proceeds struct of the specified user | function getUnclaimedProceeds(
address user
| function getUnclaimedProceeds(
address user
| 15,863 |
3 | // address private communityAddr = 0xca35b7d915458ef540ade6068dfe2f44e8fa733c;============================================================================== _| _ _|_ __ _ _|__ .(_|(_| | (_|_\(/_ | |_||_).=============================|================================================ | uint256 public registrationFee_ = 1 finney; // price to register a name
mapping(uint256 => PlayerBookReceiverInterface) public games_; // mapping of our game interfaces for sending your account info to games
mapping(address => bytes32) public gameNames_; // lookup a games name
mapping(address => uint256) public gameIDs_; // lokup a games ID
uint256 public gID_; // total number of games
uint256 public pID_; // total number of players
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amoungst any name you own)
| uint256 public registrationFee_ = 1 finney; // price to register a name
mapping(uint256 => PlayerBookReceiverInterface) public games_; // mapping of our game interfaces for sending your account info to games
mapping(address => bytes32) public gameNames_; // lookup a games name
mapping(address => uint256) public gameIDs_; // lokup a games ID
uint256 public gID_; // total number of games
uint256 public pID_; // total number of players
mapping (address => uint256) public pIDxAddr_; // (addr => pID) returns player id by address
mapping (bytes32 => uint256) public pIDxName_; // (name => pID) returns player id by name
mapping (uint256 => Player) public plyr_; // (pID => data) player data
mapping (uint256 => mapping (bytes32 => bool)) public plyrNames_; // (pID => name => bool) list of names a player owns. (used so you can change your display name amoungst any name you own)
| 19,731 |
10 | // Redemption is used to specify the information needed to redeem a swap. | struct Redemption {
bytes32 secret;
bytes32 secretHash;
}
| struct Redemption {
bytes32 secret;
bytes32 secretHash;
}
| 32,442 |
33 | // Deposit Staking tokens to FairLaunchToken for CHECK allocation. | function deposit(uint256 _pid, uint256 _amount) public {
require(_pid < poolInfo.length, 'pool is not existed');
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) _harvest(_pid);
IERC20(pool.stakeToken).safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCheckPerShare).div(1e12);
user.bonusDebt = user.amount.mul(pool.accCheckPerShareTilBonusEnd).div(1e12);
pool.lpSupply = pool.lpSupply.add(_amount);
emit Deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) public {
require(_pid < poolInfo.length, 'pool is not existed');
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) _harvest(_pid);
IERC20(pool.stakeToken).safeTransferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accCheckPerShare).div(1e12);
user.bonusDebt = user.amount.mul(pool.accCheckPerShareTilBonusEnd).div(1e12);
pool.lpSupply = pool.lpSupply.add(_amount);
emit Deposit(msg.sender, _pid, _amount);
}
| 11,268 |
258 | // If the next harvest delay is not 0: | if (newHarvestDelay != 0) {
| if (newHarvestDelay != 0) {
| 49,148 |
1 | // voterAddress => conspiracy Id => upvoted bool | mapping(address => mapping(uint256 => bool)) private upvoted;
| mapping(address => mapping(uint256 => bool)) private upvoted;
| 1,773 |
18 | // Emitted when new nums are stored along witha value (in wei) sent as a payment.timestamp block time when nums were updated num0 stored in nums[0] num1 stored in nums[1] num2 stored in nums[2] paid amount of wei sent balance amount of wei in contract's balance / | event NumsStoredAndPaid(
| event NumsStoredAndPaid(
| 47,958 |
0 | // { value, sender, gas, data } | function deposit() external payable {
userBalances[msg.sender] += msg.value;
}
| function deposit() external payable {
userBalances[msg.sender] += msg.value;
}
| 29,594 |
19 | // check if contract wallet has enough funds | require(address(this).balance >= totalCost, "Not enough ETH to pay seller"); // TODO: ensure front end checks this
| require(address(this).balance >= totalCost, "Not enough ETH to pay seller"); // TODO: ensure front end checks this
| 45,580 |
14 | // return share percent of game/ | function getGameShare() public view returns (uint256) {
return gameShare;
}
| function getGameShare() public view returns (uint256) {
return gameShare;
}
| 36,570 |
57 | // mapping containing all the number of opened positions for each setups | mapping(uint256 => uint256) private _setupPositionsCount;
| mapping(uint256 => uint256) private _setupPositionsCount;
| 3,455 |
7 | // Mint price set to low | error MintPriceTooLow();
| error MintPriceTooLow();
| 54,906 |
174 | // Sets a Vault's boost cap./vault The Vault to set the boost cap for./newBoostCap The new boost cap for the Vault. | function setBoostCapForVault(ERC4626 vault, uint256 newBoostCap) external requiresAuth {
require(newBoostCap != 0, "cap is zero");
// Add to boostable vaults array
if (getBoostCapForVault[vault] == 0) {
boostableVaults.push(vault);
}
// Update the boost cap for the Vault.
getBoostCapForVault[vault] = newBoostCap;
emit BoostCapUpdatedForVault(msg.sender, vault, newBoostCap);
}
| function setBoostCapForVault(ERC4626 vault, uint256 newBoostCap) external requiresAuth {
require(newBoostCap != 0, "cap is zero");
// Add to boostable vaults array
if (getBoostCapForVault[vault] == 0) {
boostableVaults.push(vault);
}
// Update the boost cap for the Vault.
getBoostCapForVault[vault] = newBoostCap;
emit BoostCapUpdatedForVault(msg.sender, vault, newBoostCap);
}
| 10,970 |
13 | // endDate (in seconds) | uint64 endDate;
| uint64 endDate;
| 8,841 |
71 | // _wallet where collect funds during crowdsale _startDate should be 1525132860 _endDate should be 1526342340 _maxEtherPerInvestor should be 10 ether / | function preICO(address _token, address _wallet, uint256 _startDate, uint256 _endDate) public {
require(_token != address(0) && _wallet != address(0));
require(_endDate > _startDate);
startDate = _startDate;
endDate = _endDate;
token = Token(_token);
vault = new RefundVault(_wallet);
}
| function preICO(address _token, address _wallet, uint256 _startDate, uint256 _endDate) public {
require(_token != address(0) && _wallet != address(0));
require(_endDate > _startDate);
startDate = _startDate;
endDate = _endDate;
token = Token(_token);
vault = new RefundVault(_wallet);
}
| 63,703 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.