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
26
// TEAM
walletsLocking[TEAM].directRelease = true; walletsLocking[TEAM].lockedTokens = 1303625 * 10 ** (decimals); walletsLocking[TEAM].cliff = block.timestamp.add(365 days);
walletsLocking[TEAM].directRelease = true; walletsLocking[TEAM].lockedTokens = 1303625 * 10 ** (decimals); walletsLocking[TEAM].cliff = block.timestamp.add(365 days);
41,467
11
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(_msgSender())); require( MerkleProof.verify(proof, communityMerkleRoot, node), "MerkleDistributor: Invalid proof." ); if (block.timestamp < preMintLimitDate) { require( whitelistMintLog[_msgSender()].add(amount) <= 1, "MonfterMinter: already mint or invalid amount"
bytes32 node = keccak256(abi.encodePacked(_msgSender())); require( MerkleProof.verify(proof, communityMerkleRoot, node), "MerkleDistributor: Invalid proof." ); if (block.timestamp < preMintLimitDate) { require( whitelistMintLog[_msgSender()].add(amount) <= 1, "MonfterMinter: already mint or invalid amount"
31,058
3
// Private method is used instead of inlining into modifier because modifiers are copied into each method,/ and the use of immutable means the address bytes are copied in every place the modifier is used.
function checkNotDelegateCall() private view { require(address(this) == original); }
function checkNotDelegateCall() private view { require(address(this) == original); }
4,281
41
// Get total special pending transaction/
function getTotalPendingTxs() internal view returns (uint32) { uint32 count; TransactionState txState = TransactionState.Pending; for(uint256 i = 0; i < specialTransactions.length; i++) { if(specialTransactions[i].state == txState) count++; } return count; }
function getTotalPendingTxs() internal view returns (uint32) { uint32 count; TransactionState txState = TransactionState.Pending; for(uint256 i = 0; i < specialTransactions.length; i++) { if(specialTransactions[i].state == txState) count++; } return count; }
6,993
254
// there is no point to do the ratio math as we can just get the difference between current obtained tokens and initial obtained tokens
if (results.obtainedDai > user.amountDai) { results.feeableDai = results.obtainedDai.sub(user.amountDai); }
if (results.obtainedDai > user.amountDai) { results.feeableDai = results.obtainedDai.sub(user.amountDai); }
14,495
5
// Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled/A fee amount can never be removed, so this value should be hard coded or cached in the calling context/fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee/ return The tick spacing
function feeAmountTickSpacing(uint24 fee) external view returns (int24);
function feeAmountTickSpacing(uint24 fee) external view returns (int24);
25,061
12
// Set the dao users accunt id/
function setDAOUserAccountId(address _addr, string memory _accountId) external onlyOwner { daoUsers[_addr].accountId = _accountId; }
function setDAOUserAccountId(address _addr, string memory _accountId) external onlyOwner { daoUsers[_addr].accountId = _accountId; }
32,899
4
// Accepts new implementation of comptroller. msg.sender must be pendingImplementation Admin function for new implementation to accept it's role as implementationreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) /
function _acceptImplementation() external returns (uint256);
function _acceptImplementation() external returns (uint256);
23,541
31
// allows owner to change the locked balance of a recipient manually. _owner is the address of the locked token balance to unlock. _unlockedTokens is the amount of locked tokens to unlock. /
function changeLockedBalanceManually(address _owner, uint256 _unlockedTokens) external onlyOwner { require(_owner != address(0)); require(_unlockedTokens <= lockedTokenBalance[_owner]); require(isHoldingLockedTokens[_owner]); require(!excludedFromTokenUnlock[_owner]); lockedTokenBalance[_owner] = lockedTokenBalance[_owner].sub(_unlockedTokens); emit LockedTokenBalanceChanged(_owner, _unlockedTokens, lockedTokenBalance[_owner]); unlockedTokensDaily = unlockedTokensDaily.add(_unlockedTokens); unlockedTokensTotal = unlockedTokensTotal.add(_unlockedTokens); if (lockedTokenBalance[_owner] == 0) { isHoldingLockedTokens[_owner] = false; emit CompleteTokenBalanceUnlocked(_owner, lockedTokenBalance[_owner], isHoldingLockedTokens[_owner], true); } }
function changeLockedBalanceManually(address _owner, uint256 _unlockedTokens) external onlyOwner { require(_owner != address(0)); require(_unlockedTokens <= lockedTokenBalance[_owner]); require(isHoldingLockedTokens[_owner]); require(!excludedFromTokenUnlock[_owner]); lockedTokenBalance[_owner] = lockedTokenBalance[_owner].sub(_unlockedTokens); emit LockedTokenBalanceChanged(_owner, _unlockedTokens, lockedTokenBalance[_owner]); unlockedTokensDaily = unlockedTokensDaily.add(_unlockedTokens); unlockedTokensTotal = unlockedTokensTotal.add(_unlockedTokens); if (lockedTokenBalance[_owner] == 0) { isHoldingLockedTokens[_owner] = false; emit CompleteTokenBalanceUnlocked(_owner, lockedTokenBalance[_owner], isHoldingLockedTokens[_owner], true); } }
44,235
12
// containerStatus
function containerStatus(address packageId) public view returns (string memory) { return packages[packageId].transitStatus; }
function containerStatus(address packageId) public view returns (string memory) { return packages[packageId].transitStatus; }
27,892
7
// Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`),/ after which a call is executed to an ERC677-compliant contract with the `data` parameter./ A transfer to `address(0)` triggers an ERC-20 withdraw matching the sent AnyswapV3ERC20 token in favor of caller./ Emits {Transfer} event./ Returns boolean value indicating whether operation succeeded./ Requirements:/ - caller account must have at least `value` AnyswapV3ERC20 token./ For more information on transferAndCall format, see https:github.com/ethereum/EIPs/issues/677.
function transferAndCall(address to, uint value, bytes calldata data) external returns (bool);
function transferAndCall(address to, uint value, bytes calldata data) external returns (bool);
4,700
100
// Withdraw slashed tokens.amount The amount to withdraw /
function withdrawSlashedTokens(uint256 amount) external adminOnly { require( amount <= slashedTokenAmount, 'Withdraw amount exceeds slashed token amount' ); EIP20Interface token = EIP20Interface(stakedTokenAddress); slashedTokenAmount = slashedTokenAmount.sub(amount); token.transfer(admin, amount); }
function withdrawSlashedTokens(uint256 amount) external adminOnly { require( amount <= slashedTokenAmount, 'Withdraw amount exceeds slashed token amount' ); EIP20Interface token = EIP20Interface(stakedTokenAddress); slashedTokenAmount = slashedTokenAmount.sub(amount); token.transfer(admin, amount); }
9,965
7
// Removes expired limit orders _orderIds The array of order IDs to remove. /
function cancelExpiredLimitOrders(uint256[] calldata _orderIds) external;
function cancelExpiredLimitOrders(uint256[] calldata _orderIds) external;
8,169
3
// How many tokens to mint
uint256 amount;
uint256 amount;
4,809
67
// refund non compliant member
// @param _contributor {address} of refunded contributor function refundNonCompliant(address _contributor) payable external onlyOwner() { Backer storage backer = backers[_contributor]; require (!backer.claimed); // check if tokens have been allocated already require (!backer.refunded); // check if user has been already refunded backer.refunded = true; // mark contributor as refunded. uint totalEtherReceived = backer.weiReceivedOne + backer.weiReceivedTwo + backer.weiReceivedMain; require(msg.value == totalEtherReceived); // ensure that exact amount is sent assert(totalEtherReceived > 0); //adjust amounts received ethReceivedPresaleOne -= backer.weiReceivedOne; ethReceivedPresaleTwo -= backer.weiReceivedTwo; ethReceiveMainSale -= backer.weiReceivedMain; totalRefunded += totalEtherReceived; refundCount ++; refunded[_contributor] = totalRefunded; uint tokensToSend = (dollarPerEtherRatio * backer.weiReceivedOne) / 48; // determine amount of tokens to send from first presale tokensToSend = tokensToSend + (dollarPerEtherRatio * backer.weiReceivedTwo) / 55; // determine amount of tokens to send from second presale tokensToSend = tokensToSend + (dollarPerEtherRatio * backer.weiReceivedMain) / 62; // determine amount of tokens to send from main sale if(dateICOEnded == 0) { totalTokensSold -= tokensToSend; } else { companyTokensInitial += tokensToSend; } _contributor.transfer(totalEtherReceived); // refund contribution Refunded(_contributor, totalEtherReceived); // log event }
// @param _contributor {address} of refunded contributor function refundNonCompliant(address _contributor) payable external onlyOwner() { Backer storage backer = backers[_contributor]; require (!backer.claimed); // check if tokens have been allocated already require (!backer.refunded); // check if user has been already refunded backer.refunded = true; // mark contributor as refunded. uint totalEtherReceived = backer.weiReceivedOne + backer.weiReceivedTwo + backer.weiReceivedMain; require(msg.value == totalEtherReceived); // ensure that exact amount is sent assert(totalEtherReceived > 0); //adjust amounts received ethReceivedPresaleOne -= backer.weiReceivedOne; ethReceivedPresaleTwo -= backer.weiReceivedTwo; ethReceiveMainSale -= backer.weiReceivedMain; totalRefunded += totalEtherReceived; refundCount ++; refunded[_contributor] = totalRefunded; uint tokensToSend = (dollarPerEtherRatio * backer.weiReceivedOne) / 48; // determine amount of tokens to send from first presale tokensToSend = tokensToSend + (dollarPerEtherRatio * backer.weiReceivedTwo) / 55; // determine amount of tokens to send from second presale tokensToSend = tokensToSend + (dollarPerEtherRatio * backer.weiReceivedMain) / 62; // determine amount of tokens to send from main sale if(dateICOEnded == 0) { totalTokensSold -= tokensToSend; } else { companyTokensInitial += tokensToSend; } _contributor.transfer(totalEtherReceived); // refund contribution Refunded(_contributor, totalEtherReceived); // log event }
35,644
59
// Enables approvals on behalf (permits via an EIP712 signature) Feature FEATURE_PERMITS must be enabled in order for `permit()` function to succeed /
uint32 public constant FEATURE_PERMITS = 0x0000_0200;
uint32 public constant FEATURE_PERMITS = 0x0000_0200;
50,341
32
// Decode an Item into a byte. This will not work if the/ Item is a list./self The Item./ return The decoded string.
function toByte(Item memory self) internal pure returns (byte) { require(isData(self), "Rlp.sol:Rlp:toByte:1"); (uint256 rStartPos, uint256 len) = _decode(self); require(len == 1, "Rlp.sol:Rlp:toByte:3"); byte temp; assembly { temp := byte(0, mload(rStartPos)) } return byte(temp); }
function toByte(Item memory self) internal pure returns (byte) { require(isData(self), "Rlp.sol:Rlp:toByte:1"); (uint256 rStartPos, uint256 len) = _decode(self); require(len == 1, "Rlp.sol:Rlp:toByte:3"); byte temp; assembly { temp := byte(0, mload(rStartPos)) } return byte(temp); }
37,460
24
// require(block.timestamp>NumberStatus[number].endTime, "invalid time");
uint buyTeam1count; uint buyTeam2count; uint buyTeam3count; uint allCount; uint winAmount; uint lostAmount;
uint buyTeam1count; uint buyTeam2count; uint buyTeam3count; uint allCount; uint winAmount; uint lostAmount;
7,244
12
// Check pool if exist
mapping (address => bool) public poolExist;
mapping (address => bool) public poolExist;
48,757
391
// Holds account level context information used to determine settlement and/ free collateral actions. Total storage is 28 bytes
struct AccountContext { // Used to check when settlement must be triggered on an account uint40 nextSettleTime; // For lenders that never incur debt, we use this flag to skip the free collateral check. bytes1 hasDebt; // Length of the account's asset array uint8 assetArrayLength; // If this account has bitmaps set, this is the corresponding currency id uint16 bitmapCurrencyId; // 9 total active currencies possible (2 bytes each) bytes18 activeCurrencies; }
struct AccountContext { // Used to check when settlement must be triggered on an account uint40 nextSettleTime; // For lenders that never incur debt, we use this flag to skip the free collateral check. bytes1 hasDebt; // Length of the account's asset array uint8 assetArrayLength; // If this account has bitmaps set, this is the corresponding currency id uint16 bitmapCurrencyId; // 9 total active currencies possible (2 bytes each) bytes18 activeCurrencies; }
10,903
82
// increase counter
collateralCounter++;
collateralCounter++;
49,693
30
// An event emitted when a proposal has been executed
event ProposalExecuted(uint id, uint eta);
event ProposalExecuted(uint id, uint eta);
24,455
179
// Buffer of assets to keep in Vault to handle (most) withdrawals
uint256 public vaultBuffer;
uint256 public vaultBuffer;
5,221
2
// The information related to an offer on a direct listing at a location. The type of the listing at ID `lisingId` determins how the `Offer` is interpreted. If the listing is of type `Loctok`, the `Offer` is interpreted as an offer to a direct listing at a google plus code location. listingIdThe uid of the listing the offer is made to.offerorThe account making the offer.quantityWanted The quantity of tokens from the listing wanted by the offeror.currency The currency in which the offer is made.pricePerTokenThe price per token offered to the lister.expirationTimestamp The timestamp after which a seller cannot accept this
struct Offer { uint256 listingId; address offeror; uint256 quantityWanted; address currency; uint256 pricePerToken; uint256 expirationTimestamp; string plusCode; }
struct Offer { uint256 listingId; address offeror; uint256 quantityWanted; address currency; uint256 pricePerToken; uint256 expirationTimestamp; string plusCode; }
22,877
40
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: _spender The address which will spend the funds. _value The amount of tokens to be spent. /
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { require(!frozen[_spender] && !frozen[msg.sender], "address frozen"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) { require(!frozen[_spender] && !frozen[msg.sender], "address frozen"); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
26,979
62
// Return whether a tokenId is for an original tokenId The original NFT token id /
function isSeedId(uint256 tokenId) public pure returns (bool) { return tokenId & PRINTS_FLAG_BIT != PRINTS_FLAG_BIT; }
function isSeedId(uint256 tokenId) public pure returns (bool) { return tokenId & PRINTS_FLAG_BIT != PRINTS_FLAG_BIT; }
6,220
117
// Fallback function to return money to reward distributer via pool deployer In case of issues or incorrect calls or errors
function refund(uint256 amount, address refundAddress) public onlyOwner { require(IERC20(rewardsToken).balanceOf(address(this)) >= amount, "StakingRewardsFactory::refund: Not enough tokens"); IERC20(rewardsToken).safeTransfer(refundAddress, amount); }
function refund(uint256 amount, address refundAddress) public onlyOwner { require(IERC20(rewardsToken).balanceOf(address(this)) >= amount, "StakingRewardsFactory::refund: Not enough tokens"); IERC20(rewardsToken).safeTransfer(refundAddress, amount); }
24,347
6
// Registers the contract as an implementer of the interface defined by`interfaceId`. Support of the actual ERC165 interface is automatic andregistering its interface id is not required. See `IERC165.supportsInterface`. Requirements: - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). /
function _registerInterface(bytes4 interfaceId) internal { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; }
function _registerInterface(bytes4 interfaceId) internal { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; }
35,177
56
// See {IERC721CreatorCore-tokenExtension}. /
function tokenExtension(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "Nonexistent token"); return _tokenExtension(tokenId); }
function tokenExtension(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "Nonexistent token"); return _tokenExtension(tokenId); }
24,647
16
// Return the time limit between interaction with the faucetreturn number of seconds (timestamp) /
function getTimeLimit() public view returns (uint256) { return faucetTimeLimit; }
function getTimeLimit() public view returns (uint256) { return faucetTimeLimit; }
41,501
8
// User calls here to claim rewards from a token launch. Sends a user their share of rewards. _user Address of the user to claim rewards for. _tokens An array of tokens to claim rewards from. _timePoints An array of timepoints the rewards were launched at. /
) external { for (uint256 i = 0; i < _tokens.length; i++) { require( !claimed[_user][_tokens[i]][_timePoints[i]], "Reward already claimed." ); // Vesting for airdrops is 30 days and 216000 in blocks. require( _timePoints[i] + 216000 < block.number, "Too early to claim rewards." ); claimed[_user][_tokens[i]][_timePoints[i]] = true; uint256 amount = launches[_tokens[i]][_timePoints[i]]; (uint256 balance, uint256 supply) = inedibleCheck( _user, _timePoints[i] ); uint256 owed = (amount * balance) / supply; if (owed != 0) { IERC20(_tokens[i]).safeTransfer(_user, owed); emit ClaimedReward(_user, _tokens[i], _timePoints[i], owed); } } }
) external { for (uint256 i = 0; i < _tokens.length; i++) { require( !claimed[_user][_tokens[i]][_timePoints[i]], "Reward already claimed." ); // Vesting for airdrops is 30 days and 216000 in blocks. require( _timePoints[i] + 216000 < block.number, "Too early to claim rewards." ); claimed[_user][_tokens[i]][_timePoints[i]] = true; uint256 amount = launches[_tokens[i]][_timePoints[i]]; (uint256 balance, uint256 supply) = inedibleCheck( _user, _timePoints[i] ); uint256 owed = (amount * balance) / supply; if (owed != 0) { IERC20(_tokens[i]).safeTransfer(_user, owed); emit ClaimedReward(_user, _tokens[i], _timePoints[i], owed); } } }
8,188
8
// Allows `spender` to spend the tokens owned by _msgSender() spender The user allowed to spend _msgSender() tokensreturn `true` /
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
18,650
102
// Set reward amount _amount uint256 /
function setRewardsVar(uint256 _amount) public _onlyOwner { rewardsVar = _amount; }
function setRewardsVar(uint256 _amount) public _onlyOwner { rewardsVar = _amount; }
30,421
59
// Get address of this smart contract. return address of this smart contract /
function thisAddress () internal view returns (address) { return this; }
function thisAddress () internal view returns (address) { return this; }
45,982
152
// Get where last block the voter staked was._voter Address of the voter./
function getVoterBlockStaked(address _voter) delegatedOnly public view returns(uint256) { return userStake[_voter].blockStaked; }
function getVoterBlockStaked(address _voter) delegatedOnly public view returns(uint256) { return userStake[_voter].blockStaked; }
25,599
86
// Funders who took part in the crowdfund could have reserved tokens
uint256 reservedHolos = whitelistContract.reservedTokens(beneficiary, dayIndex);
uint256 reservedHolos = whitelistContract.reservedTokens(beneficiary, dayIndex);
39,753
34
// address where funds are collected address where tokens are deposited and from where we send tokens to buyers
address public walletOwner; Stakeholder stakeholderObj; uint256 public coinPercentage = 5;
address public walletOwner; Stakeholder stakeholderObj; uint256 public coinPercentage = 5;
39,726
7
// Total number of adventurers staked
uint256 public totalAdventurersStaked = 0;
uint256 public totalAdventurersStaked = 0;
29,111
906
// Treasury (10%, initially)
uint256 public treasuryPercentage = 10; address public governance;
uint256 public treasuryPercentage = 10; address public governance;
51,049
17
// Event emitted when the community grant period ends. /
event CommunityGrantEnds();
event CommunityGrantEnds();
28,176
461
// Write the _preBytes data into the tempBytes memory 32 bytes at a time.
mstore(mc, mload(cc))
mstore(mc, mload(cc))
4,202
0
// Quinary tree zeros (0)
constructor() { zeros[0] = uint256(0); zeros[1] = uint256(14655542659562014735865511769057053982292279840403315552050801315682099828156); zeros[2] = uint256(19261153649140605024552417994922546473530072875902678653210025980873274131905); zeros[3] = uint256(21526503558325068664033192388586640128492121680588893182274749683522508994597); zeros[4] = uint256(20017764101928005973906869479218555869286328459998999367935018992260318153770); zeros[5] = uint256(16998355316577652097112514691750893516081130026395813155204269482715045879598); zeros[6] = uint256(2612442706402737973181840577010736087708621987282725873936541279764292204086); zeros[7] = uint256(17716535433480122581515618850811568065658392066947958324371350481921422579201); zeros[8] = uint256(17437916409890180001398333108882255895598851862997171508841759030332444017770); zeros[9] = uint256(20806704410832383274034364623685369279680495689837539882650535326035351322472); zeros[10] = uint256(6821382292698461711184253213986441870942786410912797736722948342942530789476); zeros[11] = uint256(5916648769022832355861175588931687601652727028178402815013820610204855544893); zeros[12] = uint256(8979092375429814404031883906996857902016801693563521316025319397481362525766); zeros[13] = uint256(2921214989930864339537708350754648834701757280474461132621735242274490553963); zeros[14] = uint256(8930183771974746972686153669144011224662017420905079900118160414492327314176); zeros[15] = uint256(235368305313252659057202520253547068193638476511860624369389264358598810396); zeros[16] = uint256(11594802086624841314469980089838552727386894436467147447204224403068085066609); zeros[17] = uint256(6527402365840056202903190531155009847198979121365335038364206235405082926579); zeros[18] = uint256(7890267294950363768070024023123773394579161137981585347919627664365669195485); zeros[19] = uint256(7743021844925994795008658518659888250339967931662466893787320922384170613250); zeros[20] = uint256(3315762791558236426429898223445373782079540514426385620818139644150484427120); zeros[21] = uint256(12047412166753578299610528762227103229354276396579409944098869901020016693788); zeros[22] = uint256(7346375653460369101190037700418084792046605818930533590372465301789036536); zeros[23] = uint256(16686328169837855831280640081580124364395471639440725186157725609010405016551); zeros[24] = uint256(19105160640579355001844872723857900201603625359252284777965070378555675817865); zeros[25] = uint256(17054399483511247964029303840879817843788388567881464290309597953132679359256); zeros[26] = uint256(5296258093842160235704190490839277292290579093574356735268980000023915581697); zeros[27] = uint256(8993437003863084469472897416707962588904917898547964184966432920162387360131); zeros[28] = uint256(7234267096117283161039619077058835089667467648437312224957703988301725566335); zeros[29] = uint256(21640448288319814375882234036901598260365718394023649234526744669922384765526); zeros[30] = uint256(1595567811792178436811872247033324109773732075641399161664435302467654689847); zeros[31] = uint256(15291095622175285816966181294098521638815701170497062413595539727181544870101); zeros[32] = uint256(15837036953038489303182430773663047564827202645548797032627170282475341436016); }
constructor() { zeros[0] = uint256(0); zeros[1] = uint256(14655542659562014735865511769057053982292279840403315552050801315682099828156); zeros[2] = uint256(19261153649140605024552417994922546473530072875902678653210025980873274131905); zeros[3] = uint256(21526503558325068664033192388586640128492121680588893182274749683522508994597); zeros[4] = uint256(20017764101928005973906869479218555869286328459998999367935018992260318153770); zeros[5] = uint256(16998355316577652097112514691750893516081130026395813155204269482715045879598); zeros[6] = uint256(2612442706402737973181840577010736087708621987282725873936541279764292204086); zeros[7] = uint256(17716535433480122581515618850811568065658392066947958324371350481921422579201); zeros[8] = uint256(17437916409890180001398333108882255895598851862997171508841759030332444017770); zeros[9] = uint256(20806704410832383274034364623685369279680495689837539882650535326035351322472); zeros[10] = uint256(6821382292698461711184253213986441870942786410912797736722948342942530789476); zeros[11] = uint256(5916648769022832355861175588931687601652727028178402815013820610204855544893); zeros[12] = uint256(8979092375429814404031883906996857902016801693563521316025319397481362525766); zeros[13] = uint256(2921214989930864339537708350754648834701757280474461132621735242274490553963); zeros[14] = uint256(8930183771974746972686153669144011224662017420905079900118160414492327314176); zeros[15] = uint256(235368305313252659057202520253547068193638476511860624369389264358598810396); zeros[16] = uint256(11594802086624841314469980089838552727386894436467147447204224403068085066609); zeros[17] = uint256(6527402365840056202903190531155009847198979121365335038364206235405082926579); zeros[18] = uint256(7890267294950363768070024023123773394579161137981585347919627664365669195485); zeros[19] = uint256(7743021844925994795008658518659888250339967931662466893787320922384170613250); zeros[20] = uint256(3315762791558236426429898223445373782079540514426385620818139644150484427120); zeros[21] = uint256(12047412166753578299610528762227103229354276396579409944098869901020016693788); zeros[22] = uint256(7346375653460369101190037700418084792046605818930533590372465301789036536); zeros[23] = uint256(16686328169837855831280640081580124364395471639440725186157725609010405016551); zeros[24] = uint256(19105160640579355001844872723857900201603625359252284777965070378555675817865); zeros[25] = uint256(17054399483511247964029303840879817843788388567881464290309597953132679359256); zeros[26] = uint256(5296258093842160235704190490839277292290579093574356735268980000023915581697); zeros[27] = uint256(8993437003863084469472897416707962588904917898547964184966432920162387360131); zeros[28] = uint256(7234267096117283161039619077058835089667467648437312224957703988301725566335); zeros[29] = uint256(21640448288319814375882234036901598260365718394023649234526744669922384765526); zeros[30] = uint256(1595567811792178436811872247033324109773732075641399161664435302467654689847); zeros[31] = uint256(15291095622175285816966181294098521638815701170497062413595539727181544870101); zeros[32] = uint256(15837036953038489303182430773663047564827202645548797032627170282475341436016); }
23,470
1
// WARN: Always remember to change the 'hash' function if modifying the struct
struct Payload { uint256 nonce; uint256 executionTime; address submitter; IERC3000Executor executor; Action[] actions; bytes32 allowFailuresMap; bytes proof; }
struct Payload { uint256 nonce; uint256 executionTime; address submitter; IERC3000Executor executor; Action[] actions; bytes32 allowFailuresMap; bytes proof; }
40,643
34
// Pool stuff There are a few notable items in how minting works 1) if ADX is sent to the LoyaltyPool in-between mints, it will calculate the incentive as if this amount has been there the whole time since the last mint 2) Compounding is happening when mint is called, so essentially when entities enter/leave/trigger it manually
function toMint() external view returns (uint) { if (block.timestamp <= lastMintTime) return 0; uint totalADX = ADXToken.balanceOf(address(this)); return (block.timestamp - lastMintTime) .mul(totalADX) .mul(incentivePerTokenPerAnnum) .div(365 days * 10e17); }
function toMint() external view returns (uint) { if (block.timestamp <= lastMintTime) return 0; uint totalADX = ADXToken.balanceOf(address(this)); return (block.timestamp - lastMintTime) .mul(totalADX) .mul(incentivePerTokenPerAnnum) .div(365 days * 10e17); }
46,547
41
// Get the address of the staker (if set)/ return staker address of the staker
function getStaker() public view returns (address staker) { return _data.staker; }
function getStaker() public view returns (address staker) { return _data.staker; }
17,960
101
// Prevent having debt represented by positive values
if (position.borrowedAmount.value == 0) { position.borrowedAmount.sign = false; }
if (position.borrowedAmount.value == 0) { position.borrowedAmount.sign = false; }
13,318
55
// Get the active data list that is associated with a CID NFT / Subprotocol/_cidNFTID ID of the CID NFT to query/_subprotocolName Name of the subprotocol to query/ return subprotocolNFTIDs The ID of the primary NFT at the queried subprotocl / CID NFT. 0 if it does not exist
function getActiveData(uint256 _cidNFTID, string calldata _subprotocolName) external view returns (uint256[] memory subprotocolNFTIDs)
function getActiveData(uint256 _cidNFTID, string calldata _subprotocolName) external view returns (uint256[] memory subprotocolNFTIDs)
9,735
308
// if no more selectors for facet address then delete the facet address
if (lastSelectorPosition == 0) {
if (lastSelectorPosition == 0) {
46,315
188
// Transfer stablecoins back to the sender
IERC20(underlyingCoin).safeTransfer(_msgSender(), underlyingCoinAmount);
IERC20(underlyingCoin).safeTransfer(_msgSender(), underlyingCoinAmount);
11,706
17
// Returns the downcasted uint144 from uint256, reverting onoverflow (when the input is greater than largest uint144). Counterpart to Solidity's `uint144` operator. Requirements: - input must fit into 144 bits /
function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); }
function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); }
37,566
365
// Curve 3Coins base strategy /
abstract contract CurveStrategy3CoinsBase is CurveStrategyBase { using SafeERC20 for IERC20; /* ========== CONSTANT VARIABLES ========== */ /// @notice Total number of coins uint256 internal constant TOTAL_COINS = 3; /* ========== STATE VARIABLES ========== */ /// @notice Stable swap pool IStableSwap3Pool public immutable pool3Coins; /* ========== CONSTRUCTOR ========== */ constructor() { pool3Coins = IStableSwap3Pool(address(pool)); } /* ========== OVERRIDDEN FUNCTIONS ========== */ /** * @dev register a strategy as shared strategy, using shared key */ function _initialize() internal virtual { StrategiesShared storage stratsShared = strategiesShared[_getSharedKey()]; stratsShared.stratAddresses[stratsShared.stratsCount] = self; stratsShared.stratsCount++; } /** * @notice Run after strategy was removed as a breakdown function */ function _disable() internal virtual { StrategiesShared storage stratsShared = strategiesShared[_getSharedKey()]; uint256 sharedStratsCount = stratsShared.stratsCount; for(uint256 i = 0; i < sharedStratsCount; i++) { if (stratsShared.stratAddresses[i] == self) { stratsShared.stratAddresses[i] = stratsShared.stratAddresses[sharedStratsCount - 1]; delete stratsShared.stratAddresses[sharedStratsCount - 1]; stratsShared.stratsCount--; break; } } } /** * @notice Deposit * @param amount Amount * @param slippage Slippage */ function _curveDeposit(uint256 amount, uint256 slippage) internal override { uint256[TOTAL_COINS] memory amounts; amounts[uint128(nCoin)] = amount; pool3Coins.add_liquidity(amounts, slippage); } /* ========== VIRTUAL FUNCTIONS ========== */ /** * @notice Get shared key * @return Shared key */ function _getSharedKey() internal virtual view returns(bytes32); }
abstract contract CurveStrategy3CoinsBase is CurveStrategyBase { using SafeERC20 for IERC20; /* ========== CONSTANT VARIABLES ========== */ /// @notice Total number of coins uint256 internal constant TOTAL_COINS = 3; /* ========== STATE VARIABLES ========== */ /// @notice Stable swap pool IStableSwap3Pool public immutable pool3Coins; /* ========== CONSTRUCTOR ========== */ constructor() { pool3Coins = IStableSwap3Pool(address(pool)); } /* ========== OVERRIDDEN FUNCTIONS ========== */ /** * @dev register a strategy as shared strategy, using shared key */ function _initialize() internal virtual { StrategiesShared storage stratsShared = strategiesShared[_getSharedKey()]; stratsShared.stratAddresses[stratsShared.stratsCount] = self; stratsShared.stratsCount++; } /** * @notice Run after strategy was removed as a breakdown function */ function _disable() internal virtual { StrategiesShared storage stratsShared = strategiesShared[_getSharedKey()]; uint256 sharedStratsCount = stratsShared.stratsCount; for(uint256 i = 0; i < sharedStratsCount; i++) { if (stratsShared.stratAddresses[i] == self) { stratsShared.stratAddresses[i] = stratsShared.stratAddresses[sharedStratsCount - 1]; delete stratsShared.stratAddresses[sharedStratsCount - 1]; stratsShared.stratsCount--; break; } } } /** * @notice Deposit * @param amount Amount * @param slippage Slippage */ function _curveDeposit(uint256 amount, uint256 slippage) internal override { uint256[TOTAL_COINS] memory amounts; amounts[uint128(nCoin)] = amount; pool3Coins.add_liquidity(amounts, slippage); } /* ========== VIRTUAL FUNCTIONS ========== */ /** * @notice Get shared key * @return Shared key */ function _getSharedKey() internal virtual view returns(bytes32); }
34,362
87
// Note that _ownedTokensIndex[tokenId] hasn't been cleared: it still points to the old slot (now occupied bylastTokenId, or just over the end of the array if the token was the last one).
}
}
40,771
71
// Pausable token ERC20 modified with pausable transfers. /
contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool) { return super.decreaseAllowance(spender, subtractedValue); } }
contract ERC20Pausable is ERC20, Pausable { function transfer(address to, uint256 value) public whenNotPaused returns (bool) { return super.transfer(to, value); } function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { return super.transferFrom(from, to, value); } function approve(address spender, uint256 value) public whenNotPaused returns (bool) { return super.approve(spender, value); } function increaseAllowance(address spender, uint addedValue) public whenNotPaused returns (bool) { return super.increaseAllowance(spender, addedValue); } function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool) { return super.decreaseAllowance(spender, subtractedValue); } }
27,195
1
// Note: double_t(1, 5) will be 1.05 but double_t(1, 50) will be 1.5example:import "multiprecision.sol";contract Test is Double
* { * function test() internal * { * double memory a = double_t(1, 20); // 1.20 * double memory b = double_t(0, 2); // 0.02 * double memory result = double_add(a, b); // 1.22 * * a = double_t(2, 0); // 2.00 * b = double_t(1, 0); // 1.00 * a.sign = true; // -2.00 * result = double_add(a, b); // -2.00 + 1.00 = -1.00 * * result = double_sub(a, b); // -2.00 - 1.00 = -3.00 * result = double_mult(a, b); // -2.00 * 1.00 = -2.00 * result = double_div(a, b); // -2.00 / 1.00 = -2.00 * * dscale = 3; // change precision (.00 -> .000) * double_t(1, 5); // now 1.005 * double_t(1, 50); // now 1.050 * double_t(1, 500); // now 1.500 * } * }
* { * function test() internal * { * double memory a = double_t(1, 20); // 1.20 * double memory b = double_t(0, 2); // 0.02 * double memory result = double_add(a, b); // 1.22 * * a = double_t(2, 0); // 2.00 * b = double_t(1, 0); // 1.00 * a.sign = true; // -2.00 * result = double_add(a, b); // -2.00 + 1.00 = -1.00 * * result = double_sub(a, b); // -2.00 - 1.00 = -3.00 * result = double_mult(a, b); // -2.00 * 1.00 = -2.00 * result = double_div(a, b); // -2.00 / 1.00 = -2.00 * * dscale = 3; // change precision (.00 -> .000) * double_t(1, 5); // now 1.005 * double_t(1, 50); // now 1.050 * double_t(1, 500); // now 1.500 * } * }
52,856
22
// set epoch claimed to current - 1
epochClaimed[msg.sender] = _epochNum() - 1; require(totalClaimable > 0, "NOTHING_TO_CLAIM");
epochClaimed[msg.sender] = _epochNum() - 1; require(totalClaimable > 0, "NOTHING_TO_CLAIM");
29,549
19
// Calculate how much other token we need to transfer.
uint otToSend = (_numShares * otherTokenReserve) / totalShareSupply;
uint otToSend = (_numShares * otherTokenReserve) / totalShareSupply;
49,340
55
// Performs a direct listing sale.
function executeSale( Listing memory _targetListing, address _payer, address _receiver, address _currency, uint256 _currencyAmountToTransfer, uint256 _listingTokenAmountToTransfer
function executeSale( Listing memory _targetListing, address _payer, address _receiver, address _currency, uint256 _currencyAmountToTransfer, uint256 _listingTokenAmountToTransfer
5,901
4
// returns 0.01 value in United States Dollar
function USD(uint _id) public view returns (uint256) { return tokens[_id].usd; }
function USD(uint _id) public view returns (uint256) { return tokens[_id].usd; }
36,308
270
// Mints tokens to an address in batch using an ERC-20 token for payment fee may or may not be required_to address of the future owner of the token_amount number of tokens to mint_erc20TokenContract erc-20 token contract to mint with/
function mintToMultipleERC20(address _to, uint256 _amount, address _erc20TokenContract) public payable { if(_amount == 0) revert MintZeroQuantity(); if(_amount > maxBatchSize) revert TransactionCapExceeded(); if(!mintingOpen) revert PublicMintClosed(); if(mintWillExceedCap(_amount)) revert CapExceeded(); if(mintingOpen && onlyAllowlistMode) revert PublicMintClosed(); if(!canMintAmount(_to, _amount)) revert ExcessiveOwnedMints(); if(msg.value != PROVIDER_FEE) revert InvalidPayment(); // ERC-20 Specific pre-flight checks if(!isApprovedForERC20Payments(_erc20TokenContract)) revert ERC20TokenNotApproved(); uint256 tokensQtyToTransfer = chargeAmountForERC20(_erc20TokenContract) * _amount; IERC20 payableToken = IERC20(_erc20TokenContract); if(payableToken.balanceOf(_to) < tokensQtyToTransfer) revert ERC20InsufficientBalance(); if(payableToken.allowance(_to, address(this)) < tokensQtyToTransfer) revert ERC20InsufficientAllowance(); bool transferComplete = payableToken.transferFrom(_to, address(this), tokensQtyToTransfer); if(!transferComplete) revert ERC20TransferFailed(); sendProviderFee(); _safeMint(_to, _amount, false); }
function mintToMultipleERC20(address _to, uint256 _amount, address _erc20TokenContract) public payable { if(_amount == 0) revert MintZeroQuantity(); if(_amount > maxBatchSize) revert TransactionCapExceeded(); if(!mintingOpen) revert PublicMintClosed(); if(mintWillExceedCap(_amount)) revert CapExceeded(); if(mintingOpen && onlyAllowlistMode) revert PublicMintClosed(); if(!canMintAmount(_to, _amount)) revert ExcessiveOwnedMints(); if(msg.value != PROVIDER_FEE) revert InvalidPayment(); // ERC-20 Specific pre-flight checks if(!isApprovedForERC20Payments(_erc20TokenContract)) revert ERC20TokenNotApproved(); uint256 tokensQtyToTransfer = chargeAmountForERC20(_erc20TokenContract) * _amount; IERC20 payableToken = IERC20(_erc20TokenContract); if(payableToken.balanceOf(_to) < tokensQtyToTransfer) revert ERC20InsufficientBalance(); if(payableToken.allowance(_to, address(this)) < tokensQtyToTransfer) revert ERC20InsufficientAllowance(); bool transferComplete = payableToken.transferFrom(_to, address(this), tokensQtyToTransfer); if(!transferComplete) revert ERC20TransferFailed(); sendProviderFee(); _safeMint(_to, _amount, false); }
23,177
229
// Following conditions need to be met if the user is borrowing at a stable rate:1. Reserve must be enabled for stable rate borrowing2. Users cannot borrow from the reserve if their collateral is (mostly) the same currency they are borrowing, to prevent abuses.3. Users will be able to borrow only a portion of the total available liquidity /check if the borrow mode is stable and if stable rate borrowing is enabled on this reserve
require(vars.stableRateBorrowingEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED); require( !userConfig.isUsingAsCollateral(reserve.id) || reserve.configuration.getLtv() == 0 || amount > IERC20(reserve.aTokenAddress).balanceOf(userAddress), Errors.VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY );
require(vars.stableRateBorrowingEnabled, Errors.VL_STABLE_BORROWING_NOT_ENABLED); require( !userConfig.isUsingAsCollateral(reserve.id) || reserve.configuration.getLtv() == 0 || amount > IERC20(reserve.aTokenAddress).balanceOf(userAddress), Errors.VL_COLLATERAL_SAME_AS_BORROWING_CURRENCY );
24,984
6
// Owned - Add an owner to the contract.
contract Owned { address public owner = msg.sender; address public potentialOwner; modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyPotentialOwner { require(msg.sender == potentialOwner); _; } event NewOwner(address old, address current); event NewPotentialOwner(address old, address potential); function setOwner(address _new) public onlyOwner { emit NewPotentialOwner(owner, _new); potentialOwner = _new; } function confirmOwnership() public onlyPotentialOwner { emit NewOwner(owner, potentialOwner); owner = potentialOwner; potentialOwner = address(0); } }
contract Owned { address public owner = msg.sender; address public potentialOwner; modifier onlyOwner { require(msg.sender == owner); _; } modifier onlyPotentialOwner { require(msg.sender == potentialOwner); _; } event NewOwner(address old, address current); event NewPotentialOwner(address old, address potential); function setOwner(address _new) public onlyOwner { emit NewPotentialOwner(owner, _new); potentialOwner = _new; } function confirmOwnership() public onlyPotentialOwner { emit NewOwner(owner, potentialOwner); owner = potentialOwner; potentialOwner = address(0); } }
18,922
0
// keep track of liquidations
function incrementLiquidations(DataTypes.UserConfigurationMap storage self) internal { uint256 oldLiquidations = self.liquidations; self.liquidations = 1 + oldLiquidations; //needs safemath }
function incrementLiquidations(DataTypes.UserConfigurationMap storage self) internal { uint256 oldLiquidations = self.liquidations; self.liquidations = 1 + oldLiquidations; //needs safemath }
21,424
9
// KILL ANIMAL
AnimalsWorld loser = AnimalsWorld(_loserAddress); loser.deadAnimal(_loserAnimal); // Might not work if it is not called from the animal owner address return returnedMessage;
AnimalsWorld loser = AnimalsWorld(_loserAddress); loser.deadAnimal(_loserAnimal); // Might not work if it is not called from the animal owner address return returnedMessage;
12,884
17
// Decodes debt information encoded in the flash loan params params Additional variadic field to include extra params. Expected parameters:address collateralAsset Address of the reserve to be swappeduint256 collateralAmount Amount of reserve to be swappeduint256 rateMode Rate modes of the debt to be repaiduint256 permitAmount Amount for the permit signatureuint256 deadline Deadline for the permit signatureuint8 v V param for the permit signaturebytes32 r R param for the permit signaturebytes32 s S param for the permit signaturereturn RepayParams struct containing decoded params /
function _decodeParams(bytes memory params) internal pure returns (RepayParams memory) { ( address collateralAsset, uint256 collateralAmount, uint256 rateMode, uint256 permitAmount, uint256 deadline, uint8 v, bytes32 r, bytes32 s, bool useEthPath ) = abi.decode( params, (address, uint256, uint256, uint256, uint256, uint8, bytes32, bytes32, bool) ); return RepayParams( collateralAsset, collateralAmount, rateMode, PermitSignature(permitAmount, deadline, v, r, s), useEthPath ); }
function _decodeParams(bytes memory params) internal pure returns (RepayParams memory) { ( address collateralAsset, uint256 collateralAmount, uint256 rateMode, uint256 permitAmount, uint256 deadline, uint8 v, bytes32 r, bytes32 s, bool useEthPath ) = abi.decode( params, (address, uint256, uint256, uint256, uint256, uint8, bytes32, bytes32, bool) ); return RepayParams( collateralAsset, collateralAmount, rateMode, PermitSignature(permitAmount, deadline, v, r, s), useEthPath ); }
517
37
// We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length, 0x02 bytes for the prefix, and 0x40 bytes for the digits. The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.
let m := add(start, 0xa0)
let m := add(start, 0xa0)
16,167
21
// pool index => swap amount of token1
mapping(uint => uint) public amountSwap1P;
mapping(uint => uint) public amountSwap1P;
44,681
73
// Gets the owner of the specified token ID _tokenId uint256 ID of the token to query the owner ofreturn owner address currently marked as the owner of the given token ID /
function ownerOf(uint256 _tokenId) public view returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; }
function ownerOf(uint256 _tokenId) public view returns (address) { address owner = tokenOwner[_tokenId]; require(owner != address(0)); return owner; }
1,399
86
// if the participant previously sent ETH, return it
if (initialParticipantValue > 0) { address(_recipient).transfer(initialParticipantValue); }
if (initialParticipantValue > 0) { address(_recipient).transfer(initialParticipantValue); }
18,252
60
// Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.The call is not executed if the target address is not a contract.from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value /
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
7,450
241
// solhint-disable-next-line payable-fallback,no-complex-fallback
fallback() external { bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { let handler := sload(slot) if iszero(handler) { return(0, 0) } calldatacopy(0, 0, calldatasize()) // The msg.sender address is shifted to the left by 12 bytes to remove the padding // Then the address without padding is stored right after the calldata mstore(calldatasize(), shl(96, caller())) // Add 20 bytes for the address appended add the end let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0) returndatacopy(0, 0, returndatasize()) if iszero(success) { revert(0, returndatasize()) } return(0, returndatasize()) } }
fallback() external { bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT; // solhint-disable-next-line no-inline-assembly assembly { let handler := sload(slot) if iszero(handler) { return(0, 0) } calldatacopy(0, 0, calldatasize()) // The msg.sender address is shifted to the left by 12 bytes to remove the padding // Then the address without padding is stored right after the calldata mstore(calldatasize(), shl(96, caller())) // Add 20 bytes for the address appended add the end let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0) returndatacopy(0, 0, returndatasize()) if iszero(success) { revert(0, returndatasize()) } return(0, returndatasize()) } }
26,757
2
// Public constructor /
constructor() public payable Controlled() {} /** * @notice Allow receives */ receive() external payable { // }
constructor() public payable Controlled() {} /** * @notice Allow receives */ receive() external payable { // }
4,237
2
// if the service '_service' is not a registered service
if (!isService(_service)) { _; }
if (!isService(_service)) { _; }
45,380
169
// If v is 1 then it is an approved hash When handling approved hashes the address of the approver is encoded into r
currentOwner = address(uint160(uint256(r)));
currentOwner = address(uint160(uint256(r)));
26,157
19
// Checks if the pool address was created in this smart contract/
function isPool(address pool) external view returns (bool valid) { return _pools.contains(pool); }
function isPool(address pool) external view returns (bool valid) { return _pools.contains(pool); }
18,211
1
// Include an address to specify the immutable WitnetRequestBoard entrypoint address./_wrb The WitnetRequestBoard immutable entrypoint address.
constructor(WitnetRequestBoard _wrb) UsingWitnet(_wrb)
constructor(WitnetRequestBoard _wrb) UsingWitnet(_wrb)
41,934
618
// amount: promised amount of stars
uint16 amount;
uint16 amount;
2,311
239
// Emits an {SchainCreated} event.Requirements:- Schain type is valid.- There is sufficient deposit to create type of schain. /
function addSchain(address from, uint deposit, bytes calldata data) external allow("SkaleManager") {
function addSchain(address from, uint deposit, bytes calldata data) external allow("SkaleManager") {
57,287
459
// See {IGovernorCompatibilityBravo-proposals}. /
function proposals(uint256 proposalId) public view virtual override returns ( uint256 id, address proposer, uint256 eta, uint256 startBlock,
function proposals(uint256 proposalId) public view virtual override returns ( uint256 id, address proposer, uint256 eta, uint256 startBlock,
20,269
39
// Init rates contract. addr Address of deployed rates contract. /
function setRatesContract(address addr) onlyOwner public{ require(addr != address(0), "Contract address cannot be null"); rates = ETHUSDRate(addr); }
function setRatesContract(address addr) onlyOwner public{ require(addr != address(0), "Contract address cannot be null"); rates = ETHUSDRate(addr); }
3,373
44
// Brainz Token representing Brainz. /
contract StoboxToken is BurnableToken { string public name; string public symbol; uint8 public decimals = 18; /** * @dev users sending ether to this contract will be reverted. Any ether sent to the contract will be sent back to the caller */ function() external payable { revert("Cannot send Ether to this contract"); } /** * @dev Constructor function to initialize the initial supply of token to the creator of the contract */ constructor(address wallet) public { owner = wallet; totalSupply = uint(1000000000).mul(10 ** uint256(decimals)); //Update total supply with the decimal amount name = "Stobox Token"; symbol = "STBU"; balances[wallet] = totalSupply; //Emitting transfer event since assigning all tokens to the creator also corresponds to the transfer of tokens to the creator emit Transfer(address(0), msg.sender, totalSupply); } /** * @dev helper method to get token details, name, symbol and totalSupply in one go */ function getTokenDetail() public view returns (string memory, string memory, uint256) { return (name, symbol, totalSupply); } function vest(address[] memory _owners, uint[] memory _amounts) public onlyOwner { require(_owners.length == _amounts.length, "Length of addresses & token amounts are not the same"); for (uint i = 0; i < _owners.length; i++) { _amounts[i] = _amounts[i].mul(10 ** 18); require(_owners[i] != address(0), "Vesting funds cannot be sent to 0x0"); require(_amounts[i] > 0, "Amount must be > 0"); require(balances[owner] > _amounts[i], "Not enough balance to vest"); require(balances[_owners[i]].add(_amounts[i]) > balances[_owners[i]], "Internal vesting error"); // SafeMath.sub will throw if there is not enough balance. balances[owner] = balances[owner].sub(_amounts[i]); balances[_owners[i]] = balances[_owners[i]].add(_amounts[i]); emit Transfer(owner, _owners[i], _amounts[i]); lockup = Lockup({ lockupAmount: _amounts[i] }); lockupParticipants[_owners[i]] = lockup; } } function initiateLockup() public onlyOwner { uint256 currentTime = now; lockupIsActive = true; lockupStartTime = currentTime; emit LockupStarted(currentTime); } function lockupActive() public view returns (bool) { return lockupIsActive; } function lockupAmountOf(address _owner) public view returns (uint256) { return lockupParticipants[_owner].lockupAmount; } }
contract StoboxToken is BurnableToken { string public name; string public symbol; uint8 public decimals = 18; /** * @dev users sending ether to this contract will be reverted. Any ether sent to the contract will be sent back to the caller */ function() external payable { revert("Cannot send Ether to this contract"); } /** * @dev Constructor function to initialize the initial supply of token to the creator of the contract */ constructor(address wallet) public { owner = wallet; totalSupply = uint(1000000000).mul(10 ** uint256(decimals)); //Update total supply with the decimal amount name = "Stobox Token"; symbol = "STBU"; balances[wallet] = totalSupply; //Emitting transfer event since assigning all tokens to the creator also corresponds to the transfer of tokens to the creator emit Transfer(address(0), msg.sender, totalSupply); } /** * @dev helper method to get token details, name, symbol and totalSupply in one go */ function getTokenDetail() public view returns (string memory, string memory, uint256) { return (name, symbol, totalSupply); } function vest(address[] memory _owners, uint[] memory _amounts) public onlyOwner { require(_owners.length == _amounts.length, "Length of addresses & token amounts are not the same"); for (uint i = 0; i < _owners.length; i++) { _amounts[i] = _amounts[i].mul(10 ** 18); require(_owners[i] != address(0), "Vesting funds cannot be sent to 0x0"); require(_amounts[i] > 0, "Amount must be > 0"); require(balances[owner] > _amounts[i], "Not enough balance to vest"); require(balances[_owners[i]].add(_amounts[i]) > balances[_owners[i]], "Internal vesting error"); // SafeMath.sub will throw if there is not enough balance. balances[owner] = balances[owner].sub(_amounts[i]); balances[_owners[i]] = balances[_owners[i]].add(_amounts[i]); emit Transfer(owner, _owners[i], _amounts[i]); lockup = Lockup({ lockupAmount: _amounts[i] }); lockupParticipants[_owners[i]] = lockup; } } function initiateLockup() public onlyOwner { uint256 currentTime = now; lockupIsActive = true; lockupStartTime = currentTime; emit LockupStarted(currentTime); } function lockupActive() public view returns (bool) { return lockupIsActive; } function lockupAmountOf(address _owner) public view returns (uint256) { return lockupParticipants[_owner].lockupAmount; } }
11,371
86
// 持有者的份额
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
73,496
11
// ERC20Basic Simpler version of ERC20 interface /
contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); }/**
contract ERC20Basic { function totalSupply() public view returns (uint256); function balanceOf(address _who) public view returns (uint256); function transfer(address _to, uint256 _value) public returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); }/**
39,109
136
// mint shares at current rate
uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(INITIAL_SHARES_PER_TOKEN); totalLockedShares = totalLockedShares.add(mintedLockedShares);
uint256 lockedTokens = totalLocked(); uint256 mintedLockedShares = (lockedTokens > 0) ? totalLockedShares.mul(amount).div(lockedTokens) : amount.mul(INITIAL_SHARES_PER_TOKEN); totalLockedShares = totalLockedShares.add(mintedLockedShares);
34,142
25
// grants controller role to address/pcvController new controller
function grantPCVController(address pcvController) external override onlyGovernor
function grantPCVController(address pcvController) external override onlyGovernor
41,966
199
// contract metadata URI for opensea
string public contractURI;
string public contractURI;
13,121
22
// Function to remove addresses from the excluded list for paying fees (only callable by the contract owner)
function includeInFees(address account) external onlyOwner { require(account != address(0), "Invalid address"); _excludedFromFees[account] = false; }
function includeInFees(address account) external onlyOwner { require(account != address(0), "Invalid address"); _excludedFromFees[account] = false; }
42,006
6
// Remove account into blacklist, only blacklist admin can do this
function removeBlacklisted(address account) public onlyBlacklistAdmin { _removeBlacklisted(account); }
function removeBlacklisted(address account) public onlyBlacklistAdmin { _removeBlacklisted(account); }
4,967
13
// if anyone votes no, there will be no consensus in the end
if (!agree) { tasks[taskId].nonconsensus = true; votedMap[taskId][msg.sender] = 2; // 2 maps to no } else {
if (!agree) { tasks[taskId].nonconsensus = true; votedMap[taskId][msg.sender] = 2; // 2 maps to no } else {
47,075
95
// Token Operator should be able to do auto renewal
modifier allowSubmission() { require( now >= stakeMap[currentStakeMapIndex].startPeriod && now <= stakeMap[currentStakeMapIndex].submissionEndPeriod && stakeMap[currentStakeMapIndex].openForExternal == true, "Staking at this point not allowed" ); _; }
modifier allowSubmission() { require( now >= stakeMap[currentStakeMapIndex].startPeriod && now <= stakeMap[currentStakeMapIndex].submissionEndPeriod && stakeMap[currentStakeMapIndex].openForExternal == true, "Staking at this point not allowed" ); _; }
51,470
8
// Cancels an initiated dispute process/Escrow is identified by a message = keccak256(_tradeRecordId, _seller, _buyer)/Seller and buyer shoud sign hash of (message, escrow address, msg.sig, _expireAtBlock, _salt) data/_tradeRecordId identifier of escrow record/_seller who will mainly deposit to escrow/_buyer who will eventually is going to receive payment/_expireAtBlock expiry block after which transaction will be invalid/_salt random bytes to identify signed data/_signature signature of an initiator/ return result code of an operation
function cancelDispute( bytes32 _tradeRecordId, address _seller, address _buyer, uint _expireAtBlock, uint _salt, bytes _signature ) external returns (uint);
function cancelDispute( bytes32 _tradeRecordId, address _seller, address _buyer, uint _expireAtBlock, uint _salt, bytes _signature ) external returns (uint);
44,381
81
// Can only be triggered by owner or governance
TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount);
TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount); emit Recovered(tokenAddress, tokenAmount);
3,521
0
// add a state variable to hold your baseURI
string private _baseTokenURI; constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps, address _primarySaleRecipient, string memory _initialBaseURI )
string private _baseTokenURI; constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps, address _primarySaleRecipient, string memory _initialBaseURI )
18,098
35
// Resize the patientEHRs array to remove empty slots
assembly { mstore(patientEHRs, count) }
assembly { mstore(patientEHRs, count) }
23,988
11
// _name = "VYFI.Finance";_symbol = "VYFI";
_name = "VYFI.Finance"; _symbol = "VYFI"; _decimals = 18; _totalSupply = 10000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
_name = "VYFI.Finance"; _symbol = "VYFI"; _decimals = 18; _totalSupply = 10000000000000000000000; _balances[creator()] = _totalSupply; emit Transfer(address(0), creator(), _totalSupply);
11,607
90
// Fallback function allowing to perform a delegatecall to the given implementation. This function will return whatever the implementation call returns /
function () payable external { address impl = implementation; require(impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } }
function () payable external { address impl = implementation; require(impl != address(0)); assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize) let result := delegatecall(gas, impl, ptr, calldatasize, 0, 0) let size := returndatasize returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } }
5,144
200
// // Redistributes the unallocated interest to the saved recipient, allowingthe siphoned assets to be used elsewhere in the system _mAssetmAsset to collect /
function distributeUnallocatedInterest(address _mAsset) external override { IRevenueRecipient recipient = revenueRecipients[_mAsset]; require(address(recipient) != address(0), "Must have valid recipient"); IERC20 mAsset = IERC20(_mAsset); uint256 balance = mAsset.balanceOf(address(this)); uint256 leftover_liq = _unstreamedRewards(_mAsset, StreamType.liquidator); uint256 leftover_yield = _unstreamedRewards(_mAsset, StreamType.yield); uint256 unallocated = balance - leftover_liq - leftover_yield; mAsset.approve(address(recipient), unallocated); recipient.notifyRedistributionAmount(_mAsset, unallocated); emit RevenueRedistributed(_mAsset, address(recipient), unallocated); }
function distributeUnallocatedInterest(address _mAsset) external override { IRevenueRecipient recipient = revenueRecipients[_mAsset]; require(address(recipient) != address(0), "Must have valid recipient"); IERC20 mAsset = IERC20(_mAsset); uint256 balance = mAsset.balanceOf(address(this)); uint256 leftover_liq = _unstreamedRewards(_mAsset, StreamType.liquidator); uint256 leftover_yield = _unstreamedRewards(_mAsset, StreamType.yield); uint256 unallocated = balance - leftover_liq - leftover_yield; mAsset.approve(address(recipient), unallocated); recipient.notifyRedistributionAmount(_mAsset, unallocated); emit RevenueRedistributed(_mAsset, address(recipient), unallocated); }
16,982
253
// Adjust the end block
endBlock += stakingPeriod[currentPhase].periodLengthInBlock;
endBlock += stakingPeriod[currentPhase].periodLengthInBlock;
52,886
11
// if needed remove wrapped
removeToken(_wrapped); emit UnLend(_wrapped, _amount);
removeToken(_wrapped); emit UnLend(_wrapped, _amount);
44,017
13
// Disables borrowing on a reserve asset The address of the underlying asset of the reserve /
function disableBorrowingOnReserve(address asset) external onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); currentConfig.setBorrowingEnabled(false); pool.setConfiguration(asset, currentConfig.data); emit BorrowingDisabledOnReserve(asset); }
function disableBorrowingOnReserve(address asset) external onlyPoolAdmin { DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); currentConfig.setBorrowingEnabled(false); pool.setConfiguration(asset, currentConfig.data); emit BorrowingDisabledOnReserve(asset); }
30,534
153
// use market collateral to calculate borrow amount this is done so that supplied can reach _targetSupply 99.99% is borrowed to be safe
uint borrowAmount = _getBorrowAmount(supplied, borrowed, marketCol).mul(9999) / 10000; require(borrowAmount > 0, "borrow = 0"); if (supplied.add(borrowAmount) > _targetSupply) {
uint borrowAmount = _getBorrowAmount(supplied, borrowed, marketCol).mul(9999) / 10000; require(borrowAmount > 0, "borrow = 0"); if (supplied.add(borrowAmount) > _targetSupply) {
19,490