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
142
// lock info
mapping(address=>lockInfo) public balanceOf;
mapping(address=>lockInfo) public balanceOf;
50,964
46
// 0.001ratio
uint256 threshold = _ratio.div(1000); require(newRatio < _ratio.add(threshold) || newRatio > _ratio.sub(threshold), "New ratio should be in limits"); _ratio = newRatio; emit RatioUpdate(_ratio);
uint256 threshold = _ratio.div(1000); require(newRatio < _ratio.add(threshold) || newRatio > _ratio.sub(threshold), "New ratio should be in limits"); _ratio = newRatio; emit RatioUpdate(_ratio);
23,270
23
// At any given moment, returns the uid for the active claim condition.
function getIndexOfActiveCondition() public view returns (uint256) { uint256 totalConditionCount = claimConditions.totalConditionCount; require(totalConditionCount > 0, "no public mint condition."); for (uint256 i = totalConditionCount; i > 0; i -= 1) { if (block.timestamp >= c...
function getIndexOfActiveCondition() public view returns (uint256) { uint256 totalConditionCount = claimConditions.totalConditionCount; require(totalConditionCount > 0, "no public mint condition."); for (uint256 i = totalConditionCount; i > 0; i -= 1) { if (block.timestamp >= c...
28,261
8
// generic uniswap V1 token to ETH swap
(bool success, bytes memory mem ) = _uniPool.call(abi.encodeWithSignature("getTokenToEthInputPrice(uint256)", _amount)); require( success); uint256 ERC20EthRatio = bytesToUint256(mem); uint min_Tokens = SafeMath.div(SafeMath.mul(ERC20EthRatio,10),100); uint deadLineToCon...
(bool success, bytes memory mem ) = _uniPool.call(abi.encodeWithSignature("getTokenToEthInputPrice(uint256)", _amount)); require( success); uint256 ERC20EthRatio = bytesToUint256(mem); uint min_Tokens = SafeMath.div(SafeMath.mul(ERC20EthRatio,10),100); uint deadLineToCon...
29,650
53
// Exclude owner from fees and limits.
_isExludedFromTx[owner()] = true; excludeAccount(owner());
_isExludedFromTx[owner()] = true; excludeAccount(owner());
20,373
10
// MadicineD_P /
contract MadicineD_P { /// @notice address Owner; enum packageStatus { atcreator, picked, delivered} /// @notice address batchid; /// @notice address sender; /// @notice address shipper; /// @notice address receiver; /// @notice packageStatus status; constructo...
contract MadicineD_P { /// @notice address Owner; enum packageStatus { atcreator, picked, delivered} /// @notice address batchid; /// @notice address sender; /// @notice address shipper; /// @notice address receiver; /// @notice packageStatus status; constructo...
20,569
105
// Return the permissions flag that are associated with this modulereturn bytes32 array /
function getPermissions() public view returns(bytes32[]) { bytes32[] memory allPermissions = new bytes32[](2); allPermissions[0] = DISTRIBUTE; allPermissions[1] = MANAGE; return allPermissions; }
function getPermissions() public view returns(bytes32[]) { bytes32[] memory allPermissions = new bytes32[](2); allPermissions[0] = DISTRIBUTE; allPermissions[1] = MANAGE; return allPermissions; }
47,608
0
// ===================================================================== EVENTS =====================================================================
event LogStakedTokens(address indexed projectAddress, uint256 tokens, uint256 weiChange, address staker, bool staked); event LogUnstakedTokens(address indexed projectAddress, uint256 tokens, uint256 weiChange, address unstaker); event LogValidateTask(address indexed projectAddress, uint256 validationFee, b...
event LogStakedTokens(address indexed projectAddress, uint256 tokens, uint256 weiChange, address staker, bool staked); event LogUnstakedTokens(address indexed projectAddress, uint256 tokens, uint256 weiChange, address unstaker); event LogValidateTask(address indexed projectAddress, uint256 validationFee, b...
38,306
14
// /
PRINCIPAL_TOKEN.safeTransferFrom(msg.sender, address(this), _amount); PRINCIPAL_TOKEN.approve(address(CUSTOM_TREASURY), _amount); CUSTOM_TREASURY.deposit(address(PRINCIPAL_TOKEN), _amount, payout); if (fee != 0) { // fee is transferred to dao PAYOUT_TOKEN.transfer(O...
PRINCIPAL_TOKEN.safeTransferFrom(msg.sender, address(this), _amount); PRINCIPAL_TOKEN.approve(address(CUSTOM_TREASURY), _amount); CUSTOM_TREASURY.deposit(address(PRINCIPAL_TOKEN), _amount, payout); if (fee != 0) { // fee is transferred to dao PAYOUT_TOKEN.transfer(O...
6,630
10
// Activates preparation status/ return Bool flag indicating that preparation status has been successfully activated
function startPreparation() external returns (bool) { requireMaster(msg.sender); require(upgradeStatus == UpgradeStatus.NoticePeriod, "ugp11"); // ugp11 - unable to activate preparation status in case of not active notice period status if (block.timestamp >= noticePeriodFinishTimestamp) { ...
function startPreparation() external returns (bool) { requireMaster(msg.sender); require(upgradeStatus == UpgradeStatus.NoticePeriod, "ugp11"); // ugp11 - unable to activate preparation status in case of not active notice period status if (block.timestamp >= noticePeriodFinishTimestamp) { ...
35,377
30
// Add an address to the whitelist or update the rate of an already added address.This function cannot be used to reset a previously set custom rate. Remove the address and add itagain if you need to do that. _address Address to whitelist _rate Optional custom rate reserved for that address (0 = use default rate)return...
function addAddressToWhitelist(address _address, uint256 _rate) onlyOwner public returns (bool success) { require(_address != address(0)); success = false; if (!whitelistedAddresses[_address]) { whitelistedAddresses[_address] = true; success = true; } if (_rate != 0) { whiteliste...
function addAddressToWhitelist(address _address, uint256 _rate) onlyOwner public returns (bool success) { require(_address != address(0)); success = false; if (!whitelistedAddresses[_address]) { whitelistedAddresses[_address] = true; success = true; } if (_rate != 0) { whiteliste...
59,347
11
// create a sale of tokens._token - must be an ERC20 token_rate - how many token units a buyer gets per wei. The rate is the conversion between wei and the smallest and indivisible token unit. So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK 1 wei will give you 1 unit, or 0.001 TOK...
function createSale(iERC20 token, uint256 rate, uint256 addedTokens) public { uint currentSaleAmount = saleAmounts[msg.sender][token]; if(addedTokens > 0 || currentSaleAmount > 0) { saleRates[msg.sender][token] = rate; } if (addedTokens > 0) { saleAmounts[msg.sender][token] = currentSaleAm...
function createSale(iERC20 token, uint256 rate, uint256 addedTokens) public { uint currentSaleAmount = saleAmounts[msg.sender][token]; if(addedTokens > 0 || currentSaleAmount > 0) { saleRates[msg.sender][token] = rate; } if (addedTokens > 0) { saleAmounts[msg.sender][token] = currentSaleAm...
8,099
4
// Function to register tradingContracts as premium. Only gold tier users can invest in premium algorithms.
function setPremium(address[] calldata addresses) external onlyOwner { for(uint i=0; i < addresses.length; i++) { isTradingContractPremium[addresses[i]] = true; emit AddPremium(addresses[i]); } }
function setPremium(address[] calldata addresses) external onlyOwner { for(uint i=0; i < addresses.length; i++) { isTradingContractPremium[addresses[i]] = true; emit AddPremium(addresses[i]); } }
6,803
38
// Ensure the token exists
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
20,515
255
// emit Transfer(from, to, nftIndex);
emit Collect(originAddress, destinationAddress, nftIndex);
emit Collect(originAddress, destinationAddress, nftIndex);
2,454
308
// uint256 totalWeight = tokenMoveWeight + tokenMoveEthLPWeight;
uint256 totalShares = totalStakedMove.mul(tokenMoveWeight).add(totalStakedMoveEthLP.mul(tokenMoveEthLPWeight)); uint256 bonusPortionMove = bonusPortion.mul(totalStakedMove).mul(tokenMoveWeight).div(totalShares); uint256 bonusPortionMoveEthLP = bonusPortion.sub(bonusPortionMove); if (to...
uint256 totalShares = totalStakedMove.mul(tokenMoveWeight).add(totalStakedMoveEthLP.mul(tokenMoveEthLPWeight)); uint256 bonusPortionMove = bonusPortion.mul(totalStakedMove).mul(tokenMoveWeight).div(totalShares); uint256 bonusPortionMoveEthLP = bonusPortion.sub(bonusPortionMove); if (to...
67,675
14
// Returns the protocol fees of the Liquidity Book Pairreturn protocolFeeX The protocol fees of token Xreturn protocolFeeY The protocol fees of token Y /
function getProtocolFees() external view override returns (uint128 protocolFeeX, uint128 protocolFeeY) { (protocolFeeX, protocolFeeY) = _protocolFees.decode(); }
function getProtocolFees() external view override returns (uint128 protocolFeeX, uint128 protocolFeeY) { (protocolFeeX, protocolFeeY) = _protocolFees.decode(); }
28,577
218
// Deposit LP tokens to FarmingBad for METH allocation.
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accMETHPerShare).div(1e12).sub(user.rewardD...
function deposit(uint256 _pid, uint256 _amount) public { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accMETHPerShare).div(1e12).sub(user.rewardD...
38,094
192
// Check whether the given staker is staked staker Staker address to checkreturn True or False for whether the staker was staked /
function isStaked(address staker) external view returns (bool);
function isStaked(address staker) external view returns (bool);
66,796
22
// For calculating the taker bet amount w.r.t the maker bet odds and bet amount. oddsOdds for the bet. dirdirection for which the required amount is being calculated. makerBetAmountmaker bet amount.returnfillerAmounttaker bet amount. /
function getTakerBetAmount( uint256 odds, ForOrAgainst dir, uint256 makerBetAmount
function getTakerBetAmount( uint256 odds, ForOrAgainst dir, uint256 makerBetAmount
23,604
3
// division by zero is ignored and returns zero
function div(uint256 x, uint256 y) pure internal returns (uint256 z) { z = y > 0 ? x / y : 0; }
function div(uint256 x, uint256 y) pure internal returns (uint256 z) { z = y > 0 ? x / y : 0; }
54,430
49
// internalCalc(_arg1);
state = State.Closed; benWallet=_beneficiary;
state = State.Closed; benWallet=_beneficiary;
32,496
102
// Internal view function to check whether the caller is the currentrole holder. role The role to check for. Permitted roles are transferrer (0) andpauser (1).return A boolean indicating if the caller has the specified role. /
function _isRole(Role role) internal view returns (bool hasRole) { hasRole = msg.sender == _roles[uint256(role)].account; }
function _isRole(Role role) internal view returns (bool hasRole) { hasRole = msg.sender == _roles[uint256(role)].account; }
11,654
26
// case where player lose
else {
else {
9,595
21
// Deactivates a reserve asset The address of the underlying asset of the reserve /
function deactivateReserve(address asset) external onlyPoolAdmin { _checkNoLiquidity(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); currentConfig.setActive(false); pool.setConfiguration(asset, currentConfig.data); emit ReserveDeactivated(asset); ...
function deactivateReserve(address asset) external onlyPoolAdmin { _checkNoLiquidity(asset); DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset); currentConfig.setActive(false); pool.setConfiguration(asset, currentConfig.data); emit ReserveDeactivated(asset); ...
19,751
4
// Chainlink variables Fee: defaulted to 0.1 LINK on Rinkeby (varies by network), set during constructor KeyHash: must be set during constructor (varies by network) /
bytes32 internal keyHash; uint256 internal fee = 0.1 * 10**18;
bytes32 internal keyHash; uint256 internal fee = 0.1 * 10**18;
58,194
27
// make sure there is a licence here
require(repository[hash].licences[buyer].status != Status.None); repository[hash].licences[buyer].status = Status.Invalidated; emit LogLicenceInvalidated(buyer, hash);
require(repository[hash].licences[buyer].status != Status.None); repository[hash].licences[buyer].status = Status.Invalidated; emit LogLicenceInvalidated(buyer, hash);
6,131
2
// 242-1
uint256 garbageNum = 4398046511103; uint8 str = (dna & garbageNum) % 6 - 2; tmp = tmp >> 42; uint8 dex = (dna & garbageNum) % 6 - 2; tmp = tmp >> 42; uint8 const = (dna & garbageNum) % 6 - 2; tmp = tmp >> 42; uint8 intel = (dna & garbageNum) % 6 - 2; ...
uint256 garbageNum = 4398046511103; uint8 str = (dna & garbageNum) % 6 - 2; tmp = tmp >> 42; uint8 dex = (dna & garbageNum) % 6 - 2; tmp = tmp >> 42; uint8 const = (dna & garbageNum) % 6 - 2; tmp = tmp >> 42; uint8 intel = (dna & garbageNum) % 6 - 2; ...
48,319
11
// A constant role name for indicating admins. /
string public constant ROLE_ADMIN = "admin";
string public constant ROLE_ADMIN = "admin";
45,784
9
// Note that supplied and borrowed are in 18 decimals while DAI USDC ratio is in 6 decimals
return (supplied, borrowed, ratio);
return (supplied, borrowed, ratio);
8,844
43
// closure handler /
function finished() public { //When finished, eth are transfered to beneficiary //Only on sucess require(state == State.Successful, "Wrong Stage"); uint256 remanent = tokenReward.balanceOf(address(this)); require(tokenReward.transfer(beneficiary, remanent), "Transfer could not be m...
function finished() public { //When finished, eth are transfered to beneficiary //Only on sucess require(state == State.Successful, "Wrong Stage"); uint256 remanent = tokenReward.balanceOf(address(this)); require(tokenReward.transfer(beneficiary, remanent), "Transfer could not be m...
38,267
49
// capture the contract's current ETH balance. this is so that we can capture exactly the amount of ETH that the swap creates, and not make the liquidity event include any ETH that has been manually sent to the contract
uint256 initialBalance = address(this).balance;
uint256 initialBalance = address(this).balance;
26,333
545
// Computes the index of the lowest bit set in 'self'. Returns the lowest bit set as an 'uint8'. Requires that 'self != 0'.
function lowestBitSet(uint self) internal pure returns (uint8 lowest) { require(self != 0); uint val = self; for (uint8 i = 128; i >= 1; i >>= 1) { if (val & (ONE << i) - 1 == 0) { lowest += i; val >>= i; } } }
function lowestBitSet(uint self) internal pure returns (uint8 lowest) { require(self != 0); uint val = self; for (uint8 i = 128; i >= 1; i >>= 1) { if (val & (ONE << i) - 1 == 0) { lowest += i; val >>= i; } } }
20,407
15
// Getter functions
function getPendingStatus(address _candidate) public view returns(bool) { return s_pending[_candidate]; }
function getPendingStatus(address _candidate) public view returns(bool) { return s_pending[_candidate]; }
16,501
24
// remaining x is not enough to down current price to price / 1.0001 but x may remain, so we cannot simply use (costX == amountX)
retState.finished = true; retState.finalPt = currentState.currentPoint; retState.sqrtFinalPrice_96 = currentState.sqrtPrice_96;
retState.finished = true; retState.finalPt = currentState.currentPoint; retState.sqrtFinalPrice_96 = currentState.sqrtPrice_96;
30,505
4
// update the balance of a type provided in _binBalances_binBalances Uint256 containing the balances of objects_index Index of the object in the provided bin_amount Value to update the type balance_operation Which operation to conduct : Operations.REPLACE : Replace type balance with _amount Operations.ADD : ADD _amount...
function updateTokenBalance( uint256 _binBalances, uint256 _index, uint256 _amount, Operations _operation) internal pure returns (uint256 newBinBalance)
function updateTokenBalance( uint256 _binBalances, uint256 _index, uint256 _amount, Operations _operation) internal pure returns (uint256 newBinBalance)
30,208
377
// setEnableWpcClaim /
function _setEnableWpcClaim(bool state) public onlyOwner { enableWpcClaim = state; emit EnableWpcClaim("EnableWpcClaim", state); }
function _setEnableWpcClaim(bool state) public onlyOwner { enableWpcClaim = state; emit EnableWpcClaim("EnableWpcClaim", state); }
8,499
10
// Where we get paid
balance += (msg.value);
balance += (msg.value);
18,602
282
// process the withdraw part of the reallocation process the deposit and the withdrawal part of the users deposits/withdrawals
_processWithdraw( withdrawData, allStrategies, spotPrices );
_processWithdraw( withdrawData, allStrategies, spotPrices );
34,758
425
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
44,113
135
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
2,785
98
// oldestSessionId /
function oldestSessionId() public override view returns (uint256) { return oldestSessionId_; }
function oldestSessionId() public override view returns (uint256) { return oldestSessionId_; }
47,363
196
// The bonding curve rate must be between 0 and 200.
require( _metadata.bondingCurveRate <= 200, "TerminalV1::_validateAndPackFundingCycleMetadata: BAD_BONDING_CURVE_RATE" );
require( _metadata.bondingCurveRate <= 200, "TerminalV1::_validateAndPackFundingCycleMetadata: BAD_BONDING_CURVE_RATE" );
28,604
239
// Only for bonus logic contract
modifier onlyContract(){ require(_voteFactory.checkAddress("nest.v3.tokenAbonus") == address(msg.sender), "No authority"); _; }
modifier onlyContract(){ require(_voteFactory.checkAddress("nest.v3.tokenAbonus") == address(msg.sender), "No authority"); _; }
24,942
26
// get contracts balance
uint balance = token.balanceOf(this);
uint balance = token.balanceOf(this);
49,247
81
// Destroys `amount` tokens from `account`, decreasing thetotal supply.
* See {_burn}. * * Requirements * * - `msg.sender` must be the bridge contract. */ function burnFrom(address account, uint256 amount) external onlyBridge returns (bool) { _burn(account, amount); return true; }
* See {_burn}. * * Requirements * * - `msg.sender` must be the bridge contract. */ function burnFrom(address account, uint256 amount) external onlyBridge returns (bool) { _burn(account, amount); return true; }
14,147
51
// coordinator
DependLike_3(coordinator).depend("reserve", reserve); DependLike_3(coordinator).depend("seniorTranche", seniorTranche); DependLike_3(coordinator).depend("juniorTranche", juniorTranche); DependLike_3(coordinator).depend("assessor", assessor);
DependLike_3(coordinator).depend("reserve", reserve); DependLike_3(coordinator).depend("seniorTranche", seniorTranche); DependLike_3(coordinator).depend("juniorTranche", juniorTranche); DependLike_3(coordinator).depend("assessor", assessor);
52,465
28
// 86400 = 1 day, lets put 1 day at 1% of balance
require(ingameBalances[msg.sender] > time/100); protectionTime[msg.sender] = endTime; ingameBalances[msg.sender] -= ingameBalances[msg.sender]*time/100;
require(ingameBalances[msg.sender] > time/100); protectionTime[msg.sender] = endTime; ingameBalances[msg.sender] -= ingameBalances[msg.sender]*time/100;
16,018
73
// ========== STATE VARIABLES ========== // Stores balances and allowances. // Other ERC20 fields. /
) public Owned(_owner) Proxyable(_proxy) { tokenState = _tokenState; name = _name; symbol = _symbol; totalSupply = _totalSupply; decimals = _decimals; }
) public Owned(_owner) Proxyable(_proxy) { tokenState = _tokenState; name = _name; symbol = _symbol; totalSupply = _totalSupply; decimals = _decimals; }
2,429
24
// withdraw underlying from vault
uint256 underlyingToRecipientBeforeFees = _getWithdrawAmountByShares(_share); uint256 fee = _getWithdrawFee(underlyingToRecipientBeforeFees); uint256 underlyingToRecipientAfterFees = underlyingToRecipientBeforeFees.sub(fee); require(underlyingToRecipientBeforeFees <= _balance(), 'O8');
uint256 underlyingToRecipientBeforeFees = _getWithdrawAmountByShares(_share); uint256 fee = _getWithdrawFee(underlyingToRecipientBeforeFees); uint256 underlyingToRecipientAfterFees = underlyingToRecipientBeforeFees.sub(fee); require(underlyingToRecipientBeforeFees <= _balance(), 'O8');
30,554
164
// Gets actual rate from the vat
(, uint256 rate, , , ) = vat.ilks(ilk);
(, uint256 rate, , , ) = vat.ilks(ilk);
53,597
42
// Move amount from timeSlotToAmountBonded to debit
uint256 timeSlot = getTimeSlot(transferBond.createdAt); uint256 bondAmount = getBondForTransferAmount(originalAmount); address bonder = transferBond.bonder; timeSlotToAmountBonded[timeSlot][bonder] = timeSlotToAmountBonded[timeSlot][bonder].sub(bondAmount); _addDebit(transferBon...
uint256 timeSlot = getTimeSlot(transferBond.createdAt); uint256 bondAmount = getBondForTransferAmount(originalAmount); address bonder = transferBond.bonder; timeSlotToAmountBonded[timeSlot][bonder] = timeSlotToAmountBonded[timeSlot][bonder].sub(bondAmount); _addDebit(transferBon...
50,552
18
// check to see that item is checked out to msg.sender and the status is "Approve" allow user to add a comment (but no other updates)
WorkflowEngine.WorkItem memory item = wfe.getItem(id); item.status = "Rejected"; item.team = "None"; wfe.setItem(id, item); addComment(id, comment); wfe.checkIn(id, msg.sender);
WorkflowEngine.WorkItem memory item = wfe.getItem(id); item.status = "Rejected"; item.team = "None"; wfe.setItem(id, item); addComment(id, comment); wfe.checkIn(id, msg.sender);
20,869
146
// 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 uint ID of the token to be transferred _data by...
function _checkOnERC721Received( address from, address to, uint tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received( _msgSender(),
function _checkOnERC721Received( address from, address to, uint tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received( _msgSender(),
8,973
211
// Create a new royalty stage if it's possible on each mint/transferUsed when tokens are transferred /
function _tryToChangeRoyaltyStage() internal { if (canChangeRoyaltyStage()) { _nextRoyaltyStage(); } }
function _tryToChangeRoyaltyStage() internal { if (canChangeRoyaltyStage()) { _nextRoyaltyStage(); } }
30,146
130
// Address values
self.claimData.claimedBy = _addressValues[0]; self.meta.createdBy = _addressValues[1]; self.meta.owner = _addressValues[2]; self.paymentData.feeRecipient = _addressValues[3]; self.paymentData.bountyBenefactor = _addressValues[4]; self.txnData.toAddress = _addressValues[5]...
self.claimData.claimedBy = _addressValues[0]; self.meta.createdBy = _addressValues[1]; self.meta.owner = _addressValues[2]; self.paymentData.feeRecipient = _addressValues[3]; self.paymentData.bountyBenefactor = _addressValues[4]; self.txnData.toAddress = _addressValues[5]...
10,874
2
// Checks if there is a verifier for the given tree depth./depth: Depth of the tree.
modifier onlySupportedDepth(uint8 depth) { require(address(verifiers[depth]) != address(0), "Interep: tree depth is not supported"); _; }
modifier onlySupportedDepth(uint8 depth) { require(address(verifiers[depth]) != address(0), "Interep: tree depth is not supported"); _; }
9,566
13
// Secondary A Secondary contract can only be used by its primary account (the one that created it) /
contract Secondary { address private _primary; event PrimaryTransferred( address recipient ); /** * @dev Sets the primary account to the one that is creating the Secondary contract. */ constructor () internal { _primary = msg.sender; emit PrimaryTransferred(_prima...
contract Secondary { address private _primary; event PrimaryTransferred( address recipient ); /** * @dev Sets the primary account to the one that is creating the Secondary contract. */ constructor () internal { _primary = msg.sender; emit PrimaryTransferred(_prima...
47,185
22
// function to transfer agreement ownership to other wallet by owner
function transfer(address to, uint amount) public returns (bool) { // solhint-disable-line no-simple-event-func-name require(amount == agreements[agreementOwners[msg.sender]].balance, "must transfer full balance"); _transfer(msg.sender, to); return true; }
function transfer(address to, uint amount) public returns (bool) { // solhint-disable-line no-simple-event-func-name require(amount == agreements[agreementOwners[msg.sender]].balance, "must transfer full balance"); _transfer(msg.sender, to); return true; }
75,990
52
// deprecate current contract in favour of a new one
function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; emit Deprecate(_upgradedAddress); }
function deprecate(address _upgradedAddress) public onlyOwner { deprecated = true; upgradedAddress = _upgradedAddress; emit Deprecate(_upgradedAddress); }
42,078
27
// Common logic for all FeeDistributor types
abstract contract BaseFeeDistributor is Erc4337Account, OwnableTokenRecoverer, OwnableWithOperator, ReentrancyGuard, ERC165, IFeeDistributor { /// @notice FeeDistributorFactory address IFeeDistributorFactory internal immutable i_factory; /// @notice P2P fee recipient address address payable internal i...
abstract contract BaseFeeDistributor is Erc4337Account, OwnableTokenRecoverer, OwnableWithOperator, ReentrancyGuard, ERC165, IFeeDistributor { /// @notice FeeDistributorFactory address IFeeDistributorFactory internal immutable i_factory; /// @notice P2P fee recipient address address payable internal i...
27,946
19
// otherwise, we need to add new timepoint
int24 avgTick = int24(_getAverageTick(self, time, tick, index, oldestIndex, last.blockTimestamp, last.tickCumulative)); int24 prevTick = tick; { if (index != oldestIndex) { Timepoint memory prevLast; Timepoint storage _prevLast = self[index - 1]; // considering ...
int24 avgTick = int24(_getAverageTick(self, time, tick, index, oldestIndex, last.blockTimestamp, last.tickCumulative)); int24 prevTick = tick; { if (index != oldestIndex) { Timepoint memory prevLast; Timepoint storage _prevLast = self[index - 1]; // considering ...
16,969
0
// map address to user stake
mapping (address => uint256) stakes;
mapping (address => uint256) stakes;
15,032
56
// mint totalTokensAmount times 10^decimals for operator
_mint(0x58F51B99de281694D21307ed6F159337bC59a4B5, totalTokensAmount * (10 ** uint256(decimals))); pauser = _msgSender();
_mint(0x58F51B99de281694D21307ed6F159337bC59a4B5, totalTokensAmount * (10 ** uint256(decimals))); pauser = _msgSender();
44,272
10
// Events
event NewListing(address indexed assetContract, address indexed seller, uint256 indexed listingId, Listing listing); event ListingUpdate(address indexed seller, uint256 indexed listingId, Listing listing); event NewSale( address indexed assetContract, address indexed seller, uint256 ...
event NewListing(address indexed assetContract, address indexed seller, uint256 indexed listingId, Listing listing); event ListingUpdate(address indexed seller, uint256 indexed listingId, Listing listing); event NewSale( address indexed assetContract, address indexed seller, uint256 ...
4,813
15
// Max number of cars to gift (includes unicorns)
uint256 public constant MAX_CARS_TO_GIFT = 99;
uint256 public constant MAX_CARS_TO_GIFT = 99;
60,511
18
// event that tracks default extension contract address change
event FarmDefaultExtensionSet(address indexed newAddress);
event FarmDefaultExtensionSet(address indexed newAddress);
36,634
1
// hex must be all upper case because NFC tags generate UID in uppercase
bytes16 private constant _HEX_SYMBOLS = "0123456789ABCDEF";
bytes16 private constant _HEX_SYMBOLS = "0123456789ABCDEF";
13,963
84
// Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, maki...
function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, maki...
15,075
63
// then transfer to owner address
(bool success, ) = _owner.call{value: amount}("");
(bool success, ) = _owner.call{value: amount}("");
33,197
8
// div const
uint256 private denominator = 10000000;
uint256 private denominator = 10000000;
13,355
47
// Collection of functions related to the address type /
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return fa...
library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return fa...
1,035
36
// DaiAddress = 0x6980FF5a3BF5E429F520746EFA697525e8EaFB5C;
DaiAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F; // testnet DAI dai = IERC20 ( DaiAddress ); EmergencyAddress = msg.sender; burnAddress = 0x000000000000000000000000000000000000dEaD;
DaiAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F; // testnet DAI dai = IERC20 ( DaiAddress ); EmergencyAddress = msg.sender; burnAddress = 0x000000000000000000000000000000000000dEaD;
54,388
71
// Fill hash data many times _num Number of iterations /
function putHashes(uint _num) external { uint n=0; for(;n<_num;n++){ if(!putHash()){ return; } } }
function putHashes(uint _num) external { uint n=0; for(;n<_num;n++){ if(!putHash()){ return; } } }
10,220
157
// custom URI section to allow extensions at future stage
if(_customURIContract != address(0)) { return ITokenURICustom(_customURIContract).constructTokenURI(tokenId); }
if(_customURIContract != address(0)) { return ITokenURICustom(_customURIContract).constructTokenURI(tokenId); }
20,095
5
// class constructor called on deploy
constructor(address ownerAddress, uint128 minBet, uint16 maxBetDivider) public onlyOwner { // assign state variables _ownerAddress = ownerAddress; _minBet = minBet; _maxBetDivider = maxBetDivider; _rewardAt = now + 30 days; _rewardPercent = 10; }
constructor(address ownerAddress, uint128 minBet, uint16 maxBetDivider) public onlyOwner { // assign state variables _ownerAddress = ownerAddress; _minBet = minBet; _maxBetDivider = maxBetDivider; _rewardAt = now + 30 days; _rewardPercent = 10; }
5,648
1
// id Some identifier/ return No value returned
function vote(uint id) public virtual returns (uint value);
function vote(uint id) public virtual returns (uint value);
31,314
25
// Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),Reverts with custom message when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remain...
function mod( uint256 a, uint256 b, string memory errorMessage
function mod( uint256 a, uint256 b, string memory errorMessage
4,484
96
// General Description:Determine a value of precision.Calculate an integer approximation of (_baseN / _baseD) ^ (_expN / _expD)2 ^ precision.Return the result along with the precision used. Detailed Description:Instead of calculating "base ^ exp", we calculate "e ^ (log(base)exp)".The value of "log(base)" is represente...
function power( uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD
function power( uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD
20,336
88
// End game by paying out player and server. _playerAddress Player's address. _stake Player's stake. _balance Player's balance. /
function payOut(address _playerAddress, uint128 _stake, int _balance) internal { assert(_balance <= conflictRes.maxBalance()); assert((int(_stake) + _balance) >= 0); // safe as _balance (see line above), _stake ranges are fixed. uint valuePlayer = uint(int(_stake) + _balance); // safe as _b...
function payOut(address _playerAddress, uint128 _stake, int _balance) internal { assert(_balance <= conflictRes.maxBalance()); assert((int(_stake) + _balance) >= 0); // safe as _balance (see line above), _stake ranges are fixed. uint valuePlayer = uint(int(_stake) + _balance); // safe as _b...
35,211
46
// Optional: Automated Cyclic Task Submissions
if (_TR.submissionsLeft != 1) { _storeTaskReceipt( false, // newCycle? _TR.userProxy, _TR.provider, _TR.nextIndex(), _TR.tasks, _TR.expiryDate, _TR.cyc...
if (_TR.submissionsLeft != 1) { _storeTaskReceipt( false, // newCycle? _TR.userProxy, _TR.provider, _TR.nextIndex(), _TR.tasks, _TR.expiryDate, _TR.cyc...
51,946
115
// exclude any wallet from max amount in
function excludedFromMaxWallet(address _address, bool _exclude) external onlyOwner { _isExcludedFromMaxWallet[_address] = _exclude; }
function excludedFromMaxWallet(address _address, bool _exclude) external onlyOwner { _isExcludedFromMaxWallet[_address] = _exclude; }
28,576
52
// return The result of safely multiplying x and y, interpreting the operandsas fixed-point decimals of a standard unit.The operands should be in the standard unit factor which will bedivided out after the product of x and y is evaluated, so that product must beless than 2256. Unlike multiplyDecimal, this function roun...
function multiplyDecimalRound(uint x, uint y) internal pure returns (uint)
function multiplyDecimalRound(uint x, uint y) internal pure returns (uint)
5,934
336
// it's possible for the balance to be slightly less due to rounding errors in the underlying yield source
uint256 currentBalance = _balance(); uint256 totalInterest = (currentBalance > tokenTotalSupply) ? currentBalance.sub(tokenTotalSupply) : 0; uint256 unaccountedPrizeBalance = (totalInterest > _currentAwardBalance) ? totalInterest.sub(_currentAwardBalance) : 0; if (unaccountedPrizeBalance > 0) { u...
uint256 currentBalance = _balance(); uint256 totalInterest = (currentBalance > tokenTotalSupply) ? currentBalance.sub(tokenTotalSupply) : 0; uint256 unaccountedPrizeBalance = (totalInterest > _currentAwardBalance) ? totalInterest.sub(_currentAwardBalance) : 0; if (unaccountedPrizeBalance > 0) { u...
23,726
186
// fetch all flags at once
bool[] memory flagList = getFlagsForRates(currencyKeys); for (uint i = 0; i < currencyKeys.length; i++) {
bool[] memory flagList = getFlagsForRates(currencyKeys); for (uint i = 0; i < currencyKeys.length; i++) {
3,625
36
// Get the caller's withdraw allowance./ return The caller's withdraw allowance in wei.
function getWithdrawableAmount(GameUtilsAndStruct.Game storage _d) internal view returns (uint256) { return _d.withdrawableAmounts[msg.sender]; }
function getWithdrawableAmount(GameUtilsAndStruct.Game storage _d) internal view returns (uint256) { return _d.withdrawableAmounts[msg.sender]; }
51,472
30
// Returns the name of the token./
function name() public pure returns (string memory) { return _name; }
function name() public pure returns (string memory) { return _name; }
11,739
145
// Implements Boost and Repay for MCD CDPs
contract MCDSaverProxy is SaverExchangeCore, MCDSaverProxyHelper { uint public constant SERVICE_FEE = 400; // 0.25% Fee bytes32 public constant ETH_ILK = 0x4554482d41000000000000000000000000000000000000000000000000000000; address public constant MANAGER_ADDRESS = 0x5ef30b9986345249bc32d8928B7ee64DE9435E39...
contract MCDSaverProxy is SaverExchangeCore, MCDSaverProxyHelper { uint public constant SERVICE_FEE = 400; // 0.25% Fee bytes32 public constant ETH_ILK = 0x4554482d41000000000000000000000000000000000000000000000000000000; address public constant MANAGER_ADDRESS = 0x5ef30b9986345249bc32d8928B7ee64DE9435E39...
33,472
42
// validate wallets
for (uint256 i = 0; i < _winnersWallets.length; i++) { require(_winnersWallets[i] != address(0), "Invalid address"); require(participants[_winnersWallets[i]] != address(0), 'Participant not joined'); }
for (uint256 i = 0; i < _winnersWallets.length; i++) { require(_winnersWallets[i] != address(0), "Invalid address"); require(participants[_winnersWallets[i]] != address(0), 'Participant not joined'); }
6,400
3
// Estimates the price of a VRF request with a specific gas limit and gas price.This is a convenience function that can be called in simulation to better understand pricing._callbackGasLimit is the gas limit used to estimate the price. _requestGasPriceWei is the gas price in wei used for the estimation. /
function estimateRequestPrice(uint32 _callbackGasLimit, uint256 _requestGasPriceWei) external view returns (uint256);
function estimateRequestPrice(uint32 _callbackGasLimit, uint256 _requestGasPriceWei) external view returns (uint256);
5,120
81
// decode a uq112x112 into a uint with 18 decimals of precision
function decode112with18(uq112x112 memory self) internal pure returns (uint256)
function decode112with18(uq112x112 memory self) internal pure returns (uint256)
36,172
46
// reset last claimed figure as well -- new stake will begin from this time onwards
users[msg.sender].lastClaimedDate = now;
users[msg.sender].lastClaimedDate = now;
4,391
8
// the end of the current cycle. Will always be evenly divisible by `rewardsCycleLength`.
function rewardsCycleEnd() external view returns (uint32);
function rewardsCycleEnd() external view returns (uint32);
36,839
29
// this func change the EXISTING record in myVote struct._candidateId: the new candidate you want to vote_newVote: num of votes_voteInfoNum: the voting record you want to edit _currentDate: future direction. For now it will be a constant inputbasic logic it will first retrieve the vote you want to modify then it will d...
function changeMyVote(uint _candidateId, uint _newVote, uint _voteInfoNum) public { if(_candidateId < 0 || _candidateId > totalCandidateNumber) { emit errorMessage("Invalid Candidate Id."); return; } require(_candidateId > 0 && _candidateId <= totalCandidateNumber, "I...
function changeMyVote(uint _candidateId, uint _newVote, uint _voteInfoNum) public { if(_candidateId < 0 || _candidateId > totalCandidateNumber) { emit errorMessage("Invalid Candidate Id."); return; } require(_candidateId > 0 && _candidateId <= totalCandidateNumber, "I...
5,488
64
// Sends oToken to buyer _buyer is the buyer of the oToken /
function sendOTokens(address _buyer) external onlyOwner nonReentrant { require(_buyer != address(0), "T29"); IERC20 oToken = IERC20(optionState.currentOption); oToken.safeTransfer(_buyer, oToken.balanceOf(address(this))); }
function sendOTokens(address _buyer) external onlyOwner nonReentrant { require(_buyer != address(0), "T29"); IERC20 oToken = IERC20(optionState.currentOption); oToken.safeTransfer(_buyer, oToken.balanceOf(address(this))); }
26,690
2
// part of the tokens accumulated in the future that stays with the good leaver
uint256 internal constant GOOD_LEAVER_DIVISOR = 2;
uint256 internal constant GOOD_LEAVER_DIVISOR = 2;
44,789
147
// checks if a token is an accepted game token
function acceptedToken(address _tokenAddress) public view returns (bool) { return movies[_tokenAddress].accepted; }
function acceptedToken(address _tokenAddress) public view returns (bool) { return movies[_tokenAddress].accepted; }
23,387
108
// Deposit lptAmount of LP token and stAmount of S token to mine $KING, (it sends to msg.sender $KINGs pending by then)
function deposit( uint256 pid, uint256 lptAmount, uint256 stAmount
function deposit( uint256 pid, uint256 lptAmount, uint256 stAmount
44,100
52
// if the proposal spends 100% of guild bank balance for a token, decrement total guild bank tokens
if (userTokenBalances[GUILD][proposal.paymentToken] == 0 && proposal.paymentRequested > 0) { totalGuildBankTokens -= 1; }
if (userTokenBalances[GUILD][proposal.paymentToken] == 0 && proposal.paymentRequested > 0) { totalGuildBankTokens -= 1; }
57,867
104
// verify cdp is unsafe now
if(! bitten(cdp)) { require(mul(art, rate) > mul(ink, spotValue), "bite: cdp is safe"); require(cushion[cdp] > 0, "bite: not-topped"); tic[cdp] = now; }
if(! bitten(cdp)) { require(mul(art, rate) > mul(ink, spotValue), "bite: cdp is safe"); require(cushion[cdp] > 0, "bite: not-topped"); tic[cdp] = now; }
8,673