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 |
|---|---|---|---|---|
112 | // check if the user receiver the | require(tokenContract.ownerOf(_tokenId) == buyer);
| require(tokenContract.ownerOf(_tokenId) == buyer);
| 30,961 |
2 | // Sets whether a specific address can call a method/_selector The method selector to set access for/_executor The address to set method access for/_canExecute Whether or not the address can execute the specified method | function setCanExecute(
bytes4 _selector,
address _executor,
bool _canExecute
) external {
if (_executor == address(this)) {
revert CannotAuthoriseSelf();
}
| function setCanExecute(
bytes4 _selector,
address _executor,
bool _canExecute
) external {
if (_executor == address(this)) {
revert CannotAuthoriseSelf();
}
| 24,011 |
387 | // New combination of mobs.The combination is personalized by players, and refreshed when the dungeon cleared. | function createNewCombination(address _playerAddress)
private
| function createNewCombination(address _playerAddress)
private
| 73,730 |
19 | // @info options on term `uint options` term_t `uint32 ct` issue_t `uint32 issueDate` | assertEq(options, divRound(3 * maxopts, 4), "2 susp + term");
| assertEq(options, divRound(3 * maxopts, 4), "2 susp + term");
| 17,299 |
186 | // Ensure that the request has had its tokens unlocked. | (bool tokensUnlocked, ) = areTokensUnlocked(execHash);
require(tokensUnlocked, "NOT_UNLOCKED");
| (bool tokensUnlocked, ) = areTokensUnlocked(execHash);
require(tokensUnlocked, "NOT_UNLOCKED");
| 65,258 |
454 | // Sets the mint states _isPublicMintOpen The public mint is open / | function setMintStates(bool _isPublicMintOpen) external onlyOwner {
isPublicOpen = _isPublicMintOpen;
}
| function setMintStates(bool _isPublicMintOpen) external onlyOwner {
isPublicOpen = _isPublicMintOpen;
}
| 25,124 |
0 | // event DebugAddress(address _address);event DebugString(string _string);event DebugUInt(uint _value);event DebugBytes4(bytes4 _signature); | 10,553 | ||
96 | // feeRate(0.1 + 0.9min(1, discountBase / bifiAmount)) | feeRateParams.unifiedPoint = 10 ** 18;
feeRateParams.minimum = 10 ** 17;
feeRateParams.slope = feeRateParams.unifiedPoint - feeRateParams.minimum;
feeRateParams.discountRate = _min(feeRateParams.unifiedPoint, handlerFlashloan[handlerID].discountBase.unifiedDiv(bifiBalance));
... | feeRateParams.unifiedPoint = 10 ** 18;
feeRateParams.minimum = 10 ** 17;
feeRateParams.slope = feeRateParams.unifiedPoint - feeRateParams.minimum;
feeRateParams.discountRate = _min(feeRateParams.unifiedPoint, handlerFlashloan[handlerID].discountBase.unifiedDiv(bifiBalance));
... | 35,591 |
289 | // ========== RESTRICTED GOVERNANCE FUNCTIONS ========== / Adds an AMO | function addAMO(address amo_address, bool sync_too) public onlyByOwnGov {
require(amo_address != address(0), "Zero address detected");
(uint256 frax_val_e18, uint256 collat_val_e18) = IAMO(amo_address).dollarBalances();
require(frax_val_e18 >= 0 && collat_val_e18 >= 0, "Invalid AMO");
... | function addAMO(address amo_address, bool sync_too) public onlyByOwnGov {
require(amo_address != address(0), "Zero address detected");
(uint256 frax_val_e18, uint256 collat_val_e18) = IAMO(amo_address).dollarBalances();
require(frax_val_e18 >= 0 && collat_val_e18 >= 0, "Invalid AMO");
... | 2,997 |
105 | // Contract constructor/As this contract inherits ownable, msg.sender will become the contract owner/_totlePrimary the address of the contract to be set as totlePrimary | constructor(address _totlePrimary) public {
authorizedPrimaries[_totlePrimary] = true;
}
| constructor(address _totlePrimary) public {
authorizedPrimaries[_totlePrimary] = true;
}
| 16,067 |
17 | // getAddresses returns all addresses and fee BPS details. These state variables are private to reduce contract file sizeand to make it more efficient to check all addresses. / | function getAddresses()
external
view
returns (string memory)
{
return
string(
abi.encodePacked(
| function getAddresses()
external
view
returns (string memory)
{
return
string(
abi.encodePacked(
| 25,231 |
1 | // the owner role is used to set the values in the store. | bytes32 public constant ROLE_OWNER = keccak256("ROLE_OWNER");
| bytes32 public constant ROLE_OWNER = keccak256("ROLE_OWNER");
| 34,665 |
21 | // Awards all external tokens with non-zero balances to the given user.The external tokens must be held by the PrizePool contract./winner The user to transfer the tokens to | function _awardAllExternalTokens(address winner) internal {
_awardExternalErc20s(winner);
_awardExternalErc721s(winner);
}
| function _awardAllExternalTokens(address winner) internal {
_awardExternalErc20s(winner);
_awardExternalErc721s(winner);
}
| 20,980 |
6 | // Redeem the generated interests of an invertible token from thecToken contract. This function will withdraw the generated interests of the cToken, andwill remove the minted amount from the cToken balance of the investor.For more information about the calculation of the generated interests, | * see the {_getTokenGeneratedInterests} function.
*
* @param _investor The address of the investor.
* @param _symbol The symbol of the invertible token.
*/
function redeemTokenGeneratedInterests(address _investor, bytes32 _symbol)
external
onlyOwner
returns (uint256... | * see the {_getTokenGeneratedInterests} function.
*
* @param _investor The address of the investor.
* @param _symbol The symbol of the invertible token.
*/
function redeemTokenGeneratedInterests(address _investor, bytes32 _symbol)
external
onlyOwner
returns (uint256... | 27,015 |
109 | // solhint-disable-next-line no-inline-assembly | assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
| assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
| 57,649 |
170 | // Returns the number of seconds remaining until the beacon period can be complete.return The number of seconds remaining until the beacon period can be complete. / | function beaconPeriodRemainingSeconds() external view returns (uint64);
| function beaconPeriodRemainingSeconds() external view returns (uint64);
| 84,560 |
33 | // Returns the address that signed a hashed message (`hash`) with`signature`. This address can then be used for verification purposes. The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:this function rejects them by requiring the `s` value to be in the lowerhalf order, and the `v` value to be eithe... | * be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
| * be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
| 1,656 |
14 | // prettier-ignore | if iszero(temp) { break }
| if iszero(temp) { break }
| 1,824 |
136 | // Calculate 2^x.x quadruple precision numberreturn quadruple precision number / | function pow_2 (bytes16 x) internal pure returns (bytes16) {
bool xNegative = uint128 (x) > 0x80000000000000000000000000000000;
uint256 xExponent = uint128 (x) >> 112 & 0x7FFF;
uint256 xSignifier = uint128 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
if (xExponent == 0x7FFF && xSignifier != 0) return NaN;
... | function pow_2 (bytes16 x) internal pure returns (bytes16) {
bool xNegative = uint128 (x) > 0x80000000000000000000000000000000;
uint256 xExponent = uint128 (x) >> 112 & 0x7FFF;
uint256 xSignifier = uint128 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
if (xExponent == 0x7FFF && xSignifier != 0) return NaN;
... | 20,250 |
26 | // 从某个指定的帐户中,向另一个帐户发送代币调用过程,会检查设置的允许最大交易额_from address 发送者地址_to address 接受者地址_value uint256 要转移的代币数量return success是否交易成功 / | function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool success) {
//检查发送者是否拥有足够余额
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
| function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool success) {
//检查发送者是否拥有足够余额
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
| 41,132 |
151 | // simplistic. not accurate | change = asset;
| change = asset;
| 20,634 |
6 | // Data is pasted in FileOutput Order. Blockchain date is skipped because it will be added when the block is mined. 8 Items in total |
string memory _file_number = metadata[0];
string memory _title = metadata[1];
string memory _album = metadata[2];
string memory _website = metadata[3];
string memory _ipfs_hash = metadata[4];
string memory _comment = metadata[5];
string memory _copyright = metadata[6];
... |
string memory _file_number = metadata[0];
string memory _title = metadata[1];
string memory _album = metadata[2];
string memory _website = metadata[3];
string memory _ipfs_hash = metadata[4];
string memory _comment = metadata[5];
string memory _copyright = metadata[6];
... | 56,546 |
33 | // Have to split on the initialization case and negative interest case | if (_valueSupplied > 0 && holdingsValue > _valueSupplied) {
adjustedAmount =
usedUnderlying -
((holdingsValue - _valueSupplied) * usedUnderlying) /
_interestSupply;
} else {
| if (_valueSupplied > 0 && holdingsValue > _valueSupplied) {
adjustedAmount =
usedUnderlying -
((holdingsValue - _valueSupplied) * usedUnderlying) /
_interestSupply;
} else {
| 24,263 |
0 | // Strings | string public baseURI;
string private baseExtension = ".json";
| string public baseURI;
string private baseExtension = ".json";
| 25,026 |
174 | // withdraw collateral from existing loan/loanId existing lona id/receiver address of withdrawn tokens/withdrawAmount amount to withdraw/ return actualWithdrawAmount actual amount withdrawn | function withdrawCollateral(
bytes32 loanId,
address receiver,
uint256 withdrawAmount
) external returns (uint256 actualWithdrawAmount);
| function withdrawCollateral(
bytes32 loanId,
address receiver,
uint256 withdrawAmount
) external returns (uint256 actualWithdrawAmount);
| 8,399 |
4 | // sortOrders function should sort BUY Orders from highest price at [0] to lowest at [length -1] should sort SELL orders from lowest price at [0] to highest at [length -1] use bubble sort algorithm. assume pre-ordered array, only one loop of bubble is necessary, new element always at position length -1/ | function _sortOrders(Order[] storage _orders, Side _side) private {
if (_side == Side.BUY){ // sort BUY Orders from highest price at [0] to lowest at [length -1]
uint i = _orders.length > 0 ?_orders.length - 1 : 0;
while(i > 0){
if(_orders[i-1].... | function _sortOrders(Order[] storage _orders, Side _side) private {
if (_side == Side.BUY){ // sort BUY Orders from highest price at [0] to lowest at [length -1]
uint i = _orders.length > 0 ?_orders.length - 1 : 0;
while(i > 0){
if(_orders[i-1].... | 17,260 |
102 | // Send the funds to gambler. | sendFunds(bet.gambler, winAmount == 0 ? 1 wei : winAmount, winAmount,
randomNumber.playerNum1,
randomNumber.playerNum2,
randomNumber.npcNum1,
randomNumber.npcNum2,
amount);
| sendFunds(bet.gambler, winAmount == 0 ? 1 wei : winAmount, winAmount,
randomNumber.playerNum1,
randomNumber.playerNum2,
randomNumber.npcNum1,
randomNumber.npcNum2,
amount);
| 49,368 |
320 | // Burn all liquidity from pool to rerange for Sorbetto's balances. | pool.burnAllLiquidity(tickLower, tickUpper);
| pool.burnAllLiquidity(tickLower, tickUpper);
| 14,903 |
270 | // Prevents a contract from calling itself, directly or indirectly.Calling a `nonReentrant` function from another `nonReentrant`function is not supported. It is possible to prevent this from happeningby making the `nonReentrant` function external, and make it call a`private` function that does the actual work. / | modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "RC");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is trig... | modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "RC");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is trig... | 1,125 |
45 | // setting anyAuth to true allows anyone to call functions protected by onlyAuth | function setAnyAuth(bool access) external onlyOwner {
anyAuth = access;
}
| function setAnyAuth(bool access) external onlyOwner {
anyAuth = access;
}
| 46,297 |
234 | // app | ids.appHash = _apporder.hash().toEthTypedStructHash(EIP712DOMAIN_SEPARATOR);
ids.appOwner = App(_apporder.app).owner();
require(m_presigned[ids.appHash] || verifySignature(ids.appOwner, ids.appHash, _apporder.sign));
| ids.appHash = _apporder.hash().toEthTypedStructHash(EIP712DOMAIN_SEPARATOR);
ids.appOwner = App(_apporder.app).owner();
require(m_presigned[ids.appHash] || verifySignature(ids.appOwner, ids.appHash, _apporder.sign));
| 56,766 |
26 | // populate return array | uint256 index = 0;
address currentOwner = owners[SENTINEL_OWNERS];
while (currentOwner != SENTINEL_OWNERS) {
array[index] = currentOwner;
currentOwner = owners[currentOwner];
index++;
}
| uint256 index = 0;
address currentOwner = owners[SENTINEL_OWNERS];
while (currentOwner != SENTINEL_OWNERS) {
array[index] = currentOwner;
currentOwner = owners[currentOwner];
index++;
}
| 8,437 |
298 | // A library for validating signatures. | library LibSignature {
/// @dev Allowed signature types.
enum SignatureType {
EIP712,
PRESIGNED
}
/// @dev Encoded EC signature.
struct Signature {
// How to validate the signature.
SignatureType signatureType;
// EC Signature data.
uint8 v;
... | library LibSignature {
/// @dev Allowed signature types.
enum SignatureType {
EIP712,
PRESIGNED
}
/// @dev Encoded EC signature.
struct Signature {
// How to validate the signature.
SignatureType signatureType;
// EC Signature data.
uint8 v;
... | 43,296 |
115 | // Manually Excluded adresses are transfering tax and lock free | bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient));
| bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient));
| 29,439 |
41 | // Allow _spender to withdraw from your account, multiple times, up to the _value amount./If this function is called again it overwrites the current allowance with _value. | function approve(address _spender, uint256 _value) returns (bool success) {
require(!frozenAccount[msg.sender]);
assert(_spender != address(0));
require(_value >= 0);
allowed[msg.sender][_spender] = _value;
return true;
}
| function approve(address _spender, uint256 _value) returns (bool success) {
require(!frozenAccount[msg.sender]);
assert(_spender != address(0));
require(_value >= 0);
allowed[msg.sender][_spender] = _value;
return true;
}
| 35,022 |
37 | // first, check the sender credential | assert(msg.sender == uni_pair); // ensure that msg.sender is actually a V2 pair
require(sender == address(this), "only this contract may initiate");
assert(amount0 == 0 || amount1 == 0); // this strategy is unidirectional
| assert(msg.sender == uni_pair); // ensure that msg.sender is actually a V2 pair
require(sender == address(this), "only this contract may initiate");
assert(amount0 == 0 || amount1 == 0); // this strategy is unidirectional
| 5,642 |
86 | // credit an affiliate for a purchase credit accepts eth and credits the affiliate's balance for the amount_affiliate - the address of the affiliate to credit _purchaseId - the purchaseId of the sale / | function credit(
address _affiliate,
uint256 _purchaseId)
public
onlyStoreOrOwner
whenNotPaused
payable
| function credit(
address _affiliate,
uint256 _purchaseId)
public
onlyStoreOrOwner
whenNotPaused
payable
| 65,800 |
17 | // Deposit to yield pool based on strategy and mint internal asset / | function _depositToYieldPool(address _asset, uint256 _amount)
internal
override
returns (address, uint256)
| function _depositToYieldPool(address _asset, uint256 _amount)
internal
override
returns (address, uint256)
| 20,504 |
0 | // for limit orders | enum Side {
BUY,
SELL
}
| enum Side {
BUY,
SELL
}
| 8,094 |
126 | // Add a new vesting entry at a given time and quantity to an account's schedule. A call to this should accompany a previous successful call to synthetix.transfer(rewardEscrow, amount),to ensure that when the funds are withdrawn, there is enough balance. account The account to append a new vesting entry to. quantity Th... | function appendVestingEntry(
address account,
uint256 quantity,
uint256 duration
| function appendVestingEntry(
address account,
uint256 quantity,
uint256 duration
| 31,217 |
235 | // Set allowed minter addresses/to Address to set allowed token minter status/canMint Boolean to set status to for given address | function updateAllowedMinter(address to, bool canMint) external {
allowedMinters[to] = canMint;
}
| function updateAllowedMinter(address to, bool canMint) external {
allowedMinters[to] = canMint;
}
| 73,755 |
48 | // Treasury/ | contract Treasury is Authorizable {
using SafeMath for uint;
IVoting voting;
KosuToken public kosuToken;
struct TokenLock {
uint value;
uint pollId;
uint tokenLockEnd;
uint pollEarlyUnlock;
}
struct Account {
uint currentBalance;
uint systemBalan... | contract Treasury is Authorizable {
using SafeMath for uint;
IVoting voting;
KosuToken public kosuToken;
struct TokenLock {
uint value;
uint pollId;
uint tokenLockEnd;
uint pollEarlyUnlock;
}
struct Account {
uint currentBalance;
uint systemBalan... | 49,356 |
84 | // Mapping from token ID to approved address | mapping(uint256 => address) private _tokenApprovals;
| mapping(uint256 => address) private _tokenApprovals;
| 61 |
38 | // Calculate the sUSD cost to buy an amount of available position options from AMM for specific market/game/market The address of the SportPositional market of a game/position The position (home/away/draw) quoted to buy from AMM/amount The position amount quoted to buy from AMM/ return _quote The sUSD cost for buying t... | function buyFromAmmQuote(
address market,
ISportsAMM.Position position,
uint amount
| function buyFromAmmQuote(
address market,
ISportsAMM.Position position,
uint amount
| 12,886 |
42 | // Updates an asset _assetTicker - Ticker _assetInfo - Info to update _newAmount - % of portfolio taken by the assetreturn True if success / | function updateAnAssetQuantity(
string memory _assetTicker,
string memory _assetInfo,
uint8 _newAmount
| function updateAnAssetQuantity(
string memory _assetTicker,
string memory _assetInfo,
uint8 _newAmount
| 41,927 |
2 | // send all ether to claimer | _claimer.send(this.balance);
Claimed(_claimer);
| _claimer.send(this.balance);
Claimed(_claimer);
| 33,462 |
232 | // 这里奖励分成了三部分 1,已经从旧奖池中cancel了的 2,还在旧奖池中的 3,在新奖池中的 | total = mOldReward[_user];
uint256 iMyOldStaking = 0;
for (
uint256 i = 0;
i < stakingStorage.getStakesdataLength(_user);
i++
) {
(uint256 stakingAmount, ) = stakingStorage.getStakesDataByIndex(
_user,
i
| total = mOldReward[_user];
uint256 iMyOldStaking = 0;
for (
uint256 i = 0;
i < stakingStorage.getStakesdataLength(_user);
i++
) {
(uint256 stakingAmount, ) = stakingStorage.getStakesDataByIndex(
_user,
i
| 38,153 |
21 | // --- [ERC1155] Single ERC20 listing --- |
function acceptERC20ListingERC1155(
IZeroExV4.ERC1155Order calldata order,
IZeroExV4.Signature calldata signature,
uint128 amount,
ERC20ListingParams calldata params,
Fee[] calldata fees
)
external
payable
|
function acceptERC20ListingERC1155(
IZeroExV4.ERC1155Order calldata order,
IZeroExV4.Signature calldata signature,
uint128 amount,
ERC20ListingParams calldata params,
Fee[] calldata fees
)
external
payable
| 21,589 |
199 | // Collect the curation fees for a subgraph deployment from an amount of tokens.This function transfer curation fees to the Curation contract by calling Curation.collect _graphToken Token to collect _subgraphDeploymentID Subgraph deployment to which the curation fees are related _tokens Total tokens received used to ca... | function _collectCurationFees(
IGraphToken _graphToken,
bytes32 _subgraphDeploymentID,
uint256 _tokens,
uint256 _curationPercentage
| function _collectCurationFees(
IGraphToken _graphToken,
bytes32 _subgraphDeploymentID,
uint256 _tokens,
uint256 _curationPercentage
| 22,936 |
449 | // Ensure component array only includes one address which will be the currentSet | require(
_components.length == 1 &&
_units.length == 1,
"Components & units must be len 1"
);
require(
_units[0] > 0,
"UnitShares not > 0"
);
| require(
_components.length == 1 &&
_units.length == 1,
"Components & units must be len 1"
);
require(
_units[0] > 0,
"UnitShares not > 0"
);
| 12,478 |
240 | // Move the last token to the slot of the to-delete token | _allTokensIndex[lastTokenId] = tokenIndex;
| _allTokensIndex[lastTokenId] = tokenIndex;
| 15,234 |
53 | // Allow the owner to withdraw all ether from the contract after the crowdsale is over | function withdrawEtherRemaining() public
returns (bool)
| function withdrawEtherRemaining() public
returns (bool)
| 48,492 |
31 | // require(minimumBid >= 0, "Marketplace: minimum bid is invalid"); |
Auction memory newAuction = Auction(
msg.sender,
minimumBid,
address(0),
0,
block.timestamp + auctionTime
);
contractTokensAuction[nftAddress][tokenId] = true;
contractAuction[nftAddress][tokenId] = newAuction;
|
Auction memory newAuction = Auction(
msg.sender,
minimumBid,
address(0),
0,
block.timestamp + auctionTime
);
contractTokensAuction[nftAddress][tokenId] = true;
contractAuction[nftAddress][tokenId] = newAuction;
| 34,718 |
1 | // versions: - LinkToken 0.0.3: added versioning, update name- LinkToken 0.0.2: upgraded to solc 0.6- LinkToken 0.0.1: initial release solc 0.4 @inheritdoc ITypeAndVersion / | function typeAndVersion()
external
pure
override
virtual
returns (string memory)
| function typeAndVersion()
external
pure
override
virtual
returns (string memory)
| 15,256 |
55 | // Destroys `amount` tokens from `account`, reducing thetotal supply. | * Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address")... | * Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address")... | 14,820 |
12 | // Emitted when the BigBoss dies and is reincarnated | event BossUpgraded(uint256 indexed level, address conqueror, uint256 maxHp, uint256 attackDamage);
| event BossUpgraded(uint256 indexed level, address conqueror, uint256 maxHp, uint256 attackDamage);
| 14,059 |
25 | // the same as withdrawAndDistributePendingRewards() but without claiming from binance staking/might be used for emergency distribution | function distributePendingRewards()
external
payable
onlyConsensus
nonReentrant
| function distributePendingRewards()
external
payable
onlyConsensus
nonReentrant
| 6,779 |
123 | // Automatic swap and liquify enabled | bool private swapAndLiquifyEnabled = false;
| bool private swapAndLiquifyEnabled = false;
| 7,869 |
7 | // sets maps token to its price _tokenId uint256 token ID (token number) _price uint256 token priceRequirements: `tokenId` must exist`owner` must the msg.owner / | function setTokenPrice(uint256 _tokenId, uint256 _price) public {
require(_exists(_tokenId), "ERC721Metadata: Price set of nonexistent token");
require(ownerOf(_tokenId) == _msgSender());
_tokenMeta[_tokenId].price = _price;
}
| function setTokenPrice(uint256 _tokenId, uint256 _price) public {
require(_exists(_tokenId), "ERC721Metadata: Price set of nonexistent token");
require(ownerOf(_tokenId) == _msgSender());
_tokenMeta[_tokenId].price = _price;
}
| 23,382 |
59 | // Info of each user that stakes LP tokens. | mapping (uint256 => mapping (address => UserInfo)) public userInfo;
| mapping (uint256 => mapping (address => UserInfo)) public userInfo;
| 39,706 |
228 | // increases the total borrows at a stable rate on a specific reserve and updates the average stable rate consequently_reserve the reserve object_amount the amount to add to the total borrows stable_rate the rate at which the amount has been borrowed/ | ) internal {
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
//updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.add(_amount);
//update the average stable rate
//weighted average of all the borrows
uint256 weig... | ) internal {
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
//updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.add(_amount);
//update the average stable rate
//weighted average of all the borrows
uint256 weig... | 24,278 |
49 | // See https:www.binance.charity/binance-charity-wallet/donate-anonymously to confirm this is the right Address |
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAn... |
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;
event RewardLiquidityProviders(uint256 tokenAmount);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAn... | 6,953 |
137 | // last block number where the user withdrew/deposited tokens | mapping(address => uint256) public lastActivity;
| mapping(address => uint256) public lastActivity;
| 19,237 |
31 | // tranfser amount from sender to the channel | balances[msg.sender] = balances[msg.sender].sub (amount);
channels[channelId].value = channels[channelId].value.add(amount);
emit ChannelAddFunds(channelId, amount);
return true;
| balances[msg.sender] = balances[msg.sender].sub (amount);
channels[channelId].value = channels[channelId].value.add(amount);
emit ChannelAddFunds(channelId, amount);
return true;
| 45,691 |
9 | // Define an internal function '_removeMasterjeweler' to remove this role, called by 'removeMasterjeweler' | function _removeMasterjeweler(address account) internal {
masterjewelers.remove(account);
emit MasterjewelerRemoved(account);
}
| function _removeMasterjeweler(address account) internal {
masterjewelers.remove(account);
emit MasterjewelerRemoved(account);
}
| 9,830 |
3 | // Calculates the total quantity of tokens that can be swapped on the AMMcurve until either 1) the limit price is reached or 2) the swap fills its entire remaining quantity.This function does NOT account for the possibility of concentrated liqbeing knocked in/out as the price on the AMM curve moves across tick boundari... | internal pure returns (uint128) {
uint128 limitFlow = calcLimitFlows(curve, inBaseQty, limitPrice);
return limitFlow > swapQty ? swapQty : limitFlow;
}
| internal pure returns (uint128) {
uint128 limitFlow = calcLimitFlows(curve, inBaseQty, limitPrice);
return limitFlow > swapQty ? swapQty : limitFlow;
}
| 13,515 |
21 | // These are all the places you can go search for loot | enum Places {
TOWN, DUNGEON, CRYPT, CASTLE, DRAGONS_LAIR, THE_ETHER,
TAINTED_KINGDOM, OOZING_DEN, ANCIENT_CHAMBER, ORC_GODS
}
| enum Places {
TOWN, DUNGEON, CRYPT, CASTLE, DRAGONS_LAIR, THE_ETHER,
TAINTED_KINGDOM, OOZING_DEN, ANCIENT_CHAMBER, ORC_GODS
}
| 38,254 |
1 | // assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold | return a / b;
| return a / b;
| 14,998 |
385 | // in PerksRewards | function redeemBattleCrates() external {
uint8 count = 0;
uint len = pendingRewards[msg.sender].length;
require(len > 0);
for (uint i = 0; i < len; i++) {
Reward memory rewardStruct = pendingRewards[msg.sender][i];
// can't open on the same timestamp
... | function redeemBattleCrates() external {
uint8 count = 0;
uint len = pendingRewards[msg.sender].length;
require(len > 0);
for (uint i = 0; i < len; i++) {
Reward memory rewardStruct = pendingRewards[msg.sender][i];
// can't open on the same timestamp
... | 46,329 |
59 | // Limits the exit fee to the maximum as hard-coded into the contract/withdrawalAmount The amount that is attempting to be withdrawn/exitFee The exit fee to check against the limit/ return The passed exit fee if it is less than the maximum, otherwise the maximum fee is returned. | function _limitExitFee(uint256 withdrawalAmount, uint256 exitFee) internal view returns (uint256) {
uint256 maxFee = FixedPoint.multiplyUintByMantissa(withdrawalAmount, maxExitFeeMantissa);
if (exitFee > maxFee) {
exitFee = maxFee;
}
return exitFee;
}
| function _limitExitFee(uint256 withdrawalAmount, uint256 exitFee) internal view returns (uint256) {
uint256 maxFee = FixedPoint.multiplyUintByMantissa(withdrawalAmount, maxExitFeeMantissa);
if (exitFee > maxFee) {
exitFee = maxFee;
}
return exitFee;
}
| 13,594 |
5 | // An event emitted when a proposal has been executed in the Timelock | event ProposalExecuted(uint id);
| event ProposalExecuted(uint id);
| 1,855 |
52 | // This function is not marked as `nonReentrant` because the underlying mechanism relies on reentrancy | function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] memory swaps,
IAsset[] memory assets,
FundManagement memory funds
| function queryBatchSwap(
SwapKind kind,
BatchSwapStep[] memory swaps,
IAsset[] memory assets,
FundManagement memory funds
| 19,436 |
13 | // Array of all active trove addresses - used to to compute an approximate hint off-chain, for the sorted list insertion | address[] public TroveOwners;
| address[] public TroveOwners;
| 15,135 |
82 | // overflow is desired. | FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(
uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed)
);
amountOut = priceAverage.mul(amountIn).decode144();
| FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(
uint224((priceCumulativeEnd - priceCumulativeStart) / timeElapsed)
);
amountOut = priceAverage.mul(amountIn).decode144();
| 7,680 |
66 | // Only append new addresses to the array, never a duplicate | if (whitelist[newElement] == Status.None) {
whitelistIndices.push(newElement);
}
| if (whitelist[newElement] == Status.None) {
whitelistIndices.push(newElement);
}
| 46,159 |
567 | // Returns the sample that corresponds to a given `index`. Using this function instead of accessing storage directly results in denser bytecode (since the storage slot isonly computed here). / | function _getSample(uint256 index) internal view returns (bytes32) {
return _samples[index];
}
| function _getSample(uint256 index) internal view returns (bytes32) {
return _samples[index];
}
| 6,944 |
0 | // Reserved for V2 GT means Governance Token | mapping(address => bool) public isGTMade;
mapping(uint256 => address) public gtMadeByKey;
mapping(address => uint256) public iTokenKey;
mapping(address => bool) public isStrategy;
mapping(uint256 => address) public strategyByKey;
mapping(address => bool) public isCalculator;
mapping(uint2... | mapping(address => bool) public isGTMade;
mapping(uint256 => address) public gtMadeByKey;
mapping(address => uint256) public iTokenKey;
mapping(address => bool) public isStrategy;
mapping(uint256 => address) public strategyByKey;
mapping(address => bool) public isCalculator;
mapping(uint2... | 14,076 |
37 | // Treasury / | function treasuryFunds() public view returns (uint) {
return address(this).balance - totalRewardFund();
}
| function treasuryFunds() public view returns (uint) {
return address(this).balance - totalRewardFund();
}
| 1,172 |
143 | // Add some extra buffer at the end | result := mload(0x40)
mstore(0x40, add(add(result, encodedLen), add(0x20, add(bytesBefore, bytesAfter))))
let tablePtr := mload(0x40)
mstore(add(tablePtr, 0x1f), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef')
mstore(add(tablePtr, 0x3f), 'ghijklmnopqrstuvwxyz0123456789+/... | result := mload(0x40)
mstore(0x40, add(add(result, encodedLen), add(0x20, add(bytesBefore, bytesAfter))))
let tablePtr := mload(0x40)
mstore(add(tablePtr, 0x1f), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef')
mstore(add(tablePtr, 0x3f), 'ghijklmnopqrstuvwxyz0123456789+/... | 80,898 |
47 | // token comes from somewhere | emit Transfer(0, _target, _amount);
| emit Transfer(0, _target, _amount);
| 43,123 |
96 | // Don't store ad details on blockchain. Use events as storage as they are significantly cheaper. ads are stored in an array, the id of an ad is its index in this array. | Ad[] ads;
| Ad[] ads;
| 26,413 |
3 | // EVENTS |
event PropertyListed(uint256 indexed id, address indexed owner, uint256 price);
event PropertySold(uint256 indexed id , address indexed oldOwner, address indexed newOwner, uint256 price);
event PropertyResold(uint256 indexed id, address indexed oldOwner, address indexed newOwner, uint256 price);
|
event PropertyListed(uint256 indexed id, address indexed owner, uint256 price);
event PropertySold(uint256 indexed id , address indexed oldOwner, address indexed newOwner, uint256 price);
event PropertyResold(uint256 indexed id, address indexed oldOwner, address indexed newOwner, uint256 price);
| 3,578 |
108 | // Introspects whether an identifier represents an non-fungible token. id Identifier to query.return True if `id` represents an non-fungible token. / | function isNFT(uint256 id) public virtual pure returns (bool) {
return (id & _NF_BIT) != 0 && (id & _NF_TOKEN_MASK != 0);
}
| function isNFT(uint256 id) public virtual pure returns (bool) {
return (id & _NF_BIT) != 0 && (id & _NF_TOKEN_MASK != 0);
}
| 42,105 |
21 | // cal weight | uint256[] memory calWeight = new uint256[](_meta.length()+1);
for(uint32 i = 0; i < _meta.length(); i++) {
calWeight[i] = _weightSlice(_meta, _meta.length()-i);
}
| uint256[] memory calWeight = new uint256[](_meta.length()+1);
for(uint32 i = 0; i < _meta.length(); i++) {
calWeight[i] = _weightSlice(_meta, _meta.length()-i);
}
| 6,505 |
118 | // Mapping from Asset Types to count of that type in exsistance | mapping(uint32 => uint64) internal assetTypeTotalCount;
mapping(uint32 => uint64) internal assetTypeBurnedCount;
| mapping(uint32 => uint64) internal assetTypeTotalCount;
mapping(uint32 => uint64) internal assetTypeBurnedCount;
| 50,862 |
101 | // Emit an event with the results of this order. | emit OrderResult(
hash,
_order.outline.maker,
_taker,
settledParameters
);
| emit OrderResult(
hash,
_order.outline.maker,
_taker,
settledParameters
);
| 21,134 |
90 | // The ETH raised from the staking fees collected before boogiePoolActive == true is used to seed the ETH side of the BOOGIE-ETH Uniswap pool. Mint 500,000 new BOOGIE to seed the BOOGIE liquidity in the BOOGIE-ETH Uniswap pool + referral bonus | uint256 initialMintAmount = 500000 * 10**18;
boogie.mint(address(this), initialMintAmount);
uint256 initialBoogieLiquidity = initialMintAmount.div(2); //Allocate 250k tokens to seed the BOOGIE liquidity in the BOOGIE-ETH Uniswap pool
uint256 referralBonusAmount = initialMintAmount.div(2... | uint256 initialMintAmount = 500000 * 10**18;
boogie.mint(address(this), initialMintAmount);
uint256 initialBoogieLiquidity = initialMintAmount.div(2); //Allocate 250k tokens to seed the BOOGIE liquidity in the BOOGIE-ETH Uniswap pool
uint256 referralBonusAmount = initialMintAmount.div(2... | 65,987 |
122 | // Basic checks | require(buyStrikePrice < sellStrikePrice, "buyStrikePrice should be less than sellStrikePrice");
require(controller.isOperator(ownerAddress, address(this)), "You haven't added this contract as an operator");
| require(buyStrikePrice < sellStrikePrice, "buyStrikePrice should be less than sellStrikePrice");
require(controller.isOperator(ownerAddress, address(this)), "You haven't added this contract as an operator");
| 3,955 |
47 | // Called by the delegator on a delegate to forfeit its responsibility / | function _resignImplementation() public;
| function _resignImplementation() public;
| 33,446 |
38 | // Pay previous tokenOwner if owner is not contract | if (oldOwner != address(this)) {
oldOwner.transfer(payment); //(1-0.2)
}
| if (oldOwner != address(this)) {
oldOwner.transfer(payment); //(1-0.2)
}
| 21,332 |
17 | // Unilateral Functions / start exit with onchain state | function startExit(
address user
| function startExit(
address user
| 5,636 |
39 | // Gets owners/ return memory array of owners | function getOwners() public constant returns (address[]) {
address[] memory result = new address[](m_numOwners);
for (uint i = 0; i < m_numOwners; i++)
result[i] = getOwner(i);
return result;
}
| function getOwners() public constant returns (address[]) {
address[] memory result = new address[](m_numOwners);
for (uint i = 0; i < m_numOwners; i++)
result[i] = getOwner(i);
return result;
}
| 56,636 |
3 | // Beneficial address | address public beneficial;
| address public beneficial;
| 81,285 |
24 | // Helper function to make safe "blind" Uniswap Swaps by comparing value in vs value out of the swap. Only works for Uniswap V2 or V3 exchanges. assetIn the asset to make a swap with assetOut the asset to get out of the swap amountIn the amount of `assetIn` to swap with, can be type(uint256).max exchange enum value tha... | function oracleSwap(
ERC20 assetIn,
ERC20 assetOut,
uint256 amountIn,
SwapRouter.Exchange exchange,
bytes memory params,
| function oracleSwap(
ERC20 assetIn,
ERC20 assetOut,
uint256 amountIn,
SwapRouter.Exchange exchange,
bytes memory params,
| 3,751 |
71 | // Update the global state due to more time cumulated and/or new BPT staking token amount New BPT staking deposited (can be 0) / | function _updateTotalStaking(uint256 amount) private {
uint256 additionalAmountTime = totalStakingAmount.mul(now.sub(lastUpdatedTimestamp));
totalStakingAmount = totalStakingAmount.add(amount);
totalStakingAmountTime = totalStakingAmountTime.add(additionalAmountTime);
lastUpdatedTime... | function _updateTotalStaking(uint256 amount) private {
uint256 additionalAmountTime = totalStakingAmount.mul(now.sub(lastUpdatedTimestamp));
totalStakingAmount = totalStakingAmount.add(amount);
totalStakingAmountTime = totalStakingAmountTime.add(additionalAmountTime);
lastUpdatedTime... | 75,474 |
27 | // The underlying queue data structure stores 2 elements per insertion, so to get the real queue length we need to divide by 2 and subtract 1. | uint256 queueIndex = queueRef.length() / 2 - 1;
emit TransactionEnqueued(
sender,
_target,
_gasLimit,
_data,
queueIndex,
block.timestamp
);
| uint256 queueIndex = queueRef.length() / 2 - 1;
emit TransactionEnqueued(
sender,
_target,
_gasLimit,
_data,
queueIndex,
block.timestamp
);
| 27,760 |
313 | // Emit an event to track whitelist activation status changes. | emit WhitelistActiveUpdate(whitelistId, isActive);
| emit WhitelistActiveUpdate(whitelistId, isActive);
| 33,116 |
76 | // Lock token Lockwhich is defined the lock logic / | contract Lock is PausableToken{
mapping(address => uint256) public teamLockTime; // Lock start time
mapping(address => uint256) public fundLockTime; // Lock start time
uint256 public issueDate =0 ;//issueDate
mapping(address => uint256) public teamLocked;// Total Team lock
mapping(address => uint... | contract Lock is PausableToken{
mapping(address => uint256) public teamLockTime; // Lock start time
mapping(address => uint256) public fundLockTime; // Lock start time
uint256 public issueDate =0 ;//issueDate
mapping(address => uint256) public teamLocked;// Total Team lock
mapping(address => uint... | 8,886 |
0 | // this field can be negative | int funds_correction;
| int funds_correction;
| 63,638 |
8 | // return number of the stored document | return index;
| return index;
| 46,920 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.