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
16
// Gas Costs - Process gas cost
uint256 private constant PROCESS_COST = 65990;
uint256 private constant PROCESS_COST = 65990;
66,726
6
// 0x1626ba7e is the interfaceId for signature contracts (see IERC1271)
return (IERC1271(signer).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, digest);
return (IERC1271(signer).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, digest);
30,822
50
// Contract initialization name the chosen name for this NFT symbol the chosen symbol (Ticker) for this NFT source - The address of the Original ERC1155 NFT Wrapped in this collection supportsSpecificName - Set to true if the given source NFT supports the 'name(uint256)' function. supportsSpecificSymbol - Set to true if the given source NFT supports the 'symbol(uint256)' function. supportsSpecificDecimals - Set to true if the given source NFT supports the 'decimals(uint256)' function. /
function init( address source, string calldata name, string calldata symbol, bool supportsSpecificName, bool supportsSpecificSymbol, bool supportsSpecificDecimals ) external;
function init( address source, string calldata name, string calldata symbol, bool supportsSpecificName, bool supportsSpecificSymbol, bool supportsSpecificDecimals ) external;
44,052
0
// Interface of the ERC165 standard, as defined in the Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
* queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
3,149
6
// Emitted when apply withdraw
event ApplyWithdraw(address indexed user,uint256 amount, uint256 time); using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public lockDownDuration = 5 seconds; uint256 public totalStakes ;
event ApplyWithdraw(address indexed user,uint256 amount, uint256 time); using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public rewardsToken; IERC20 public stakingToken; uint256 public lockDownDuration = 5 seconds; uint256 public totalStakes ;
20,092
286
// Count stones and find empty territories
for (uint8 position = 0; position < BOARD_SIZE; position++) { if (PlayerColor(board.positionToColor[position]) == PlayerColor.Black) { blackScore++; } else if (PlayerColor(board.positionToColor[position]) == PlayerColor.White) {
for (uint8 position = 0; position < BOARD_SIZE; position++) { if (PlayerColor(board.positionToColor[position]) == PlayerColor.Black) { blackScore++; } else if (PlayerColor(board.positionToColor[position]) == PlayerColor.White) {
33,196
79
// Devevloper's cut which is left in contract and accesed by `withdrawAll` and `withdrawAmountTo` methods.
uint256 devCut = ceil(calculateDevCut(price)); uint256 firstCut = ceil(calculateFirstCut(price));
uint256 devCut = ceil(calculateDevCut(price)); uint256 firstCut = ceil(calculateFirstCut(price));
15,601
3
// harvest low order bytes of 5 Blum Blum Shubs for 5-word log output
for (uint k = 0; k < 5; ++k) { uint sqr = shub[k]; sqr *= sqr; sqr %= blum; shub[k] = sqr; out[k] |= (sqr & 255) << j; }
for (uint k = 0; k < 5; ++k) { uint sqr = shub[k]; sqr *= sqr; sqr %= blum; shub[k] = sqr; out[k] |= (sqr & 255) << j; }
23,914
65
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
if (_currentIndex != startTokenId) revert();
2,392
125
// Execute order
(, , , bytes memory signature) = __decodeZeroExOrderArgs(encodedZeroExOrderArgs); IZeroExV2(EXCHANGE).fillOrder(order, takerAssetFillAmount, signature);
(, , , bytes memory signature) = __decodeZeroExOrderArgs(encodedZeroExOrderArgs); IZeroExV2(EXCHANGE).fillOrder(order, takerAssetFillAmount, signature);
25,426
303
// _tokenOwners.set(tokenId, to);
_tokenIdTracker.increment();
_tokenIdTracker.increment();
17,137
6
// Returns the default royalty recipient and bps.
function getDefaultRoyaltyInfo() external view override returns (address, uint16) { return (royaltyRecipient, uint16(royaltyBps)); }
function getDefaultRoyaltyInfo() external view override returns (address, uint16) { return (royaltyRecipient, uint16(royaltyBps)); }
36,035
7
// Allow you to buy asset on our website_nftId The Id of the NFT you are trying to upgrade_price The price paid for the different assets/
function buyAsset(uint256 _nftId, uint _price) external payable { require(!paused, "The smart contract is paused"); // is the smart contract paused? require(ownerOf(_nftId)==msg.sender, "This nft does not belong to you"); // are you the owner of this NFT? require(msg.value >= _price, "You didn't sent enough funds"); // have you sent the right price? emit AssetBougth(msg.sender, _nftId, _price); // Emits event that will be double check by the website to prove that you passed all previous verification so that we can upload your NFT image }
function buyAsset(uint256 _nftId, uint _price) external payable { require(!paused, "The smart contract is paused"); // is the smart contract paused? require(ownerOf(_nftId)==msg.sender, "This nft does not belong to you"); // are you the owner of this NFT? require(msg.value >= _price, "You didn't sent enough funds"); // have you sent the right price? emit AssetBougth(msg.sender, _nftId, _price); // Emits event that will be double check by the website to prove that you passed all previous verification so that we can upload your NFT image }
4,524
98
// TODO: Should add a new `rewardRate()` like function to call `getFixedRewardRatePerToken(uint256 _timestamp)`?
// function rewardRate() public view returns (uint256) { // return getFixedRewardRate(block.timestamp); // }
// function rewardRate() public view returns (uint256) { // return getFixedRewardRate(block.timestamp); // }
40,922
1
// this is a dinamic array because can change of size accord to the input
People[] public people;
People[] public people;
24,872
35
// calculate the number of liquidity tokens to return to user using:
liquidityTokenQty = calculateLiquidityTokenQtyForSingleAssetEntryWithQuoteTokenDecay( _baseTokenReserveQty, _totalSupplyOfLiquidityTokens, baseTokenQty, _internalBalances.baseTokenReserveQty );
liquidityTokenQty = calculateLiquidityTokenQtyForSingleAssetEntryWithQuoteTokenDecay( _baseTokenReserveQty, _totalSupplyOfLiquidityTokens, baseTokenQty, _internalBalances.baseTokenReserveQty );
39,494
1
// Mapping of Txn IDs to Transaction objects
mapping (uint => Transaction) public transactions;
mapping (uint => Transaction) public transactions;
23,971
640
// approve canonical token so swapBridgeForCanonical can work. or we approve before call it in mint w/ added gas
function approveCanonical() external onlyOwner { _approve(address(this), canonical, type(uint256).max); }
function approveCanonical() external onlyOwner { _approve(address(this), canonical, type(uint256).max); }
5,384
211
// returns the amount of address in the reservation
function getReservationAddressCount() public view returns (uint256) { return reservationAllowedCount; }
function getReservationAddressCount() public view returns (uint256) { return reservationAllowedCount; }
82,521
40
// returns the uri for a given tokenconsists of a concatenation of baseUri and uriId tokenId tokenId for which the uri should be retrieved /
function uri(uint256 tokenId) public view virtual override returns (string memory)
function uri(uint256 tokenId) public view virtual override returns (string memory)
29,052
38
// Returns an array of tokens and amounts available for claim/_tokenAddress The address of erc20 token/_claimExtraRewards True if it should claim the extra rewards from convex/ return _rewards The array of tokens and amount available for claim
function claimableRewards( address _tokenAddress, bool _claimExtraRewards ) external view returns (Reward[] memory _rewards);
function claimableRewards( address _tokenAddress, bool _claimExtraRewards ) external view returns (Reward[] memory _rewards);
27,956
246
// ------Variables----
mapping (uint256 => bool) public mutationStatus; mapping (uint256 => MutationDetails) public mutationDetails; mapping (uint256 => bool) public mutation; mapping (address => bool) public genesisTrasnsferer;
mapping (uint256 => bool) public mutationStatus; mapping (uint256 => MutationDetails) public mutationDetails; mapping (uint256 => bool) public mutation; mapping (address => bool) public genesisTrasnsferer;
24,048
1
// Check if the deposit contract supports the new token
if (S.depositContract != IDepositContract(0)) { require(S.depositContract.isTokenSupported(tokenAddress), "UNSUPPORTED_TOKEN"); }
if (S.depositContract != IDepositContract(0)) { require(S.depositContract.isTokenSupported(tokenAddress), "UNSUPPORTED_TOKEN"); }
27,504
23
//
function tokenMetadata(uint256 _tokenId) public view returns (string infoUrl)
function tokenMetadata(uint256 _tokenId) public view returns (string infoUrl)
31,396
206
// pay outstanding interest to lender
_payInterest( loanLocal.lender, loanParamsLocal.loanToken ); LoanInterest storage loanInterestLocal = loanInterest[loanLocal.id]; LenderInterest storage lenderInterestLocal = lenderInterest[loanLocal.lender][loanParamsLocal.loanToken]; uint256 maxLoanTerm = loanParamsLocal.maxLoanTerm;
_payInterest( loanLocal.lender, loanParamsLocal.loanToken ); LoanInterest storage loanInterestLocal = loanInterest[loanLocal.id]; LenderInterest storage lenderInterestLocal = lenderInterest[loanLocal.lender][loanParamsLocal.loanToken]; uint256 maxLoanTerm = loanParamsLocal.maxLoanTerm;
25,668
9
// Function for owner to create a new vesting slot. _vestingStartTime Time in epoch, at which vestings created in this slot will start. _vestingDuration Duration in epoch, for all vestings created in this slot. /
function createVestingSlot( uint256 _vestingStartTime, uint256 _vestingDuration
function createVestingSlot( uint256 _vestingStartTime, uint256 _vestingDuration
8,218
44
// If BITX is given to the contract, that amount in BXTG will be given to the next buyer since we have no idea who gave us the BITX.
uint256 tokensGiven, address indexed referrer, uint8 indexed bitFlags // 1 = invalidMasternode, 2 = usedBITXsMasternode, 4 = reinvestment ); event onTokenSell( address indexed accountHolder, uint256 tokensDestroyed, uint256 ethereumEarned ); event onWithdraw(
uint256 tokensGiven, address indexed referrer, uint8 indexed bitFlags // 1 = invalidMasternode, 2 = usedBITXsMasternode, 4 = reinvestment ); event onTokenSell( address indexed accountHolder, uint256 tokensDestroyed, uint256 ethereumEarned ); event onWithdraw(
21,460
214
// FL Initiator must be this contract
error UntrustedInitiator();
error UntrustedInitiator();
17,732
18
// Function to set number of excuses for post violations/This function can be accessed by the user with role ADMIN
function setNumberOfExcuses(uint256 _excuses) public onlyRole(DEFAULT_ADMIN_ROLE)
function setNumberOfExcuses(uint256 _excuses) public onlyRole(DEFAULT_ADMIN_ROLE)
23,684
17
// Burns tokens from an address/_account The account to burn from/_amount The amount of token to burn
function burn(address _account, uint256 _amount) external override onlyMintAuthority
function burn(address _account, uint256 _amount) external override onlyMintAuthority
11,334
39
// Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction
require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "Hash has not been approved");
require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "Hash has not been approved");
21,918
15
// Store the amount of ETH deposited by each account.
mapping (address => uint256) public balances; mapping (address => uint256) public balances_bonus;
mapping (address => uint256) public balances; mapping (address => uint256) public balances_bonus;
28,990
215
// address of appointed talent agent
address appointedAgent;
address appointedAgent;
13,434
13
// The number of epochs to pass before the bet becomes refundable
uint constant internal REFUNDABLE_BET_EPOCHS_DISTANCE = 2;
uint constant internal REFUNDABLE_BET_EPOCHS_DISTANCE = 2;
17,842
2
// The allowance has underflowed.
error AllowanceUnderflow();
error AllowanceUnderflow();
19,118
121
// 10%, 30%, 60%
uint256[3] private rewardPercentages = [10, 30, 60];
uint256[3] private rewardPercentages = [10, 30, 60];
19,368
190
// Handle back interest: calculates interest owned since the loan endtime passed but the loan remained open
uint256 backInterestTime; uint256 backInterestOwed; if (block.timestamp > loanLocal.endTimestamp) { backInterestTime = block.timestamp .sub(loanLocal.endTimestamp); backInterestOwed = backInterestTime .mul(loanInterestLocal.owedPerDay); backInterestOwed = backInterestOwed .div(24 hours); }
uint256 backInterestTime; uint256 backInterestOwed; if (block.timestamp > loanLocal.endTimestamp) { backInterestTime = block.timestamp .sub(loanLocal.endTimestamp); backInterestOwed = backInterestTime .mul(loanInterestLocal.owedPerDay); backInterestOwed = backInterestOwed .div(24 hours); }
40,992
4
// Calls the initialize function./_dao The managing DAO./_name The name of the [ERC-20](https:eips.ethereum.org/EIPS/eip-20) governance token./_symbol The symbol of the [ERC-20](https:eips.ethereum.org/EIPS/eip-20) governance token./_mintSettings The token mint settings struct containing the `receivers` and `amounts`.
constructor( IDAO _dao, string memory _name, string memory _symbol, MintSettings memory _mintSettings
constructor( IDAO _dao, string memory _name, string memory _symbol, MintSettings memory _mintSettings
12,011
52
// add x^27(33! / 27!)
xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000001b29340;
xi = (xi * _x) >> _precision; res += xi * 0x0000000000000000000000001b29340;
7,358
3
// presale is only for whitelist members
require(!presale || whitelisted[msg.sender], "We are currently in presale, which is only for whitelisted members!");
require(!presale || whitelisted[msg.sender], "We are currently in presale, which is only for whitelisted members!");
81,385
6
// See {IAdminControl-approveAdmin}. /
function approveAdmin(address admin) external override onlyOwner { if (!_admins.contains(admin)) { emit AdminApproved(admin, msg.sender); _admins.add(admin); }
function approveAdmin(address admin) external override onlyOwner { if (!_admins.contains(admin)) { emit AdminApproved(admin, msg.sender); _admins.add(admin); }
30,540
165
// Maps total amount staked per address
mapping(address => uint) public totalStaked;
mapping(address => uint) public totalStaked;
49,049
57
// Compute and transfer the net gage deposit + any rewards due to the receiver
uint256 eternalRewards = amountETRNL > dAmount ? amountETRNL - dAmount : 0; uint256 eternalFee = eternalStorage.getUint(entity, feeRate) * providedAsset / (10 ** 5); if (winner) { require(eternal.transfer(receiver, amountETRNL * dRisk / (10 ** 4)), "Failed to transfer ETRNL reward");
uint256 eternalRewards = amountETRNL > dAmount ? amountETRNL - dAmount : 0; uint256 eternalFee = eternalStorage.getUint(entity, feeRate) * providedAsset / (10 ** 5); if (winner) { require(eternal.transfer(receiver, amountETRNL * dRisk / (10 ** 4)), "Failed to transfer ETRNL reward");
32,052
742
// New query, enqueue it for review.
queryIndices[identifier][time][ancillaryData] = QueryIndex(true, requestedPrices.length); requestedPrices.push(QueryPoint(identifier, time, ancillaryData));
queryIndices[identifier][time][ancillaryData] = QueryIndex(true, requestedPrices.length); requestedPrices.push(QueryPoint(identifier, time, ancillaryData));
30,402
54
// Called by the bridge node processes on startup/ to determine early whether the address pointing to the main/ bridge contract is misconfigured./ so we can provide a helpful error message instead of the very/ unhelpful errors encountered otherwise.
function isMainBridgeContract() public pure returns (bool) { return true; }
function isMainBridgeContract() public pure returns (bool) { return true; }
38,185
1
// Produces the URI describing a particular stream NFT./This is a data URI with the JSON contents directly inlined./sablier The address of the Sablier contract the stream was created in./streamId The id of the stream for which to produce a description./ return uri The URI of the ERC721-compliant metadata.
function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);
function tokenURI(IERC721Metadata sablier, uint256 streamId) external view returns (string memory uri);
31,221
367
// Validates that the provided bid shares sum to 100 /
function isValidBidShares(BidShares memory bidShares) public pure override returns (bool)
function isValidBidShares(BidShares memory bidShares) public pure override returns (bool)
22,018
135
// now add the new address.
nextGeneration.members.length += 1; nextGeneration.members[nextGeneration.members.length - 1] = resourceAddress; return nextGenerationId;
nextGeneration.members.length += 1; nextGeneration.members[nextGeneration.members.length - 1] = resourceAddress; return nextGenerationId;
50,603
0
// hooks token controller to token contract and allows to replace it
contract ITokenControllerHook { //////////////////////// // Events //////////////////////// event LogChangeTokenController( address oldController, address newController, address by ); //////////////////////// // Public functions //////////////////////// /// @notice replace current token controller /// @dev please note that this process is also controlled by existing controller function changeTokenController(address newController) public; /// @notice returns current controller function tokenController() public constant returns (address currentController); }
contract ITokenControllerHook { //////////////////////// // Events //////////////////////// event LogChangeTokenController( address oldController, address newController, address by ); //////////////////////// // Public functions //////////////////////// /// @notice replace current token controller /// @dev please note that this process is also controlled by existing controller function changeTokenController(address newController) public; /// @notice returns current controller function tokenController() public constant returns (address currentController); }
37,298
34
// get the staking epoch which is 1 epoch more
function _stakingEpochId(uint128 epochId) internal pure returns (uint128) { return epochId + 1; }
function _stakingEpochId(uint128 epochId) internal pure returns (uint128) { return epochId + 1; }
25,254
13
// -check if end of the round
if(nb_player[zone_selected] == 3){ //end of a round EndRound(zone_selected); }
if(nb_player[zone_selected] == 3){ //end of a round EndRound(zone_selected); }
865
27
// Hard coded value to limit amount of asset in a single LN OLA_ADDITIONS: This field
uint internal constant maxAllowedAssets = 25;
uint internal constant maxAllowedAssets = 25;
26,225
288
// Set merkeleroot once it's calculated/
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner { merkleRoot = _merkleRoot; wlUsedRound++; }
function setMerkleRoot(bytes32 _merkleRoot) public onlyOwner { merkleRoot = _merkleRoot; wlUsedRound++; }
78,704
31
// floor to 0
val_ = val_.subFloor(posDebt + posOiCurrent.mulUp(posEntryPrice));
val_ = val_.subFloor(posDebt + posOiCurrent.mulUp(posEntryPrice));
29,565
4
// For this example, retrieve 1 random value in one request. Cannot exceed VRFCoordinatorV2.MAX_NUM_WORDS.
uint32 numWords = 1;
uint32 numWords = 1;
38,938
23
// Mask arbitrary poem to keep opposite half
bytes32 keep2 = poems[arbitraryMate] & tempMask2;
bytes32 keep2 = poems[arbitraryMate] & tempMask2;
56,065
5
// Lock the ppay in the contract
ppay.transferFrom(msg.sender, address(this), _amount); startTime[msg.sender] = block.timestamp;
ppay.transferFrom(msg.sender, address(this), _amount); startTime[msg.sender] = block.timestamp;
47,535
59
// maximum size of trade from first token to second token
function maxSize( address firstToken, address secondToken ) public view returns ( uint ) { return maxCanAdd( firstToken ).add( maxCanRemove( secondToken ) ); }
function maxSize( address firstToken, address secondToken ) public view returns ( uint ) { return maxCanAdd( firstToken ).add( maxCanRemove( secondToken ) ); }
32,181
186
// GluonView//view of current app data//appId index of the provisioned app in question/ return current address of the app's current contract/ return proposal address of the app's pending proposal contract (if any)/ return activationBlock the block in which the proposal can be activated
function app(uint32 appId) external view returns (address current, address proposal, uint activationBlock) { App storage app_ = apps[appId]; current = app_.history[app_.history.length - 1]; proposal = app_.proposal; activationBlock = app_.activationBlock; }
function app(uint32 appId) external view returns (address current, address proposal, uint activationBlock) { App storage app_ = apps[appId]; current = app_.history[app_.history.length - 1]; proposal = app_.proposal; activationBlock = app_.activationBlock; }
35,366
296
// update block price
if (blockSetPrice_[blockID_] == 0){ blockSetPrice_[blockID_] = Cons.setCheckPriceInitial_; changedBlockID_.push(blockID_); }else{
if (blockSetPrice_[blockID_] == 0){ blockSetPrice_[blockID_] = Cons.setCheckPriceInitial_; changedBlockID_.push(blockID_); }else{
37,007
23
// Get the underlying balance on the lending protocol/
function availableLiquidity(address token_) external override view
function availableLiquidity(address token_) external override view
47,906
167
// Creator of the proposal
address proposer;
address proposer;
55,652
33
// Internal method authorizing the upgrade of the contract via the [upgradeability mechanism for UUPS proxies](https:docs.openzeppelin.com/contracts/4.x/api/proxyUUPSUpgradeable) (see [ERC-1822](https:eips.ethereum.org/EIPS/eip-1822))./The caller must have the `UPGRADE_DAO_PERMISSION_ID` permission.
function _authorizeUpgrade(address) internal virtual override auth(UPGRADE_DAO_PERMISSION_ID) {} /// @inheritdoc IDAO function setTrustedForwarder( address _newTrustedForwarder ) external override auth(SET_TRUSTED_FORWARDER_PERMISSION_ID) { _setTrustedForwarder(_newTrustedForwarder); }
function _authorizeUpgrade(address) internal virtual override auth(UPGRADE_DAO_PERMISSION_ID) {} /// @inheritdoc IDAO function setTrustedForwarder( address _newTrustedForwarder ) external override auth(SET_TRUSTED_FORWARDER_PERMISSION_ID) { _setTrustedForwarder(_newTrustedForwarder); }
24,908
148
// local accounting
uint256 prizeValue;
uint256 prizeValue;
14,952
25
// add invoice
invoices[pool][invoiceId] = info; lastInvoiceIdForPool[pool]++; uint256 index = registry.service().addInvoiceEvent(pool, invoiceId); eventIndex[pool][invoiceId] = index; emit InvoiceCreated(pool, invoiceId); registry.log( msg.sender,
invoices[pool][invoiceId] = info; lastInvoiceIdForPool[pool]++; uint256 index = registry.service().addInvoiceEvent(pool, invoiceId); eventIndex[pool][invoiceId] = index; emit InvoiceCreated(pool, invoiceId); registry.log( msg.sender,
31,470
41
// Execute a voted proposal
function execute(uint256 proposalId) external onlyOwner returns (bool) { Proposal memory currentProposal = _proposalStorage[proposalId]; require(block.timestamp > _proposalStorage[proposalId].expired, "MultiSig: Voting period wasn't over"); require(currentProposal.vote >= int256(_ownerCount / 2), 'MultiSig: Vote was not pass threshold'); require(currentProposal.executed == false, 'MultiSig: Proposal was executed'); if (currentProposal.delegate) { currentProposal.target.functionDelegateCall(currentProposal.data); } else { if (currentProposal.target.isContract()) { currentProposal.target.functionCallWithValue(currentProposal.data, currentProposal.value); } else { payable(address(currentProposal.target)).transfer(currentProposal.value); } } currentProposal.executed = true; _proposalStorage[proposalId] = currentProposal; emit ExecuteProposal(proposalId, msg.sender, currentProposal.vote); return true; }
function execute(uint256 proposalId) external onlyOwner returns (bool) { Proposal memory currentProposal = _proposalStorage[proposalId]; require(block.timestamp > _proposalStorage[proposalId].expired, "MultiSig: Voting period wasn't over"); require(currentProposal.vote >= int256(_ownerCount / 2), 'MultiSig: Vote was not pass threshold'); require(currentProposal.executed == false, 'MultiSig: Proposal was executed'); if (currentProposal.delegate) { currentProposal.target.functionDelegateCall(currentProposal.data); } else { if (currentProposal.target.isContract()) { currentProposal.target.functionCallWithValue(currentProposal.data, currentProposal.value); } else { payable(address(currentProposal.target)).transfer(currentProposal.value); } } currentProposal.executed = true; _proposalStorage[proposalId] = currentProposal; emit ExecuteProposal(proposalId, msg.sender, currentProposal.vote); return true; }
7,753
17
// require (isArtist(), "user is not an artist"); does not work
require (artists[msg.sender].enabled, "user is not an artist"); _;
require (artists[msg.sender].enabled, "user is not an artist"); _;
9,387
10
// Check for truncated codepoints
if (l > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; }
if (l > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; }
15,772
56
// Otherwise, between 0 and 255 tokens in this word are finalized; form a mask of their indices. (This subtraction doesn't underflow because the shift produces a nonzero value, given the bounds on `_numFinalizedSinceStartOfWord`.)
return (1 << _numFinalizedSinceStartOfWord) - 1;
return (1 << _numFinalizedSinceStartOfWord) - 1;
27,804
2
// Period in blocks that an update deployer cut operation is delayed./ Must be greater than funding round block diff in order/ to prevent manipulation around a funding round
uint256 private deployerCutLockupDuration;
uint256 private deployerCutLockupDuration;
9,742
70
// Approved rebaser for this contract /
address public rebaser;
address public rebaser;
26,430
95
// Look up how much the spender or contract is allowed to spend? _owner address _spender party approved for transfering funds return the allowed amount _spender can spend of _owner&39;s balance/
function allowance(address _owner, address _spender) public constant returns (uint) { return drct.allowance(_owner,_spender); }
function allowance(address _owner, address _spender) public constant returns (uint) { return drct.allowance(_owner,_spender); }
21,352
13
// Functions use i++ because overflowing a uint256 by iteration isn't a concern
library UIntArrayUtils { function map(uint256[] memory A, function(uint256) pure returns (uint256) fn) internal pure returns (uint256[] memory) { uint256[] memory mapped = new uint256[](A.length); for (uint256 i = 0; i < A.length; i++) { mapped[i] = fn(A[i]); } return mapped; } function reduce(uint256[] memory A, function(uint256, uint256) pure returns (uint256) fn) internal pure returns (uint256) { uint256 reduced = A[0]; for (uint256 i = 1; i < A.length; i++) { reduced = fn(reduced, A[i]); } return reduced; } /** * Looks through each value in the list, returning an array of all the values that pass a truth test (predicate). */ function filter(uint256[] memory A, function(uint256) pure returns (bool) predicate) internal pure returns (uint256[] memory) { bool[] memory includeMap = new bool[](A.length); uint256 count = 0; for (uint256 i = 0; i < A.length; i++) { if (predicate(A[i])) { includeMap[i] = true; count++; } } uint256[] memory filtered = new uint256[](count); uint256 j = 0; for (i = 0; i < A.length; i++) { if (includeMap[i]) { filtered[j] = A[i]; j++; } } return filtered; } function argFilter(uint256[] memory A, function(uint256) pure returns (bool) predicate) internal pure returns (uint256[] memory) { bool[] memory includeMap = new bool[](A.length); uint256 count = 0; for (uint256 i = 0; i < A.length; i++) { if (predicate(A[i])) { includeMap[i] = true; count++; } } uint256[] memory indexArray = new uint256[](count); uint256 j = 0; for (i = 0; i < A.length; i++) { if (includeMap[i]) { indexArray[j] = i; j++; } } return indexArray; } // https://docs.scipy.org/doc/numpy-1.14.0/user/basics.indexing.html#index-arrays function argGet(uint256[] memory A, uint256[] memory indexArray) internal pure returns (uint256[] memory) { uint256[] memory array = new uint256[](indexArray.length); for (uint256 i = 0; i < indexArray.length; i++) { array[i] = A[indexArray[i]]; } return array; } /** * @return Returns index and isIn for the first occurrence starting from index 0 */ function indexOf(uint256[] memory A, uint256 a) internal returns (uint256, bool) { uint256 length = A.length; for (uint256 i = 0; i < length; i++) { if (A[i] == a) { return (i, true); } } return (0, false); } function sPop(uint256[] storage A, uint256 index) internal returns (uint256) { uint256 length = A.length; if (index >= length) { revert("Error: index out of bounds"); } uint256 entry = A[index]; for (uint256 i = index; i < length - 1; i++) { A[i] = A[i + 1]; } A.length--; return entry; } function sPopCheap(uint256[] storage A, uint256 index) internal returns (uint256) { uint256 length = A.length; if (index >= length) { revert("Error: index out of bounds"); } uint256 entry = A[index]; if (index != length - 1) { A[index] = A[length - 1]; delete A[length - 1]; } A.length--; return entry; } function isEqual(uint256[] A, uint256[] B) internal pure returns (bool) { if (A.length != B.length) { return false; } for (uint256 i = 0; i < A.length; i++) { if (A[i] != B[i]) { return false; } } return true; } function equal(uint256[] A, uint256[] B) internal pure returns (bool) { return isEqual(A, B); } function eq(uint256[] A, uint256[] B) internal pure returns (bool) { return isEqual(A, B); } }
library UIntArrayUtils { function map(uint256[] memory A, function(uint256) pure returns (uint256) fn) internal pure returns (uint256[] memory) { uint256[] memory mapped = new uint256[](A.length); for (uint256 i = 0; i < A.length; i++) { mapped[i] = fn(A[i]); } return mapped; } function reduce(uint256[] memory A, function(uint256, uint256) pure returns (uint256) fn) internal pure returns (uint256) { uint256 reduced = A[0]; for (uint256 i = 1; i < A.length; i++) { reduced = fn(reduced, A[i]); } return reduced; } /** * Looks through each value in the list, returning an array of all the values that pass a truth test (predicate). */ function filter(uint256[] memory A, function(uint256) pure returns (bool) predicate) internal pure returns (uint256[] memory) { bool[] memory includeMap = new bool[](A.length); uint256 count = 0; for (uint256 i = 0; i < A.length; i++) { if (predicate(A[i])) { includeMap[i] = true; count++; } } uint256[] memory filtered = new uint256[](count); uint256 j = 0; for (i = 0; i < A.length; i++) { if (includeMap[i]) { filtered[j] = A[i]; j++; } } return filtered; } function argFilter(uint256[] memory A, function(uint256) pure returns (bool) predicate) internal pure returns (uint256[] memory) { bool[] memory includeMap = new bool[](A.length); uint256 count = 0; for (uint256 i = 0; i < A.length; i++) { if (predicate(A[i])) { includeMap[i] = true; count++; } } uint256[] memory indexArray = new uint256[](count); uint256 j = 0; for (i = 0; i < A.length; i++) { if (includeMap[i]) { indexArray[j] = i; j++; } } return indexArray; } // https://docs.scipy.org/doc/numpy-1.14.0/user/basics.indexing.html#index-arrays function argGet(uint256[] memory A, uint256[] memory indexArray) internal pure returns (uint256[] memory) { uint256[] memory array = new uint256[](indexArray.length); for (uint256 i = 0; i < indexArray.length; i++) { array[i] = A[indexArray[i]]; } return array; } /** * @return Returns index and isIn for the first occurrence starting from index 0 */ function indexOf(uint256[] memory A, uint256 a) internal returns (uint256, bool) { uint256 length = A.length; for (uint256 i = 0; i < length; i++) { if (A[i] == a) { return (i, true); } } return (0, false); } function sPop(uint256[] storage A, uint256 index) internal returns (uint256) { uint256 length = A.length; if (index >= length) { revert("Error: index out of bounds"); } uint256 entry = A[index]; for (uint256 i = index; i < length - 1; i++) { A[i] = A[i + 1]; } A.length--; return entry; } function sPopCheap(uint256[] storage A, uint256 index) internal returns (uint256) { uint256 length = A.length; if (index >= length) { revert("Error: index out of bounds"); } uint256 entry = A[index]; if (index != length - 1) { A[index] = A[length - 1]; delete A[length - 1]; } A.length--; return entry; } function isEqual(uint256[] A, uint256[] B) internal pure returns (bool) { if (A.length != B.length) { return false; } for (uint256 i = 0; i < A.length; i++) { if (A[i] != B[i]) { return false; } } return true; } function equal(uint256[] A, uint256[] B) internal pure returns (bool) { return isEqual(A, B); } function eq(uint256[] A, uint256[] B) internal pure returns (bool) { return isEqual(A, B); } }
38,967
46
// _name = "moonfi";_symbol = "MOON";
_name = "moonfi"; _symbol = "MOON"; _decimals = 18; _totalSupply = 80000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
_name = "moonfi"; _symbol = "MOON"; _decimals = 18; _totalSupply = 80000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
40,922
87
// Updates `owner` s allowance for `spender` based on spent `amount`. Does not update the allowance amount in case of infinite allowance.Revert if not enough allowance is available.
* Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } }
* Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } }
31,412
86
// For debug
trustedSigner[msg.sender]=true;
trustedSigner[msg.sender]=true;
16,340
35
// Trade ETH -> Any
if (etherERC20 == src) { destAmount = _tradeEtherToToken(tradingProxyIndex, srcAmount, dest);
if (etherERC20 == src) { destAmount = _tradeEtherToToken(tradingProxyIndex, srcAmount, dest);
12,138
32
// Emmitted when a contract has been removed to the registry
event AddressRemoved(address indexed _address);
event AddressRemoved(address indexed _address);
9,483
2
// allow contract to receive ether
function () external payable {} function beforeEach() public { // contract to test stores = new Stores(); storeOwnerProxy = new Proxy(stores); buyerProxy = new Proxy(stores); randomProxy = new Proxy(stores); // seed buyers with some funds (in WEI) uint256 seedValue = itemPrice + 1; address(buyerProxy).transfer(seedValue); bool result = stores.addStoreOwner(address(storeOwnerProxy)); Assert.isTrue(result, "Only Admin can add a Store Owner"); }
function () external payable {} function beforeEach() public { // contract to test stores = new Stores(); storeOwnerProxy = new Proxy(stores); buyerProxy = new Proxy(stores); randomProxy = new Proxy(stores); // seed buyers with some funds (in WEI) uint256 seedValue = itemPrice + 1; address(buyerProxy).transfer(seedValue); bool result = stores.addStoreOwner(address(storeOwnerProxy)); Assert.isTrue(result, "Only Admin can add a Store Owner"); }
30,350
95
// Reject a swap with reason. Allows the initialiser to immediately withdraw the funds again sender initialiser of the swap id id of the swap reason reason for rejection delegate only /
function reject(address sender, uint256 id, uint256 expirationBlock, string calldata reason) external onlyDelegate()
function reject(address sender, uint256 id, uint256 expirationBlock, string calldata reason) external onlyDelegate()
36,826
319
// Adds given addresses to the active reporters control list./Can only be called from the owner address./Emits the `ReportersSet` event. /_reporters List of addresses to be added to the active reporters control list.
function setReporters(address[] memory _reporters) public override onlyOwner
function setReporters(address[] memory _reporters) public override onlyOwner
19,953
257
// Gas saving: Use cached totalBalance with accrued interest since last rebalance.
uint256 totalBalance = _totalBalance; uint256 sTokenAmount = _getMintAmount( bTokenAmountNormalized, totalBalance, _getBalance(info), _getSoftWeight(info), _getHardWeight(info) ); return sTokenAmount.mul(totalSupply()).div(totalBalance);
uint256 totalBalance = _totalBalance; uint256 sTokenAmount = _getMintAmount( bTokenAmountNormalized, totalBalance, _getBalance(info), _getSoftWeight(info), _getHardWeight(info) ); return sTokenAmount.mul(totalSupply()).div(totalBalance);
71,061
341
// Keep track of the debt they're about to create
_addToDebtRegister(currencyKey, amount);
_addToDebtRegister(currencyKey, amount);
6,202
1
// Tokens holdtime
uint256 public _holdtime = 1 days;
uint256 public _holdtime = 1 days;
34,995
244
// Emitted when the pause is lifted by a pauser. /
event Unpaused(); bool private _paused; address public pauser;
event Unpaused(); bool private _paused; address public pauser;
39,001
33
// Get address for ChainLink token contract/ChainLink contract method
function getChainlinkToken() public view returns (address tokenAddress) { return chainlinkTokenAddress(); }
function getChainlinkToken() public view returns (address tokenAddress) { return chainlinkTokenAddress(); }
14,443
61
// Store the roll struct - 20k gas.
playerSpins[_tkn.sender] = spin;
playerSpins[_tkn.sender] = spin;
24,138
41
// Mintable token Simple ERC20 Token example, with mintable token creation /
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) public hasMintPermission canMint returns (bool) { _mint(_to, _amount); emit Mint(_to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
contract MintableToken is StandardToken, Ownable { event Mint(address indexed to, uint256 amount); event MintFinished(); bool public mintingFinished = false; modifier canMint() { require(!mintingFinished); _; } modifier hasMintPermission() { require(msg.sender == owner); _; } /** * @dev Function to mint tokens * @param _to The address that will receive the minted tokens. * @param _amount The amount of tokens to mint. * @return A boolean that indicates if the operation was successful. */ function mint( address _to, uint256 _amount ) public hasMintPermission canMint returns (bool) { _mint(_to, _amount); emit Mint(_to, _amount); return true; } /** * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() public onlyOwner canMint returns (bool) { mintingFinished = true; emit MintFinished(); return true; } }
967
78
// INTERNAL FUNCTIONS / Gateway check - did you send exactly the right amount?
function _isCorrectBuyin(uint _buyin) private pure
function _isCorrectBuyin(uint _buyin) private pure
41,837
113
// See {IERC721-setApprovalForAll}. /
function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); }
function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); }
27,258
7
// dev Add an airdrop admin/
function setAirdropAdmin(address _admin, bool _isAdmin) public onlyOwner { airdropAdmins[_admin] = _isAdmin; }
function setAirdropAdmin(address _admin, bool _isAdmin) public onlyOwner { airdropAdmins[_admin] = _isAdmin; }
9,378
8
// We might be getting a refund from Enjin&39;s multisig wallet. It could also be someone who has missed the buy, so we keep track of this as well so that he can safely withdraw. We might get the Enjin refund from another wallet, so this is why we allow this behavior.
balances_after_buy[msg.sender] += msg.value; if (msg.sender == sale && this.balance >= contract_eth_value) { refunded = true; }
balances_after_buy[msg.sender] += msg.value; if (msg.sender == sale && this.balance >= contract_eth_value) { refunded = true; }
42,990
13
// funds to an existing stream.Throws if the caller is not the stream.sender streamId The id of the stream to query. amount deposit amount by stream sender /
function fundStream(uint256 streamId, uint256 amount) public payable nonReentrant streamExists(streamId) returns (bool)
function fundStream(uint256 streamId, uint256 amount) public payable nonReentrant streamExists(streamId) returns (bool)
6,746
0
// Token constructor _name Token name _symbol Token symbol _decimals Token decimals _supply Total supply /
constructor(string memory _name, string memory _symbol, uint _decimals, uint256 _supply) public { name = _name; symbol = _symbol; decimals = _decimals; _mint(msg.sender, _supply); }
constructor(string memory _name, string memory _symbol, uint _decimals, uint256 _supply) public { name = _name; symbol = _symbol; decimals = _decimals; _mint(msg.sender, _supply); }
8,596
7
// Functions/ Initializes approved function hashes and updates the minimum dispute fees /
constructor() { bytes4[10] memory _funcs = [ bytes4(0x3c46a185), // changeControllerContract(address) 0xe8ce51d7, // changeGovernanceContract(address) 0x1cbd3151, // changeOracleContract(address) 0xbd87e0c9, // changeTreasuryContract(address) 0x740358e6, // changeUint(bytes32,uint256) 0x40c10f19, // mint(address,uint256) 0xe48d4b3b, // setApprovedFunction(bytes4,bool) 0x5d183cfa, // changeReportingLock(uint256) 0x6d53585f, // changeTimeBasedReward(uint256) 0x6274885f // issueTreasury(uint256,uint256,uint256) ]; // Approve function hashes and update dispute fee for (uint256 _i = 0; _i < _funcs.length; _i++) { functionApproved[_funcs[_i]] = true; } updateMinDisputeFee(); }
constructor() { bytes4[10] memory _funcs = [ bytes4(0x3c46a185), // changeControllerContract(address) 0xe8ce51d7, // changeGovernanceContract(address) 0x1cbd3151, // changeOracleContract(address) 0xbd87e0c9, // changeTreasuryContract(address) 0x740358e6, // changeUint(bytes32,uint256) 0x40c10f19, // mint(address,uint256) 0xe48d4b3b, // setApprovedFunction(bytes4,bool) 0x5d183cfa, // changeReportingLock(uint256) 0x6d53585f, // changeTimeBasedReward(uint256) 0x6274885f // issueTreasury(uint256,uint256,uint256) ]; // Approve function hashes and update dispute fee for (uint256 _i = 0; _i < _funcs.length; _i++) { functionApproved[_funcs[_i]] = true; } updateMinDisputeFee(); }
5,965
5
// The deposit structure holds all the info about the deposit made
struct Deposit { address depositor; //The depositor address uint128 deposit; //The deposit amount uint128 expect; //How much we should pay out (initially it is 111%-141% of deposit) }
struct Deposit { address depositor; //The depositor address uint128 deposit; //The deposit amount uint128 expect; //How much we should pay out (initially it is 111%-141% of deposit) }
49,615
132
// Create a resolution to update the owner agreement threshold. Performs update if threshold is 1 or zero.
function createResolutionUpdateThreshold(uint160 threshold) public onlyOwners()
function createResolutionUpdateThreshold(uint160 threshold) public onlyOwners()
83,322
4
// Dex Router02 contract interface
interface IDexRouter { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
interface IDexRouter { function factory() external pure returns (address); function WETH() external pure returns (address); function addLiquidityETH( address token, uint256 amountTokenDesired, uint256 amountTokenMin, uint256 amountETHMin, address to, uint256 deadline ) external payable returns ( uint256 amountToken, uint256 amountETH, uint256 liquidity ); function swapExactTokensForETHSupportingFeeOnTransferTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external; }
32,366
410
// LendingPool contract Implements the actions of the LendingPool, and exposes accessory methods to fetch the users and reserve data Aave /
contract LendingPool { /** * @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens) * is minted. * @param _reserve the address of the reserve * @param _amount the amount to be deposited * @param _referralCode integrators are assigned a referral code and can potentially receive rewards. */ function deposit(address _reserve, uint256 _amount, uint16 _referralCode) external payable; }
contract LendingPool { /** * @dev deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens) * is minted. * @param _reserve the address of the reserve * @param _amount the amount to be deposited * @param _referralCode integrators are assigned a referral code and can potentially receive rewards. */ function deposit(address _reserve, uint256 _amount, uint16 _referralCode) external payable; }
2,424
110
// Contract address of the interest setter for this market
address interestSetter;
address interestSetter;
506