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 |
|---|---|---|---|---|
39 | // Reset back to 0 for next day | m_nEarlyAndLateUnstakePool = 0;
| m_nEarlyAndLateUnstakePool = 0;
| 31,142 |
65 | // Overriden to calculate bonuses | function getTokenAmount(uint256 weiAmount) internal view returns(uint256)
| function getTokenAmount(uint256 weiAmount) internal view returns(uint256)
| 20,807 |
62 | // EOA only | require(msg.sender == tx.origin);
| require(msg.sender == tx.origin);
| 10,116 |
94 | // Check if bet exists / | function isBetExists(uint256 _betId) public view returns (bool isExists) {
isExists = bets[_betId].firstParty != address(0);
}
| function isBetExists(uint256 _betId) public view returns (bool isExists) {
isExists = bets[_betId].firstParty != address(0);
}
| 1,881 |
21 | // Odd coordinate | bool[] memory hasNeighborByIndex = new bool[](6);
hasNeighborByIndex[0] = canSubtract(y, 1);
hasNeighborByIndex[1] = canSubtract(x, 1);
hasNeighborByIndex[2] = canAdd(x, 1);
hasNeighborByIndex[3] = canSubtract(x, 1) && canAdd(y, 1);
hasNeighborByIndex[4] = canAdd(y, 1);
hasNeighborByIndex[5] = canAdd(x, 1) && canAdd(y, 1);
uint neighborCount = countTrueValues(hasNeighborByIndex);
uint16[] memory resultX = new uint16[](neighborCount);
| bool[] memory hasNeighborByIndex = new bool[](6);
hasNeighborByIndex[0] = canSubtract(y, 1);
hasNeighborByIndex[1] = canSubtract(x, 1);
hasNeighborByIndex[2] = canAdd(x, 1);
hasNeighborByIndex[3] = canSubtract(x, 1) && canAdd(y, 1);
hasNeighborByIndex[4] = canAdd(y, 1);
hasNeighborByIndex[5] = canAdd(x, 1) && canAdd(y, 1);
uint neighborCount = countTrueValues(hasNeighborByIndex);
uint16[] memory resultX = new uint16[](neighborCount);
| 17,305 |
102 | // Throws if called by any account other than the owner or governer. / | modifier onlyAdmin {
require(
_msgSender() == owner() || _msgSender() == governor(),
"Caller is not an admin"
);
_;
}
| modifier onlyAdmin {
require(
_msgSender() == owner() || _msgSender() == governor(),
"Caller is not an admin"
);
_;
}
| 85,655 |
57 | // fire an event | emit FeaturesUpdated(caller, mask, features);
| emit FeaturesUpdated(caller, mask, features);
| 32,272 |
12 | // User info@member collectRate Collect rate@member stakeAmount APE staked amount in each pool@member iTokenAmount Amount of iToken received upon deposit in each pool@member stakeIds NFT IDs in each staking pool@member depositIds NFT IDs deposited in each pool / | struct UserInfo {
uint256 collectRate;
mapping(uint256 => uint256) stakeAmount;
mapping(uint256 => uint256) iTokenAmount;
mapping(uint256 => EnumerableSetUpgradeable.UintSet) stakeIds;
mapping(uint256 => EnumerableSetUpgradeable.UintSet) depositIds;
}
| struct UserInfo {
uint256 collectRate;
mapping(uint256 => uint256) stakeAmount;
mapping(uint256 => uint256) iTokenAmount;
mapping(uint256 => EnumerableSetUpgradeable.UintSet) stakeIds;
mapping(uint256 => EnumerableSetUpgradeable.UintSet) depositIds;
}
| 41,348 |
210 | // Mints a token to an address with a tokenURI. fee may or may not be required_to address of the future owner of the token_amount number of tokens to mint/ | function mintToMultiple(address _to, uint256 _amount) public payable {
require(_amount >= 1, "Must mint at least 1 token");
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction");
require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!");
require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints");
require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 88");
require(msg.value == getPrice(_amount), "Value below required mint fee for amount");
_safeMint(_to, _amount);
updateMintCount(_to, _amount);
}
| function mintToMultiple(address _to, uint256 _amount) public payable {
require(_amount >= 1, "Must mint at least 1 token");
require(_amount <= maxBatchSize, "Cannot mint more than max mint per transaction");
require(mintingOpen == true && onlyAllowlistMode == false, "Public minting is not open right now!");
require(canMintAmount(_to, _amount), "Wallet address is over the maximum allowed mints");
require(currentTokenId() + _amount <= collectionSize, "Cannot mint over supply cap of 88");
require(msg.value == getPrice(_amount), "Value below required mint fee for amount");
_safeMint(_to, _amount);
updateMintCount(_to, _amount);
}
| 19,681 |
20 | // Dev Account 2 | ambassadors_[0x83Be6BCb09975bF893811f18586C7e0cB233757d] = true;
| ambassadors_[0x83Be6BCb09975bF893811f18586C7e0cB233757d] = true;
| 57,212 |
8 | // return the 0 address which we define to be nil | return _profiles[address(0)];
| return _profiles[address(0)];
| 29,167 |
91 | // Adds the {flashLoan} method, which provides flash loan support at the tokenlevel. By default there is no fee, but this can be changed by overriding {flashFee}./ Returns the maximum amount of tokens available for loan. token The address of the token that is requested.return The amount of token that can be loaned. / | function maxFlashLoan(address token) public view virtual override returns (uint256) {
return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;
}
| function maxFlashLoan(address token) public view virtual override returns (uint256) {
return token == address(this) ? type(uint256).max - ERC20.totalSupply() : 0;
}
| 37,746 |
14 | // Removes a function in the diamond proxy/Reverts if selectors do not already exist | function _removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) private {
DiamondStorage storage ds = s.diamondStorage();
uint256 selectorCount = ds.selectors.length;
if (_facetAddress != address(0)) {
revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);
}
uint256 functionSelectorsLength = _functionSelectors.length;
for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; selectorIndex++) {
bytes4 selector = _functionSelectors[selectorIndex];
FacetInfo memory oldFacetAddressAndSelectorPosition = ds.selectorInfo[selector];
if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {
revert CannotRemoveFunctionThatDoesNotExist(selector);
}
// Can't remove immutable functions -- functions defined directly in the diamond
if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {
revert CannotRemoveImmutableFunction(selector);
}
// Replace selector with last selector
selectorCount--;
if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {
bytes4 lastSelector = ds.selectors[selectorCount];
ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;
ds.selectorInfo[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition.selectorPosition;
}
// Delete last selector
ds.selectors.pop();
delete ds.selectorInfo[selector];
}
}
| function _removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) private {
DiamondStorage storage ds = s.diamondStorage();
uint256 selectorCount = ds.selectors.length;
if (_facetAddress != address(0)) {
revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);
}
uint256 functionSelectorsLength = _functionSelectors.length;
for (uint256 selectorIndex; selectorIndex < functionSelectorsLength; selectorIndex++) {
bytes4 selector = _functionSelectors[selectorIndex];
FacetInfo memory oldFacetAddressAndSelectorPosition = ds.selectorInfo[selector];
if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) {
revert CannotRemoveFunctionThatDoesNotExist(selector);
}
// Can't remove immutable functions -- functions defined directly in the diamond
if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) {
revert CannotRemoveImmutableFunction(selector);
}
// Replace selector with last selector
selectorCount--;
if (oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount) {
bytes4 lastSelector = ds.selectors[selectorCount];
ds.selectors[oldFacetAddressAndSelectorPosition.selectorPosition] = lastSelector;
ds.selectorInfo[lastSelector].selectorPosition = oldFacetAddressAndSelectorPosition.selectorPosition;
}
// Delete last selector
ds.selectors.pop();
delete ds.selectorInfo[selector];
}
}
| 29,393 |
131 | // Remove sender's unlock data | delete unlock_identifier_to_unlock_data[unlock_key];
emit ChannelUnlocked(
channel_identifier,
receiver,
sender,
computed_locksroot,
unlocked_amount,
returned_tokens
);
| delete unlock_identifier_to_unlock_data[unlock_key];
emit ChannelUnlocked(
channel_identifier,
receiver,
sender,
computed_locksroot,
unlocked_amount,
returned_tokens
);
| 23,654 |
3 | // mapping(uint => Swap) public swaps; | mapping(uint => Transaction) public transactions;
| mapping(uint => Transaction) public transactions;
| 15,979 |
7 | // Stake COMP and force proposal to delegate votes to itself | IComp(comp).transferFrom(msg.sender, address(proposal), compStakeAmount);
| IComp(comp).transferFrom(msg.sender, address(proposal), compStakeAmount);
| 61,710 |
232 | // View the amount of rewards that an address has withdrawn. _account The address of a token holder.return The amount of rewards that `account` has withdrawn. / | function withdrawnRewardsOf(address _account) public view override returns (uint256) {
return withdrawnRewards[_account];
}
| function withdrawnRewardsOf(address _account) public view override returns (uint256) {
return withdrawnRewards[_account];
}
| 28,791 |
11 | // Address to receive EIP-2981 royalties from secondary sales / | address public royaltyReceiver = address(0x379e2119f6e0D6088537da82968e2a7ea178dDcF);
| address public royaltyReceiver = address(0x379e2119f6e0D6088537da82968e2a7ea178dDcF);
| 50,302 |
13 | // Check receiver effectiveness | for (uint256 i = 0; i < _to.length; i++) {
require(_to[i] != address(0));
sum.add(_value[i]);
}
| for (uint256 i = 0; i < _to.length; i++) {
require(_to[i] != address(0));
sum.add(_value[i]);
}
| 17,724 |
5 | // See {IERC20-totalSupply}. / | function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| 4,734 |
100 | // Allows the owner to revoke the vesting. Tokens already vestedremain in the contract, the rest are returned to the owner. token ERC20 token which is being vested / | function revoke(ERC20Basic token) public onlyOwner {
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
token.safeTransfer(owner, refund);
Revoked();
}
| function revoke(ERC20Basic token) public onlyOwner {
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
token.safeTransfer(owner, refund);
Revoked();
}
| 11,818 |
268 | // Move ether from root to child chain, accepts ether transferKeep in mind this ether cannot be used to pay gas on child chainUse Matic tokens deposited using plasma mechanism for that user address of account that should receive WETH on child chain / | function depositEtherFor(address user) external override payable {
_depositEtherFor(user);
}
| function depositEtherFor(address user) external override payable {
_depositEtherFor(user);
}
| 20,624 |
82 | // Currently the only consideration is whether or notthe src is allowed to redeem this many tokens | uint allowed = redeemAllowedInternal(cToken, src, transferTokens);
if (allowed != uint(Error.NO_ERROR)) {
return allowed;
}
| uint allowed = redeemAllowedInternal(cToken, src, transferTokens);
if (allowed != uint(Error.NO_ERROR)) {
return allowed;
}
| 11,875 |
109 | // Refund 15,000 gas per slot. amount number of slots to free / | function gasRefund15(uint256 amount) internal {
// refund gas
assembly {
// get number of free slots
let offset := sload(0xfffff)
// make sure there are enough slots
if lt(offset, amount) {
amount := offset
}
if eq(amount, 0) {
stop()
}
// get location of first slot
let location := add(offset, 0xfffff)
// calculate loop end
let end := sub(location, amount)
// loop until end is reached
for {
} gt(location, end) {
location := sub(location, 1)
} {
// set storage location to zero
// this refunds 15,000 gas
sstore(location, 0)
}
// store new number of free slots
sstore(0xfffff, sub(offset, amount))
}
}
| function gasRefund15(uint256 amount) internal {
// refund gas
assembly {
// get number of free slots
let offset := sload(0xfffff)
// make sure there are enough slots
if lt(offset, amount) {
amount := offset
}
if eq(amount, 0) {
stop()
}
// get location of first slot
let location := add(offset, 0xfffff)
// calculate loop end
let end := sub(location, amount)
// loop until end is reached
for {
} gt(location, end) {
location := sub(location, 1)
} {
// set storage location to zero
// this refunds 15,000 gas
sstore(location, 0)
}
// store new number of free slots
sstore(0xfffff, sub(offset, amount))
}
}
| 28,397 |
41 | // ToG redeem event with encrypted message (hopefully a contact info) | event tokenRedemption(address indexed supported, string message);
| event tokenRedemption(address indexed supported, string message);
| 11,526 |
57 | // After close_time has been reached, no new offers are allowed. | modifier can_offer {
require(!isClosed());
_;
}
| modifier can_offer {
require(!isClosed());
_;
}
| 10,125 |
12 | // validamos que no haya overflow int256, si ocurre se empieza de 0 | uint previousBalanceTo = balanceOf(_owner); //cogemos los tokens totales del Owner hasta el momento
require(previousBalanceTo + _tokensGenerated >= previousBalanceTo,"ERROR: Owner Tokens it has been exceeded.");
| uint previousBalanceTo = balanceOf(_owner); //cogemos los tokens totales del Owner hasta el momento
require(previousBalanceTo + _tokensGenerated >= previousBalanceTo,"ERROR: Owner Tokens it has been exceeded.");
| 34,651 |
189 | // current owned liquidity | require(
farmingPosition.creationBlock != 0 &&
removedLiquidity <= farmingPosition.liquidityPoolTokenAmount &&
farmingPosition.uniqueOwner == msg.sender,
"Invalid withdraw"
);
_withdrawReward(positionId, removedLiquidity);
_setups[farmingPosition.setupIndex].totalSupply -= removedLiquidity;
farmingPosition.liquidityPoolTokenAmount -= removedLiquidity;
| require(
farmingPosition.creationBlock != 0 &&
removedLiquidity <= farmingPosition.liquidityPoolTokenAmount &&
farmingPosition.uniqueOwner == msg.sender,
"Invalid withdraw"
);
_withdrawReward(positionId, removedLiquidity);
_setups[farmingPosition.setupIndex].totalSupply -= removedLiquidity;
farmingPosition.liquidityPoolTokenAmount -= removedLiquidity;
| 27,850 |
67 | // Make sure the operator exists | require(
isOperator[_operator],
"Not an operator."
);
| require(
isOperator[_operator],
"Not an operator."
);
| 3,409 |
25 | // Change URI | function setBaseURI(string memory baseURI) public onlyOwner {
baseTokenURI = baseURI;
emit BaseURIChanged(baseURI);
}
| function setBaseURI(string memory baseURI) public onlyOwner {
baseTokenURI = baseURI;
emit BaseURIChanged(baseURI);
}
| 31,837 |
66 | // Base URI | string private _baseURIextended;
constructor(string memory _name, string memory _symbol)
ERC721(_name, _symbol)
| string private _baseURIextended;
constructor(string memory _name, string memory _symbol)
ERC721(_name, _symbol)
| 6,740 |
374 | // Get all risk parameters in a single struct. returnAll global risk parameters / | function getRiskParams()
public
view
returns (Storage.RiskParams memory)
| function getRiskParams()
public
view
returns (Storage.RiskParams memory)
| 23,857 |
55 | // Hash(current element of the proof + current computed hash) | computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
| computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
| 1,872 |
3 | // amount {uint} Amount of the payment (in wei) to {address} Address of the recipientreturn receipt {uint} Receipt acknowledging the payment in the amount givenwas sent to the given address / | function pay(uint amount, address to) payable returns (uint receipt);
| function pay(uint amount, address to) payable returns (uint receipt);
| 49,992 |
249 | // fetch reserve data | (
vars.reserveDecimals,
vars.baseLtv,
vars.liquidationThreshold,
vars.usageAsCollateralEnabled
) = core.getReserveConfiguration(vars.currentReserve);
vars.tokenUnit = 10 ** vars.reserveDecimals;
vars.reserveUnitPrice = oracle.getAssetPrice(vars.currentReserve);
| (
vars.reserveDecimals,
vars.baseLtv,
vars.liquidationThreshold,
vars.usageAsCollateralEnabled
) = core.getReserveConfiguration(vars.currentReserve);
vars.tokenUnit = 10 ** vars.reserveDecimals;
vars.reserveUnitPrice = oracle.getAssetPrice(vars.currentReserve);
| 31,990 |
105 | // The total of committed balances / | uint256 __deprecated__committedSupply;
| uint256 __deprecated__committedSupply;
| 55,134 |
33 | // set new oracle address. _address new address / | function setOracleAddress(address _address) external onlyGovernor {
require(_address != address(0), "UnilendV2: ZERO ADDRESS");
oracleAddress = _address;
emit NewOracleAddress(_address);
}
| function setOracleAddress(address _address) external onlyGovernor {
require(_address != address(0), "UnilendV2: ZERO ADDRESS");
oracleAddress = _address;
emit NewOracleAddress(_address);
}
| 22,361 |
45 | // returns lbry string | function getLbry(uint tokenId) public view returns (string memory) {
return (lbrys[tokenId].lbry);
}
| function getLbry(uint tokenId) public view returns (string memory) {
return (lbrys[tokenId].lbry);
}
| 1,887 |
51 | // Implementation of the addClaim function from the ERC-735 standard Require that the msg.sender has claim signer key._topic The type of claim _scheme The scheme with which this claim SHOULD be verified or how it should be processed. _issuer The issuers identity contract address, or the address used to sign the above signature. _signature Signature which is the proof that the claim issuer issued a claim of topic for this identity.it MUST be a signed message of the following structure: keccak256(abi.encode(address identityHolder_address, uint256 _ topic, bytes data)) _data The hash of the claim data, sitting in another location, a bit-mask, call |
function addClaim(
uint256 _topic,
uint256 _scheme,
address _issuer,
bytes memory _signature,
bytes memory _data,
string memory _uri
)
public
|
function addClaim(
uint256 _topic,
uint256 _scheme,
address _issuer,
bytes memory _signature,
bytes memory _data,
string memory _uri
)
public
| 10,430 |
48 | // update token value in pass; | Update_Global_Data();
Update_User(msg.sender);
m_User_Map[msg.sender].Stacking_Operation_Block_Stamp=block.number;
m_User_Map[msg.sender].Block_of_Last_Stack[period_id]=block.number;
| Update_Global_Data();
Update_User(msg.sender);
m_User_Map[msg.sender].Stacking_Operation_Block_Stamp=block.number;
m_User_Map[msg.sender].Block_of_Last_Stack[period_id]=block.number;
| 26,753 |
16 | // Handle the operation of ETH deposit into the SGRToken contract. _sender The address of the account which has issued the operation. _balance The amount of ETH in the SGRToken contract. _amount The deposited ETH amount.return The address of the reserve-wallet and the deficient amount of ETH in the SGRToken contract. / | function uponDeposit(address _sender, uint256 _balance, uint256 _amount) external returns (address, uint256);
| function uponDeposit(address _sender, uint256 _balance, uint256 _amount) external returns (address, uint256);
| 36,936 |
33 | // owner only function to set the minimum Mars List index supported/newMinimumIndex the newMinimumIndex | function setMinimumIndex(uint256 newMinimumIndex) public onlyRealOwner {
minimumIndex = newMinimumIndex;
}
| function setMinimumIndex(uint256 newMinimumIndex) public onlyRealOwner {
minimumIndex = newMinimumIndex;
}
| 18,325 |
4 | // Minimum value that can be represented in an int256 Test minInt256 equals (2^255)(-1) / | function minInt256() internal pure returns(int256) {
return -57896044618658097711785492504343953926634992332820282019728792003956564819968;
}
| function minInt256() internal pure returns(int256) {
return -57896044618658097711785492504343953926634992332820282019728792003956564819968;
}
| 47,946 |
24 | // Map the articleId to the contentId | _addArticleToContentMap(articleId, contentId);
| _addArticleToContentMap(articleId, contentId);
| 11,060 |
84 | // mapping(address => uint256) private _holderLastTransferTimestamp; | mapping(address => bool) public _isExcludedMaxTransactionAmount;
uint256 public maxWallet;
uint256 public maxTransactionAmount;
| mapping(address => bool) public _isExcludedMaxTransactionAmount;
uint256 public maxWallet;
uint256 public maxTransactionAmount;
| 13,451 |
111 | // We need to parse Flash loan actions in a different way | enum ActionType { FL_ACTION, STANDARD_ACTION, CUSTOM_ACTION }
/// @notice Parses inputs and runs the implemented action through a proxy
/// @dev Is called by the TaskExecutor chaining actions together
/// @param _callData Array of input values each value encoded as bytes
/// @param _subData Array of subscribed vales, replaces input values if specified
/// @param _paramMapping Array that specifies how return and subscribed values are mapped in input
/// @param _returnValues Returns values from actions before, which can be injected in inputs
/// @return Returns a bytes32 value through DSProxy, each actions implements what that value is
function executeAction(
bytes[] memory _callData,
bytes[] memory _subData,
uint8[] memory _paramMapping,
bytes32[] memory _returnValues
) public payable virtual returns (bytes32);
/// @notice Parses inputs and runs the single implemented action through a proxy
/// @dev Used to save gas when executing a single action directly
function executeActionDirect(bytes[] memory _callData) public virtual payable;
/// @notice Returns the type of action we are implementing
function actionType() public pure virtual returns (uint8);
//////////////////////////// HELPER METHODS ////////////////////////////
/// @notice Given an uint256 input, injects return/sub values if specified
/// @param _param The original input value
/// @param _mapType Indicated the type of the input in paramMapping
/// @param _subData Array of subscription data we can replace the input value with
/// @param _returnValues Array of subscription data we can replace the input value with
function _parseParamUint(
uint _param,
uint8 _mapType,
bytes[] memory _subData,
bytes32[] memory _returnValues
) internal pure returns (uint) {
if (isReplaceable(_mapType)) {
if (isReturnInjection(_mapType)) {
_param = uint(_returnValues[getReturnIndex(_mapType)]);
} else {
_param = abi.decode(_subData[getSubIndex(_mapType)], (uint));
}
}
return _param;
}
| enum ActionType { FL_ACTION, STANDARD_ACTION, CUSTOM_ACTION }
/// @notice Parses inputs and runs the implemented action through a proxy
/// @dev Is called by the TaskExecutor chaining actions together
/// @param _callData Array of input values each value encoded as bytes
/// @param _subData Array of subscribed vales, replaces input values if specified
/// @param _paramMapping Array that specifies how return and subscribed values are mapped in input
/// @param _returnValues Returns values from actions before, which can be injected in inputs
/// @return Returns a bytes32 value through DSProxy, each actions implements what that value is
function executeAction(
bytes[] memory _callData,
bytes[] memory _subData,
uint8[] memory _paramMapping,
bytes32[] memory _returnValues
) public payable virtual returns (bytes32);
/// @notice Parses inputs and runs the single implemented action through a proxy
/// @dev Used to save gas when executing a single action directly
function executeActionDirect(bytes[] memory _callData) public virtual payable;
/// @notice Returns the type of action we are implementing
function actionType() public pure virtual returns (uint8);
//////////////////////////// HELPER METHODS ////////////////////////////
/// @notice Given an uint256 input, injects return/sub values if specified
/// @param _param The original input value
/// @param _mapType Indicated the type of the input in paramMapping
/// @param _subData Array of subscription data we can replace the input value with
/// @param _returnValues Array of subscription data we can replace the input value with
function _parseParamUint(
uint _param,
uint8 _mapType,
bytes[] memory _subData,
bytes32[] memory _returnValues
) internal pure returns (uint) {
if (isReplaceable(_mapType)) {
if (isReturnInjection(_mapType)) {
_param = uint(_returnValues[getReturnIndex(_mapType)]);
} else {
_param = abi.decode(_subData[getSubIndex(_mapType)], (uint));
}
}
return _param;
}
| 3,265 |
93 | // Checks if an address is a guardian for a wallet. _wallet The target wallet. _guardian The address to check.return _isGuardian `true` if the address is a guardian for the wallet otherwise `false`. / | function isGuardian(address _wallet, address _guardian) public view returns (bool _isGuardian) {
return guardianStorage.isGuardian(_wallet, _guardian);
}
| function isGuardian(address _wallet, address _guardian) public view returns (bool _isGuardian) {
return guardianStorage.isGuardian(_wallet, _guardian);
}
| 29,286 |
37 | // performs chained getAmountOut calculations on any number of pairs | function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
| function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
| 2,048 |
3 | // The token ID Yokai detail | mapping(uint256 => Detail) private _detail;
| mapping(uint256 => Detail) private _detail;
| 9,706 |
2 | // Distribution for airdrops wallet | uint256 public constant INITIAL_AIRDROP_WALLET_DISTRIBUTION = 0 ether;
| uint256 public constant INITIAL_AIRDROP_WALLET_DISTRIBUTION = 0 ether;
| 14,324 |
30 | // Allows the controller/owner to update rewards parameters_self Data pointer to storage_name ParameterName name of the parameter_value uint256 new value for the parameter_rewardsDay uint256 the rewards day/ | function updateParameter(
Data storage _self,
ParameterName _name,
uint256 _value,
uint256 _rewardsDay
)
public
onlyValidFutureRewardsDay(_self, _rewardsDay)
| function updateParameter(
Data storage _self,
ParameterName _name,
uint256 _value,
uint256 _rewardsDay
)
public
onlyValidFutureRewardsDay(_self, _rewardsDay)
| 35,415 |
16 | // staking pool | poolInfo.push(PoolInfo({
lpToken: _charm,
allocPoint: 1000,
lastRewardBlock: startBlock,
accCharmPerShare: 0
}));
| poolInfo.push(PoolInfo({
lpToken: _charm,
allocPoint: 1000,
lastRewardBlock: startBlock,
accCharmPerShare: 0
}));
| 24,863 |
52 | // Obtain next bid index, decrease cumulative sum | (state.nextCumSumBids, state.nextBidIndex) = _decreaseCumSumBids(
sortedBids,
state.nextBidIndex,
state.nextCumSumBids,
state.nextOfferPrice
);
state.nextMaxClearingVolume = _minUint256(
state.nextCumSumBids,
state.nextCumSumOffers
| (state.nextCumSumBids, state.nextBidIndex) = _decreaseCumSumBids(
sortedBids,
state.nextBidIndex,
state.nextCumSumBids,
state.nextOfferPrice
);
state.nextMaxClearingVolume = _minUint256(
state.nextCumSumBids,
state.nextCumSumOffers
| 35,450 |
602 | // 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;
| 4,129 |
15 | // prevent double counting | if (addressCountedAtPhase[account] == phaseBeingUpdated) {
continue;
}
| if (addressCountedAtPhase[account] == phaseBeingUpdated) {
continue;
}
| 17,132 |
21 | // Oldest slot from which to start claiming unlocked rewards | mapping (address => uint256) public oldestEscrowSlot;
| mapping (address => uint256) public oldestEscrowSlot;
| 41,858 |
15 | // Calculates the amount of tokens that has already vested. Default implementation is a linear vesting curve. / | function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp);
}
| function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp);
}
| 24,655 |
83 | // Change the miner staked to locked to be withdrawStake | stakes.currentStatus = 2;
| stakes.currentStatus = 2;
| 55,383 |
27 | // Sets the stored oracle contract with the address resolved by ENS This may be called on its own as long as `useChainlinkWithENS` has been called previously / | function updateChainlinkOracleWithENS() internal {
bytes32 oracleSubnode = keccak256(
abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME)
);
ENSResolver_Chainlink resolver = ENSResolver_Chainlink(
s_ens.resolver(oracleSubnode)
);
setChainlinkOracle(resolver.addr(oracleSubnode));
}
| function updateChainlinkOracleWithENS() internal {
bytes32 oracleSubnode = keccak256(
abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME)
);
ENSResolver_Chainlink resolver = ENSResolver_Chainlink(
s_ens.resolver(oracleSubnode)
);
setChainlinkOracle(resolver.addr(oracleSubnode));
}
| 15,209 |
11 | // Ownable The Ownable contract has an owner address, and provides basic authorization controlfunctions, ownership can be transferred in 2 steps (transfer-accept). / | contract Ownable {
address public owner;
address public pendingOwner;
bool isOwnershipTransferActive = false;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Only owner can do that.");
_;
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(isOwnershipTransferActive);
require(msg.sender == pendingOwner, "Only nominated pretender can do that.");
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
pendingOwner = _newOwner;
isOwnershipTransferActive = true;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function acceptOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
isOwnershipTransferActive = false;
pendingOwner = address(0);
}
}
| contract Ownable {
address public owner;
address public pendingOwner;
bool isOwnershipTransferActive = false;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "Only owner can do that.");
_;
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(isOwnershipTransferActive);
require(msg.sender == pendingOwner, "Only nominated pretender can do that.");
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
pendingOwner = _newOwner;
isOwnershipTransferActive = true;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function acceptOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
isOwnershipTransferActive = false;
pendingOwner = address(0);
}
}
| 28,888 |
24 | // / | function setTierStakingLimit(
uint256 _tier1StakedAmount,
uint256 _tier2StakedAmount,
uint256 _tier3StakedAmount
| function setTierStakingLimit(
uint256 _tier1StakedAmount,
uint256 _tier2StakedAmount,
uint256 _tier3StakedAmount
| 75,609 |
41 | // Module Manager - A contract that manages modules that can execute transactions via this contract/Stefan George - <[email protected]>/Richard Meissner - <[email protected]> | contract ModuleManager is SelfAuthorized, Executor {
event EnabledModule(address module);
event DisabledModule(address module);
event ExecutionFromModuleSuccess(address indexed module);
event ExecutionFromModuleFailure(address indexed module);
address internal constant SENTINEL_MODULES = address(0x1);
mapping(address => address) internal modules;
function setupModules(address to, bytes memory data) internal {
require(modules[SENTINEL_MODULES] == address(0), "GS100");
modules[SENTINEL_MODULES] = SENTINEL_MODULES;
if (to != address(0))
// Setup has to complete successfully or transaction fails.
require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), "GS000");
}
/// @dev Allows to add a module to the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Enables the module `module` for the Safe.
/// @param module Module to be whitelisted.
function enableModule(address module) public authorized {
// Module address cannot be null or sentinel.
require(module != address(0) && module != SENTINEL_MODULES, "GS101");
// Module cannot be added twice.
require(modules[module] == address(0), "GS102");
modules[module] = modules[SENTINEL_MODULES];
modules[SENTINEL_MODULES] = module;
emit EnabledModule(module);
}
/// @dev Allows to remove a module from the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Disables the module `module` for the Safe.
/// @param prevModule Module that pointed to the module to be removed in the linked list
/// @param module Module to be removed.
function disableModule(address prevModule, address module) public authorized {
// Validate module address and check that it corresponds to module index.
require(module != address(0) && module != SENTINEL_MODULES, "GS101");
require(modules[prevModule] == module, "GS103");
modules[prevModule] = modules[module];
modules[module] = address(0);
emit DisabledModule(module);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations.
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModule(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) public virtual returns (bool success) {
// Only whitelisted modules are allowed.
require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "GS104");
// Execute transaction without further confirmations.
success = execute(to, value, data, operation, gasleft());
if (success) emit ExecutionFromModuleSuccess(msg.sender);
else emit ExecutionFromModuleFailure(msg.sender);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModuleReturnData(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) public returns (bool success, bytes memory returnData) {
success = execTransactionFromModule(to, value, data, operation);
// solhint-disable-next-line no-inline-assembly
assembly {
// Load free memory location
let ptr := mload(0x40)
// We allocate memory for the return data by setting the free memory location to
// current free memory location + data size + 32 bytes for data size value
mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
// Store the size
mstore(ptr, returndatasize())
// Store the data
returndatacopy(add(ptr, 0x20), 0, returndatasize())
// Point the return data to the correct memory location
returnData := ptr
}
}
/// @dev Returns if an module is enabled
/// @return True if the module is enabled
function isModuleEnabled(address module) public view returns (bool) {
return SENTINEL_MODULES != module && modules[module] != address(0);
}
/// @dev Returns array of modules.
/// @param start Start of the page.
/// @param pageSize Maximum number of modules that should be returned.
/// @return array Array of modules.
/// @return next Start of the next page.
function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {
// Init array with max page size
array = new address[](pageSize);
// Populate return array
uint256 moduleCount = 0;
address currentModule = modules[start];
while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {
array[moduleCount] = currentModule;
currentModule = modules[currentModule];
moduleCount++;
}
next = currentModule;
// Set correct size of returned array
// solhint-disable-next-line no-inline-assembly
assembly {
mstore(array, moduleCount)
}
}
}
| contract ModuleManager is SelfAuthorized, Executor {
event EnabledModule(address module);
event DisabledModule(address module);
event ExecutionFromModuleSuccess(address indexed module);
event ExecutionFromModuleFailure(address indexed module);
address internal constant SENTINEL_MODULES = address(0x1);
mapping(address => address) internal modules;
function setupModules(address to, bytes memory data) internal {
require(modules[SENTINEL_MODULES] == address(0), "GS100");
modules[SENTINEL_MODULES] = SENTINEL_MODULES;
if (to != address(0))
// Setup has to complete successfully or transaction fails.
require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), "GS000");
}
/// @dev Allows to add a module to the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Enables the module `module` for the Safe.
/// @param module Module to be whitelisted.
function enableModule(address module) public authorized {
// Module address cannot be null or sentinel.
require(module != address(0) && module != SENTINEL_MODULES, "GS101");
// Module cannot be added twice.
require(modules[module] == address(0), "GS102");
modules[module] = modules[SENTINEL_MODULES];
modules[SENTINEL_MODULES] = module;
emit EnabledModule(module);
}
/// @dev Allows to remove a module from the whitelist.
/// This can only be done via a Safe transaction.
/// @notice Disables the module `module` for the Safe.
/// @param prevModule Module that pointed to the module to be removed in the linked list
/// @param module Module to be removed.
function disableModule(address prevModule, address module) public authorized {
// Validate module address and check that it corresponds to module index.
require(module != address(0) && module != SENTINEL_MODULES, "GS101");
require(modules[prevModule] == module, "GS103");
modules[prevModule] = modules[module];
modules[module] = address(0);
emit DisabledModule(module);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations.
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModule(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) public virtual returns (bool success) {
// Only whitelisted modules are allowed.
require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "GS104");
// Execute transaction without further confirmations.
success = execute(to, value, data, operation, gasleft());
if (success) emit ExecutionFromModuleSuccess(msg.sender);
else emit ExecutionFromModuleFailure(msg.sender);
}
/// @dev Allows a Module to execute a Safe transaction without any further confirmations and return data
/// @param to Destination address of module transaction.
/// @param value Ether value of module transaction.
/// @param data Data payload of module transaction.
/// @param operation Operation type of module transaction.
function execTransactionFromModuleReturnData(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
) public returns (bool success, bytes memory returnData) {
success = execTransactionFromModule(to, value, data, operation);
// solhint-disable-next-line no-inline-assembly
assembly {
// Load free memory location
let ptr := mload(0x40)
// We allocate memory for the return data by setting the free memory location to
// current free memory location + data size + 32 bytes for data size value
mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
// Store the size
mstore(ptr, returndatasize())
// Store the data
returndatacopy(add(ptr, 0x20), 0, returndatasize())
// Point the return data to the correct memory location
returnData := ptr
}
}
/// @dev Returns if an module is enabled
/// @return True if the module is enabled
function isModuleEnabled(address module) public view returns (bool) {
return SENTINEL_MODULES != module && modules[module] != address(0);
}
/// @dev Returns array of modules.
/// @param start Start of the page.
/// @param pageSize Maximum number of modules that should be returned.
/// @return array Array of modules.
/// @return next Start of the next page.
function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {
// Init array with max page size
array = new address[](pageSize);
// Populate return array
uint256 moduleCount = 0;
address currentModule = modules[start];
while (currentModule != address(0x0) && currentModule != SENTINEL_MODULES && moduleCount < pageSize) {
array[moduleCount] = currentModule;
currentModule = modules[currentModule];
moduleCount++;
}
next = currentModule;
// Set correct size of returned array
// solhint-disable-next-line no-inline-assembly
assembly {
mstore(array, moduleCount)
}
}
}
| 54,436 |
84 | // Dynamic value of Ether in reserve, according to the CRR requirement. | function reserve() internal constant returns (uint256 amount) {
return sub(balance(),
((uint256) ((int256) (earningsPerToken * totalSupply) - totalPayouts) / scaleFactor));
}
| function reserve() internal constant returns (uint256 amount) {
return sub(balance(),
((uint256) ((int256) (earningsPerToken * totalSupply) - totalPayouts) / scaleFactor));
}
| 49,083 |
57 | // Returns an array of token IDs owned by `owner`. This function scans the ownership mapping and is O(`totalSupply`) in complexity.It is meant to be called off-chain. This function is compatiable with ERC721AQueryable. / | function tokensOfOwner(address owner) external view virtual returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
if (_exists(i)) {
if (ownerOf(i) == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
}
return tokenIds;
}
}
| function tokensOfOwner(address owner) external view virtual returns (uint256[] memory) {
unchecked {
uint256 tokenIdsIdx;
uint256 tokenIdsLength = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenIdsLength);
for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
if (_exists(i)) {
if (ownerOf(i) == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
}
return tokenIds;
}
}
| 36,528 |
26 | // Returns the decimals places of the token./ | function decimals() external view returns (uint8);
| function decimals() external view returns (uint8);
| 6,030 |
352 | // The loan has been repaid, and the collateral has been returned to the borrower. This is a terminal state. | Repaid,
| Repaid,
| 24,434 |
23 | // Secondary auth can lower the risk ratio of any protocol./protocolId_ The Id of the protocol to reduce the risk ratio./newRiskRatio_ New risk ratio of the protocol in terms of Eth and Steth, scaled to factor 4. i.e 1e6 = 100%, 1e4 = 1%/ Note Risk ratio is calculated in terms of `ETH` and `STETH` to maintain a common/ standard between protocols. (Risk ratio = Eth debt / Steth collateral). | function reduceMaxRiskRatio(
uint8[] memory protocolId_,
uint256[] memory newRiskRatio_
| function reduceMaxRiskRatio(
uint8[] memory protocolId_,
uint256[] memory newRiskRatio_
| 3,374 |
38 | // transfer platform fee to factory | payable(address(_factory)).safeTransferETH(platformFee);
| payable(address(_factory)).safeTransferETH(platformFee);
| 272 |
32 | // Emitted after all the tokens have been transfered. / | event TokensSent(uint256 total, address tokenAddress);
| event TokensSent(uint256 total, address tokenAddress);
| 35,915 |
337 | // round 11 | ark(i, q, 4852706232225925756777361208698488277369799648067343227630786518486608711772);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 4852706232225925756777361208698488277369799648067343227630786518486608711772);
sbox_partial(i, q);
mix(i, q);
| 36,789 |
266 | // GlobalsStore public globals; | function globals() external view returns (
uint72 lockedHeartsTotal,
uint72 nextStakeSharesTotal,
uint40 shareRate,
uint72 stakePenaltyTotal,
uint16 dailyDataCount,
uint72 stakeSharesTotal,
uint40 latestStakeId,
uint128 claimStats
);
| function globals() external view returns (
uint72 lockedHeartsTotal,
uint72 nextStakeSharesTotal,
uint40 shareRate,
uint72 stakePenaltyTotal,
uint16 dailyDataCount,
uint72 stakeSharesTotal,
uint40 latestStakeId,
uint128 claimStats
);
| 32,129 |
52 | // Previous monster just fled, new monster awaiting. | if (monster.level + monsterStrength > _heroHealth) {
_heroHealth = 0;
_monsterLevel = monster.level;
_monsterInitialHealth = monster.initialHealth;
_monsterHealth = monster.health;
_gameState = 2;
} else {
| if (monster.level + monsterStrength > _heroHealth) {
_heroHealth = 0;
_monsterLevel = monster.level;
_monsterInitialHealth = monster.initialHealth;
_monsterHealth = monster.health;
_gameState = 2;
} else {
| 82,831 |
109 | // Now our 4 key numbers are available: numerLS, numerMS, denomLS, denomMS | uint256 reward;
if (denom.MS == 0) {
| uint256 reward;
if (denom.MS == 0) {
| 25,496 |
163 | // Check the signature length | if (signature.length != 65) {
revert("ECDSA: invalid signature length");
}
| if (signature.length != 65) {
revert("ECDSA: invalid signature length");
}
| 1,698 |
119 | // grab our winning player and team id's | uint256 _winPID = round_[_rID].plyr;
| uint256 _winPID = round_[_rID].plyr;
| 6,942 |
128 | // Don't take profits with this call, but adjust for better gains | adjustPosition(vault.debtOutstanding());
| adjustPosition(vault.debtOutstanding());
| 850 |
428 | // Then withdraw all from all other pools | for (uint256 i = 0; i < _supportedPools.length; i++)
if (hasETHInPool(_supportedPools[i]))
_withdrawAllFromPool(_supportedPools[i]);
| for (uint256 i = 0; i < _supportedPools.length; i++)
if (hasETHInPool(_supportedPools[i]))
_withdrawAllFromPool(_supportedPools[i]);
| 64,850 |
48 | // can be called by the seller at every moment once enough funds has been raised/_raffleId Id of the raffle/the seller of the ETH, if the minimum amount has been reached, can call an early cashout, finishing the raffle/it triggers Chainlink VRF1 consumer, and generates a random number that is normalized and checked that corresponds to a MW player | function earlyCashOut(uint256 _raffleId) external onlyRole(OPERATOR_ROLE) {
RaffleStruct storage raffle = raffles[_raffleId];
require(raffle.status == STATUS.STARTED, "Raffle not started");
require(
raffle.amountRaised >= raffle.minimumFunds,
"Not enough funds raised"
);
raffle.status = STATUS.EARLY_CASHOUT;
getRandomNumber(_raffleId, raffle.entriesLength);
emit EarlyCashoutTriggered(_raffleId, raffle.amountRaised);
}
| function earlyCashOut(uint256 _raffleId) external onlyRole(OPERATOR_ROLE) {
RaffleStruct storage raffle = raffles[_raffleId];
require(raffle.status == STATUS.STARTED, "Raffle not started");
require(
raffle.amountRaised >= raffle.minimumFunds,
"Not enough funds raised"
);
raffle.status = STATUS.EARLY_CASHOUT;
getRandomNumber(_raffleId, raffle.entriesLength);
emit EarlyCashoutTriggered(_raffleId, raffle.amountRaised);
}
| 19,696 |
53 | // If 2-out-of-3 of the Buyer, Seller, and/or Mediator have Disapproved the Mediated Sales Transaction, then it's status cannot be changed, because the Seller has already beenpaid 95% of the Sales Amount, and the Mediator has already been paid 5% of the Sales Amount. | require(!mediatedSalesTransactionHasBeenApproved(_mediatedSalesTransactionIpfsHash),
"Mediated Sales Transaction has already been Approved by at least 2-out-of-3 of the Buyer, Seller, and/or Mediator! Cannot Disapprove at this point!");
uint indexBuyerSellerOrMediator = 0;
for (uint i = 0; i < 3; i++) {
if (mediatedSalesTransactionAddresses[_mediatedSalesTransactionIpfsHash][i] == msg.sender) {
indexBuyerSellerOrMediator = i;
}
| require(!mediatedSalesTransactionHasBeenApproved(_mediatedSalesTransactionIpfsHash),
"Mediated Sales Transaction has already been Approved by at least 2-out-of-3 of the Buyer, Seller, and/or Mediator! Cannot Disapprove at this point!");
uint indexBuyerSellerOrMediator = 0;
for (uint i = 0; i < 3; i++) {
if (mediatedSalesTransactionAddresses[_mediatedSalesTransactionIpfsHash][i] == msg.sender) {
indexBuyerSellerOrMediator = i;
}
| 53,301 |
17 | // Fully fill an OTC order. "Meta-transaction" variant,/requires order to be signed by both maker and taker./order The OTC order./makerSignature The order signature from the maker./takerSignature The order signature from the taker. | function fillTakerSignedOtcOrder(
LibNativeOrder.OtcOrder memory order,
LibSignature.Signature memory makerSignature,
LibSignature.Signature memory takerSignature
)
public
override
| function fillTakerSignedOtcOrder(
LibNativeOrder.OtcOrder memory order,
LibSignature.Signature memory makerSignature,
LibSignature.Signature memory takerSignature
)
public
override
| 13,022 |
14 | // Query if an address is an authorized operator for another address. _owner The address that owns the records. _operator The address that acts on behalf of the owner.return True if `operator` is an approved operator for `owner`, false otherwise. / | function isApprovedForAll(address _owner, address _operator) external view returns (bool) {
return operators[_owner][_operator];
}
| function isApprovedForAll(address _owner, address _operator) external view returns (bool) {
return operators[_owner][_operator];
}
| 38,780 |
179 | // Enforce the existence of only 10000 Useless NFTs / | uint256 USELESSNFTS_SUPPLY = 10000;
| uint256 USELESSNFTS_SUPPLY = 10000;
| 11,223 |
139 | // Event for tracking activated deposits.account - account the deposit was activated for.validatorIndex - index of the activated validator.value - amount activated.sender - address of the transaction sender./ | event Activated(address indexed account, uint256 validatorIndex, uint256 value, address indexed sender);
| event Activated(address indexed account, uint256 validatorIndex, uint256 value, address indexed sender);
| 67,476 |
7 | // Acquire free egg from the egg giveaway contract. To acquire an egg, a few conditions have to be met: 1. The sender is not allowed to send Ether. The game is free to play. 2. The transaction must occur within the giveaway period, as specifiedat the top of this file. 3. The sender must not already have acquired a free egg. 4. There must be an availability of at least one (1) for the time slotthe transaction occurs in. / | function acquireFreeEgg() payable external {
require(msg.value == 0);
require(START_DATE <= now && now < END_DATE);
require(eggOwners[msg.sender] == false);
uint8 currentTimeSlot = getTimeSlot(now);
require(remainingFreeEggs[currentTimeSlot] > 0);
remainingFreeEggs[currentTimeSlot] -= 1;
eggOwners[msg.sender] = true;
LogEggAcquisition(msg.sender, now);
}
| function acquireFreeEgg() payable external {
require(msg.value == 0);
require(START_DATE <= now && now < END_DATE);
require(eggOwners[msg.sender] == false);
uint8 currentTimeSlot = getTimeSlot(now);
require(remainingFreeEggs[currentTimeSlot] > 0);
remainingFreeEggs[currentTimeSlot] -= 1;
eggOwners[msg.sender] = true;
LogEggAcquisition(msg.sender, now);
}
| 8,656 |
171 | // Credits accumulated fees to a user's position/self The individual position to update/liquidityDelta The change in pool liquidity as a result of the position update/feeGrowthInside0X128 The all-time fee growth in token0, per unit of liquidity, inside the position's tick boundaries/feeGrowthInside1X128 The all-time fee growth in token1, per unit of liquidity, inside the position's tick boundaries | function update(
Info storage self,
int128 liquidityDelta,
uint256 feeGrowthInside0X128,
uint256 feeGrowthInside1X128
| function update(
Info storage self,
int128 liquidityDelta,
uint256 feeGrowthInside0X128,
uint256 feeGrowthInside1X128
| 76,267 |
339 | // Retrieves the whole Request record posted to the Witnet Request Board./Fails if the `_queryId` is not valid or, if it has been deleted,/or if the related script bytecode got changed after being posted./_queryId The unique identifier of a previously posted query. | function readRequest(uint256 _queryId)
external view
override
notDeleted(_queryId)
returns (Witnet.Request memory)
| function readRequest(uint256 _queryId)
external view
override
notDeleted(_queryId)
returns (Witnet.Request memory)
| 28,929 |
13 | // msg.value contains amount of money a caller sent in the transaction in order to call the "contribute" function | require(msg.value >= minimumContribution);
| require(msg.value >= minimumContribution);
| 20,007 |
377 | // Mint token and set token URI | _safeMint(_beneficiary, tokenId);
_setTokenURI(tokenId, metadataList[_randomIndex]);
emit DigitalaxPodePortalMinted(tokenId, _beneficiary, metadataList[_randomIndex]);
return tokenId;
| _safeMint(_beneficiary, tokenId);
_setTokenURI(tokenId, metadataList[_randomIndex]);
emit DigitalaxPodePortalMinted(tokenId, _beneficiary, metadataList[_randomIndex]);
return tokenId;
| 40,845 |
85 | // Writes the implementation hook of a signature _signature Signature function _implementation Hook implementation contract/ | function _writeHook(bytes4 _signature, address _implementation) private {
bytes32 key = keccak256(abi.encode(_signature, HOOKS_KEY));
_writeBytes32(key, bytes32(uint256(_implementation)));
}
| function _writeHook(bytes4 _signature, address _implementation) private {
bytes32 key = keccak256(abi.encode(_signature, HOOKS_KEY));
_writeBytes32(key, bytes32(uint256(_implementation)));
}
| 33,971 |
62 | // Calculate how much the user is allowed to withdraw given their debt was repaid | Amount.Principal memory collateralDelta = calculateCollateralDelta(
position.collateralAmount,
position.borrowedAmount.calculateAdjusted(borrowIndex),
currentPrice
);
| Amount.Principal memory collateralDelta = calculateCollateralDelta(
position.collateralAmount,
position.borrowedAmount.calculateAdjusted(borrowIndex),
currentPrice
);
| 13,290 |
14 | // Emitted when an `amount` of tokens is burned. / | event Burned(uint amount);
| event Burned(uint amount);
| 30,826 |
24 | // Revert if xx + half overflowed. | if lt(xxRound, xx) {
revert(0, 0)
}
| if lt(xxRound, xx) {
revert(0, 0)
}
| 18,282 |
153 | // Checks to see if two dogs can breed together, including checks for/ownership and siring approvals. Does NOT check that both dogs are ready for/breeding (i.e. breedWith could still fail until the cooldowns are finished)./TODO: Shouldn't this check pregnancy and cooldowns?!?/_matronId The ID of the proposed matron./_sireId The ID of the proposed sire. | function canBreedWith(uint256 _matronId, uint256 _sireId)
external
view
returns(bool)
| function canBreedWith(uint256 _matronId, uint256 _sireId)
external
view
returns(bool)
| 20,829 |
47 | // If the first argument of 'require' evaluates to 'false', execution terminates and all changes to the state and to Ether balances are reverted. This used to consume all gas in old EVM versions, but not anymore. It is often a good idea to use 'require' to check if functions are called correctly. As a second argument, you can also provide an explanation about what went wrong. | require(msg.sender == owner, "Caller is not owner");
_;
| require(msg.sender == owner, "Caller is not owner");
_;
| 1,253 |
0 | // bytes4(keccak256("execute(address,bytes)")) | bytes4 public constant FUNCTION_SIG_EXECUTE = 0x1cff79cd;
constructor(address payable _owner)
public
DestructibleAction(_owner)
DelegateCallAction()
| bytes4 public constant FUNCTION_SIG_EXECUTE = 0x1cff79cd;
constructor(address payable _owner)
public
DestructibleAction(_owner)
DelegateCallAction()
| 26,297 |
160 | // Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) bypresenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't/ Sets `value` as the allowance of `spender` over ``owner``'s tokens,given ``owner``'s signed approval. IMPORTANT: The same issues {IERC20-approve} has related to transactionordering also apply here. Emits an {Approval} event. Requirements: - `spender` cannot be the zero address.- `deadline` must be a timestamp in the future.- `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`over the EIP712-formatted function arguments.- the signature must use ``owner``'s current | function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
| function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
| 18,123 |
3 | // 定义一个调用AddressList的合约 | contract MockStringUtils {
using StringUtils for string;
using StringUtils for StringUtils.slice;
function toSlice(string _str) public pure returns (StringUtils.slice memory) {
return _str.toSlice();
}
function len(string _str) public pure returns (uint256) {
return _str.toSlice().len();
}
function copy(string _str) public pure returns (StringUtils.slice memory) {
return _str.toSlice().copy();
}
}
| contract MockStringUtils {
using StringUtils for string;
using StringUtils for StringUtils.slice;
function toSlice(string _str) public pure returns (StringUtils.slice memory) {
return _str.toSlice();
}
function len(string _str) public pure returns (uint256) {
return _str.toSlice().len();
}
function copy(string _str) public pure returns (StringUtils.slice memory) {
return _str.toSlice().copy();
}
}
| 22,009 |
21 | // Balance is implicitly checked with SafeMath's underflow protection | balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
| balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
| 38,537 |
194 | // checks if the tokenId exists | modifier onlyValidTokenId(uint256 _tokenId)
| modifier onlyValidTokenId(uint256 _tokenId)
| 58,403 |
366 | // verify an amount is set | require(_amount > 0, "zero amount");
| require(_amount > 0, "zero amount");
| 68,091 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.